Skip to content

Instantly share code, notes, and snippets.

View tadman's full-sized avatar
🤔
Enumerating

Scott Tadman tadman

🤔
Enumerating
View GitHub Profile
before_filter :load_${1:model}, :except => [ :index, :new, :create ]
before_filter :build_${1}, :only => [ :new, :create ]
def index
self.page_title << '${1/(^|_)(\w)/\U$2/g}s'
@${1}s = ${1/(^|_)(\w)/\U$2/g}.new_search(search_params)
end
def new
def globals(root = Module)
root.constants.collect do |name|
object = eval(name) rescue nil
if (object === Module || object === Class)
name
elsif (object.is_a?(Module) || object.is_a?(Class))
globals(object).collect do |subname|
[ name, subname ].join('::')
end << name
else
#!/usr/bin/env ruby
# Replug hack
# - Local install of plugin
require 'rubygems'
# Rails Plugin Manager.
#
# Listing available plugins:
# monkey patch HTTParty to use a configurable timeout
module HTTParty
class Request
private
def http
http = Net::HTTP.new(uri.host, uri.port, options[:http_proxyaddr], options[:http_proxyport])
http.use_ssl = (uri.port == 443)
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.open_timeout = http.read_timeout = options[:timeout].to_i if options[:timeout].to_i > 0
http
def test_parse_address
[
[ '[email protected]', [ '[email protected]', nil ] ],
[ '[email protected]', [ '[email protected]', nil ] ],
[ '[email protected] (Amy Test)', [ '[email protected]', nil ] ],
[ 'Bob Test <[email protected]>', [ '[email protected]', 'Bob Test' ] ]
].each do |test_case|
assert_equal test_case[1], Message.parse_email_address(test_case[0])
end
end
def self.each(key_column = :id, &block)
connection.select_values("SELECT `#{key_column}` FROM `#{table_name}`").each do |key|
begin
yield(find(key))
rescue ActiveRecord::RecordNotFound
# Ignore records which may have been deleted between the time the
# list is created and the record is fetched.
end
end
end
class ApplicationController < ActionController::Base
before_filter :set_time_zone
protected
# -- Page Title -----------------------------------------------------------
def page_title
@page_title ||= [ ]
end
class Multiplexer
instance_methods.each do |m|
undef_method m unless(m.match(/^__/))
end
def initialize(*objects)
@objects = objects
end
def method_missing(m, *args)
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/environment'
conn = ActiveRecord::Base.connection
STDOUT.sync = true
while (true)
print "\e[;H"