Skip to content

Instantly share code, notes, and snippets.

View purp's full-sized avatar
🖤
https://xrl.us/mlkbirmletterpdf

Jim Meyer purp

🖤
https://xrl.us/mlkbirmletterpdf
View GitHub Profile
@purp
purp / rbenv-copy-gems.rb
Created July 7, 2016 16:01
rbenv: install all gems from one version to another
#!/bin/bash
# copy is a misnomer; it's actually LIST + INSTALL
# --from 2.2.1 [--to other-version-else-whatever-is-currently-set]
#
# TODO: install only most-recent version that's installed in FROM
# TODO: use gem names only from FROM, install latest available version (might be more recent than in FROM)
# TODO: pass arguments to gem command (e.g. --no-document)
CURRENT_VERSION=`rbenv version | cut -d' ' -f1`
GEM_LIST_ARGS="--local"
@purp
purp / mapped_open_struct.rb
Created February 21, 2016 05:52
MappedOpenStruct: useful for hashes from JSON with crappy keys
require 'ostruct'
class MappedOpenStruct < OpenStruct
MAP = {}
def initialize(hash=nil)
super
add_mapped_methods
end
@purp
purp / array_expand.rb
Last active January 24, 2016 17:06
Expand a two-element array by an interval
class Array
def expand(interval=1)
raise "Can only expand two-element arrays" if self.size != 2
raise "Can only expand numeric arrays" unless self.first.kind_of?(Numeric) && self.last.kind_of?(Numeric)
result = [self.first]
while result.last < self.last do
next_value = result.last + interval
@purp
purp / openstack_approved_vendors.rb
Created July 16, 2015 09:41
Get the list of OpenStack-approved vendors from the OpenStack Marketplace
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'uri'
class String
def titleize
humanize.split(' ').map(&:capitalize).join(' ')
end
@purp
purp / schedule_urls.csv
Created May 12, 2015 02:06
MLB Team Names, Abbreviations, and Up-to-date iCal link (from http://mlb.com/schedule/downloadable.jsp?c_id=ABBREV&year=2015)
Arizona Diamondbacks ari webcal://mlb.am/tix/diamondbacks_schedule_full
Atlanta Braves atl webcal://mlb.am/tix/braves_schedule_full
Baltimore Orioles bal webcal://mlb.am/tix/orioles_schedule_full
Boston Red Sox bos webcal://mlb.am/tix/redsox_schedule_full
Chicago White Sox cws webcal://mlb.am/tix/whitesox_schedule_full
Chicago Cubs chc webcal://mlb.am/tix/cubs_schedule_full
Cinncinnati Reds cin webcal://mlb.am/tix/reds_schedule_full
Cleveland Indians cle webcal://mlb.am/tix/indians_schedule_full
Colorado Rockies col webcal://mlb.am/tix/rockies_schedule_full
Detroit Tigers det webcal://mlb.am/tix/tigers_schedule_full

Keybase proof

I hereby claim:

  • I am purp on github.
  • I am purp (https://keybase.io/purp) on keybase.
  • I have a public key whose fingerprint is C28F 189B 850A 6618 13CE FD57 8210 67C8 ED49 73A1

To claim this, I am signing this object:

@purp
purp / gist:3751802
Created September 19, 2012 19:46
I love multilingualization ... no, really
irb(main):002:0> lines = FasterCSV.read('/Users/purp/Desktop/some_random_file.csv'); nil
NotImplementedError: Please switch to Ruby 1.9's standard CSV library. It's FasterCSV plus support for Ruby 1.9's m17n encoding engine.
from /Users/purp/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/fastercsv-1.5.5/lib/faster_csv.rb:13:in `const_missing'
from /Users/purp/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/fastercsv-1.5.5/lib/faster_csv.rb:19:in `method_missing'
from (irb):2
from /Users/purp/.rbenv/versions/1.9.3-p194/bin/irb:12:in `<main>'
irb(main):003:0> require 'csv'
=> true
irb(main):004:0> lines = CSV.read('/Users/purp/Desktop/some_random_file.csv'); nil
ArgumentError: invalid byte sequence in UTF-8
@purp
purp / README.mdown
Created July 9, 2012 23:37
purp's d3 sandbox
@purp
purp / Aliasing.rb
Created March 29, 2011 22:33
How to alias method chain manually
def foo
'foo'
end
def foo_with_bar
foo_without_bar + 'bar'
end
alias foo_without_bar foo
alias foo foo_with_bar
Evan Phoenix Rubinius Hydra branch
Ron Evans TicketMaster: A Universal API to Project Management & Tickets
Pete Forde The Impossible Project
David Stevenson FixtureBuilder
Noah Gibbs Getting Rid of Java
Aman Gupta perftools.rb
John Woodell Dubious
Seth Ladd Smart Browsers
Pat Nakajima Screw Cucumber! (nah, just playin')
Nathan Esquenazi Terminator