Skip to content

Instantly share code, notes, and snippets.

View halogenandtoast's full-sized avatar

Matthew Mongeau halogenandtoast

View GitHub Profile
# Hot deploy Rails apps (rolling restart) with Capistrano, Haproxy, and cluster of Passengers
# Capistrano config
namespace :passenger do
task :disable_load_balancing, :roles => :app do
run "rm -f #{current_path}/public/http-check.txt"
end
task :enable_load_balancing, :roles => :app do
source 'http://rubygems.org'
gem 'rails', '3.0.0.beta3'
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
gem 'haml', '3.0.0.rc.4'
gem 'will_paginate', '3.0.pre'
group :test do
gem 'capybara', '0.3.7'
gem 'database_cleaner', '0.5.2'
This is a normal conversation between a friend and I:
Chris
3:45
Having had a few smart phones I have enough experience to know their merits and their fallacies.
Matthew
3:46
Having owned several computers I know enough to take them apart to increase my gigawatts
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void create_node(char* property_list) {
char* item;
char* list;
const char *end = property_list;
while(*end)
class BrainfuckInterpreter
def initialize(program)
@memory = Array.new(255) { 0 } # 255 memory cells
@m_ptr = 0 # memory pointer: which cell
@i_ptr_stack = Array.new # instruction pointer stack: used for loops and nested loops
@i_ptr = 0 # instruction pointer: which instruction
@program = program
end
def run
class Mastermind
attr_accessor :actual, :title
def initialize
@actual = [rand(6) + 1, rand(6) + 1, rand(6) + 1, rand(6) + 1]
@title = "Mastermind"
end
def play
display_title
@halogenandtoast
halogenandtoast / countdown.asm
Created March 15, 2013 18:19
A very simple toy vm
push 5
ifeq 4
jump 8
print
push -1
add
jump 2
print
(ns poker.core)
(def suits ['C 'D 'H 'S])
(def values ['A '2 '3 '4 '5 '6 '7 '8 '9 'T 'J 'Q 'K])
(def deck (map (fn [i] [(rem i 13) (quot i 13)]) (range 52)))
(defn format-card [card]
(apply str (map get [values suits] card)))
(defn low-card [hand]
@halogenandtoast
halogenandtoast / forge.c
Created August 28, 2014 15:56
A crappy editor
#include <ncurses.h>
#include <stdlib.h>
#include <string.h>
enum mode {
NORMAL,
INSERT,
COMMAND
};
@halogenandtoast
halogenandtoast / index.html
Created October 28, 2014 17:21
Includes both examples from the talk. index.html and main.js are the pure WebGL example and three.html is the ThreeJS example.
<!DOCTYPE html>
<html>
<head>
<title>WebGL Example</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.2.1/gl-matrix-min.js"></script>
<script id="shader-fs" type="x-shader/x-fragment">
precision mediump float;
void main(void) {