Skip to content

Instantly share code, notes, and snippets.


Chris Corbyn d11wtq

  • Melbourne, Australia
View GitHub Profile
d11wtq / docker-ssh-forward.bash
Created Jan 29, 2014
How to SSH agent forward into a docker container
View docker-ssh-forward.bash
docker run -rm -t -i -v $(dirname $SSH_AUTH_SOCK) -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK ubuntu /bin/bash
d11wtq / enum.sql
Created Oct 26, 2012
Renaming an ENUM label in PostgreSQL
View enum.sql
Assuming you have an enum type like this.
You want to rename 'pending' to 'lodged'
CREATE TYPE dispute_status AS ENUM('pending', 'resolved', 'open', 'cancelled');
ALTER TYPE dispute_status ADD VALUE 'lodged';
UPDATE dispute SET status = 'lodged' WHERE status = 'pending';
d11wtq / let.js
Created Aug 18, 2012
RSpec style let() in Jasmine/Mocha
View let.js
* Get RSpec-style let() in your Mocha/Jasmine specs.
var let = function (callback) {
var value, called = false;
var memoizer = function() {
if (called) {
return value;
} else {
called = true;
d11wtq / deliver_email_job.rb
Created Aug 28, 2011
Customizing ActionMailer delivery methods
View deliver_email_job.rb
# Resque job to do the true outbound sending
class DeliverEmailJob
include ProjectName::Job::Logging
@queue = :mail_queue
def self.perform(args)
message = QueuedEmail.get!(args["message_id"])"Delivering (%s) to %s" % [message.subject, message.formatted_recipient])
d11wtq / binary_tree.erl
Created Mar 21, 2013
Binary tree implementation in Erlang.
View binary_tree.erl
%% @doc A binary tree implementation in Erlang.
%% A binary tree stores keys and values.
-export([init/0, init/1, insert/3, lookup/2]).
-define(EMPTY_NODE, {node, 'empty'}).
%% @doc Initialize an empty binary tree node.
%% This is how the root of the tree should be established.
d11wtq / schedule.clj
Last active Jan 4, 2016
Seeking DSL style review
View schedule.clj
(defschedule app-schedule "Application tasks"
[:every "5 seconds" (println "Woohoo!")]
[:at "7am tomorrow" (wake-up!)])
d11wtq / thread-macro.clj
Created Dec 13, 2013
Demonstration implementation of the `->` macro in Clojure.
View thread-macro.clj
(defmacro demo-> [val & fns]
(reduce (fn [acc fname] (list fname acc)) val fns))
(macroexpand '(demo-> 42 inc dec inc)) ; (inc (dec (inc 42)))
d11wtq / inc-number.el
Created Jun 22, 2013
Vim-style increment/decrement numbers under the cursor, for Emacs.
View inc-number.el
;; vim-style increment/decrement numbers
(defun inc-number-at-point (n)
"Increment the number under the point, if present.
Called with a prefix argument, changes the number by N."
(interactive "p")
(let ((amt (or n 1))
(word (thing-at-point 'word))
(bounds (bounds-of-thing-at-point 'word)))
(when (string-match "^[0-9]+$" word)
(replace-string word
View colorize.el
(defun colorize-mode-line (&rest args)
(let ((color (cond ((evil-insert-state-p) "#fa4444")
((evil-emacs-state-p) "#fafa00")
((buffer-modified-p) "#22bff0"))))
(set-face-background 'mode-line (or color "#ffffff"))))
(add-to-list 'post-command-hook 'colorize-mode-line)
d11wtq /
Last active Dec 16, 2015
SQL vs ORM vs QLCs

Comparing the power and expressiveness of various database query systems

Simple select all.

SELECT * FROM users;
You can’t perform that action at this time.