Skip to content

Instantly share code, notes, and snippets.

View rmm5t's full-sized avatar
🌐
building itsy bitsy parts of the internet that grow

Ryan McGeary rmm5t

🌐
building itsy bitsy parts of the internet that grow
View GitHub Profile
puts "Holy crap, Batman, this is freakin' wicked!"
@rmm5t
rmm5t / README.md
Created August 19, 2008 23:38
Locale override examples for the timeago jQuery plugin (http://timeago.yarp.com)

This gist is now deprecated

Please visit the locales directory inside the main timeago repository intead.

@rmm5t
rmm5t / vcard2asterisk
Created December 5, 2008 20:56
vCards -> Asterisk commands for improved caller id
#!/usr/bin/env ruby
# Example Usage:
# vcard2asterisk *.vcf
# vcard2asterisk http://getvcard.com/dogetvcard.asp?UID=LD7U7mM
require 'rubygems'
require 'vpim/vcard'
def format_phone_number(phone)
@rmm5t
rmm5t / vcard_skidoosh.rb
Created December 7, 2008 00:32
vCards -> Asterisk commands for improved caller id
#!/usr/bin/env ruby
# usage: ruby vcard_skidoosh.rb vcard.vcf
# outputs a bunch of asterisk commands to stdout.
# taste it.
# Cargo culters: look elsewhere for best practices and good coding principles
# Original regex idea from @coderifous's earlier revisions of http://gist.github.com/32529
ARGV.collect{ |f| open(f).readlines }.flatten.each do |line|
if line =~ /^FN:(.*)$/
@rmm5t
rmm5t / gist:41978
Created December 31, 2008 14:50 — forked from jimweirich/gist:41973
;;; Load twittering mode.
(require 'twittering-mode)
(load "~/.pw/twittering-pw.el" 'noerror)
@rmm5t
rmm5t / controller_macros.rb
Created January 12, 2009 23:22
Less verbose controller macros for shoulda.
# Helper controller macros that define:
# on_get, on_post, on_put, on_delete
module ControllerMacros
[:get, :post, :put, :delete].each do |method|
class_eval <<-RUBY
def on_#{method}(action, options = {}, &block)
on_http_method(#{method.inspect}, action, options, &block)
end
RUBY
module ControllerMacros
[:get, :post, :put, :delete].each do |method|
class_eval <<-RUBY
def on_#{method}(action, options = {}, &block)
on_http_method(#{method.inspect}, action, options, &block)
end
RUBY
end
def on_http_method(method, action, options = {}, &block)
#!/usr/bin/env ruby
Package = Struct.new(:name, :path, :main, :globs)
packages =
[
Package.new("ruby", "~/external/ruby-1.8.7-p72", "README", %w(*.c lib/**/*.rb)),
Package.new("rails", "~/external/rails", "railties/README", %w(*/README */lib/**/*)),
Package.new("shoulda", "~/external/shoulda", "README.rdoc", %w(lib/**/*.rb))
]
class Test::Unit::TestCase
# Ensures that the model has a method named scope_name that returns a NamedScope object with the
# proxy options set to the options you supply. scope_name can be either a symbol, or a method
# call which will be evaled against the model. The eval'd method call has access to all the same
# instance variables that a should statement would.
#
# Options: Any of the options that the named scope would pass on to find.
#
# Example:
#
# Change the window title of X terminals
case $TERM in
xterm*|rxvt|Eterm|eterm)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
;;
screen)
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
;;
esac