My Life As A Blog

Archive for September 2008

Watch the satnav

leave a comment »

It looks incredible, but this may be the first satnav – only there’s no sat, so maybe it’s just a nav…

Written by remark

September 30, 2008 at 8:11 pm

Posted in General, Kit

Ruby Tuesday #20 : Prevent monkeypatching

leave a comment »

Monkeypatching is the practice of redefining methods in classes at runtime.  According to this Wikipedia article, the exact definition varies between the Ruby and Python communities.  Some think it’s a good thing, while others take a different view.  If you want to prevent it from happening, here’s an answer : make methods immutable.

Written by remark

September 30, 2008 at 7:47 pm

Posted in Design, Ruby

Ruby Tuesday #19 : Silverline

leave a comment »

Even though I’ve been focussing on Python today, I couldn’t let this Tuesday pass without writing something Ruby related.  Silverline is a Ruby on Rails plugin that allows you to write client side Ruby (courtesy of Silverlight.)  Here’s how it works:

Silverline also lets you run pieces of your Rails application on the client, removing the need to write a separate JavaScript or Flash application simply to move functionality to the client. This is accomplished by flagging certain actions as "client", and running the necessary pieces of your Rails application and Rails itself on IronRuby in the browser.

To see it in action, check out this watch.  There’s more demo-ness here.

Written by remark

September 23, 2008 at 10:18 pm

Posted in Ruby, silverlight, Software

Running Python from C#

with one comment

Having posted a number of times about Ruby over the last few months, I thought I should also write a bit about Python.  The first thing I decided to try and do was to run some IronPython from C#.  I downloaded version 2.0 beta 5, which includes the latest version of the DLR.  I created a Console Application and added references to Microsoft.Scripting.dll and Microsoft.Scripting.Core.dll – the assemblies that constitute the DLR.  I also added a reference to IronPython.dll and IronPython.Modules.dll.  I decided to try to output some text, set a variable in IronPython and retrieve the value in C#.  Here’s the code:

ScriptRuntimeSetup setup = new ScriptRuntimeSetup();
ScriptRuntime runtime = new ScriptRuntime(setup);
ScriptEngine engine = runtime.GetEngine("IronPython");
ScriptScope scope = engine.CreateScope();
ScriptSource source = engine.CreateScriptSourceFromString("print 'Hello World'\r\na=1", SourceCodeKind.Statements);

I’m impressed that C# and IronPython can interact like this.  The possibilities for extending applications with runtime dynamic code are intriguing  – worth looking into.

Written by remark

September 23, 2008 at 10:04 pm

Posted in .NET, c#, Python, Software, Tools