Skip to content

Instantly share code, notes, and snippets.


Erik Berlin sferik

View GitHub Profile
JoshCheek / png_dots.rb
Last active Jan 11, 2016
Freaky Dot Patterns, based on this video by Numberphile:
View png_dots.rb
# Pics at
# Gif at
# Based on
require 'chunky_png'
require 'matrix'
include Math
def white
ChunkyPNG::Color.rgb(255, 255, 255)
nicolasembleton /
Last active Oct 21, 2022
Restart Bluetooth Daemon on Mac OS X without restarting
sudo kextunload -b
sudo kextload -b
tomstuart / gist:4382332089a8402bf475
Created Apr 30, 2014
Person#age gives the wrong answer for a person who hasn’t had their birthday yet this year
View gist:4382332089a8402bf475
require 'active_support/time'
require 'active_support/testing/time_helpers'
require 'rspec/expectations'
include ActiveSupport::Testing::TimeHelpers
include RSpec::Matchers
class Person <
def age - birthday.year
jbenet /
Last active Jan 23, 2023
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

busterbenson / markov_tweets.rb
Created Sep 25, 2013
How I do @buster_ebooks.
View markov_tweets.rb
# Make sure you have these gems installed
require 'rubygems'
require 'thread'
require 'csv'
require 'twitter'
require 'marky_markov'
# Create a new Twitter account that you'd like to have your auto-tweets posted to
robmiller / .gitconfig
Last active May 20, 2020
Want to find out what changes were introduced by a particular merge commit? Hey, so do I! ALL THE TIME. These aliases will do that.
View .gitconfig
# `git merge-log` shows the commits that were introduced in a given merge
# `git merge-diff` shows the actual changes that were introduced by a given merge
# Both commands accept an optional commitish; if ommitted, the last merge commit is used
merge-span = "!f() { echo $(git log -1 $2 --merges --pretty=format:%P | cut -d' ' -f1)$1$(git log -1 $2 --merges --pretty=format:%P | cut -d' ' -f2); }; f"
merge-log = "!git log `git merge-span .. $1`"
merge-diff = "!git diff `git merge-span ... $1`"
merge-difftool = "!git difftool `git merge-span ... $1`"
mislav / OpenSSL
Last active May 9, 2019
Fix OpenSSL certificate errors on Ruby 2.0
View OpenSSL

The reason why you might get certificate errors in Ruby 2.0 when talking HTTPS is because there isn't a default certificate bundle that OpenSSL (which was used when building Ruby) trusts.

Update: this problem is solved in edge versions of rbenv and RVM.

$ ruby -rnet/https -e "Net::HTTP.get URI('')"
net/http.rb:917:in `connect': SSL_connect returned=1 errno=0 state=SSLv3
  read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)

You can work around the issue by installing a certificate bundle that you trust. I trust Mozilla and curl.

View gist:4085034
Subject: [ruby-dev: 46350] RubySpec maintainer
From: Yukihiro Matsumoto <matz>
Date: Fri, 2 Nov 2012 10:43:12 +0900
Yukihiro Matsumoto is
Dis was've been on a grand scale and to Brian Ford at RubyConf.
It is not matter since it's always on it (truth is
Specification originally not good), so less contribution from Japan to RubySpec
Checking to what it is not, the distinction between behavior and specifications of chance
mislav / geoip_service.rb
Created Sep 3, 2012
Simple GeoIP service class using and Faraday
View geoip_service.rb
require 'faraday_middleware'
require 'hashie/mash'
# Public: GeoIP service using
# See
# Examples
# res = ''
piscisaureus /
Created Aug 13, 2012
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url =

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: