Skip to content

Instantly share code, notes, and snippets.

View sferik's full-sized avatar

Erik Berlin sferik

View GitHub Profile
@JoshCheek
JoshCheek / png_dots.rb
Last active January 11, 2016 15:51
Freaky Dot Patterns, based on this video by Numberphile: https://www.youtube.com/watch?v=QAja2jp1VjE
# Pics at https://twitter.com/josh_cheek/status/681062928980783104
# Gif at https://twitter.com/josh_cheek/status/686465757476065280
# Based on https://www.youtube.com/watch?v=QAja2jp1VjE
require 'chunky_png'
require 'matrix'
include Math
def white
ChunkyPNG::Color.rgb(255, 255, 255)
end
@nicolasembleton
nicolasembleton / restart_bluetooth.sh
Last active October 21, 2022 20:10
Restart Bluetooth Daemon on Mac OS X without restarting
#!/bin/bash
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
@tomstuart
tomstuart / gist:4382332089a8402bf475
Created April 30, 2014 12:59
Person#age gives the wrong answer for a person who hasn’t had their birthday yet this year
require 'active_support/time'
require 'active_support/testing/time_helpers'
require 'rspec/expectations'
include ActiveSupport::Testing::TimeHelpers
include RSpec::Matchers
class Person < Struct.new(:birthday)
def age
Date.today.year - birthday.year
end
@jbenet
jbenet / simple-git-branching-model.md
Last active April 9, 2024 03:31
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
busterbenson / markov_tweets.rb
Created September 25, 2013 05:05
How I do @buster_ebooks.
#!/usr/bin/ruby
# 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
robmiller / .gitconfig
Last active May 20, 2020 13:45
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.
# `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
mislav / OpenSSL fix.md
Last active June 8, 2023 07:48
Fix OpenSSL certificate errors on Ruby 2.0

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('https://github.com')"
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.

Subject: [ruby-dev: 46350] RubySpec maintainer
From: Yukihiro Matsumoto <matz ruby.or.jp>
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
mislav / geoip_service.rb
Created September 3, 2012 11:48
Simple GeoIP service class using freegeoip.net and Faraday
require 'faraday_middleware'
require 'hashie/mash'
# Public: GeoIP service using freegeoip.net
#
# See https://github.com/fiorix/freegeoip#readme
#
# Examples
#
# res = GeoipService.new.call '173.194.64.19'
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
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 = git@github.com:joyent/node.git

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: