Skip to content

Instantly share code, notes, and snippets.

@yhara
yhara / zipper.rb
Created August 7, 2008 07:41
Ruby implementation of Zipper (and its spec)
#
# Zipper has @left and @right.
# When a zipper represents [1, 2, 3, <cursor>, 4, 5],
# @left == [3, [2, [1, []]]], @right == [4, [5, []]]
# Note that @left is in reverse order.
#
class Zipper
include Enumerable
def self.make(*vals)
@matthewtodd
matthewtodd / tmux
Created January 27, 2011 11:30
script/tmux
#!/bin/sh
tmux start-server
if ! $(tmux has-session -t grow); then
tmux new-session -d -s grow -n foreground
tmux send-keys 'cd .' C-m C-l
tmux send-keys 'AUTOFEATURE=true autotest --quiet' C-m
tmux split-window -h
tmux send-keys 'cd .' C-m C-l
@bergie
bergie / README.md
Created May 18, 2011 11:33
Falsy Values tutorials
@nrabinowitz
nrabinowitz / quantize.js
Created July 25, 2011 17:19
Javascript module for color quantization, based on Leptonica
/*!
* quantize.js Copyright 2008 Nick Rabinowitz.
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
// fill out a couple protovis dependencies
/*!
* Block below copied from Protovis: http://mbostock.github.com/protovis/
* Copyright 2010 Stanford Visualization Group
* Licensed under the BSD License: http://www.opensource.org/licenses/bsd-license.php
@oparrish
oparrish / assets_deploy.rb
Created September 20, 2011 15:44
Rake task for copying Rails compiled assets to S3
require 'aws/s3'
require 'digest/md5'
require 'mime/types'
## These are some constants to keep track of my S3 credentials and
## bucket name. Nothing fancy here.
AWS_ACCESS_KEY_ID = ENV['S3_KEY']
AWS_SECRET_ACCESS_KEY = ENV['S3_SECRET']
AWS_BUCKET = ENV['S3_BUCKET']
require 'rubygems'
require 'matrix'
require 'lingua/stemmer'
require 'csv'
require 'erb'
require 'iconv'
require 'sanitize'
require './cleaner.rb'
STEMMER = Lingua::Stemmer.new
@geuis
geuis / remote-typeahead.js
Created February 16, 2012 22:58
Remote data querying for Twitter Bootstrap 2.0 Typeahead without modifications
<script>
// Charles Lawrence - Feb 16, 2012. Free to use and modify. Please attribute back to @geuis if you find this useful
// Twitter Bootstrap Typeahead doesn't support remote data querying. This is an expected feature in the future. In the meantime, others have submitted patches to the core bootstrap component that allow it.
// The following will allow remote autocompletes *without* modifying any officially released core code.
// If others find ways to improve this, please share.
var autocomplete = $('#searchinput').typeahead()
.on('keyup', function(ev){
ev.stopPropagation();
@rn0
rn0 / remote-typeahead.js
Created February 16, 2012 23:45 — forked from geuis/remote-typeahead.js
Remote data querying for Twitter Bootstrap 2.0 Typeahead without modifications
// Charles Lawrence - Feb 16, 2012. Free to use and modify. Please attribute back to @geuis if you find this useful
// Twitter Bootstrap Typeahead doesn't support remote data querying. This is an expected feature in the future. In the meantime, others have submitted patches to the core bootstrap component that allow it.
// The following will allow remote autocompletes *without* modifying any officially released core code.
// If others find ways to improve this, please share.
var autocomplete = $('#searchinput').typeahead()
.on('keyup', function(ev){
ev.stopPropagation();
ev.preventDefault();
@ROFISH
ROFISH / erbengine.rb
Created February 23, 2012 01:10 — forked from mislav/gist:17371
haml2erb
class ErbEngine < Haml::Engine
def push_script(text, preserve_script, in_tag = false, preserve_tag = false,
escape_html = false, nuke_inner_whitespace = false)
push_text "<%= #{text.strip} %>"
end
def push_silent(text, can_suppress = false)
push_text "<% #{text.strip} %>"
end
@rhicks
rhicks / gist:3156727
Created July 21, 2012 18:47 — forked from jasoncodes/gist:1223731
Installing Ruby 1.9.3 with rbenv
brew install rbenv
brew install ruby-build
brew install rbenv-vars
brew install readline
brew install ctags
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile
exec $SHELL -i # reload the shell
CONFIGURE_OPTS="--disable-install-doc --with-readline-dir=$(brew --prefix readline)"
rbenv install 1.9.3-p194
rbenv global 1.9.3-p194