Skip to content

Instantly share code, notes, and snippets.

View rafaelss's full-sized avatar

Rafael Souza rafaelss

View GitHub Profile
@rafaelss
rafaelss / gist:1006315
Created June 3, 2011 13:13 — forked from tinogomes/gist:1006296
.boolean? method for ruby objects
module RubyExt
module Boolean
def bool?
[ true, false ].include?(self)
end
end
end
::Object.__send__ :include, RubyExt::Boolean
before_filter :load_comments, :only => [ :index, :create ]
def index
end
def create
@comment = Comment.new(params[:comment])
if @comment.save
render 'index'
end
def index
@trainers = if params[:franchise_id]
Trainer.where(:franchise_id => params[:franchise_id]).all
else
Trainer.all
end
end
require 'mechanize'
require 'sinatra'
get '/:psuid' do
find_name params[:psuid]
end
def find_name(psuid)
page = Mechanize.new.get('http://psu.edu/ph')
search_result = page.form_with(:name => 'search') do |search|
class SpiderController < ApplicationController
def index
@sites = Site.all
@sites.each do |site|
uri = URI.parse(site.url)
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
request["User-Agent"] = "Status Monitor"
response = http.request(request)
@rafaelss
rafaelss / Gemfile
Created May 20, 2010 22:18 — forked from rmanalan/.gems
rack static site
source "http://rubygems.org"
gem 'rack-contrib', :git => 'git://github.com/rack/rack-contrib.git'
gem 'rack-rewrite'