RSSAmplifier

Blog

Conrad Irwin

cirw.inRSS feed ↗27 posts

Latest posts

Single mutable ownership

The best feature of Rust is the single-mutable reference. The way this is implemented in Rust is via the borrow checker. Each variable is either owned, a shared (immutable) reference, or mutably borrowed. What’s interesting about references in Rust is they really do two things: They track permissions (am I allowed to mutate this or not) They enable pass-by-reference instead of pass-by-value. In a…

What if typescript was right about union types...?

One thing I love about Rust is the exhaustive pattern matching. The killer use case of this is preventing nil pointer deferences. You never have an invalid pointer, you represent that as an Option<T> . That said, Rust’s enums (on which this feature are based) feel very heavy. The type signatures are too precise: it is rare to care about the difference between an Option<Result<T, Error>> and a…

A better for loop?

One of the things that winds me up in Rust is that by defult you’re “supposed” to iterate over collections using .map and other fancy iterator methods. This actually is not a very bad thing, the real problem is that you’re also “supposed” to return results by putting a cheeky ? on the end of the line. But, as anyone who’s actually used Rust can tell you, you can’t do both. That means if you want…

To garbage collect or not?

As many programmers do, I harbor a secret desire to build a “better” programming language. One of the things I’ve come to realize (having used a few of them at this point) is that your approach to recycling memory has far-reaching ramifications. There are (roughly) three common approaches in use today: Fully managed. Think Go, Python, etc. You allocate memory when you need it, and the garbage…

CONL: "markdown" for your config files

In my day job building software, I have to interact with complex configuration files continually. They are (as of 2025) typically in one of three formats: JSON-with-comments, YAML, or TOML. Although they enjoy widespread usage, each of these formats is painful to use in practice: JSON-with-comments — it’s really hard to comment out a line in a JSON file, because you end up with an extra trailing ,…

Tools for Go modules

For the last ~two years I’ve been working on pushing for a small quality of life improvement for Go teams. I’m thrilled that modules can now declare tool dependencies starting with Go 1.24: # go.mod module example.com/mod go 1.24 tool ( golang.org/x/tools/cmd/stringer ./cmd/migrate ) require ( ... ) A common problem that development teams run into is the need to have a consistent development…

What does = do in rust?

I have been learning rust for the last few months and, like many others, have found it hard to develop an intuition for when the borrow checker will disallow what I’m trying to do. I had an insight recently that may be helpful to others who are switching to rust from other languages, and I wanted to share it. In prior languages (for me, a hodgepodge of Go, Javascript and variants, Ruby, Python,…

Smooth animated HTML-5 icons

Recently we added our first animated icon to Superhuman as part of the transition to the search interface: NOTE: The animations in this video are running at 1/10th of normal speed. There’s clearly more work to be done here, but you get the idea: the icon animates to enforce the perceptual link between the user’s click and its effect, while the text flicks right to draw the user’s attention to the…

Hacking smart-quote support into a font

I’ve recently been doing some work on making Superhuman the most beautiful email client in the world. (N.B. We’re looking to hire a lead designer, please email me ). One of the features we wanted was automatic “smart quotes”. Instead of the bland vertical quotes you often see on a computer “•”, we’d replace them at render time by fun curvy quotes “•” to make the text more alive. I’d known for a…

How to serve a static site from Heroku

Heroku provides an awesome hosting service for all your apps. But it turns out that you can use it to serve static pages too. There are a variety of tricks I’ve seen, but most of them seem to involve complicated hackery, this solution uses ruby’s builtin web-server: it’s not going to be the most scalable site in the world, but it’s more than enough considering that it’s totally free :). Solution…

IPv6 comes to San Francisco

If you live in San Francisco there’s a good chance that you can use IPv6 on your home router. Comcast, AT&T, and Sonic.net all support it. ( let me know if there’s one I missed). It took me a while to get everything set up, so here is a collection of everything you need to know to move from IPv4 only to IPv4 + IPv6. It goes without saying that you’ll need an IPv6 compatible modem. Almost all…

IPv6 configuration instructions

This is a companion article to IPv6 comes to San Francisco that explains how to set up IPv6 with Sonic.net and Comcast. Comcast For Comcast, you can double-check that you have support by visiting comcast6.net . If you see “Your CMTS is ready for IPv6.”, you’re ready to rock! Then navigate to your router (probably 192.168.1.1 or 192.168.0.1) and find the IPv6 settings. There are two questions to be…

dotgpg — easy to use storage for your production secrets

Where are your database passwords? your cookie encryption keys? your SSL certificates? The most common answers are “in git” and “in Dropbox”. Hopefully with a guilty squirm and followed by an awkward “it’s on my todo list”… Storing production secrets on cloud services in plain text is very tempting but it’s obviously insecure. We’ve seen hacks via API keys in git , we’ve seen Dropbox passwords…

Avoiding MongoDB hash-injection attacks

