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
module RubyExt | |
module Boolean | |
def bool? | |
[ true, false ].include?(self) | |
end | |
end | |
end | |
::Object.__send__ :include, RubyExt::Boolean |
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
OpenSSL::SSL::SSLError: | |
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed |
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
before_filter :load_comments, :only => [ :index, :create ] | |
def index | |
end | |
def create | |
@comment = Comment.new(params[:comment]) | |
if @comment.save | |
render 'index' | |
end |
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
def index | |
@trainers = if params[:franchise_id] | |
Trainer.where(:franchise_id => params[:franchise_id]).all | |
else | |
Trainer.all | |
end | |
end |
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) | |