Skip to content

Instantly share code, notes, and snippets.

View michael-erasmus's full-sized avatar

Michael Erasmus michael-erasmus

View GitHub Profile
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <!-- makes IE8+ use the latest rendering engine -->
<style type="text/css" media="screen"> body {margin:0;padding:0} </style> <!-- removes margin -->
<!--[if IE]><script type="text/javascript" src="excanvas.compiled.js"></script><![endif]--> <!-- loads excanvas -->
<script src="socks-0.7-compressed.js" type="text/javascript" charset="utf-8"></script> <!-- loads socks -->
<script type="application/javascript-socks" charset="utf-8">
//Draws a Sierpinski triangle using the game of chaos rules
//http://en.wikipedia.org/wiki/Sierpi%C5%84ski_triangle
require 'rubygems'
require 'sinatra'
require 'rack/test'
require 'spec'
require 'spec/autorun'
require 'spec/interop/test'
require 'hpricot'
describe "My Sinatra App" do
include Rack::Test::Methods
it "should display the header text 'Pity the fool!'" do
get '/'
tag("h1").inner_text.should == "Pity the fool!"
end
it "should have menu items" do
get '/'
(doc/".menu-item").should_not be_nil
end
dynamic sampleObject = new ExpandoObject()
sampleObject.number = 10;
sampleObject.Increment = (Action)(() => { sampleObject.number++; });
// Before calling the Increment method.
Console.WriteLine(sampleObject.number);
sampleObject.Increment();
class Expando
def method_missing(method_id, *arguments)
if match = method_id.id2name.match(/(\w*)(\s*)(=)(\s*)(\.*)/)
self.class.class_eval{ attr_accessor match[1].to_sym }
instance_variable_set(match[1], match[5])
else
super.method_missing(method_id, *arguments)
end
end
end
[TestClass]
class DescribePerson
{
private Creature person;
[TestInitialize]
public void Before()
{
person = new Person();
ruby execfac.rb 10
require File.join(File.dirname(__FILE__), "flippant")
include Flippant
#Say you have this
class Movie
attr_accessor :name
attr_accessor :actors
def initialize(name)
@name = name
public static class NinjectExtensions
{
public static T ToFake<T>(this IBindingToSyntax<T> binding)
{
var fake = A.Fake<T>();
binding.ToConstant(fake);
return fake;
}
}