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 ruby | |
require "rubygems" | |
require "highline/import" | |
interval = ask("What time interval?", Integer) { |q| q.default = 15 } | |
amount = ask("What is the charge?", Integer) { |q| q.default = 1 } | |
capacity = ask("What is the capacity?", Integer) { |q| q.default = 15 } | |
average_hours_per_day = ask("Average number of hours per day?", Integer) { |q| q.default = 7 } |
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 "airplay" | |
require "open-uri" | |
require "mechanize" | |
require "digest/md5" | |
agent = Mechanize.new | |
page = agent.get("http://www.path.com/login") | |
login_form = page.form_with(:action => "/login") | |
login_form["username_or_email"] = "[email address]" |
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
Checkout github project |
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 Favorite < ActiveRecord::Base | |
module HasManyExtension | |
def videos | |
proxy_owner.favorites.where(:favorite_type => "Video") | |
end | |
end | |
end | |
class User < ActiveRecord::Base | |
has_many :favorites, :extend => Favorite::HasManyExtension |
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 MyExtension | |
def my_method | |
end | |
end | |
class User | |
include MyExtension | |
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
<? | |
class MyClass { | |
public static $my_value; | |
} | |
MyClass::$my_value = "testing"; | |
echo MyClass::$my_value; |
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 "spec_helper" | |
describe Admin::CoursesController do | |
let(:admin) { Fabricate(:admin) } | |
let(:course) { Fabricate(:course) } | |
before(:each) do | |
sign_in(admin) | |
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
subject do | |
Course.create!({:title => 'Test Course', :image => File.open(File.join(Rails.root, 'public', 'images', 'test-image.gif'))}) | |
end | |
describe "when an image is attached" do | |
it "should respond to an image object" do | |
subject.image.class.should == Paperclip::Attachment | |
end | |
it "should have a vaild image that's not missing" do |
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
$r = new HydraRouter(); | |
$r->dispatch("/", function() use ($env, $db) { | |
$result = $db->execute("SELECT (1 + 1) AS count"); | |
$view = new HyrdaView("app/views/application.php"); | |
list($header, $body) = $view->html( | |
"app/views/home.php", | |
array( "result" => $result )); |
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 'digest/sha2' | |
require 'base64' | |
module Digraph | |
def identifier(*args) | |
args.join('|') | |
Base64.encode64(Digest::SHA2.hexdigest(args.join)) | |
end | |
class Node |