This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
models | |
------ | |
class Bookmark | |
referenced_in :user | |
end | |
class User | |
references_many :bookmarks, :dependent => :destroy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- content_for :no_right do | |
No |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("hello world!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# idéia original em php: http://goncin.wordpress.com/2010/06/21/ditados-populares-em-php/ | |
############### | |
if tempo.is?(:chuvoso) | |
cavalinho.recolher | |
end | |
################ |