Skip to content

Instantly share code, notes, and snippets.

@tmiller
tmiller / pairings.rb
Last active August 29, 2015 13:56
Pairing Algorithm
require 'pp'
devs = %w{ Andrew Anthony Ben Matt Tom Zac }
devs << nil if devs.length.odd?
top, bottom = devs.each_slice(devs.length/2).to_a
pivot, *top = top
result = []
(devs.length-1).times do
top.unshift(bottom.shift)
@tmiller
tmiller / halt.mixal
Last active August 29, 2015 13:56
Replace all 4000 memory cells with HLT
* My solution
MAIN ENT1 0
ENT2 3999
ENTA 133
STA 0,2
DEC2 1
CMP2 7(4:5)
JGE 3
MOVE 9(9)
CON 9
@tmiller
tmiller / rollback-to-master.sh
Created January 9, 2014 17:02
Rollback migrations to master from HEAD or a ref
#!/bin/sh
if test -n "$1"; then
ref="$1"
else
ref="HEAD"
fi
git diff $ref --not master --name-only -- db/migrate/ |
cut -d/ -f3 |
@tmiller
tmiller / commit-messages.txt
Created January 2, 2014 01:26
Commit Messages
Context
The circumstances that form the setting for an event, statement, or
idea, and in terms of which it can be fully understood and assessed.
When you are writing a commit message getting the context right is very
important. Here are some pieces of information that are useful for
building up a proper context.
* Explain what was done.
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 5647055..b67a350 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -810,11 +810,6 @@ static int do_fetch(struct transport *transport,
if (tags == TAGS_DEFAULT && autotags)
transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, "1");
- if (fetch_refs(transport, ref_map)) {
- free_refs(ref_map);
@tmiller
tmiller / tokenizer.rb
Created August 25, 2013 02:59
Hand written CSV tokenizer
class Tokenizer
class Buffer # :nodoc:
def initialize io
@io = io
@buffer = []
end
def peek len = 1
(len - @buffer.length).times {
require File.dirname(__FILE__) + '/../test_helper'
class RangeTest < Test::Unit::TestCase
test <<-TEST do
Range#coinsides_with?
|
|
TEST
range = Time.zone.now..Time.zone.now
require 'action_mailer'
require 'mail'
module ActionMailer
class TestCase
def set_expected_mail
@expected = Mail.new
@expected.content_type = "text/plain; charset=#{charset}"
@expected.mime_version = '1.0'
@tmiller
tmiller / README.md
Last active February 2, 2024 20:41
A very simple example of using a map of channels for pub/sub in go.
@tmiller
tmiller / ruby-syntax-settings.json
Last active December 16, 2015 22:49
A temporary place for my package settings for sublime
{
"tab_size": 2,
"translate_tabs_to_spaces": true,
"draw_white_space": "all"
}