Skip to content

Instantly share code, notes, and snippets.

require 'digest/sha2'
require 'base64'
module Digraph
def identifier(*args)
args.join('|')
Base64.encode64(Digest::SHA2.hexdigest(args.join))
end
class Node
$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 ));
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
require "spec_helper"
describe Admin::CoursesController do
let(:admin) { Fabricate(:admin) }
let(:course) { Fabricate(:course) }
before(:each) do
sign_in(admin)
end
<?
class MyClass {
public static $my_value;
}
MyClass::$my_value = "testing";
echo MyClass::$my_value;
module MyExtension
def my_method
end
end
class User
include MyExtension
end
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
Checkout github project
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]"
#!/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 }