Skip to content

Instantly share code, notes, and snippets.

View federomero's full-sized avatar

Federico Romero federomero

View GitHub Profile
@federomero
federomero / wiki.rb
Created May 25, 2011 22:29
Simple script for testing http://xkcd.com/903/ alltext trivia
# encoding: UTF-8
require 'rubygems'
require 'nokogiri'
require 'open-uri'
start = 'C.A._Penarol'
target = 'Philosophy'
visited = []
@federomero
federomero / gist:2173058
Created March 23, 2012 17:35
User setup
subject do
User.new.tap do |user|
user.password = "something"
user.password_confirmation = user.password
user.email = "[email protected]"
end
end
@federomero
federomero / app.rb
Created July 21, 2012 05:09
Sinatra namespace bug
require 'sinatra'
require 'sinatra/namespace'
set :foo, 42
namespace '/foo' do
get '/bar' do
settings.respond_to?(:foo).to_s
end
end
@federomero
federomero / formatter.rb
Created August 9, 2012 13:53
Uruguayan constitution markdown formatter
# encoding: UTF-8
require 'open-uri'
years = %w{1997 1994 1989 1967 1952 1942 1934 1918 1830}
i = years.last
file = open("http://www0.parlamento.gub.uy/constituciones/const#{i.slice(1..-1)}.htm").read
t = file.encode('UTF-8', 'ISO-8859-1', universal_newline: true)
@federomero
federomero / max_vago.sh
Created October 26, 2012 18:49
No seas vago max
git clone git://github.com/federomero/ti.git ~/Code/ti
git clone git://github.com/federomero/ti-plugins.git ~/.ti
ln -s ~/Code/ti/ti /usr/local/bin/ti
echo "export NRTT_PREFIX='NeonRoots'" >> ~/.bashrc
@federomero
federomero / alexa.rb
Created February 7, 2013 12:49
Get alexa ranks for a list of urls
require 'alexa'
key = "…"
secret = "…"
client = Alexa::Client.new(access_key_id: key, secret_access_key: secret)
STDIN.each_line do |l|
url = l.rstrip
rank = client.url_info({
@federomero
federomero / facebook_pages.rb
Created February 7, 2013 14:05
Get a facebook urls and likes for the pages based on a list of urls
require 'json'
require 'open-uri'
access_token = "…"
begin
urls_file = File.open('./urls.txt', 'w')
likes_file = File.open('./likes.txt', 'w')
STDIN.each_line do |l|
url = l.rstrip
$(document).ready(function(){
var toggle = $('<div id="pomelo-toggle"><a href="#">&#9021;</a></div>')
toggle.css({
position: 'fixed',
'font-size': '30px',
right: '10px',
top: '10px',
'z-index': '1001',
height: '24px',
});