A general heuristic I’ve learned from reading, writing, and debugging a lot of code is don’t try to predict whether a future operation will fail. This comes up a lot when handling error conditions. For example, I’ve seen plenty of code that reads something like this (pseudocode): if not file_exists('input'): print('Input file not found') else: input = open('input') # or... if not…
I often need to connect to PostgreSQL databases for projects I'm working on, and over time I've developed a method that works pretty well for me. It's pretty specific to how I like to work so I wouldn't recommend it for everyone. But since some of my coworkers have asked about it, I figured I'd write down the major pieces of the puzzle so others can adapt any parts they like to their own…
One thing I wish I had understood better earlier on in my experience with PostgreSQL is how transactions and locks can be used together to provide serializable logic. An easy way to illustrate this is with a simple bank account system. Suppose we create an accounts table and populate it like this: create table accounts ( name text primary key, balance int not null ); insert into accounts (name,…
This week, I was working on a Go program and I wanted to understand which part was taking the most time. I had seen some people use flame graphs for this, but had never made one myself, so I decided to try it out. It took a little time to figure out the right tools to use, but once I did it was pretty easy. Here’s what one looks like (full size):
Aerc is an open-source email client that runs in your terminal. During 2019 and early 2020, I contributed 32 patches to the project. Many of them were minor enhancements, bug fixes, and documentation updates, but I also contributed a number of more substantial features as well. While I no longer use aerc regularly, I found it really rewarding to work with the other contributors and to interact…
One of my all-time favorite tools is Wireshark. During college, my summer internship at Lutron Electronics was focused on packaging a custom internal build of Wireshark, complete with new dissectors for Lutron’s proprietary network protocols. Lutron’s lighting control hardware communicates using a variety of proprietary wired and wireless link protocols. My goal was to make it quicker and easier…
I wrote previously about how I like to use mitmproxy for debugging HTTP services. This is a continued exploration of debugging network services, in particular focused around inspecting TLS encrypted traffic that your application is sending and receiving. Transport Layer Security is a fundamental building block of modern secure communications on the Internet, and increasingly the software we write…
I spend a lot of my time at work writing Go services that talk to other Go services over HTTP. Much of the time, everything works as expected, but every now and then a situation arises where I’m struggling to understand why my program is receiving a specific value. Is my request not being built correctly? Am I not properly deserializing the response? Logging can be helpful, but sometimes I really…
I’d heard about being able to run Docker containers with a custom security profile, but wasn’t really sure what that meant or what was happening behind the scenes, so I decided to do some experimentation to find out. It turns out that the Linux kernel includes a feature called “secure computing mode,” or seccomp for short. Using seccomp lets you tell the kernel that you only expect your program to…
Recently, I needed to store some customer-specific data in a PostgreSQL database and grant customers access to only their data in the shared tables. Fortunately, PostgreSQL has support for row level security in conjunction with its RBAC model which helps us do exactly that. While row level security does exactly what we need it to for tables, I ran into a challenge when I needed to apply the same…
Recently, I took a MIG welding class at Artisan’s Asylum in Somerville, MA. I wanted to document what I learned so that I can refer back to it in the future, so here it is! Safety There are four primary hazards: Burns. You’re dealing with liquid metal, so the work piece will remain hot even after you finish a weld. Also, small balls of molten steel will fly away from the work area and can burn…
The Dewey Decimal Classification (DDC) is widely used in libraries to organize their collections. I think a lot of people have probably used the DDC to find a book in a library, and a lot of people generally know how it works: number ranges correspond to high-level topics, with more numbers in the middle to fill in more specific subjects. You might be familiar with the table of main classes:
I saw this SQL Murder Mystery appear on Hacker News recently, thought it sounded fun, and figured I’d do a quick write-up of how I worked through it. If you want to follow along, go ahead and download the SQLite database (which is copyright NUKnightLab and redistributed here under the MIT license). You’ll need some kind of SQLite client to interact with it (I just used the sqlite3 CLI tool).
Despite what you may believe from simply looking at this site, I’ve actually done quite a bit of front-end development. A couple of years ago, I worked on a project with a friend of mine. For part of the project, he’d designed the behavior of a form control inspired by Material Design which I then built from scratch. Recently, he asked me to remind him how I’d implemented it, and I thought I’d…
Information security is complicated. When you combine that with the fact that an increasing number of people seem to also consider it to be very important, the result is something I like to call “pop infosec.” As in pop science or popular psychology, making information security accessible often involves simplifying concepts to improve their general palatability which results in laypeople…
I have a FreeBSD server which primarily serves as a jail host. As such, I’d like to keep its installed packages to a minimum. FreeBSD’s default install comes with vi, but not vim. Using vi feels familiar enough, but it becomes annoying not to have things like gg available. So I decided to install vim to make my life a little nicer: $ sudo pkg install vim Updating FreeBSD repository catalogue.
I decided to take another crack at the jail configuration I started in Experiment 1. After reading bits and pieces of a few random websites (including various ServerFault posts), on an inkling I added the line interface = "bge0"; to my /etc/jail.conf file and ran service jail restart www (bge0 is my LAN interface on the host). After jexecing in, I tried pkg install nginx again and it worked like a…
DHCP (Dynamic Host Configuration Protocol) is an integral part of most networks, from small home network to campuses serving thousands of devices. I recently realized that I didn’t have a solid understanding of how it functions. I knew that DHCP was used to obtain an IP address from a central server when joining a network, but wasn’t clear on how that negotiation takes place. How could a machine…
In my preparations for removing ESXi, I tried creating a simple jail on my test box helios. As part of my purpose is to learn as much as possible, I decided against using a tool like ezjail in favor of doing it “by hand.” While the FreeBSD Handbook has some information on creating jails without using additional tools, pretty much every other document I found suggested using ezjail. There’s a…
A few months ago, I purchased a beefy second-hand tower to act as a home server. I was looking to bring some of the services that I was previously outsourcing into a single location, and to expand my familiarity with networking and systems administration. Specifically, I wanted to: Replace the small DigitalOcean box that I was using as a VPN/proxy when I needed to use public WiFi Stop paying for a…
On March 30th, 2016, CloudFlare posted a blog entry entitled “The Trouble with Tor” outlining the issues Cloudflare has with serving clients’ sites to Tor users. The Tor project quickly followed it up with their own post, “The Trouble with CloudFlare”, which presented an analysis of the situation from Tor’s perspective. CloudFlare’s post acknowledged that Tor does play an important role on the…
When I upgraded to Ubuntu 15.04, I was unable to log in. The machine started normally and I was presented with the login window. But when I entered my password, the screen went black for a few moments and then the login screen came back. Since I’m using an NVIDIA GeForce GTX 750, which Ubuntu’s Nouveau drivers don’t support, I previously needed to install the NVIDIA graphics drivers. By entering…
Here’s the situation I recently found myself in: Ubuntu Linux 14.10 Unknown password for user account Unknown (but set) root password (Ubuntu’s philosophy is to use sudo for everything) LUKS encrypted filesystem (known passphrase) Physical access to the computer I needed to reset my account password. Normally, with physical access to a machine, all bets are off when it comes to security. I tried…
One of my pet peeves in website usability design is forcing people to create unnecessary accounts. My recent purchase of some concert tickets from Ticketfly required me to make an account to buy them. For people who buy a lot of concert tickets, having an account may make a lot of sense. But for me, as someone who buys concert tickets at most once every year or two, having an account on a site…
Recently, I had to give a presentation and decided to do some research on using Markdown. By coincidence, I had also been looking into Puppet, a flexible and powerful configuration manager, when I stumbled across Showoff, another Puppet Labs project. Showoff is a Ruby application that takes a Markdown file with some special formatting and transforms it into a web-accessible slideshow. As expected,…
On September 29, 2014, CloudFlare, a web security company and CDN provider, announced that they would begin offering free, automatic SSL to all its customers (including those on their free plan). This is an enormous step forward for enhancing security and privacy on the Internet; while website owners would previously need to purchase an SSL certificate for their site and often pay extra for SSL…
I recently wrote about migrating my website to GitHub Pages and noted that I wasn’t completely satisfied with my deployment workflow. Ideally, creating a build should be done in a single step. As I wrote, my previous build workflow required me to manually compile my LESS files before committing if I’d made changes. While my stylesheet doesn’t change often, this method is certainly not ideal. Using…
A common frustration of Muhlenberg students is to print a document to a dorm printer only to find that the printer had no paper when going to collect it. This leads to both frustration and wasted paper, since when more paper is put into the printer, it will print out all the queued jobs from when the tray was empty. By that time, students have often given up and printed their document to another…
I’ve always been a fan of using Markdown to create web content. Several years ago, I created MDEngine, a small PHP script to render Markdown files in HTML dynamically. For a while, it was responsible for much of the content on my website. In October 2013, I began work on a fresh design. I decided to use a custom Node.js app deployed on Heroku for processing the Markdown. While this worked…