Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / Pair.hs
Last active August 29, 2015 14:03
Round robin tournament algorthim for generating coding pairs in Haskell
module Main where
import Data.List
data Coder = Coder String
| Nobody
deriving (Show)
data Pairings = Pair Coder Coder
| Pairs [Pairings]
@tmiller
tmiller / events.js
Last active August 29, 2015 14:04
jQuery event sample
$(document).ready(function() {
$(document)
.on(
'ajax:before',
'form.single-line-qualification',
function(e) {
if (e.target[1].value.trim() === '') {
e.target[1].value = '';
alert('You must enter a name!');
return false;
@tmiller
tmiller / gist:1274563
Created October 10, 2011 03:15
Install unicode font for look of disapproval on OSX
cd ~/Library/Fonts/ && curl -O http://web.nickshanks.com/downloads/fonts/Kedage.dfont
@tmiller
tmiller / irssi-bottom
Created February 11, 2012 02:17
irssi config
settings = {
core = {
real_name = "Tom Miller";
user_name = "tmiller";
nick = "tmiller";
};
"fe-text" = { actlist_sort = "refnum"; };
"perl/core/scripts" = {
growl_show_message_public = "yes";
growl_show_message_action = "yes";
@tmiller
tmiller / server.rb
Created June 26, 2012 18:40
Small server
require 'socket'
require 'thread'
server = TCPServer.open(8080)
HEADER = <<-EOH
HTTP/1.1 200 OK
Content-Type: text/html; charset=ISO-8859-1
EOH
;; Packages
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)
;; General
(fset 'yes-or-no-p 'y-or-n-p)
(setq inhibit-startup-screen t)
(setq inhibit-startup-echo-area-message t)
@tmiller
tmiller / gist:3787980
Created September 26, 2012 13:18
Get status of working tree
git status --porcelain | sort -u | sed -e 's/^.\(.\).*/\1/' -e 's/M/*/' -e 's/D/-/' -e 's/?/+/' | tr -d '\n'
<%
def database_adapter
if Bundler.load.specs.map(&:name).include? "mysql2"
"mysql2"
else
"mysql"
end
end
def database_name(environment)