Skip to content

Instantly share code, notes, and snippets.

View peleteiro's full-sized avatar
🏠
Working from home

Jose Peleteiro peleteiro

🏠
Working from home
View GitHub Profile
#!/usr/bin/env ruby
$:.unshift File.dirname(__FILE__)+"/../lib"
require 'mongomapper'
require 'irb'
IRB.setup(nil)
irb = IRB::Irb.new
IRB.conf[:MAIN_CONTEXT] = irb.context
# http://unicorn.bogomips.org/SIGNALS.html
rails_env = ENV['RAILS_ENV'] || 'production'
rails_root = ENV['RAILS_ROOT'] || "/data/github/current"
God.watch do |w|
w.name = "unicorn"
w.interval = 30.seconds # default
# unicorn needs to be run from the rails root
@peleteiro
peleteiro / url_dsl.rb
Created December 14, 2009 19:26 — forked from defunkt/url_dsl.rb
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json
require 'spec/matchers/wrap_expectation'
require 'nokogiri'
class BeHtmlWith
def matches?(stwing, &block)
@scope.wrap_expectation self do
begin
bwock = block || @block || proc{}
builder = Nokogiri::HTML::Builder.new(&bwock)
match = builder.doc.root
@peleteiro
peleteiro / gist:352495
Created April 1, 2010 23:07
rake task to install and run mongodb
desc "Runs mongodb"
task :mongodb => %w{mongodb:install mongodb:run}
namespace :mongodb do
task :install do
next if File.exist?("vendor/mongodb/1.4.0")
if RUBY_PLATFORM =~ /darwin/ # OSX
system <<-bash
mkdir -p #{Rails.root}/vendor/mongodb/data
curl http://downloads.mongodb.org/osx/mongodb-osx-x86_64-1.4.0.tgz -o /tmp/mongodb.tgz
require "rubygems"
require "json"
require "open-uri"
CONCURSOS = 1188..1195
APOSTAS = [[10, 12, 14, 34, 37, 49], [14, 27, 31, 39, 40, 53], [2, 10, 22, 43, 44, 51]]
CONCURSOS.each do |concurso|
resultado = JSON.load(open("http://apiz.heroku.com/megasena/#{concurso}.json")) rescue next
require 'rubygems'
require 'dnssd'
@hosts = Array.new
DNSSD.browse! '_mongodb._tcp' do |service|
DNSSD.resolve! service do |r|
@hosts << {:host => r.target, :port => r.port}
break unless r.flags.more_coming?
end
break unless service.flags.more_coming?
~/Projects/globo/chef-repo (master)$ brew outdated
node (0.1.100, 0.1.101, 0.1.104, 0.1.31, 0.1.32, 0.1.33, 0.1.90, 0.1.91, 0.1.93, 0.1.94, 0.1.96, 0.1.97, 0.1.99 < 0.1.104)
pango (1.26.2, 1.28.0 < 1.28.1)
pcre (8.02 < 8.10)
pip (0.6.3, 0.7.2 < 0.8)
scala (2.7.7 < 2.8.0)
scons (1.3.0, 20090919 < 2.0.0)
skipfish (1.29b, 1.30b, 1.32b, 1.33b, 1.34b, 1.41b < 1.55b)
sqlite (3.6.22, 3.6.23, 3.6.23.1, 3.7.0 < 3.7.0.1)
tokyo-cabinet (1.4.42, 1.4.45 < 1.4.46)
require "nokogiri"
class SitemapBuilder
attr_reader :root
def initialize
@urls = Array.new
@root = File.expand_path("public", Rails.root)
Dir[File.join(root, "sitemap*")].each{|f| FileUtils.rm f}
end
REDIS_VERSION = "2.0.4"
task :redis => "redis:start"
namespace :redis do
task :install do
next if File.exist?("#{Rails.root}/vendor/redis/#{REDIS_VERSION}/redis-server")
system <<-bash
curl http://redis.googlecode.com/files/redis-#{REDIS_VERSION}.tar.gz -o /tmp/redis.tar.gz
mkdir -p #{Rails.root}/vendor/redis