Skip to content

Instantly share code, notes, and snippets.

View jashmenn's full-sized avatar

Nate Murray jashmenn

View GitHub Profile
@jashmenn
jashmenn / gist:6206
Created August 19, 2008 17:24
growl notify for irssi
upgraded to a real git repository. Please see: http://github.com/jashmenn/irssi-growl
@jashmenn
jashmenn / gist:6626
Created August 21, 2008 20:05
nate murray's .irbrc
# Nate Murray's ~/.irbrc
#
# Can be found at:
# http://gist.github.com/6626
# git clone git://gist.github.com/6626.git gist-6626
#
# Include colorization
require 'rubygems'
require 'wirble'
Wirble.init
# paste whatever is in the clipboard to gist using gisit from http://gist.github.com/5774
# and MacClipboard code from http://project.ioni.st/post/1334#snippet_1334
# this goes in your ~/.irbrc
# * todo, change code to update an existing gist
def gistit
require 'mechanize'
require 'gistit'
gist = Gistit.new
number = gist.paste(MacClipboard.read) # => 12345
gist_url = Gistit::LOGIN_SUCCESS_URL + number.to_s
ruby -e "require 'irb'; IRB.setup(__FILE__); gistit"
# Function to check for a minimum rubygems version
#
# Can be found at: http://gist.github.com/9998
def check_rubygems_version
min_version = '1.2.0'
local_version = %x[gem --version].chomp
unless local_version >= min_version
puts "You need to update the RubyGems utility to #{min_version} using the following"
puts ""
@jashmenn
jashmenn / gist:13686
Created September 29, 2008 21:58
use inflectors from cli
#!/usr/bin/env ruby
# http://gist.github.com/13686
# Nate Murray 2008
require 'activesupport'
#
# Examples:
# * inflect camelize foo_bar
# * echo "foo_bar" | inflect camelize
unless method = ARGV[0]
puts "usage: #{$0} method string"
# exponential random backoff ala ethernet
# Nate Murray, 2008
# inspired by code found in http://files.rubyforge.vm.bytemark.co.uk/rhb/xmpphttpbind.rb
class EthernetBackoff
class Error < StandardError
end
# Retries block with exponential random backoff ala ethernet The retry is
# based on the return value of &block. If the value evaluates to a boolean
# true then the value is returned. Otherwise it will sleep for the calculated
@jashmenn
jashmenn / gist:16729
Created October 14, 2008 15:50
A tiny utility to generate graphviz dot files from objects that use pluginaweek's excellent state_machine library.
#!/usr/bin/env ruby
require 'trollop'
require 'pp'
opts = Trollop::options do
version "#{$0} (c) 2008 Nate Murray"
banner <<-EOS
http://gist.github.com/16729
A tiny utility to generate graphviz dot files from objects that use pluginaweek's
@jashmenn
jashmenn / gist:16738
Created October 14, 2008 16:38
random-pronounceable-strings-in-ruby
#!/usr/bin/env ruby
# from http://e-huned.com/2008/10/13/random-pronounceable-strings-in-ruby/
require 'rubygems'
require 'activesupport'
class String
def self.random_pronounceable(syllables = 2)
alphabet = ('a'..'z').to_a
vowels = %w{ a e i o u }
@jashmenn
jashmenn / remote.rb
Created November 6, 2008 19:05
sake task to create a new bare git repo on a foreign server
# http://gist.github.com/22673
# Nate Murray 2008
# based on ssh:install_public_key
namespace :git do
namespace :init do
namespace :bare do
desc "Init a new bare repository on a foreign server"
task :remote do
begin
(