Skip to content

Instantly share code, notes, and snippets.

require 'benchmark'
Benchmark.bm { |x| x.report { require 'rubygems' } }
#
# user system total real
# eager transformation
# 1.622410 0.031200 1.653611 ( 1.581316)
# lazy transformation
# 1.170008 0.031200 1.201208 ( 1.099220)
#
# make sure we put "Lib" on the path -- this contains only
# libs required to load unittest ...
import sys
sys.path.append("Lib")
# stop the SL loading animation by setting the rootvisual
from System.Windows import Application
from System.Windows.Controls import UserControl
Application.Current.RootVisual = UserControl()
# accessing named child elements
### normal
w.find_name("msg").text = "Hello"
### wpf.rb
w.msg.text = "Hello"
# showing, hiding, and collapsing elements
### normal
include System::Windows
e.visibility = Visibility.hidden
# Accessing named children
# ------------------------
# Normal WPF
window.find_name('message_box').text = "Hello"
# wpf.rb
window.message_box.text = "Hello"
# Hiding, Showing, Collapsing elements
begin
require 'Microsoft.Scripting, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
rescue
require 'Microsoft.Scripting, Version=2.0.5.0, Culture=neutral, PublicKeyToken=null'
end
include Microsoft::Scripting
include Microsoft::Scripting::Hosting
def python(str, type = :file)
@python_engine ||= DynamicApplication.Current.Runtime.
TOPLEVEL_BINDING = binding unless defined?(TOPLEVEL_BINDING)
def repl(scope = TOPLEVEL_BINDING)
Repl.start(scope)
end
module Repl
def self.start(scope = TOPLEVEL_BINDING)
quitstr = ['quit', 'exit', '']
while true
--- a\ruby\lib\ruby\1.8\webrick\httprequest.rb Tue Feb 13 03:01:20 2007
+++ b\ruby\lib\ruby\1.8\webrick\httprequest.rb Thu May 7 16:45:54 2009
@@ -16,6 +16,11 @@
require 'webrick/httputils'
require 'webrick/cookie'
+# IronRuby bug: IO#read seems to chop off the first char
+
+class TCPSocket
+ def read size
@jschementi
jschementi / sinatra-0.9.4.patch
Created May 14, 2009 23:44
Patch Sinatra 0.9.1.1 to work with IronRuby
--- a/sinatra-0.9.4/lib/sinatra/base.rb Tue Aug 18 21:10:44 2009
+++ b/sinatra-0.9.4/lib/sinatra/base.rb Tue Aug 18 22:52:03 2009
@@ -957,6 +957,14 @@
/active_support/, # active_support require hacks
] unless self.const_defined?('CALLERS_TO_IGNORE')
+ unless self.const_defined?('RUBY_IGNORE_CALLERS')
+ IRONRUBY_IGNORE_CALLERS = [
+ /\.cs/, # C# stack traces that shows up in debug mode
+ /$^/ # .NET stack traces that shows up in release mode are without the filename
irb(main):002:0> Person.all
=> [#<Person id: 1, first_name: "Foo", last_name: "Bar">]
irb(main):003:0> p = Person.first
=> #<Person id: 1, first_name: "Foo", last_name: "Bar">
irb(main):004:0> p.first_name = "Jimmy"
=> "Jimmy"
irb(main):005:0> p.last_name = "Schementi"
=> "Schementi"
irb(main):006:0> p.save
=> true
class CreatePeople < ActiveRecord::Migration
def self.up
create_table :people do |t|
t.string :first_name
t.string :last_name
t.integer :age
t.timestamps
end
end