Skip to content

Instantly share code, notes, and snippets.

@peterkeen
peterkeen / about.md
Last active Aug 29, 2015
Email courses as state machines.
View about.md

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

Hello there! This is a sample post for gist.io, 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
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
MAINTAINER Pete Keen "pete@petekeen.com"
# 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
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
end
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
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 <ward.cunningham@gmail.com>
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
/^(?:Expenses:(Cable|Utils))/
* $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>
<thead>
<tr>
<th>From</th>
<th>Subject</th>
<th>Date</th>
</tr>
View built.coffee
foo = () ->
a = 17
40
foo()
View example transfer
2012/02/29 * Medical Fund Transfer To Savings
[Assets:Checking] $4,000.00
[Assets:Funds:Medical]
2012/02/29 * Savings Deposit
Assets:Savings $4,000.00
Assets:Checking
2012/02/29 * Medical Fund Transfer To Savings
[Assets:Medical] $4,000.00