Software dev, tech, mind hacks and the occasional personal bit

Author: James Page 5 of 20

TRON and NORT

On the ultra-geeky front, I watched the original TRON last night, kindly leant to me by my buddy Doctor Dray. Having never seen it before, but heard a lot about it, I was keen to watch it at last. The core idea of computer programs personified is pretty cool, and the 80s rendering is interesting to watch (looks like stuff we did in computer graphics class at uni!). The plot does stretch belief a bit too thin at times though. To get an idea how far movie tech has come between the 80s and today, check out the original 80s trailer and the new Tron Legacy trailer.

Also, at high school, I and my fellow geeks spent quite a bit of time writing games in C like the TRON light cycle game, cunningly avoiding copyright violation by calling them NORT. After writing the 2 player version, we moved on to writing simple AIs so that you could play against the computer. Recently going through an old computer’s hard disk, I found the code for these. Thanks to the backward comparability features of Windows they still run, although they were written in Borland C/C++ for DOS! Amazing blast from the past.. here’s a picture of AI NORT in action:

nRake Microsoft Case Study

nRake is now the subject of a Microsoft case study. Check it out here:

UPDATE: Now on the Microsoft Case Study site.

Rails Refactor & Hack Night

During the RORO hack night last Wednesday, Ryan Bigg (@ryanbigg) and I worked on a Rails Refactor, something I’ve been meaning to get going for a long time.

How often have you wasted time doing renames in rails? Sure it’s hard to automate everything without understanding the code, but there sure are a lot of mechanical steps that you can easily automate. Ryan and I took on controller renames and got a fair way in the few hours we spent on the night.

Code is on github

To rename a controller:
$ rails_refactor.rb rename OldController NewController

  • renames controller file & class name in file
  • renames controller spec file & class name in file
  • renames view directory
  • renames helper file & module name in file
  • updates routes

To rename a controller action:
$ rails_refactor.rb rename DummyController.old_action new_action

  • renames controller action in controller class file
  • renames view files for all formats

Looking to extend it with model renames, and then more complex refactoring.
If you like it, please fork and contribute 🙂

Odd Date and Time Comparisons in Rails & Hack night

While comparing Dates and Times in Rails (both 2.3 and 3), I came across an odd behaviour:

>> Time.parse("Mon, 26 Jul 2010 9:59") == Date.new(2010, 7, 26)
=> false
>> Time.parse("Mon, 26 Jul 2010 10:00") == Date.new(2010, 7, 26)
=> true
>> Time.parse("Mon, 26 Jul 2010 10:01") == Date.new(2010, 7, 26)
=> false

Also

>> Date.new(2010, 7, 26) == Time.parse("Mon, 26 Jul 2010 10:00")
=> false (Rails 2.3)
=> nil (Rails 3)
>> Date.new(2010, 7, 26) == Time.parse("Mon, 26 Jul 2010 0:00")
=> false (Rails 2.3)
=> nil (Rails 3)

Tonight, we’ll be having the RORO hack night in the ThoughtWorks Sydney office, with a focus on open source projects (your own or contributing). A patch for this date/time behaviour might be an interesting area to pursue.

Ruby 1.8 Scoping and Blocks

Quick ruby quiz.. after these two lines execute, what is the value of number?

>> number = 5
>> (1..10).each {|number| print number}

Well, number will be 10, thanks to the block being run and re-assigning the value of number. This can cause you some pretty subtle bugs if you happen to have the same name for a local/function argument, and as a variable name in a block.

In C#, the compiler is kind enough to tell you that this would be a very bad idea and give you an error.

And thanks to Sudhinda for commenting – this has been fixed in Ruby 1.9. In 1.9, the variable used as the argument in the block does not affect the variable outside the block.

Showing Hidden Files in Mac Finder

If you’ve been longing for your Mac finder to show all the files on disk, then this command is for you. Run on the console:

defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
Now you’ll be able to see all the .config files in your home directory and all the normal Unix directories on the root.

Azure Build and Deploy using Powershell

Started working with Windows Azure? Want to have automated build and deploy, rather than clicking around in a web console or Visual Studio?

Check out the AzureBuildDeploy repository on GitHub.

I set this up for an Azure proof of concept project. It contains Powershell scripts for simple automated packaging, build and deploy, and a dummy WCF application for deployment to the cloud. The WCF application can however be easily replaced with a web application or what ever other .NET application you would like to host in the cloud.

How to use

  • Clone or download the source from http://github.com/jcrisp/AzureBuildDeploy
  • Update the $serviceName at the top of build-package-deploy.ps1
  • Update the certificate details, and subscription id at the top of deploy.ps1
  • If you plan to use SqlAzure (as in my proof of concept), update the connection details in HelloWorldService.svc.cs. If you don’t plan to use SqlAzure, just stub out the whole FindFirstGreetingUsingSqlAzure() method by returning a string.
  • Test out deployment to the cloud (run build-package-deploy.ps1). You can ensure it is working using the sample client in the repository.
  • Now you’ve got everything working, replace the dummy WCF application with whatever you want.

Notes
In my experience, the deployment of a simple application via these scripts, Visual Studio or the console takes about 16 minutes, from start of deploy to the service able to accept clients. This is extremely slow – I hope it improves!

Workaround for Subversion (SVN) certificate verification error: insecure algorithm on Ubuntu 10.04 Lucid Lynx

If you try to check out your code from a hosted subversion repository, under your shiny new Ubuntu 10.04, you may be disappointed to have it fail with the error:

svn: OPTIONS of 'https://server.com/repo': Certificate verification error: signed using insecure algorithm (https://server.com/repo)

Despite multiple threads on various linux and subversion forums which didn’t really help (it’s not subversion’s fault, it’s from gnu-utils, and yes, it would be great if everyone could get all their hosting providers to upgrade their certificates, and you could patch and recompile relevant utils), I finally found a work around here in Slovak. With a bit of help from Google translate, here is the work around:

Add to the end of your ~/.subversion/servers file:
ssl-trust-default-ca = no

It means you’ll have to verify every certificate manually, but at least you’ll be able to check out your code until you can get your hosting provider to update their certificates! Happy days!

ACS Alm Talk: Presentation Wrap Up & Slides

Thanks everyone who came along last night. It was a fun session, with a lot of lively discussion, especially around project management and software design. As mentioned during the talk, you might want to check out nRake for .NET builds and psDeploy for Powershell deployments. Here are the slides from the talk. If you have any more questions or areas to discuss, please feel free to drop me a line.

ACS Talk: The Ultimate ALM Environment (circa 2010)

I’ll be giving a presentation at an Australian Computer Society Special Interest Group on Wed 2 June, 6:30pm. More details here.

The abstract is:

Application Lifecycle Management (ALM) covers the whole software development lifecycle and associated processes including project management, business analysis, testing, build and deploy and development. Based on experiences in the field on projects with ThoughtWorks and consulting with other teams, I will describe what I consider to be the ultimate ALM environment, using an agile approach and techniques. This talk will cover goals, assessment criteria, practices, tools, and physical workspace design.

Hope to see you there!

Page 5 of 20

Powered by WordPress & Theme by Anders Norén