MongoDB is a popular document store. Its query API neatly sidesteps SQL-injection attacks by not being SQL. Unfortunately when using a framework like Rails, it’s easy to build an app that’s vulnerable to a hash-injection attack. Hash-injection is much less severe than SQL-injection, because an attacker is more limited in the kind of changes they can make, but it can lead to authentication-bypass,…

Node's Unicode Dragon

At Bugsnag we accept JSON payloads of application crashes. These often contain broken data. For example, if your app has crashed with an invalid encoding error, the JSON will often contain the invalid string that crashed your server. This shouldn’t be a problem for us as we read the JSON payload with Node and Node replaces all the invalid bytes with the unicode replacement character (� U+FFFD).…

bracketed paste mode

One of the least well known, and therefore least used, features of many terminal emulators is bracketed paste mode . When you are in bracketed paste mode and you paste into your terminal the content will be wrapped by the sequences \e[200~ and \e[201~ . For example, let's say I copied the string "echo 'hello'\n" from a website. When I paste into my terminal it will send "\e[200~echo…

Visualizing memory leaks in Ruby

Memory leaks are my least favourite type of bug. To track them down requires not only a detailed knowledge of the entire codebase but also strong intuition (or a lot of luck). To make the process more fun I’ve written a patch for ruby 1.9.3 that lets you visualize portions of the memory graph. ObjectSpace.each_object Ruby already comes with ObjectSpace which contains a few methods for analyzing…

LSpace: Dynamic scope for Ruby

At Rapportive we have one master database that’s always up-to-date, and a read slave that may be a little bit behind. Usually a database read can use either connection, but if a user is viewing their own page we need to use the master database. This is so that if they’ve just edited their information, their edits are guaranteed to show up, even if the read slave is lagging. LSpace is a library…

Everything you ever wanted to know about constant lookup in Ruby

One of the best things about Ruby is that it just does what you mean. The downside of this is that if you’re dealing with a fiddly situation, it can be somewhat hard to work out exactly what it will do. This is particularly true of constant lookup. To access a constant in ruby, you just use its name: FooClass . But how does that actually work? Although the answer turns out to be reasonably…

pry to the rescue

This post is also available [in Russian](http://scriptogr.am/entooru/post/20120827-pry-to-the-rescue). Thanks [kyrylo](mailto:kyrylosilin@gmail.com)! Introducing: pry-rescue : super-fast, painless, debugging for the (ruby) masses. What does it do? Whenever an unhandled exception happens in your program, pry-rescue opens an interactive pry shell right at the point it was raised. Instead of…

MVC is dead, it's time to MOVE on.

MVC is a phenomenal idea. You have models, which are nice self-contained bits of state, views which are nice self-contained bits of UI, and controllers which are nice self-contained bits of … What? I’m certainly not the first person to notice this, but the problem with MVC as given is that you end up stuffing too much code into your controllers, because you don’t know where else to put it. To fix…

A quick introduction to Teacup

Teacup is a library for RubyMotion that let’s you create views and layouts in simple declarative code. The simplest way to understand it is that it’s “CSS for iOS”, but that would be to heavily underestimate what it can do. Perhaps a better analogy is “Interface Builder for RubyMotion”, as both tools solve the same problem. Creating layouts Once you’ve added teacup to your app , you can get…

adding context to a shared git repository

At Rapportive we use git extensively for its powerful branching and merging capabilities. The workflow we use is very similar to that used by GitHub : everything in master is deployed, everything else is in branches based off master. We’re also using Heroku ’s git push deployment model, so git is the canonical source of information about which code is where. In order to make this easier to work…

How to program like an explorer (with Pry!).

I'm one of the core committers to the [Pry REPL](http://pry.github.com/). Talking about this at work a few weeks ago, a colleague asked me: "Why should I use pry? I mean, I know it's better, but what's it for?". This is a somewhat long-winded attempt to answer that question. Exploring is a large part of what programmers do during the time when we’re not typing out code. Attempting to discover the…

git aliae so that you never lose work (part 2)

Git is an incredibly powerful tool for version control. Much of this power stems from its underlying append-only object database which ensures that once you’ve made a commit it can never be changed or unmade. This is great because it means you can refactor history safe in the knowledge that you can git reset back to a working version if something goes wrong. One thing I’ve yearned for however is…

ampex — a practical use of Ruby's & operator

Ruby is renowned for both its readability and its flexibility. The ultimate goal of every Ruby program is to work well while appearing as simple as possible. To achieve this as a Ruby programmer, you’re encouraged to push a lot of the fiddly bits of code deep into parts of your program where a casual reader of the source can ignore them. Out of the box Ruby ships with some very powerful tools to…

git aliae to make you more awesome (part 1)

One of the amazing advantages of git is that you can create commits locally on your own computer. I think this is one of the massively underestimated features of distributed version control systems as it enables (at least) three hugely wonderful things: You can make permanent check-points every time you get the code into a working state, and refer to them to when you break stuff. You can save what…

Conrad Irwin · RSS Amplifier