Skip to content

Instantly share code, notes, and snippets.

View vinbarnes's full-sized avatar

Kevin R. Barnes vinbarnes

View GitHub Profile
module RexmlExtender
def better() 'yer mom'; end
...
end
class Rexml
include RexmlExtender
end
module TestCaseExtensions
def should(testname, &block)
unless block_given?
pending = 'PENDING '
block = lambda {}
end
testname = "test #{pending}#{@focus}should #{testname}".gsub(/\s(no|not)\s/i, ' *\1* ')
define_method(testname, block)
end
#!/usr/bin/ruby -w
class QuoteCleaner
module ClassMethods
LEFT_SINGLE_SMARTQUOTE = /\342\200\230/
RIGHT_SINGLE_SMARTQUOTE = /\342\200\231/
SINGLE_SMARTQUOTES = Regexp.union(LEFT_SINGLE_SMARTQUOTE, RIGHT_SINGLE_SMARTQUOTE)
LEFT_DOUBLE_SMARTQUOTE = /\342\200\234/
RIGHT_DOUBLE_SMARTQUOTE = /\342\200\235/
DOUBLE_SMARTQUOTES = Regexp.union(LEFT_DOUBLE_SMARTQUOTE, RIGHT_DOUBLE_SMARTQUOTE)
Autotest.send(:alias_method, :real_find_files, :find_files)
Autotest.send(:define_method, :find_files) do |*args|
real_find_files.reject do |k, v|
if (ENV['AUTOLIMIT'] and !ENV['AUTOLIMIT'].empty?)
!Regexp.new(ENV['AUTOLIMIT']).match(k)
end
end
end
#!/usr/bin/env ruby -w
require 'yaml'
users = YAML::load(File.open(File.join(File.expand_path('~/'), '.twitrc'), 'r'))
user = users.find {|u| u[:name] == ARGV[0]}
if (not user.empty?)
post = ARGV[1..-1].join(' ')
bark = %[curl -u #{user[:name]}:'#{user[:password]}' -d status="#{post}" http://twitter.com/statuses/update.json]
[barnekr@saturnino:~]$ ruby -v
ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]
[barnekr@saturnino:~]$ echo '1.3' |irb
>> 1.3
=> 1.3
@vinbarnes
vinbarnes / url_dsl.rb
Created December 18, 2009 14:52 — forked from defunkt/url_dsl.rb
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json
#!/usr/bin/env ruby -w
=begin
cont: #HBHhourlyView
hour: #HBHhourlyView .textsmallbold
temp: .textsmall:nth-child(4)
desc: .textsmall:nth-child(5)
=end
@vinbarnes
vinbarnes / ideabin.rb
Created December 30, 2009 00:18
ideabin.rb
#!/usr/bin/env ruby
require 'gmail'
unless ENV['GMAIL_USERNAME'] && ENV['GMAIL_PASSWORD']
raise StandardError, <<-INFO
Please create a ~/.gmail_keys file with the following:
export GMAIL_USERNAME='username'
export GMAIL_PASSWORD='password'
This is basically a dirty hack :) I have no idea if messing with the default OSX apache config this way is frowned upon. My view is that it works now, and if it breaks I'll fix it.
Add any domains you want to blacklist to /etc/hosts, pointing at 127.0.0.1. You need to enable web sharing to get apache running of course.
Changes to the default /etc/apache2/httpd.conf
==============================================
Listen 127.0.0.1:80 # so that the world can't see the list
DocumentRoot "/Library/WebServer/Documents/public" # to fit in with passenger, you need to create the public dir (and maybe /tmp too)