This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
| source "http://rubygems.org" | |
| gem 'rack-contrib', :git => 'git://github.com/rack/rack-contrib.git' | |
| gem 'rack-rewrite' |