Skip to content

Instantly share code, notes, and snippets.

View radamant's full-sized avatar

Adam Pearson radamant

  • The Instrumental Group
  • Olympia
View GitHub Profile
@radamant
radamant / gist:1114333
Created July 29, 2011 17:49
Alias Enumerable#map to Enumerable#transform
>> module Enumerable
>> alias_method :transform, :map
>> end
=> Enumerable
>> names.transform{|n| n.upcase}
=> ["FRYE", "BENDER", "LEELA", "ZOIDBERG"]
@radamant
radamant / gist:1372195
Created November 17, 2011 02:30
Install REE 1.8.7 with XCode 4.2
# using_gcc for 64btt compiling on lion (solves compatability issues)
function using_gcc() {
env CC="/usr/bin/gcc-4.2" ARCHFLAGS="-arch x86_32" ARCHS="x86_32" $*
}
#then
using_gcc rvm install ree
@radamant
radamant / current_branch_grep.rb
Created February 15, 2012 17:39
A feature branch git-grep script
#!/usr/bin/env ruby
require 'set'
@term = ARGV[0]
def set_from_command(command)
result = `#{command}`
Set.new(result.split "\n")
end
mencoder -nosound mf://*.jpg -mf w=800:h=371:type=jpg:fps=15 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=2160000:mbd=2:keyint=132:v4mv:vqmin=3:lumi_mask=0.07:dark_mask=0.2:mpeg_quant:scplx_mask=0.1:tcplx_mask=0.1:naq -o face-time-lapse.avi
@radamant
radamant / gist:5113602
Created March 8, 2013 01:46
irb-openssl-fubar.log
irb
>> require 'open-uri'
=> true
>> open 'https://www.google.com'
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server key exchange B: bad ecpoint
from /Users/adam/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/http.rb:799:in `connect'
from /Users/adam/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/http.rb:799:in `block in connect'
from /Users/adam/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
from /Users/adam/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
from /Users/adam/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/http.rb:799:in `connect'
chef_gem 'mysql'
include_recipe "mysql::ruby"
mysql_database node['mysql']['database_name'] do
connection({:host => "localhost", :username => 'root', :password => node['mysql']['server_root_password']})
action :create
end
'(ansi-color-names-vector ["#3f3f3f" "#cc9393" "#7f9f7f" "#f0dfaf" "#8cd0d3" "#dc8cc3" "#93e0e3" "#dcdccc"])
'(ansi-term-color-vector [unspecified "white" "red" "green" "yellow" "royal blue" "magenta" "cyan" "white"] t)
(defface term-color-black
'((t :foreground "black" :background "black"))
"Face used to render black color code."
:group 'term)
(defface term-color-red
'((t :foreground "red3" :background "red3"))
"Face used to render red color code."
:group 'term)
#include <iostream>
#define ASTRO_UNITS_PER_LIGHT_YEAR 63240
float lightYearsToAstronomicalUnits(float);
int main()
{
using namespace std;
cout << "Enter the number of light years: ";
float lightYears;
@radamant
radamant / find-self-in-inits-objc.sh
Created October 15, 2013 21:40
Finds init* methods in Objective-C that contain self.property=value
find code-folder/ -name '*.m' -exec pcregrep -M 'init.*(\n|[\{])+\{(\n|[^\}])+self\.(\n|[^\}])+\}' {} \; -exec echo "Filename: " {} \;q