Skip to content

Instantly share code, notes, and snippets.

View JackDanger's full-sized avatar

Jack Danger JackDanger

View GitHub Profile
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 = File.read(filename).lines.length.to_f - 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!"
return
a_little_recursion(n + 1)
a_little_recursion(0)
module Injectable
class Placeholder
def initialize(target)
@target = target
end
def injected_value
@target.generate
end
end
# 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
JackDanger / gist:6232426
Created August 14, 2013 15:56
error installing Revel go web framework
# If you see this:
$ go get github.com/robfig/revel
package code.google.com/p/go.net/websocket
imports github.com/robfig/pathtree
imports github.com/streadway/simpleuuid
imports net/http/cookiejar: unrecognized import path "net/http/cookiejar"
# You need to upgrade to go version 1.1
@JackDanger
JackDanger / gist:5592942
Created May 16, 2013 16:14
Compiling JRuby on Java 1.8?
# 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
compile-jruby:
[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/JavaClass.java:1418: error: cannot find symbol
[javac] return getRuntime().newBoolean(javaClass().isAnnotationPresent(((JavaClass)annoClass).javaClass()));
[javac] ^
[javac] symbol: method isAnnotationPresent(Class)
def odd(list)
list.each_with_index do |item, index|
yield item if index % 2 == 0
end
end
def even(list)
list.each_with_index do |item, index|
yield item if index % 2 == 1
end
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
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) # ┴
# 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