Skip to content

Instantly share code, notes, and snippets.

View spraints's full-sized avatar
🦦

Matt Burke spraints

🦦
View GitHub Profile
@spraints
spraints / bench-init.rb
Created October 5, 2016 12:13
benchmark a few styles of constructors in ruby
# I wanted to see how fast different constructor styles were.
#
# Calculating -------------------------------------
# splat 73.970k i/100ms
# manual splat 77.512k i/100ms
# kwarg 23.687k i/100ms
# attr 77.930k i/100ms
# opts 34.173k i/100ms
# fetch 29.289k i/100ms
# -------------------------------------------------
@spraints
spraints / .gitignore
Last active August 20, 2016 22:40
farmersmarket.com helpers
.bundle

I wanted to connect from a docker container on a prod server to an SVN server on my laptop today. The steps were tricky, so here they are:

ssh tunnel

Exposing the local port to the prod server is pretty straightforward

laptop$ ssh -R 4204:127.0.0.1:4204 myserver

docker networking

@spraints
spraints / blink.rb
Last active December 11, 2015 18:21

Terminal 1:

ruby 01-build-repo.rb test.git
ruby 02b-read-refs.rb test.git

Terminal 2:

@spraints
spraints / farmhacks.md
Last active August 29, 2015 14:27
Farm Hacks
#!/bin/sh -x
httpd -f /Users/burke/github/svn_apache/httpd.conf -k `basename $0`

Hit Tab to get a Coke.

def process(pull, attributes)
pull.review_comments.find_each do |comment|
rewrite_urls_in_model_body(comment)
comment.updated_at = comment.created_at # fix for referred_at
quiesce(comment, :ensure_synced_with_pull) do
comment.save
end
end
issue_post_processor.process(pull.issue, attributes)
# To demonstrate what a "Bank of Dad" would be like
require "date"
INTEREST_PER_MONTH = 0.1
birthday = Date.today # replace this with the child's birthday
twentyone = 21.times.inject(birthday) { |d, _| d.next_year }
balance = 0.0