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 'active_support/all' | |
class Yeah | |
def initialize | |
@params = {"university_id" => 2, "id" => 3} | |
end | |
def method_missing(name, *args) | |
if name.to_s =~ /^find_([a-z]+)_id$/ | |
find_id($1) |
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 ApplicationController < ActionController::Base | |
protect_from_forgery | |
def method_missing(method, *args) | |
if method.to_s =~ /^find_([a-z]+)_id$/ | |
find_id($1) | |
elsif method.to_s =~ /^find_([a-z]+)$/ | |
find_id($1, :search_name_only) | |
else | |
super |
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 authorize | |
%w{HTTP_AUTHORIZATION X-HTTP_AUTHORIZATION X_HTTP_AUTHORIZATION}.each do |http_header| | |
@request = request.env[http_header] if request.env[http_header].present? | |
end | |
if @request.present? | |
@oauth_request = OAuth::Helper.parse_header @request | |
if @oauth_request["oauth_signature_method"] == "HMAC-SHA1" |
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 'oauth' | |
URL = "http://localhost:9090/oauth/check" | |
CONSUMER_KEY = "c740398d919e199ff222be3f75b916e6" # App.first.consumer_key | |
CONSUMER_SECRET = "414e9edf0dd2f24fc78c6da47cbd2dd9" # App.first.consumer_secret | |
TOKEN_KEY = "4db6a2ce6f1dc173e9000002" # User.first.id | |
TOKEN_SECRET = "f8b3cb31ad6351af93e47f1a962f808a4e46038d" # User.first.tokens.first.secret |
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
~/Projects/Work/parabola on master(2e2bb5d) exited 30 | |
parabola:master! % ./parabola.rb -d "14.02.03 21:12-12.04.05" | |
Error: Last date less than start date | |
~/Projects/Work/parabola on master(2e2bb5d) exited 30 | |
parabola:master! % ./parabola.rb -d "11.02.03 21:12-12.04.05" | |
2011-02-03 21:12:00 +0000 | |
2012-04-05 23:59:59 +0000 | |
~/Projects/Work/parabola on master(2e2bb5d) |
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 'nokogiri' | |
require 'open-uri' | |
i = 0 | |
heroes = [] | |
descriptions = [] | |
puts "Parsing..." | |
while i+=1 |
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 'zlib' | |
require 'lzoruby' | |
module GZIP | |
def self.compress string, level | |
z = Zlib::Deflate.new level | |
dst = z.deflate string, Zlib::FINISH | |
z.close | |
dst | |
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
source 'http://rubygems.org' | |
gem 'rails', '>= 3.1.0.rc1' | |
gem 'spork', '>= 0.9.0.rc5' | |
gem 'ZenTest', '>= 4.5.0' | |
gem 'sqlite3' | |
gem 'sass' |
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 Group | |
include DataMapper::Resource | |
property :id, Serial | |
property :title, String, unique: true, length: 1..20 | |
property :rules, String | |
SUPPORT_MODELS = %w[account offering city country] | |
SUPPORT_ACTIONS = %w[read create destroy edit] |
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
APP_ROOT = File.expand_path(File.dirname(File.dirname(__FILE__))) | |
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm') | |
begin | |
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME'])) | |
rvm_lib_path = File.join(rvm_path, 'lib') | |
$LOAD_PATH.unshift rvm_lib_path | |
require 'rvm' | |
RVM.use_from_path! APP_ROOT | |
rescue LoadError |
OlderNewer