This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#IRC Response | |
=begin | |
Needs some work, but I could definitely see this helping those people who like to sit in IRC and be jerks when people ask questions. | |
You could leave your computer and continue be just as unhelpful as you could if you were still there. | |
=end | |
def irc_person_response(question) | |
answer = question.gsub(/How do I/, "Why would you want to") | |
if answer == question | |
answer = "Why?" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
Written by: Patrick Tulskie (http://github.com/patricktulskie) | |
WARNING: This will delete any previous fixture dumps that you've made with the script before it runs. | |
Review the code and understand it before running it. | |
=end | |
namespace :db do | |
desc 'Create YAML test fixtures from data in an existing database. Defaults to development database automagically. | |
Set RAILS_ENV to override. Set FIXTURES to specify what fixtures to extract.' | |
task :extract_fixtures => :environment do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# usage: script/server_restarter | |
# | |
# Rails autoloading, while nice in theory, frequently doesn't work. Since Rails 2.3+ | |
# is so fast when completely reloading the server, I wrote this script to listen to the | |
# given directories, and kill/restart the server when any file is changed. | |
# | |
# It's quick, simple, and it reliably reloads your application when changes are made. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def antiuniq | |
duplicates = [] | |
clone = [] + self | |
while clone.length > 0 | |
item = clone.pop | |
duplicates.push(item) if clone.include?(item) || duplicates.include?(item) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AnnoyingKid | |
def self.why?(answer) | |
self.why?(answer) | |
end | |
end | |
AnnoyingKid.why?('because') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Hpricot | |
module Hextensions | |
def hashify(xml_data) | |
hsh = {} | |
xml_data.each_child do |b| | |
key_name = b.name.strip | |
if key_name.length > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%w(rubygems benchmark).each { |gem| require gem } | |
puts "Outside: " + Benchmark.measure { |a| puts "Inside: " + (Benchmark.measure { |b| 10000.times { |val| puts "#{val} bananas!" } }).to_s }.to_s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%w(rubygems activesupport).each { |g| require g } | |
class KanyeWest | |
def self.outburst(name, item) | |
"Yo #{name}. I'm really happy for you. I'm gonna let you finish, but Beyonce had one of the best #{item.pluralize} of all time. One of the best #{item.pluralize} of all time!" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'mash' | |
require 'hashie' | |
require 'benchmark' | |
huge_hash = { } | |
big_block_of_text = ";dfngsd;gndsfgnsdf;gnsdf;hndfs'hfgnh'isfgng'asifnsd;iofgbdsf;hugsdbf;isdangliusdfgn;sdfing'disv c;jvb f;jb fs;ib s;div d;dfngsd;gndsfgnsdf;gnsdf;hndfs'hfgnh'isfgng'asifnsd;iofgbdsf;hugsdbf;isdangliusdfgn;sdfing'disv c;jvb f;jb fs;ib s;div d;dfngsd;gndsfgnsdf;gnsdf;hndfs'hfgnh'isfgng'asifnsd;iofgbdsf;hugsdbf;isdangliusdfgn;sdfing'disv c;jvb f;jb fs;ib s;div d;dfngsd;gndsfgnsdf;gnsdf;hndfs'hfgnh'isfgng'asifnsd;iofgbdsf;hugsdbf;isdangliusdfgn;sdfing'disv c;jvb f;jb fs;ib s;div d;dfngsd;gndsfgnsdf;gnsdf;hndfs'hfgnh'isfgng'asifnsd;iofgbdsf;hugsdbf;isdangliusdfgn;sdfing'disv c;jvb f;jb fs;ib s;div d;dfngsd;gndsfgnsdf;gnsdf;hndfs'hfgnh'isfgng'asifnsd;iofgbdsf;hugsdbf;isdangliusdfgn;sdfing'disv c;jvb f;jb fs;ib s;div d;dfngsd;gndsfgnsdf;gnsdf;hndfs'hfgnh'isfgng'asifnsd;iofgbdsf;hugsdbf;isdangliusdfgn;sdfing'disv c;jvb f;jb fs;ib s;div d;dfngsd;gndsfgnsdf;gnsdf;hndfs'hfgnh'isfgng'asifnsd;iofgbdsf;hugsdbf;isdang |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'money' | |
require 'yaml' | |
class Array | |
def total_hashes | |
self.inject({}) do |totals, hsh| | |
hsh.each { |key, value| (totals[key] = totals[key] ? value + totals[key] : value) unless %w(String Hash Array).include?(value.class.to_s) } if hsh.is_a?(Hash) | |
totals |
OlderNewer