Skip to content

Instantly share code, notes, and snippets.

View aitor's full-sized avatar
👊
Working!

Aitor García Rey aitor

👊
Working!
View GitHub Profile
.DS_Store
myapp/
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 September 8, 2008 09:54
Fake community
require 'faker'
require 'colored'
class Object
def tap
yield self
self
end
end
class Percentage
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
//
// 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);
//
// 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);
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
#!/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
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)
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