Skip to content

Instantly share code, notes, and snippets.


Jack Danger JackDanger

View GitHub Profile
View gist:9864648
require 'csv'
def import(filename, out = $stdout, &block)
# Yes, there are gems that do progress bars.
# No, I'm not about to add another dependency for something this simple.
width = `tput cols`.to_i - 4
processed = 0
total = - 1
label = File.basename(filename, '.csv')
out.puts "%11s:" % label
def a_little_recursion(n):
if n > 100:
print "all done!"
print "not done yet!"
a_little_recursion(n + 1)
View ruby_dependency_injection.rb
module Injectable
class Placeholder
def initialize(target)
@target = target
def injected_value
View gist:7835036
# Square Software Engineer, Foundation Server
Behind the teams that build new features for our millions of merchants there is
a group that builds tools and services to make the product teams' work easier.
We work in every software language and at every layer in the technology stack – from
client to api to server to database. Our mission is to serve the engineers of Square
and, by extension, all the small business owners who need a simple and powerful
payment system. You don't have to know these languages or technologies but you do
need to be willing to learn.
JackDanger / gist:6232426
Created Aug 14, 2013
error installing Revel go web framework
View gist:6232426
# If you see this:
$ go get
imports net/http/cookiejar: unrecognized import path "net/http/cookiejar"
# You need to upgrade to go version 1.1
JackDanger / gist:5592942
Created May 16, 2013
Compiling JRuby on Java 1.8?
View gist:5592942
# If you get the following, the solution is to try compiling under Java 1.6
# $ JAVA_HOME=`/usr/libexec/java_home -v 1.6` rvm install jruby-head
[javac] Compiling 1395 source files to /Users/jackdanger/.rvm/src/jruby-head/build/classes/jruby
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6
[javac] /Users/jackdanger/.rvm/src/jruby-head/src/org/jruby/javasupport/ error: cannot find symbol
[javac] return getRuntime().newBoolean(javaClass().isAnnotationPresent(((JavaClass)annoClass).javaClass()));
[javac] ^
[javac] symbol: method isAnnotationPresent(Class)
View evenodd.rb
def odd(list)
list.each_with_index do |item, index|
yield item if index % 2 == 0
def even(list)
list.each_with_index do |item, index|
yield item if index % 2 == 1
projects=`locate Gemfile.lock | egrep -v "(.rvm|bundler|.passenger)" | xargs egrep " rails" | cut -d : -f 1 | uniq | xargs egrep -L 'rails \((2.3.15|3.0.19|3.1.10|3.2.11)\)' |cut -d : -f 1 | xargs -n 1 dirname`
for project in $projects; do
echo '-----------------'
echo '-- PATCHING' $project ' -- '
echo '-----------------'
cd $project
git stash
git checkout master
git pull
sed -i .bak "s/gem [\"|']rails[\"|'], [\"|']2.*[\"|']/gem 'rails', '2.3.15'/g" Gemfile
View gist:4010396
printf("%c\n", 14)
printf("%c ", 0x6A) # ┘
printf("%c ", 0x6B) # ┐
printf("%c ", 0x6C) # ┌
printf("%c ", 0x6D) # └
printf("%c ", 0x6E) # ┼
printf("%c ", 0x71) # ─
printf("%c ", 0x74) # ├
printf("%c ", 0x75) # ┤
printf("%c ", 0x76) # ┴
View tmux.conf
# use C-a, since it's on the home row and easier to hit than C-b
set-option -g prefix C-a
unbind-key C-a
bind-key C-a send-prefix
set -g base-index 1
# vi is good
setw -g mode-keys vi
set-option -g default-terminal screen-256color