Skip to content

Instantly share code, notes, and snippets.

View jeffreybaird's full-sized avatar

Jeffrey Baird jeffreybaird

View GitHub Profile
@jeffreybaird
jeffreybaird / keybase.md
Created March 21, 2014 16:57
keybase.md

Keybase proof

I hereby claim:

  • I am jeffreybaird on github.
  • I am jeffreybaird (https://keybase.io/jeffreybaird) on keybase.
  • I have a public key whose fingerprint is F6EE 23D3 5669 09FD 77EE 0FA2 6752 C11E 4841 E0B9

To claim this, I am signing this object:

-----BEGIN PGP MESSAGE-----
Version: Keybase OpenPGP v0.1.1
Comment: https://keybase.io/crypto
wcBMA7m3rH38ud1BAQf9GSKMVwzMQbBiFDYI+L/3X2XdDl/Kq9QZNSq3350MPkJI
vNHaZdcCCrOMf8yksG3cQjgK373bU2YWU5i2eyUZzHMzpntC8MLPT2hr27PBIOvL
HjB7KXchfDJfReIEJRUdFMsZjgPqsNkbofLg/kB3ZeA86FkV/nixMTbdwS3Iaska
SVziby35cHHODIEp6wGVOwQO9BrrN8pFjRfNI1MflOIVKaY4laCds3hMZDVRVMo7
HIX2ULaA4otw+Ocob1gT/Eo4Z3xVBd7N2mxgnYNMl9LILMZdNM+V/FtXCFlcnVHJ
wFa0RTdJ3/YilTRzTC3FThcioyQSSy7JBgNOOyICOtLA9gEuetDo/uRxsewaBUP8
Node 'riak@127.0.0.1' not responding to pings.
config is OK
Exec: /usr/local/Cellar/riak/1.4.8/libexec/erts-5.9.1/bin/erlexec -boot /usr/local/Cellar/riak/1.4.8/libexec/releases/1.4.8/riak -config /usr/local/Cellar/riak/1.4.8/libexec/etc/app.config -pa /usr/local/Cellar/riak/1.4.8/libexec/lib/basho-patches -args_file /usr/local/Cellar/riak/1.4.8/libexec/etc/vm.args -- console
Root: /usr/local/Cellar/riak/1.4.8/libexec
{error_logger,{{2014,6,10},{9,6,37}},"Protocol: ~p: register error: ~p~n",["inet_tcp",{{badmatch,{error,duplicate_name}},[{inet_tcp_dist,listen,1,[{file,"inet_tcp_dist.erl"},{line,70}]},{net_kernel,start_protos,4,[{file,"net_kernel.erl"},{line,1314}]},{net_kernel,start_protos,3,[{file,"net_kernel.erl"},{line,1307}]},{net_kernel,init_node,2,[{file,"net_kernel.erl"},{line,1197}]},{net_kernel,init,1,[{file,"net_kernel.erl"},{line,357}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,304}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,227}]}]}]}
@jeffreybaird
jeffreybaird / subtract_letters.rb
Created May 25, 2012 04:48 — forked from agoodman/subtract_letters.rb
Word Pruning by Letter Subtraction
possible_words = ["seek", "find", "ignore", "pursue", "covet"]
available_letters = [ "w5","g6","f7","s2","e1","l3","h8","n1","f7","b8","r12","u3","g6","i4","q9","o3","d2","s2","f7"]
words = Array[possible_words].flatten
available_letters = tiles.map {|e| e[0]}
available_letters.each {|e| words = words.map {|w| w.sub(e, '')}}
viable_words = words.each_with_index.collect {|w,k| possible_words[k] if w==""}.compact
letter_value_hash = Hash[tiles.map {|l| [l.slice(0), l.slice(1..3).to_i]}]
word_as_values = viable_words.map do |word|
@jeffreybaird
jeffreybaird / shuffle_algorithm.rb
Created May 30, 2012 23:17
Learn to Program Exercise 10.3
@new_array = %w(fun apple dance Zebra goose teenager)
def choose_a_random_word some_array
word = some_array[rand(0...some_array.size)]
some_array.delete_if do |w|
w == word
end
word
end
@jeffreybaird
jeffreybaird / playlist_maker.rb
Created May 31, 2012 20:01
Script for creating a playlist Chapter 11 exercises
Dir.chdir #add your music directory here
all_music = (Dir['**/*.mp3'].shuffle)
puts "what do you want to name your playlist?"
answer = gets.chomp
File.open "#{answer}.m3u",'w' do |file|
all_music.each do |mp3_file_name|
file.write "#{mp3_file_name}\n"
end
end
@jeffreybaird
jeffreybaird / gist:3295351
Created August 8, 2012 14:14
Find out which classes are called most often (stolen from gary bearnhart)
grep -rh '^[[:space:]]*\(class\|module\)\b' app lib --include='*.rb' |
sed 's/^[[:space:]]*//' |
cut -d ' ' -f 2 |
while read class; do
echo "`grep -rl "\b$class\b" app lib --include="*.rb" | wc -l` $class";
done |
sort -n
@jeffreybaird
jeffreybaird / marketing_sources.rb
Created August 17, 2012 15:24
Script to cleanup the cap production marketing:sources output
#create a file (here called "file.txt") to paste the cap output into, run this file to clean the output.
require 'fileutils'
require 'tempfile'
t_file = Tempfile.new('sources.txt')
File.open("file.txt", 'r+') do |f|
f.each_line do |line|
line = line.to_s
line = line.strip
require 'csv'
def remove_dupes
uniq_csv = []
CSV.foreach("input.csv","r+") {|csv| uniq_csv << csv }
uniq_csv.uniq!.compact.compact
end
CSV.open("ouput.csv","w+") do |csv|
@jeffreybaird
jeffreybaird / gist:4039285
Created November 8, 2012 14:58
A user search
scope :search, lambda{|query|
return scoped if query.blank?
tokens = query.split(/ |\+|,/).collect {|c| "%#{c.downcase}%"}
joins(:user).where(["#{(["(lower(user.first_name) like ? \
or lower(user.last_name) like ? \
or lower(user.social_security_digits) like ? \
or lower(users.email) like ? \
or user.date_of_birth like ? \
or user.id like ? \