Skip to content

Instantly share code, notes, and snippets.

View gist:8002
require 'net/http'
class Object
def method_missing(methId)
suggestion = Net::HTTP.get('search.yahooapis.com', "/WebSearchService/V1/spellingSuggestion?appid=YahooDemo&query=#{methId.to_s}")
method = /<Result>(.*)<\/Result>/.match(suggestion)
if method
puts "#{method[1]} bloody bastard, is ****#{method[1].upcase}****, not #{methId}... read the fucking docs!!!"
self.send method[1]
else
puts "what the hell '#{methId}' is bloody bastard?... read the fucking docs!!!"
@aitor
aitor / gist:9404
Created Sep 8, 2008
Fake community
View gist:9404
require 'faker'
require 'colored'
class Object
def tap
yield self
self
end
end
class Percentage
View gist:11048
setup do
@margie = Factory(:user, :login => 'm.thatcher')
@jaiku = Factory(:jaiku, :content => "To solve Britain’s economic Disease with Socialism is like treating leukaemia with leeches.", :user => @margie)
@activity = @jaiku.activities.first
end
should 'link the activities created on a model with the user that is generating the activity' do
assert_equal @margie, @activity.user, "The activity should be registered as made by the user that create the jaiku"
end
View copy to clipboard from a web page
//
// copied from: http://www.tek-tips.com/viewthread.cfm?qid=1465395&page=5
// TODO: reference original author...
//
function copy(rubyurl) {
var flashcopier = 'flashcopier';
if(!document.getElementById(flashcopier)) {
var divholder = document.createElement('div');
divholder.id = flashcopier;
document.body.appendChild(divholder);
View copy to clipboard from a web page.js
//
// copied from: http://www.tek-tips.com/viewthread.cfm?qid=1465395&page=5
// TODO: reference original author...
//
function copy(rubyurl) {
var flashcopier = 'flashcopier';
if(!document.getElementById(flashcopier)) {
var divholder = document.createElement('div');
divholder.id = flashcopier;
document.body.appendChild(divholder);
View gist:14592
require 'rubygems'
require 'hpricot'
require 'open-uri'
# el de Ara t. Howard no el de facets.
require 'openobject'
def scrap(element, id)
img = element.search("/img").first
paragraph = element.search("/p").first
View gist:37522
#!/usr/bin/env ruby
require 'rubygems'
require 'tools'
require 'tog'
require 'plugins'
def with_migration_tpl_file(tpl_file)
File.open(tpl_file, 'w') {|file|
file.write <<-eos
class CreateComments < ActiveRecord::Migration
View gist:108030
require 'rubygems'
# the "jnunemaker-twitter" gem
require 'twitter'
#client = get_auth_client
# todo Store the last tweet
since_tw = 0
results = Twitter::Search.new("#euruko").per_page(100).since(since_tw)
View tog_template.rb
sentinel = 'Rails::Initializer.run do |config|'
gsub_file 'config/environment.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
"\nrequire 'desert'\n#{match}"
end
def gsub_file(path, regexp, *args, &block)
content = File.read(path).gsub(regexp, *args, &block)
File.open(path, 'wb') { |file| file.write(content) }
end