This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Injectable | |
class Placeholder | |
def initialize(target) | |
@target = target | |
end | |
def injected_value | |
@target.generate | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) # ┴ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |