Skip to content

Instantly share code, notes, and snippets.

View michel's full-sized avatar

Michel de Graaf michel

View GitHub Profile
@michel
michel / lru.rb
Created March 23, 2012 10:24
LRU caching code kata
class Cache
attr_accessor :max_size
def initialize
@max_size = 99
@cache = {}
end
def store(key,object)
@cache[key] = [0,object]
purge_old
key
@michel
michel / test.xml
Created March 1, 2012 20:00
ringr
<?xml version="1.0" encoding="UTF-8"?><Response><Play>http://izerion.com/da1392f0-460b-012f-74be-3c07544054a5.wav?asdf</Play></Response>
alias app_setup='br db:drop:all && br db:create:all && br dsi:schema:load && br db:schema:load && br db:seed'
@michel
michel / download_chromium.sh
Created March 17, 2011 10:34
Download and install latest Chromium build on OS X. For a quick install run the following command in your console: curl https://gist.github.com/raw/874137/2f045246310587f5384c9db57e62f049e89ffbc6/download_chromium.sh > download_chromium.sh; chmod +x down
#!/bin/bash
BASEDIR=http://build.chromium.org/f/chromium/snapshots/Mac
mkdir -p /tmp/chromium_nightly
cd /tmp/chromium_nightly
echo "Downloading number of latest revision"
REVNUM=`curl -# $BASEDIR/LATEST`
echo "Found latest revision number $REVNUM, starting download"
@michel
michel / alpha_substr.rb
Created November 20, 2010 13:12
Alphabet in substring?
#!/usr/bin/env ruby -wKU
# Say you have one string of alphabetic characters, and say you have another,
# guaranteed smaller string of alphabetic characters. Algorithmically speaking,
# what's the fastest way to find out if all the characters in the smaller string are in the larger string?
#
# For example, if the two strings were:
#
#
# String 1: ABCDEFGHLMNOPQRS
require 'socket'
require 'openssl'
require 'net/ftp'
class Net::FTPS < Net::FTP
end
class Net::FTPS::Implicit < Net::FTP
FTP_PORT = 990
@michel
michel / protheme.xccolortheme
Created March 1, 2010 18:54
Xcode pro theme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Colors</key>
<dict>
<key>Background</key>
<string>0.097 0.101 0.124</string>
<key>InsertionPoint</key>
<string>1.000 1.000 1.000</string>
@michel
michel / Gemfile
Created February 17, 2010 20:46
Rails 2.3.5 and bundler
#Example gemfile
source :gemcutter
# Rails 2.3.5
gem 'rails', '~> 2.3.5', :require => nil
gem 'ruby-mysql', '>= 2.9.1', :require => 'mysql'
gem 'haml', '2.2.19', :require => nil
gem 'inherited_resources', '= 1.0.3'