Skip to content

Instantly share code, notes, and snippets.

View rafaelss's full-sized avatar

Rafael Souza rafaelss

View GitHub Profile
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)
function _git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function _rvm_gemset {
rvm gemset name | sed -e '/^$/d' -e 's/\(.*\)/ \1/'
}
function reload {
source ~/.bash_profile
#!/usr/bin/env python
# Try to determine how much RAM is currently being used per program.
# Note the per program, not per process. So for example this script
# will report mem used by all httpd process together. In detail it reports:
# sum(all RSS for process instances) + max(shared mem for any process instance)
#
# The shared calculation below will factor out shared text and
# libs etc. within a program, but not between programs. So there
#!/usr/bin/env ruby
current = `defaults read com.apple.finder AppleShowAllFiles`
current = current.strip == 'TRUE' ? 'FALSE' : 'TRUE'
`defaults write com.apple.finder AppleShowAllFiles #{current}`
`killall Finder`
# idéia original em php: http://goncin.wordpress.com/2010/06/21/ditados-populares-em-php/
###############
if tempo.is?(:chuvoso)
cavalinho.recolher
end
################