July 29, 2024 - Running CRON Jobs on Modal
Recently, I’ve been working to migrate my own personal infrastructure off of Kubernetes, given that it has become quite expensive to run for just a single hosted website. For example, on Linode, the smallest cluster (3 nodes), along with a load balancer, and several disks, was approaching 50$ a month. Indeed, what did I actually use my cluster for? I used it for hosting one-off websites for a couple of days, and then tearing them down, I used it for my own personal website, and I used it for a host of CRON jobs that have to run every hour or every couple of days....
June 11, 2024 - Using K9s to Manage Kubernetes Clusters
I use Kubernetes (K8s) to manage both my personal website, and some client-facing projects. Recently, however, I’ve discovered something that is making my life a whole lot easier: K9s - a terminal-based UI (think htop) for managing Kubernetes clusters. Some of the awesome features: I can actually see all of my pods running at once, their CPU/memory usage, and what their internal IPs are I can tail logs using a UI, and I don’t have to remember all of the kubectl commands to do so I can see if things are dead, or died, at a glance....
March 18, 2024 - Adding a tag to an older commit
To add a tag to an older commit, you can use the following command: git tag -a {{ Tag Name }} {{ Commit Hash }} -m "Message here" For example, if you wanted to add a tag to the commit with the hash a1b2c3d4, you would use the following command: git tag -a v1.0 a1b2c3d4 -m "Version 1.0" This will add a tag called v1.0 to the commit with the hash a1b2c3d4, and the message “Version 1....
January 29, 2024 - Appending content to a database using Notion's API
Sometimes, I want to visualize some of my experimental results, or share them with others. One of the easiest ways to do this is using notion: which is capable of handling a variety of data types, and can be published to a relatively nice looking website, with minimal effort. Step 1: Creating a notion integration To do this, you first have to create a notion integration, which you can do here....
January 24, 2024 - Using UUID for Unique Identifiers in Python
In lots of situations, we may need a unique identifier for an object, for example, when running a database transformation, we may want to create a unique key for each record, or when creating a database, we might want a unique key for each object in the database. In these situations, I’ve seen a lot of people use some variant of the following code: import random import string def generate_random_unique_identifier(length=10): return ''....
January 23, 2024 - Detecting COCO Objects with Detectron2 API
Sometimes you need to run an object detector as part of a larger system. One of the best tools for bringing in a pre-trained detector may be the detectron2 framework from Meta. Installation To install detectron2, it’s as easy as a pip install: python -m pip install git+https://github.com/facebookresearch/detectron2.git Detectron2 API It’s amazingly easy to being to extract objects from images using their pre-trained models. First, you get a model from the model zoo:...
January 22, 2024 - Handling basePath in next.js client components
It turns out that hosting a next.js application in a subdirectory isn’t as easy as it should be. There are two major issues that I’ve run into when doing this: (1) Handling links to local pages and (2) Handling links to static assets. The right way to handle this is to set the basePath in the next.config.js file. This will cause the next.js router to prepend the basePath to all links:...
January 19, 2024 - Cloudfront Egress is pretty cheap!
This isn’t really a TIL, but it turns out that Amazon provides 1TB of free egress from S3 buckets with a CloudFront CDN front-end (instead of the standard 100GB available for free with S3 alone). To get started, I followed this tutorial – but it assumes a pretty high level of prior understanding of AWS, so if you’ve never used CloudFront, AWS, or S3 before, it might be best to google around for another tutorial....
January 11, 2024 - Configuring AWS CLI Endpoint URL
So, for a long time, it wasn’t possible to configure the AWS CLI to use a custom endpoint url by default. Since I usually use Wasabi for my S3 storage, I had to use the --endpoint-url flag every time I wanted to use the CLI, pretty annoying, right? Well, turns out at some point Amazon added a set of useful configs to their CLI. To configure the CLI to use a custom endpoint url, you can add the following to your ~/....
May 12, 2023 - Testing for Multivariate Normality with a Henze-Zirkler Test (In Python)
If you’re just interested in the code, it’s super easy to use pingouin to do this: import numpy as np import pingouin as pg data = np.random.normal(size=(100, 3)) output = pg.multivariate_normality(data, alpha=.05) print(output.hz, output.pval, output.normal) Sometimes, it’s useful to know when a sample looks a lot like a normal distribution. In a single dimension, we can use the function from scipy scipy.stats.normaltest to test whether a sample is normal. This test combines tests from D’Agostino and Pearson which measure the skew and kurtosis of the sample, and report when those differ from a similar normal population....