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
OpenSSL::SSL::SSLError:
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
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|
models
------
class Bookmark
referenced_in :user
end
class User
references_many :bookmarks, :dependent => :destroy
@rafaelss
rafaelss / action.haml
Created November 4, 2010 22:06
gente criativa é outra coisa...
- content_for :no_right do
No
console.log("hello world!");
#!/usr/bin/env sh
# 1. save this file in /usr/local/bin/htmlsite
# 2. change default path (~/projects) to whatever you want
# 3. then execute:
# $ chmod +x /usr/local/bin/htmlsite
# now you're able to execute: htmlsite <project name>
git clone http://github.com/joelsouza/html5-structure.git ~/projects/$1
cd ~/projects/$1
rm -rf .git
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)