Skip to content

Instantly share code, notes, and snippets.

peterkeen /
Last active Aug 29, 2015
Email courses as state machines.

This is a first draft of an idea I had in the shower this morning.

Email courses (aka sequences of email autoresponders) can be trivially modeled as finite state machines. Each state is the last email they were sent (or queued to receive) and each transition queues an email to be sent.

This example implementation builds on top of AASM for the state machine and ActsAsTaggableOn to keep track of states. In a production-ready implementation, likely the state machine implementation would be wrapped in a DSL that streamlines the process a little more.

peterkeen / gist:7591428
Created Nov 21, 2013 is down
View gist:7591428
$ dig @
; <<>> DiG 9.7.6-P1 <<>> @
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 15309
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
View gist:6017752

Hello there! This is a sample post for, a super-lightweight writing soapbox for hackers.

Now look up. Further. Above the post title. See that grey text with the gist ID?

Now back to me. That grey text is a link! Open that sucker in a new tab to see the source for this post. Also, I'm on a horse.

This is a SUPER major heading

If you peek at it with a web inspector, you'll see that it is a second-level heading. You can use first level headings, but they'll look just like the second level ones, and the gods of the HTML5 outlining algorithm will frown upon you.

peterkeen / Dockerfile
Created Jun 27, 2013
My very first Dockerfile! It installs Ruby 2.0 from scratch, installs bundler, and then vendors in my app and installs dependencies.
View Dockerfile
# Use Ubuntu 12.04 as the base image
FROM ubuntu:precise
# Install a bunch of prerequisites
RUN apt-get update
RUN apt-get install -y git-core curl wget libssl1.0.0 python-yaml build-essential libssl-dev
# Install ruby-build
peterkeen / 20121108220000_add_budget_tables.rb
Created Jan 8, 2013
This is how I implement budgets for ledger web
View 20121108220000_add_budget_tables.rb
Sequel.migration do
up do
create_table(:budget_periods) do
String :account
BigDecimal :amount
Date :from_date
Date :to_date
create_or_replace_view :budget_months, "select xtn_month, account, amount from (select distinct xtn_month from accounts_months) x cross join budget_periods where xtn_month between budget_periods.from_date and (coalesce(budget_periods.to_date, now()::date))"
peterkeen / ward.txt
Created Nov 29, 2012
Ward Cunningham on Pair Programming to the pdxruby mailing list
View ward.txt
Subject: Re: [pdxruby] Re: Complex return value anti-pattern?
From: Ward Cunningham <>
Date: Thu, 29 Nov 2012 08:23:26 -0800
Pair programming is often misunderstood.
To understand pairing one must examine the world views of programmers. For
many (perhaps all programmers historically) programming is difficult and re
quires skill and concentration to be successful. For others, and here we fi
nd roots in dynamic languages, programming is easy but requires imagination
View gist:3177415
* $account -0.5
* Assets:Receivable:GF 0.5
= /^Expenses:Rent$/
* $account -0.2968
* Assets:Receivable:GF 0.2968
View gist:3062758
<table class="table table-striped table-bordered">
<col class="span2"></col>
<col class="span8"></col>
<col class="span2"></col>
foo = () ->
a = 17
View example transfer
2012/02/29 * Medical Fund Transfer To Savings
[Assets:Checking] $4,000.00
2012/02/29 * Savings Deposit
Assets:Savings $4,000.00
2012/02/29 * Medical Fund Transfer To Savings
[Assets:Medical] $4,000.00