Skip to content

Instantly share code, notes, and snippets.


John Bachir jjb

View GitHub Profile
jjb / gist:742241
Created Dec 15, 2010
git bisect run, eat your heart out
View gist:742241
>> while (!system('rake'))
>> `git checkout HEAD~1`
>> end
jjb / runix.rb
Last active Jan 22, 2016
runix: The ruby shell command executor you've always wanted.
View runix.rb
# Ruby + UNIX = runix
# If return status is 0, returns standard out.
# If return status is non-0, raises an exception with standard error in the message.
# (None of the other methods you know about have this behavior)
# Great overview of all ruby shell methods:
# dependency: open4 gem
jjb / class_parents.rb
Created Apr 15, 2011
Viewing the lineage of a Ruby class
View class_parents.rb
def parents(obj)
( (obj.superclass ? parents(obj.superclass) : []) << obj)
jjb / gist:950975
Created May 1, 2011
Using whenever with capistrano and bundler in multiple environments
We couldn’t find that file to show.
jjb / gist:996292
Created May 27, 2011
How to securely acquire the Mozilla root certificate bundle for use with curl, Net::HTTP, etc.
View gist:996292

If you want to use curl or net-http/open-uri to access https resources, you will often (always?) get an error, because they don't have the large number of root certificates installed that web browsers have.

You can manually install the root certs, but first you have to get them from somewhere. This article gives a nice description of how to do that. The source of the cert files it points to is hosted by the curl project, who kindly provide it in the .pem format.

problem: Sadly, ironically, and comically, it's not possible to access that file via https! Luckily, the awesome curl project does provide us with the script that they use to produce the file, so we can do it securely ourselves. Here's how.

  1. git clone
  2. cd curl/lib
  3. edit and change:
jjb / gist:996510
Created May 28, 2011
How to set the certificate file for Net::HTTP library-wide
View gist:996510

In my previous post I described how to securely acquire the Mozilla list of root certificates and convert them to a form usable by curl and various libraries which don't ship with them.

Next, I want to point Net:HTTP at this file library-wide, so that it is used by all invocations of methods accessing https resources (in particular, Kernel#open, which in ruby 1.8.7 does not have a ca_file option and is therefore unusable with https). I hunted around the ruby standard library for a couple hours and came up with this:

require 'open-uri'
require 'net/https'

module Net
  class HTTP
View gist:1262562
➔ whois
Whois Server Version 2.0
Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to
for detailed information.
View gist:1285883
foo = 1
[2].each{|foo| }
# in ruby 1.8, foo in this scope is now 2
# in ruby 1.9, foo stays as it was before the block, 1. hooray!
jjb / gist:1771190
Created Feb 8, 2012 — forked from trevorturk/gist:1756760
Bare minimum html5 template
View gist:1771190
<!DOCTYPE html>
jjb /
Last active May 8, 2020
How to install ruby 1.9.3 on OS X with macports
You can’t perform that action at this time.