How-To

2023


Analyze data with SQL window functions

We regularly use tools like PostgreSQL, Pandas, and Jupyter Notebooks to analyze data here at Caktus. Recently, we were reviewing North Carolina traffic stop data for the NC CopWatch project and had the opportunity to use PostgreSQL's window functions, which are helpful when aggregating data.

2021


cover-using-celery-scheduling-tasks.png

How to Use Celery for Scheduling Tasks

Dan Poirier

There are multiple ways to schedule tasks in your Django app, but there are some advantages to using Celery. It’s supported, scales well, and works nicely with Django. Given its wide use, there are also lots of resources for learning more about it, and once learned, that knowledge is likely to be useful on other projects.

cover-mock-improve-unit-tests.png

How Mock Can Improve Your Unit Tests: Part 2

Dan Poirier

In Part 1 of this blog series, we started looking at how we can use mocking to improve our unit tests. We'll expand on that in this post.

cover-mock-unit-tests-part-1.png

How Mock Can Improve Your Unit Tests: Part 1

Dan Poirier

We've written in the past about the importance of unit tests and how to write better ones: Culture of Unit Testing, Subtests are the Best.

cover-automating-pypi-releases.jpg

Automating PyPI releases with Github Actions

Vinod Kurup

At Caktus, we maintain some open source packages, which are usually pieces of code that we’ve found useful when building an application, and we figure they might be useful to others. From time to time, those open source projects need a little maintenance: Maybe a bug fix has been provided from a community member, or we need to update to support a new version of Python or Django. I always hesitate to do this because I know there are multiple steps involved to ensure that any updates are properly tested, documented, versioned, and released. One of my silly blockers is that I always seem to forget how to upload a release to PyPI, which is the Python Package Index, a repository of software for Python. I call it silly because it shouldn’t really be a blocker, seeing how simple it actually is, but I still forget it each time and have to walk through the documentation step by step to make sure I do it properly. I recently found a tool that helps with this process.

cover-javascript-variable.png

JavaScript Variable Declaration in the 21st Century

Michael Ashton

October 2020 marked the 14th anniversary of the introduction of “let” and "const" to Javascript. Yes, it was in 2006 that this feature was first introduced, and we’re still having conversations about it. So why, you ask, are we still talking about this? It seems that a lot of confusion remains, not to mention a lot of old code being passed around on StackOverflow with “var” all over the place. Here I’ll discuss the difference between these three declarations, and come to a conclusion about best practices

cover-python-development-environment.jpg

My Python Development Environment

Dan Poirier

This is how to set up the One True Development Environment for Python.

Haha, just kidding, there is no such thing. Here's one way to do it that works for me, and an attempt to explain the benefits of doing it this way.

cover-top-20-blogs-2020.png

Our Top 20 Blogs in 2020

Elizabeth Michalka

We’ve published summaries of our most popular blog posts before (see Top 19 of 2019 and Top 18 of 2018), but this time, we’re taking it a step further. We’re sharing the 20 most popular posts in 2020, regardless of the year the post was originally published. And some of these have been around a while! Based on total pageviews, here are the blogs that rose to the top of the popularity list, from most viewed to least viewed.

2020


cover-usekeypress-hook-react.png

Build a useKeypress Hook in React

Michael Ashton

One of the great patterns to come out of React 16.8 is composable hooks. Using React's built-in hooks such as useState and useEffect, we can encapsulate and modularize bits of functionality — almost the same way we create reusable components. In this article we're going to throw together a quick hook that registers an event listener on a keypress and performs an action. Nothing fancy, but it's a nice abstraction that makes it a lot easier to add some nice power-user features to your app.

cover-how-schedule-tasks-using-celery-beat-container.jpg

How to Schedule Tasks Using Celery Beat in a Container

Dan Poirier

When running services in a container, changes to files can be discarded at any time, but the Celery beat default scheduler keeps its state in a file.