Skip to content

Instantly share code, notes, and snippets.

View jwhitmire's full-sized avatar

Jeff Whitmire jwhitmire

View GitHub Profile
# This is a snippet from my ~/.irbrc
# You need to gem install ruby2ruby ParseTree
# This is what you do with it
#
# > class Bar; define_method(:foo) { 'ou hai' }; end
# > puts Bar.to_ruby
# class Bar < Object
# def foo
# "ou hai"
@jwhitmire
jwhitmire / Ode to _why
Created August 20, 2010 02:50
Happy _whyday everybody! In honor of his absence, I've composed a little haiku that I think _why would appreciate. I think you'll agree it's quite ... like the man himself.
_why the lucky stiff
his brain was rare in the world
hackety hack -- brilliant
_why the lucky stiff
we miss him even today
how very poignant
_why the lucky stiff
sometimes didn't make much sense
@gvaughn
gvaughn / gist:1436816
Created December 6, 2011 04:57
Conway's Game of Life in functional ruby
def evolve(generation)
live_neighbor_stats = generation_stats(generation)
live_neighbor_stats[3] + (live_neighbor_stats[2] & generation)
end
def generation_stats(live_cells)
live_cells.each_with_object(Hash.new(0)) {|live_cell, counter|
neighbors(*live_cell).each {|neighbor| counter[neighbor] += 1 }
}.each_with_object(Hash.new {|h,k| h[k] = []}) {|(cell, count), collector| collector[count] << cell}
end
@glv
glv / gist:1438719
Created December 6, 2011 16:05 — forked from gvaughn/gist:1436816
Conway's Game of Life in functional ruby
def evolve(generation)
live_neighbor_stats = generation_stats(generation)
live_neighbor_stats[3] + (live_neighbor_stats[2] & generation)
end
def generation_stats(live_cells)
live_cells.each_with_object(Hash.new(0)) {|live_cell, counter|
neighbors(*live_cell).each {|neighbor| counter[neighbor] += 1 }
}.each_with_object(Hash.new {|h,k| h[k] = []}) {|(cell, count), collector| collector[count] << cell}
end
@coreyti
coreyti / console.css
Created February 3, 2012 22:16
js & css to send window.console calls to the web page
ul.console {
font-size : 0.85em;
color : #FFF;
text-shadow : 0 1px #000;
position : fixed;
top : 70%;
right : 10px;
z-index : 10000;
width : 200px;
height : 25%;
@vindia
vindia / assigned_to_pullrequest.rb
Created May 11, 2012 16:40
Fetch username of person assigned to GitHub pull request
require 'json'
require 'open-uri'
user = 'GITHUB_USERNAME'
pass = 'GITHUB_PASSWORD'
repo = 'user/repo'
pulls = JSON.parse(open("https://api.github.com/repos/#{repo}/pulls", :http_basic_authentication => [user, pass]).read)
pulls.each do |pull|
@bobuss
bobuss / commits-by-hour
Created July 2, 2012 14:47
Git commits funstats
#!/usr/bin/env bash
for i in 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23; do echo $( echo -e "$i\t"; git shortlog -n --format='%ad %s' | grep " $i:" | wc -l); done
@sway
sway / commits-by-hour
Created July 11, 2012 20:25 — forked from bobuss/commits-by-hour
Git commits funstats
#!/usr/bin/env bash
for i in $(seq -f %02g 0 23); do echo $( echo -e "$i\t"; git shortlog -n --format='%ad %s' | grep " $i:" | wc -l); done
@jwhitmire
jwhitmire / template-mysql2.rb
Created November 11, 2012 00:24
Rails 3 templates of interest to me
#
# Install mysql2 gem with local brew settings which normally fails during regular rails install
#
puts "Installing mysql2 gem"
run "gem install mysql2 -- --with-mysql-include=/usr/local/Cellar/mysql/5.5.27/include --with-mysql-lib=/usr/local/Cellar/mysql/5.5.27/lib"
@zerowidth
zerowidth / bash_profile.sh
Created January 3, 2013 16:21
custom test runners with bash / fuubar / test/unit. hacks heaped upon hacks for a particular dev environment.
# http://www.linuxjournal.com/content/use-date-command-measure-elapsed-time
function timer() {
if [[ $# -eq 0 ]]; then
echo $(date '+%s')
else
local stime=$1
etime=$(date '+%s')
if [[ -z "$stime" ]]; then stime=$etime; fi