Skip to content

Instantly share code, notes, and snippets.

View Jirapong's full-sized avatar

Jirapong Nanta Jirapong

View GitHub Profile
describe "Widget#foo" do
it "does something" do
# This should be the functionality specs specific to the semantics of the method
Widget.new.foo.should == "do something"
end
end
# This captures the "type signature" of the method. Here are recipes for corner cases that you might forget.
# Note that the examples are not self-consistent by design. Only some of them might apply to any given method.
# However, the goal below is to include the union of all possible examples so that you can cut and paste
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="microsoft.scripting" type="Microsoft.Scripting.Hosting.Configuration.Section, Microsoft.Scripting, Version=0.9.5.1, Culture=neutral, PublicKeyToken=null" requirePermission="false" />
</configSections>
<microsoft.scripting>
<languages>
<language names="IronPython;Python;py" extensions=".py" displayName="IronPython 2.6 Alpha" type="IronPython.Runtime.PythonContext, IronPython, Version=2.6.0.1, Culture=neutral, PublicKeyToken=null" />
<language names="IronRuby;Ruby;rb" extensions=".rb" displayName="IronRuby 0.3" type="IronRuby.Runtime.RubyContext, IronRuby, Version=0.3.0.0, Culture=neutral, PublicKeyToken=null" />
require 'active_record/connection_adapters/abstract_adapter'
require 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
require 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
module System
class DBNull
def nil?
true
end
end
IronRuby 0.4 0.4.0.0 on .NET 2.0.0.0
OpenSSL::Cipher's CipherError
- exists under OpenSSL namespace (FAILED - 1)
OpenSSL::HMAC.digest
- returns an SHA1 digest
OpenSSL::HMAC.hexdigest
- returns an SHA1 hex digest
#!/usr/bin/env ruby
require 'openssl'
require 'base64'
private_key_file = 'private.pem';
password = 'boost facile'
encrypted_string = %Q{
qBF3gjF8iKhDh+g+TOvAzBkJA/1d2lD8RUyz2Ol+s1OpLB5aA3RA7EHm0KGL
require 'time'
t = Time.now
puts "UTC #{t.utc}" # fail in IronRuby
puts "RFC2822: #{t.rfc822}" # fail in IronRuby
puts "UTC then RFC2822: #{t.utc.rfc822}" #fail in IronRuby
describe "Widget#foo" do
it "does something" do
# This should be the functionality specs specific to the semantics of the method
Widget.new.foo.should == "do something"
end
end
# This captures the "type signature" of the method. Here are recipes for corner cases that you might forget.
# Note that the examples are not self-consistent by design. Only some of them might apply to any given method.
# However, the goal below is to include the union of all possible examples so that you can cut and paste
@Jirapong
Jirapong / sample.rb
Created May 4, 2009 10:59
dynamic add control on-the-fly
require 'winforms'
form = create_form :text => "Hello", :top_most => true
btn = create :text => "Click Me"
txt = create :text => "(Your name)"
layout form, [btn, txt], :top => 100, :spacing => 20
btn.click do |sener, args|
myip = (require 'open-uri'; open("http://www.whatismyip.org/").read)
require 'xamltools.rb'
class MyCommand
include System::Windows::Input::ICommand
def add_CanExecuteChanged(h)
@change_handlers << h
end
def remove_CanExecuteChanged(h)
@change_handlers.remove(h)
end