RSS Amplifier

Blog

Russell Cohen

rcoh.svbtle.comRSS feed ↗9 posts

Latest posts

How Postgres Unique Constraints Can Cause Deadlock

A recent outage lead me to investigate Postgres unique constraints more deeply. Postgres implements unique constraints by creating a unique index – an index that can only contain unique values.[ 4] It turns out that unique indices and concurrent transactions can interact in nasty and surprising ways. Before I get into the “why”, here are the implications: When two transactions insert the same…

Notes on CPython Lists

As I was learning to program, Python lists seemed totally magical to me. I imagined them as being implemented by some sort of magical datastructure that was part linked-list, part array that was perfect for everything. As I grew as an engineer, it occurred that this was unlikely. I guessed (correctly) that rather than some sort of magical implementation, it was just backed by a resizable array. I…

Trip Report: North Arete on Bear Creek Spire

After 4 days climbing long moderates in Tuolumne Meadows, Eben and I were stoked to get out of the park for the weekend and escape the crowds on some eastside alpine rock. After a few minutes of flipping through the guidebook, we settled on the North Arete on Bear Creek Spire. The granite prow of Bear Creek Spire rises to 13713’, roughly 1500’ above the scree at its base. The North Arete climbs…

Open Sesame

Several months ago, we accidentally left our garage door open. A bunch of stuff got stolen and it sucked. I resolved to make sure this never happened again by making our garage door text us if we left it open. The components of this build are very similar to what I wrote about in my DIY nest article , so I’ll skip the nitty gritty and just tell you what to buy and lay out how it works. This…

No Magic: Regular Expressions, Part 3

Evaluating the NFA # In part 1 , we parsed the regular expression into an abstract syntax tree. In part 2 , we converted that syntax tree into an NFA. Now it’s time evaluate that NFA against a potential string. NFAs, DFAs and Regular Expressions # Recall from part 2 that there are two types of finite automata: deterministic and non-deterministic. They have one key difference: A non-deterministic…

No Magic: Regular Expressions, Part 2

The code for this post, as well as the post itself, are on github . This post is part of a 3 part series. Part 1 Part 2 Part 3 Converting the Parse Tree to an NFA # In the last post, we transformed the flat string representation of a regular expression to the hierarchical parse tree form. In this post we’ll transform the parse tree to a state machine. The state machine linearizes the regex…

No Magic: Regular Expressions

This post is part 1 part of a 3 part series. Part 1 Part 2 Part 3 The code from this post, as well as the post itself, are on github . Until recently, regular expressions seemed magical to me. I never understood how you could determine if a string matched a given regular expression. Now I know! Here’s how I implemented a basic regular expression engine in under 200 lines of code. The Spec #…

HBO's SV Damaging Portrayal of The Valley

When I first watched the pilot of HBO’s Silicon Valley, I thought it was pretty funny. I found its over-the-top antics about startups, venture capitalists, and Google comically accurate. Some of my friends were less amused, primarily by the complete lack of women. While initially, this didn’t bother me, I’ve come around to a different point of view: I think the depiction of the valley with no…

Make Your Own Internet Connected Thermostat

During a brief stint of funemployment I decided to make an internet controllable thermostat for our apartment. While I had our normal thermostat on a schedule, it would be nice to turn it off before a trip and be able to turn it back on from my phone during the car ride home. You can buy a smart thermostat like a Nest, but they’re either very expensive or equally hard to use. Anyways, it’s more…