(blogarhythm ~ end roll 浜崎あゆみ)
So I just listened to the last IT Conversations podcast of all time All's Well That Ends Well.
I'll miss the curation they provided. Did you know that 8 out of 10 interesting facts I quote at dinner parties I learned on the network? ;-)
And still learning: IT Conversations was the 2nd podcast ever? Apparently Doug Kaye uploaded a feed the day after Dave Winer posted his first example of using the RSS enclosure tag.
I'm not sure the Conversations Network couldn't have remained relevant and valuable for years to come, but it is an admirable decision to go out on a high and close down gracefully - importantly taking the time and care to ensure that the content archives remain available indefinitely.
My occasional technical diary of thoughts, tips, and tools from some of the more interesting things I'm playing around with at the time. That means all things Web, Open Source, Polyglot-programming, Electronics and Data, or just my latest rant.. who knows!
Friday, December 14, 2012
Monday, October 22, 2012
Building C# on MacOSX with Sublime Text
It's been a while since I last cranked up mono to compile some C#, and this time I'm on a Mac.
Fortunately, no dramas. The mono team have made it a very smooth process. I simply downloaded and installed the Mono SDK (it is packaged as a standard disk image [.dmg]). That's enough to compile and run simple projects.
There's a whole cross-platform IDE available now called MonoDevelop and it looks great if you are doing serious C#. Right now though, I was happy enough to build from the command line .. or from my favourite editor of the moment, Sublime Text.
Setting up a C# build system is trivial. From the "Tools | Build System" choose "New Build System..." option. My version simply associates with all .cs files and passes them to the mcs compiler:
And you get a .exe that runs under mono from the bash prompt. Wild!
Blogarhythm: Because It's There - Michael Hedges #NP
Fortunately, no dramas. The mono team have made it a very smooth process. I simply downloaded and installed the Mono SDK (it is packaged as a standard disk image [.dmg]). That's enough to compile and run simple projects.
$ mcs hello_world.cs $ mono hello_world.exe
There's a whole cross-platform IDE available now called MonoDevelop and it looks great if you are doing serious C#. Right now though, I was happy enough to build from the command line .. or from my favourite editor of the moment, Sublime Text.
Setting up a C# build system is trivial. From the "Tools | Build System" choose "New Build System..." option. My version simply associates with all .cs files and passes them to the mcs compiler:
{
"cmd": ["mcs","$file"],
"selector": "source.cs"
}Then when you are in a C# file you can simply ⌘B to compile. Like this:And you get a .exe that runs under mono from the bash prompt. Wild!
Blogarhythm: Because It's There - Michael Hedges #NP
Saturday, October 13, 2012
The Full Monty - from Ruby to Python n00bie
Ruby developers are a pretty spoilt bunch these days. The community has overall done a great job of rolling many of the advances in modern development practice into the tools and conventions we unconsciously put to work every day.
Now I wonder what life is like in the Python community? Like many Rubyists, I've played around with Python and Jython on and off. But nothing serious. And although you could get into a pedantic syntax war, I suspect for the most part the Python and Ruby communities don't overlap simply because once you dive into one camp, the only real reason you would switch to the other is because of some external driver (like a client's development standards).
It was a casual discussion about testing that re-ignited my interest in taking a peek over the fence. I picked up a copy of Greg L. Turnquist's Python Testing Cookbook and enjoyed playing around with a couple of the Python testing tools. It's an excellent book for ramping up your testing skills with Python - eminently clear and practical.
I was pretty sure that if any language community came close to matching Ruby's approach to development it would be Python. But is that true?
Most comparisons of Ruby and Python (like here, here and here) focus on language syntax and features. Conclusion?
So here is a rundown for some of the common patterns I could not do without when developing in Ruby, and what appear to be the leading Python equivalents - according to my research as of Oct-2012, but I welcome corrections and further information from any Python experts out there!
The Ruby Way: rvm is the leading tool for creating isolated ruby and gemset environments. A less intrusive alternative is rbenv (compared here).
The Python Way: virtualenv creates isolated Python environments. Ref: SO.
The Ruby Way: bundler
The Python Way: pip with a requirements.txt file. Ref: SO
The Ruby Way: we use gems. Easily built by hand, or bootstrapped with a tool like bundler or jeweler
The Python Way: use setuptools (enhancements to the Python distutils) to build and distribute eggs. Ref: SO
The Ruby Way: RubyGems for distribution, with source code most often found on github.
The Python Way: pip. And source code also seems to be showing up more on github than historical use of svn repositories. Ref: quora
The Ruby Way: rake.
The Python Way: this one I'm not so sure of. It seems most projects simply provide a custom setup script using distutils, but there are a variety of projects that support more complex build requirements. Ref: SO
The Ruby Way: Test::Unit, RSpec, Cucumber amongst others. It is extremely rare to find a project these days that doesn't have tests of some flavour.
The Python Way: unittest (sometimes called PyUnit) and doctest are common frameworks for unit testing and TDD. nose is a test runner, especially good for non-trivial projects. Lettuce is the rough Python equivalent of Cucumber. Like Ruby, there are many other projects to assist testing such as mocking tools like Mockito.
Bonus: open source projects have been rapidly adopting Travis for automated continuous integration on the back of a github commit. And it works for Ruby and Python.
Blogarhythm: Always Look On The Bright Side Of Life - Eric Idle/Monty Python
Now I wonder what life is like in the Python community? Like many Rubyists, I've played around with Python and Jython on and off. But nothing serious. And although you could get into a pedantic syntax war, I suspect for the most part the Python and Ruby communities don't overlap simply because once you dive into one camp, the only real reason you would switch to the other is because of some external driver (like a client's development standards).
It was a casual discussion about testing that re-ignited my interest in taking a peek over the fence. I picked up a copy of Greg L. Turnquist's Python Testing Cookbook and enjoyed playing around with a couple of the Python testing tools. It's an excellent book for ramping up your testing skills with Python - eminently clear and practical.
I was pretty sure that if any language community came close to matching Ruby's approach to development it would be Python. But is that true?
Most comparisons of Ruby and Python (like here, here and here) focus on language syntax and features. Conclusion?
same but different!What I find more interesting is a comparison of the fundamental productivity patterns used in each community, assuming your goal is to produce high-quality code that can be reliably distributed or deployed, and likely makes liberal use of other - probably open source - code components.
So here is a rundown for some of the common patterns I could not do without when developing in Ruby, and what appear to be the leading Python equivalents - according to my research as of Oct-2012, but I welcome corrections and further information from any Python experts out there!
Environment Partitioning
We don't like dependencies from other projects leaking over to contaminate and confound what we are trying to work on. While you could run up a separate VM for each project, it is much better if you have tools that can keep installed libraries and even the language distributions separate for each project.The Ruby Way: rvm is the leading tool for creating isolated ruby and gemset environments. A less intrusive alternative is rbenv (compared here).
The Python Way: virtualenv creates isolated Python environments. Ref: SO.
Dependency Management
It is likely our project will make use of other packages. We want automatic dependency management so that we can easy deploy predictable compositions of code packages.The Ruby Way: bundler
The Python Way: pip with a requirements.txt file. Ref: SO
Reusable Code Packaging
For anything more than trivial scripts, we probably want to package our project so that it can be reliably distributed or deployed.The Ruby Way: we use gems. Easily built by hand, or bootstrapped with a tool like bundler or jeweler
The Python Way: use setuptools (enhancements to the Python distutils) to build and distribute eggs. Ref: SO
Reusable Code Distribution
Both Ruby and Python are very open-source oriented programming communities. Not only do we consume a great deal, but it's likely we'll often want to make our own contributions easily available to others.The Ruby Way: RubyGems for distribution, with source code most often found on github.
The Python Way: pip. And source code also seems to be showing up more on github than historical use of svn repositories. Ref: quora
Project Build Tool
We'd prefer a common approach to running project build, doc, install and test tasks rather than rolling our own for each project.The Ruby Way: rake.
The Python Way: this one I'm not so sure of. It seems most projects simply provide a custom setup script using distutils, but there are a variety of projects that support more complex build requirements. Ref: SO
Automated Testing
It's 2012 already, we know that automated testing is a cornerstone of quality software. Especially so for code that is going to be widely shared and reused. Whether you do TDD, BDD or simply unit test, we all have a good test framework or two on our toolbelt.The Ruby Way: Test::Unit, RSpec, Cucumber amongst others. It is extremely rare to find a project these days that doesn't have tests of some flavour.
The Python Way: unittest (sometimes called PyUnit) and doctest are common frameworks for unit testing and TDD. nose is a test runner, especially good for non-trivial projects. Lettuce is the rough Python equivalent of Cucumber. Like Ruby, there are many other projects to assist testing such as mocking tools like Mockito.
Bonus: open source projects have been rapidly adopting Travis for automated continuous integration on the back of a github commit. And it works for Ruby and Python.
Blogarhythm: Always Look On The Bright Side Of Life - Eric Idle/Monty Python
Wednesday, July 04, 2012
Are You Experienced?
How many times have you seen a webdev job ad that asks for things like:
So it just came up again on a mailing list, and we all had a good lol.
When people ask for more years experience than the technology has even existed, at one level the incongruity simply tickles our geeky funny bone like a classic joke setup.
At another level however - and one that HR professionals the world over still struggle with - specifying job requirements in terms of many years experience with a certain technology betrays a fundamental lack of understanding for what developers do. Like advertising for doctors "with 5 years experience prescribing naltrexone" - I don't think I want to be treated by one who was selected on that basis!
When when specifying technical job roles, it comes back to the key question of how do we ask: "Are you experienced?"
For some jobs, length of service with a technology is a useful indicator for hiring purposes. If we are seeking deep skills with a relatively stable body of knowledge: we want evidence that candidates have had enough time to get their green horns knocked off, learned to swim in the deep end, and pick up all those heuristic tricks they don't teach in school.
In the IT realm, these jobs tend to be those involved with more stable back-end technologies (e.g. relation databases), or developers doing application maintenance on legacy systems (e.g. 6 year old java applications used by a bank).
However, the closer you get to front-end technologies and the more dynamic your needs (read: startups), the more irrelevant - and often misleading - the "judge experience by years with a technology" rule becomes. The rate at which technologies change is just too fast. I've been doing this for many years (more than I'll admit here!), but:
IMHO, the fundamental skill that great developers share is the ability to learn and assimilate. You don't want them stuck in a rut.
So how do we measure it? Rather than years of service, we need indicators of applied learning, for example:
So when I write a job ad for a technical role, I'd suggest defining the technical requirements along these lines:
I haven't asked for all the technologies they've used in the past - assuming that this will come out when they explain exactly what they've been doing during those "5+ years professional web development".
Of course that still leaves a whole range of matters such as soft-skills and how you actually go about selling your startup vacancy. You can find this and more in the most excellent JFDI Hiring & Firing guide.
Blogarhythm: Are You Experienced? - Jimi Hendrix
Minimum 5 years experience in Ruby on Rails, html5, JQuery, Mongo DB, and building andriod and iphone/ipad apps
So it just came up again on a mailing list, and we all had a good lol.
When people ask for more years experience than the technology has even existed, at one level the incongruity simply tickles our geeky funny bone like a classic joke setup.
At another level however - and one that HR professionals the world over still struggle with - specifying job requirements in terms of many years experience with a certain technology betrays a fundamental lack of understanding for what developers do. Like advertising for doctors "with 5 years experience prescribing naltrexone" - I don't think I want to be treated by one who was selected on that basis!
When when specifying technical job roles, it comes back to the key question of how do we ask: "Are you experienced?"
For some jobs, length of service with a technology is a useful indicator for hiring purposes. If we are seeking deep skills with a relatively stable body of knowledge: we want evidence that candidates have had enough time to get their green horns knocked off, learned to swim in the deep end, and pick up all those heuristic tricks they don't teach in school.
In the IT realm, these jobs tend to be those involved with more stable back-end technologies (e.g. relation databases), or developers doing application maintenance on legacy systems (e.g. 6 year old java applications used by a bank).
However, the closer you get to front-end technologies and the more dynamic your needs (read: startups), the more irrelevant - and often misleading - the "judge experience by years with a technology" rule becomes. The rate at which technologies change is just too fast. I've been doing this for many years (more than I'll admit here!), but:
- I'm still learning new things every month - probably at an even faster rate than when I was a fresh grad
- Half of what I learned last year is now obsolete, probably never to be called on again
- I've lost count of the number of times I've developed mastery in something for 1 project, and never used it again
IMHO, the fundamental skill that great developers share is the ability to learn and assimilate. You don't want them stuck in a rut.
So how do we measure it? Rather than years of service, we need indicators of applied learning, for example:
- A single significant project delivery (i.e. that goes live) is often enough to develop a good mastery of a technology
- Multiple project deliveries demonstrates the ability to hone and apply that knowledge in different scenarios
- Working with various technologies over time demonstrates flexibility and adaptability to the new
- Founding an open source project shows that the individual not only has the creativity and inspiration to create something new, but has the tenacity to get it done (without a boss looking over their shoulder)
- Contributing to an open source project demonstrates that the individual has pounded it enough to identify something that needs fixing, has had the mental firepower to figure out the root cause and how to fix it, and the collaborative skills to get the contribution merged.
So when I write a job ad for a technical role, I'd suggest defining the technical requirements along these lines:
- 5+ years professional web development experience
[a guide to the level of seniority within the general professional discipline]
- Delivered multiple projects and current experience using: Rails 3.x, PostgreSQL 9.x, git
[the specific technical skills you expect people to have on day 1. Reference major version numbers where they represent significant evolutions of the technology, and make sure you use the correct nomenclature to avoid more lolz;-)]
- Ideally, recent project experience using one of more of the following technologies: capistrano, redis, and MongoDb.
[technologies you use or are planning to use, but it won't kill you to allow the person time to get up to speed]
- Experience contributing to or founding open source projects
[it's almost getting to the stage where developers really have to be quite uninterested in their career to avoid some involvement with open source projects - see comments above]
I haven't asked for all the technologies they've used in the past - assuming that this will come out when they explain exactly what they've been doing during those "5+ years professional web development".
Of course that still leaves a whole range of matters such as soft-skills and how you actually go about selling your startup vacancy. You can find this and more in the most excellent JFDI Hiring & Firing guide.
Blogarhythm: Are You Experienced? - Jimi Hendrix
Sunday, May 27, 2012
gource - cool and not totally pointless
Run gource on a source code repository and it animates the code's evolution. I think I first saw it used to illustrate the history of Python development since 1990, and I must admit my first reaction was cool but probably pointless.
Recently @dmm6319 ran it over our own project, and inspired me to play around a bit with it too.
So after watching our animation a few times I'm sheepishly revising my opinion of gource.
Yes, you probably need to have something invested in the particular code-base to care, and it certainly helps if you avoid the obvious cliche of using an "atmospheric" soundtrack.
But there are some real, big-picture insights that come through very clearly in the animation that you wouldn't necessarily get if you just looked at the source - for example, the shift from Cucumber to RSpec as our primary testing framework.
Blogarhythm: Asik Veysel - Joe Satriani
Recently @dmm6319 ran it over our own project, and inspired me to play around a bit with it too.
So after watching our animation a few times I'm sheepishly revising my opinion of gource.
Yes, you probably need to have something invested in the particular code-base to care, and it certainly helps if you avoid the obvious cliche of using an "atmospheric" soundtrack.
But there are some real, big-picture insights that come through very clearly in the animation that you wouldn't necessarily get if you just looked at the source - for example, the shift from Cucumber to RSpec as our primary testing framework.
Blogarhythm: Asik Veysel - Joe Satriani
Monday, March 19, 2012
Rails + Ember + MongoDB + bootstrap
I was fired up to try out ember.js after seeing Cameron's presentation at the last Singapore Ruby Brigade meetup.
Ember is one of the many javascript MVC frameworks that have been sprouting up over the past year, and it seems to offer a nice level of abstraction. I was quite interested to see how it might fit for a Rails/MongoDB application we're currently working on, so a few tests were in order.
I hosted some tests on a Rails 3.2.2 base, and threw in a whole bunch of technologies to see how well they play together. The story so far:
Surprisingly, this all hangs together without too much fuss! You can see & fork the demo at rails-ember-mongo-bootstrap-demo.
What's next?
Blogarhythm: Remember - Jimi Hendrix
Ember is one of the many javascript MVC frameworks that have been sprouting up over the past year, and it seems to offer a nice level of abstraction. I was quite interested to see how it might fit for a Rails/MongoDB application we're currently working on, so a few tests were in order.
I hosted some tests on a Rails 3.2.2 base, and threw in a whole bunch of technologies to see how well they play together. The story so far:
- ruby 1.9.3 + rails 3.2.2 with rspec-rails and factory_girl_rails for testing
- haml - templating for a pure rails alternative to compare with the ember app
- mongoid - using MongoDB for server-side persistence, to see how this plays with ember
- inherited_resources - for super thin controllers. Works beautifully with ember and Mongo (I literally wrote just a single line in the server-side controller
- ember.js - the ember distribution...
- ember-rails - makes it easy to add ember to the project (gem installed with bundler)
- CoffeeScript - for the ember scripting
- ember-rest - a simple RESTful resource adapter between ember and rails
- twitter-bootstrap-rails - a gem packaging of twitter bootstrap (adds LESS to the asset pipeline)
Surprisingly, this all hangs together without too much fuss! You can see & fork the demo at rails-ember-mongo-bootstrap-demo.
What's next?
- Testing: I've got RSpec in the project for conventional testing, but I haven't investigated the best ways to test the ember app itself yet.
- Relations: perhaps switching to ember-data to test some non-trivial model associations
- ember-bootstrap: adds bootstrap components to ember. Sounds promising but my initial attempts to use it weren't too successful
Blogarhythm: Remember - Jimi Hendrix
Monday, November 07, 2011
Adding Mobile Support with Web 2.0 Touch to the NoAgenda Attack Vector Dashboard
The quest for an ideal javascript framework for mobile web applications has been a bit of a work-in-progress for some time (at least if you cared about cross-platform).
You might have got started (like me) with Jonathan Stark's excellent books Building iPhone Apps with HTML, CSS, and JavaScript
and Building Android Apps with HTML, CSS, and JavaScript
, and maybe tried the jQTouch framework that these spawned. Meanwhile, the official jQuery mobile framework has slowly been moving to fruition.
I recently discovered another project - Web 2.0 Touch - that is pitched as a mini framework with better features and more ease of use than jQTouch. Since I had a little side-project underway that could benefit from mobile support, I thought I'd give it a test drive.
And I was duly impressed. In just a few hours, I had a full and distinct mobile version of the site. Better yet, I didn't run into any weird behaviours that can plague mobile development. It just worked.
Now I'm not going to stop tracking the jQuery Mobile project or other solutions like Rhomobile, but if all you need is a quick, functional and good looking mobile view, then Web 2.0 Touch is well worth a look.
The NoAgenda Attack Vector Dashboard is the project I used Web 2.0 Touch for, and if you want to see all the intricate details of how I made the site mobile-friendly - you can! The entire site is open sourced and available on
GitHub. I'll just describe a couple of the features here...
Since the application has a very specific and rich desktop presentation, I knew the mobile version was going to be very different. Here are the desktop and mobile "home pages" side-by-side:
Rather than weigh down view code with lots of conditionals, I decided to use the MIME-type method of differentiation.
If you haven't used this before, it essentially means registering a suitable MIME-type (I called it mobile), and in the main ApplicationController, the request.format is set to this type if the client is detected to require the special mobile view. Now a request to an :index page will render with index.mobile.erb (or index.mobile.haml as is my preference), while the non-mobile view will render with index.html.erb / index.html.haml.
I've added the browser gem to the project for device identification, and for this app I've decided to only specifically handle iPhone and Android. I also don't give these phones a desktop view alternative, since I know it is not going to be nice.
In the application, I've made this 'unobtrusive' so it might be worth pointing out what is going on. The .touch_load class is used to tag items that should initiate a page transition. The data-url and data-transition attributes tell it where to go and what transition animation to use.
Blogarhythm: Touch - Noiseworks
You might have got started (like me) with Jonathan Stark's excellent books Building iPhone Apps with HTML, CSS, and JavaScript
I recently discovered another project - Web 2.0 Touch - that is pitched as a mini framework with better features and more ease of use than jQTouch. Since I had a little side-project underway that could benefit from mobile support, I thought I'd give it a test drive.
And I was duly impressed. In just a few hours, I had a full and distinct mobile version of the site. Better yet, I didn't run into any weird behaviours that can plague mobile development. It just worked.
Now I'm not going to stop tracking the jQuery Mobile project or other solutions like Rhomobile, but if all you need is a quick, functional and good looking mobile view, then Web 2.0 Touch is well worth a look.
The NoAgenda Attack Vector Dashboard is the project I used Web 2.0 Touch for, and if you want to see all the intricate details of how I made the site mobile-friendly - you can! The entire site is open sourced and available on
GitHub. I'll just describe a couple of the features here...
Differentiated Views
The first has not much to do with Web 2.0 Touch per se, and is more just a demonstration of how easy it is to work with a range of view technologies in Rails.Since the application has a very specific and rich desktop presentation, I knew the mobile version was going to be very different. Here are the desktop and mobile "home pages" side-by-side:
Rather than weigh down view code with lots of conditionals, I decided to use the MIME-type method of differentiation.
If you haven't used this before, it essentially means registering a suitable MIME-type (I called it mobile), and in the main ApplicationController, the request.format is set to this type if the client is detected to require the special mobile view. Now a request to an :index page will render with index.mobile.erb (or index.mobile.haml as is my preference), while the non-mobile view will render with index.html.erb / index.html.haml.
I've added the browser gem to the project for device identification, and for this app I've decided to only specifically handle iPhone and Android. I also don't give these phones a desktop view alternative, since I know it is not going to be nice.
# config/initializers/mime_types.rb:
Mime::Type.register_alias "text/html", :mobile
# application_controller.rb:
class ApplicationController < ActionController::Base
before_filter { request.format = :mobile if (browser.iphone? || browser.android?) }
end
With that in place, my *.mobile.haml view and layout files just need to focus on rendering the mobile site.Page Transitions
The jsTouch.loadPage method is used to load and navigate pages in the Web 2.0 Touch framework.In the application, I've made this 'unobtrusive' so it might be worth pointing out what is going on. The .touch_load class is used to tag items that should initiate a page transition. The data-url and data-transition attributes tell it where to go and what transition animation to use.
.toolbar
%h1= t('.title')
%a.button.back.touch_load{'data-url' => menu_dashboard_path, 'data-transition' => 'pop-out' }= t(:done)
.content
= render :partial => 'notes/table'The enableSmartphonePageLoad function runs during page load to setup the behaviour: enableSmartphonePageLoad: function() {
$('.touch_load').live('click', function() {
var url = $(this).data('url') || $(this).attr('href');
var transition = $(this).data('transition') || 'slide-left';
if (url != "") {
jsTouch.loadPage(url, { transition: transition });
}
return false;
});
},
Blogarhythm: Touch - Noiseworks
Saturday, October 01, 2011
gitfall#1: Falling off a branch
Ever had a merge fail with a fatal: git write-tree failed to write a tree message out of the blue?
It sounds terrifying, but when I got the root cause is quite mundane: file name conflicts in the merging commits that git is not smart enough to figure out without help. And when you fixup your merge, you are left with a commit that's lost one of its parents ("falling off a branch").
If you do much file reorganisation in a project with branches, it turns out this can be quite common (had it a few times on a recent project).
In an attempt to understand exactly what was going on, I put together the steps needed to reproduce and recover from the error. I've tidied these up and made it a full "tutorial/demo" script. You can find it in a repo called gitfalls - in the expectation that there are many more git curiosities and idiosynchrasies worth a similar treatment. Enjoy!
The script not only shows how to create the error, but two ways of resolving it and the "lost parent branch" issue:
Lessons learned form all of this? Perhaps:
Hope you enjoy the script, and if you have any others to contribute please be my guest!
Blogarhythm: Fall Out - The Police
It sounds terrifying, but when I got the root cause is quite mundane: file name conflicts in the merging commits that git is not smart enough to figure out without help. And when you fixup your merge, you are left with a commit that's lost one of its parents ("falling off a branch").
If you do much file reorganisation in a project with branches, it turns out this can be quite common (had it a few times on a recent project).
In an attempt to understand exactly what was going on, I put together the steps needed to reproduce and recover from the error. I've tidied these up and made it a full "tutorial/demo" script. You can find it in a repo called gitfalls - in the expectation that there are many more git curiosities and idiosynchrasies worth a similar treatment. Enjoy!
The script not only shows how to create the error, but two ways of resolving it and the "lost parent branch" issue:
- Merge again after fixing the first failed commit. Duh!
- Going a bit deeper and using git commit-tree to manufacture a new merge commit with the correct parentage
Lessons learned form all of this? Perhaps:
- Avoid reorganising folder structures using folder names that once were used by files (or vice versa)
- If you must do such a reorganisation, immediately merge or cherry-pick to other active branches if you can. This avoids laying a trap for a co-worker to hit later on.
Hope you enjoy the script, and if you have any others to contribute please be my guest!
Blogarhythm: Fall Out - The Police
Wednesday, July 20, 2011
Mikko Hyppönen@TED
Doing more than just talking about viruses: he fires up a few classics in a DOS box and pokes around with a binary editor before looking at current threats and live infection data. Very cool and entertaining. Not many are brave enough to do live demos, but if you watch to the end you'll get to see how prepared he was for failure;-)
Best served with sides of:
PS: better quality vid on youtube. And yes, that is a 5 1/4" floppy.
Blogarhythm: Security - Jo Jo Zep & The Falcons
Best served with sides of:
- Daniel Suarez's Daemon
- for the extreme version of how bad things can go wrong,
- Rebecca MacKinnon: Let's take back the Internet! - because maybe organised crime is the perfect distraction as we rush headlong to enslave ourselves to the Sovereigns of the Internet, and
- Security Now! #291 - for Steve Gibson's deconstruction of stuxnet, the most spohisticated Internet-borne "weaponised payload" ever discovered... and perhaps a plausibly-deniable warning from Government(s) that "you call that a knife? THIS is a knife!"
PS: better quality vid on youtube. And yes, that is a 5 1/4" floppy.
Blogarhythm: Security - Jo Jo Zep & The Falcons
Sunday, July 10, 2011
It goes PING!
If you're like me, you have a bunch of trusty (and rusty) shell scripts that you reach for when doing things like testing a new load balancer.
Enough of that! igp (It goes PING!) is a simple command line utility for testing services with a range of common protocols: ICMP, UDP, TCP, HTTP/S, LDAP/S and so on.
This is nothing earth shattering I know, but it's nice to have simple cross-platform (since it's ruby) tool that does all the common protocols in one. Thankfully, most of the work has already been done by the net-ping library - igp really just provides a sleek command-line wrapper.
The only dependency is ruby+rubygems. Just:
Blogarhythm: Keep it Up - Snap!
Enough of that! igp (It goes PING!) is a simple command line utility for testing services with a range of common protocols: ICMP, UDP, TCP, HTTP/S, LDAP/S and so on.
This is nothing earth shattering I know, but it's nice to have simple cross-platform (since it's ruby) tool that does all the common protocols in one. Thankfully, most of the work has already been done by the net-ping library - igp really just provides a sleek command-line wrapper.
The only dependency is ruby+rubygems. Just:
gem install igpAnd then you are ready to capture traces, for example:
igp my.server.com
# ^ ICMP assumed by default. This is the same as:
igp icmp://my.server.com
igp http://my.insecure.server.com
igp http://my.insecure.server-hiding-on-a-funny-port.com:8080/javascripts/all.js
igp https://my.secure.server.com
igp https://my.secure.server-hiding-on-a-funny-port.com:4443
igp tcp://my.tcp-service.com:9091
igp udp://my.udp-service.com:123
igp ldap://my.insecure.ldap.server.com
igp ldaps://my.secure.ldap.server.com
Blogarhythm: Keep it Up - Snap!
Sunday, April 24, 2011
Multi-tenancy with Rails
RedDotRubyConf 2011 in Singapore is over. It was an amazing event (ryan takes notes so we don't have to - day#1 day#2)
Somehow I managed to cheat my way into a line-up of legendary speakers that included Matz himself. Here are the slides..
I spoke about multi-tenancy - what it is and why it's increasingly relevant for Rails development. It dives a little into four of the many approaches and ends with the challenge: Isn't it about time there was a 'Rails Way'?
Blogarhythm: So Many Ways POP DISASTER
Somehow I managed to cheat my way into a line-up of legendary speakers that included Matz himself. Here are the slides..
I spoke about multi-tenancy - what it is and why it's increasingly relevant for Rails development. It dives a little into four of the many approaches and ends with the challenge: Isn't it about time there was a 'Rails Way'?
Blogarhythm: So Many Ways POP DISASTER
Sunday, March 20, 2011
jQuery UI AddToCalendar update
Thanks to nfarina for a patch to improve compatibility with older IE versions.. jQuery UI AddToCal widget is stepped to 0.1.1 and now listed in the jQuery plugin store.
To recap .. use AddToCal if you want to offer your website visitors the ability to add any events you list or present on your site to their own calendar. It supports Google Calendar, Microsoft Live Calendar, Yahoo! Calendar, 30boxes, any iCal or vCalendar compatible desktop application (and you can extend it to support any special calendar software you might be dealing with).
See my previous post that describes how to use it in a bit more detail..
Blogarhythm: Birthday
To recap .. use AddToCal if you want to offer your website visitors the ability to add any events you list or present on your site to their own calendar. It supports Google Calendar, Microsoft Live Calendar, Yahoo! Calendar, 30boxes, any iCal or vCalendar compatible desktop application (and you can extend it to support any special calendar software you might be dealing with).
See my previous post that describes how to use it in a bit more detail..
Blogarhythm: Birthday
Sunday, January 30, 2011
Paranoid Yak Shaving
So a few weeks ago I found myself wanting "soft-delete" in a Rails app. Ruby Toolbox is a little long in the tooth on the subject, but after a little more research I discovered xpond's paranoid project that was just what I wanted:
All was cool, except at about the same time we updated to Rails 3.0.3 and it broke (as it turned out, due to changes in AREL 2.0.6 internals).
One of the beautiful things about github and the way it's been adopted by the ruby/rails community in particular is that it makes it so damn easy to just dive in and help update code originally contributed by other people. So paranoid needs updating for Rails 3.0.3? No problem - fork it, diagnose the issue and push your fixes back up to github.
But that's also a great recipe for yak shaving ;-)
The fixes are yet to make it into the released gem, but if you desparately need 3.0.3 support you can install from my repo. i.e. in your Gemfile:
Blogarhythm: Paranoid (of course - but this is the bluegrass version!)
- packaged as a gem, not a plugin
- built for Rails 3 (arel-aware in particular)
- can be selectively applied to your models
All was cool, except at about the same time we updated to Rails 3.0.3 and it broke (as it turned out, due to changes in AREL 2.0.6 internals).
One of the beautiful things about github and the way it's been adopted by the ruby/rails community in particular is that it makes it so damn easy to just dive in and help update code originally contributed by other people. So paranoid needs updating for Rails 3.0.3? No problem - fork it, diagnose the issue and push your fixes back up to github.
But that's also a great recipe for yak shaving ;-)
The fixes are yet to make it into the released gem, but if you desparately need 3.0.3 support you can install from my repo. i.e. in your Gemfile:
gem 'paranoid', '~> 0.0.10', :require => 'paranoid', :git => 'git://github.com/tardate/paranoid'
Blogarhythm: Paranoid (of course - but this is the bluegrass version!)
Tuesday, December 14, 2010
CruiseControlling Ruby 1.9.2 and Rails 3.0.2
CruiseControl for Ruby from ThoughWorks has long been one of the easiest ways to your rails project under continuous integration.
But there's still an issue that it can't run under Ruby 1.9.x. That's not very good if you are targeting 1.9.2 for your project.
Here's a quick recipe for how you can build a 1.9.2 project with CC, using the wonders of rvm..
In ~/.cruise/projects/my_project_name, edit cruise_config.rb to run a shell script instead of the standard build task (I'm calling it ccbuild.sh and it will be in the root of my git repo):
Add ccbuild.sh to your repository (don't forget to chmod u+x it). It needs to ensure rvm script is loaded and activate the correct ruby & gemset.
The script initialization is necessary because it seems the way CC spawns the shell script it doesn't pick up the rvm initialization you might already have in .bash_profile. Without rvm script initialization, "rvm" will invoke the binary which can't make the direct environment mods it needs to do.
Here's what I have in ccbuild.sh:
Once that's checked in and pushed to the repo, you can kick-off CC:
Now my ccmenu is green, and CruiseControl is running my project under 1.9.2 and rails 3.0.2;-)
Blogarhythm: Waiting for the light ART-SCHOOL
But there's still an issue that it can't run under Ruby 1.9.x. That's not very good if you are targeting 1.9.2 for your project.
Here's a quick recipe for how you can build a 1.9.2 project with CC, using the wonders of rvm..
# download and unpack CC to /usr/local/cruisecontrol-1.4.0 (or where you like)
# for convenience, add .rvmrc in /usr/local/cruisecontrol-1.4.0 to have it run 1.8.7
echo "rvm 1.8.7-p302" > /usr/local/cruisecontrol-1.4.0/.rvmrc
# configure CC:
cd /usr/local/cruisecontrol-1.4.0
./cruise add my_project_name --source-control git --repository git@github.com:myname/myproject.git
# ^^ This will initialize the ~/.cruise/projects/my_project_name folder for a git-based project
# if you have an .rvmrc file in your git repo, pre-emptively trust it to avoid clogging CC:
mkdir ~/.cruise/projects/my_project_name
rvm rvmrc trust ~/.cruise/projects/my_project_name
In ~/.cruise/projects/my_project_name, edit cruise_config.rb to run a shell script instead of the standard build task (I'm calling it ccbuild.sh and it will be in the root of my git repo):
Project.configure do |project|
# [.. other stuff ..]
project.build_command = './ccbuild.sh'
# [.. other stuff ..]
end
Add ccbuild.sh to your repository (don't forget to chmod u+x it). It needs to ensure rvm script is loaded and activate the correct ruby & gemset.
The script initialization is necessary because it seems the way CC spawns the shell script it doesn't pick up the rvm initialization you might already have in .bash_profile. Without rvm script initialization, "rvm" will invoke the binary which can't make the direct environment mods it needs to do.
Here's what I have in ccbuild.sh:
#!/bin/bash
if [ "$(type rvm | head -1)" != "rvm is a function" ]
then
source ~/.rvm/scripts/rvm || exit 1
fi
if [ "$(type rvm | head -1)" != "rvm is a function" ]
then
echo "rvm not properly installed and available"
exit 1
fi
rvm use 1.9.2-p0@mygemsetname --create
bundle check || bundle install || exit 1
rake # setup to run all required tests by default
Once that's checked in and pushed to the repo, you can kick-off CC:
cd /usr/local/cruisecontrol-1.4.0
./cruise start
Now my ccmenu is green, and CruiseControl is running my project under 1.9.2 and rails 3.0.2;-)
Blogarhythm: Waiting for the light ART-SCHOOL
Saturday, November 06, 2010
Rock till you drop.io
Bombshell announcement on 29-Oct: drop.io have .. struck a deal with Facebook.
drop.io was widely acclaimed as the simple file sharing mechanisms we all needed. It resolutely solved the problem that everyone with a computer and a network connection has known at one time or another: how to share files too cumbersome for email, without resorting to techno-geekery like ftp and such. And it worked. Beautifully.
But it doesn't work anymore.
Goodbye drop.io! You were an amazing service. One of the best and brightest of the Class of Web 2.0. You made things simple. You solved a real, pressing problem.
Unfortunately, that's not what I'll remember you for now.
Instead, it will be for brewing a thunderstorm of concern over the very dependability of cloud services, as John C. Dvorak went to town on in his column.
And for teaching us that it's true - startup founders really don't give a toss for their customers if they can get a sweet deal and a plum job with one of the heavyweights instead.
And for once again propelling Facebook into the privacy-conspiracy-theory limelight. Sure, "no data will be transferred to Facebook", but they put you out of business and bought "most of [your] technology and assets", right? So will we be surprised when Facebook takes aim to lure it's unsuspecting users into sharing pretty much anything and everything - private, commercially confidential, and otherwise - using Facebook?
Well, I guess drop.io does really deserve our thanks for that last point, if anyone cares to notice.
The very best news—for anyone who can't imagine life without drop.io—is that there is another exceptional product out there called Dropbox that can handle most team sharing needs in addition to looking after your personal documents.
That's not a paid advertisement or anything. I simply use Dropbox everyday and just love it. I wouldn't be exaggerating to say it's probably improved the way I work more than anything even the folks in Redmond or Cupertino have shipped in recent memory.
Blogarhythm: Rock Rock (till you drop) .. Def Leppard
What this means is that Facebook has bought most of drop.io’s technology and assets, and Sam Lessin is moving to Facebook.
drop.io was widely acclaimed as the simple file sharing mechanisms we all needed. It resolutely solved the problem that everyone with a computer and a network connection has known at one time or another: how to share files too cumbersome for email, without resorting to techno-geekery like ftp and such. And it worked. Beautifully.
But it doesn't work anymore.
Goodbye drop.io! You were an amazing service. One of the best and brightest of the Class of Web 2.0. You made things simple. You solved a real, pressing problem.
Unfortunately, that's not what I'll remember you for now.
Instead, it will be for brewing a thunderstorm of concern over the very dependability of cloud services, as John C. Dvorak went to town on in his column.
And for teaching us that it's true - startup founders really don't give a toss for their customers if they can get a sweet deal and a plum job with one of the heavyweights instead.
And for once again propelling Facebook into the privacy-conspiracy-theory limelight. Sure, "no data will be transferred to Facebook", but they put you out of business and bought "most of [your] technology and assets", right? So will we be surprised when Facebook takes aim to lure it's unsuspecting users into sharing pretty much anything and everything - private, commercially confidential, and otherwise - using Facebook?
Well, I guess drop.io does really deserve our thanks for that last point, if anyone cares to notice.
The very best news—for anyone who can't imagine life without drop.io—is that there is another exceptional product out there called Dropbox that can handle most team sharing needs in addition to looking after your personal documents.That's not a paid advertisement or anything. I simply use Dropbox everyday and just love it. I wouldn't be exaggerating to say it's probably improved the way I work more than anything even the folks in Redmond or Cupertino have shipped in recent memory.
Blogarhythm: Rock Rock (till you drop) .. Def Leppard
Saturday, October 30, 2010
The Ultimate Steampunk Project needs $10
Now, we are talking about a truck-sized, steam-powered machine that is Turing-complete and features (without silicon or electricity) "modern" ideas like instruction pipelining. The ultimate steampunk project. It also has a serious educational and academic aspect (including to digitize all of Babbage's plans and notes).
Due to significant private support coming forth, the pledge target has apparently been reduced from 50,000 to just 10,000 signatories. At the time of writing, John only needed another 6358 pledges of $10/£10/€10 each to get the project moving.
Now I don't often get behind fundraisers and campaigns, but this strikes me as one of those once-in-a-lifetime follies you cannot help but support. And all for about the price of the cheapest bottle of wine in the shop around the corner.
Blogarhythm: L.O.V.E. Machine WASP
Sunday, October 03, 2010
Add to Calendar with a jQuery Widget
If you deal with any kind of event-based information on your websites, you would probably really like an easy way of letting users add it to their calendar.Unlike link sharing—where there are some great drop-in solutions like AddToAny and AddThis—calendar integration unfortunately remains a bit rough around the edges. Varying standards with varying degrees of adoption; consideration for desktop and web-based calendar clients; and the complicating factor of timezones make it all a bit harder than it really should be.
AddToCal is a jQuery UI Widget that I put together to help me solve the problem and do things like you see in the screen clip on the right. It's freely shared and available on github.
Using it on a web page is as simple as including the js links, binding it to the DOM elements or classes on your page that contain "events", and provide an implementation of the getEventDetails method that knows how to extract the event details from your particular DOM structure.
The example also demonstrates how to use AddToCal in conjunction with the hCalendar microformat for event notation (try it out here).
I've currently included support for the web-based calendars by Google, Yahoo!, and Microsoft Live. If you can serve iCal or vCalendar format event links then AddToCal also links to 30boxes and iCal/vCalendar desktop software—including the iPad Calendar application;-)
Serving iCal and vCalendar links
What about iCal and vCalendar formats? These are complicated a little because we need a URL to the respective iCal and vCalendar format resources .. so we need to be able to serve them before AddToCal can link to them.
Thankfully, this can be relatively trivial once you get a handle on the file formats. Here's an example of how to implement with Ruby on Rails.
Say we have an Events controller and associated Event model that represents an activity people may like to add to their calendars. A simple iCal implementation with ERB means creating a views/events/show.ics.erb along these lines:
BEGIN:VCALENDAR
PRODID:-//AddToCal Example//EN
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
DTSTART:<%= @event.start_time.rfc3339 %>
DTEND:<%= @event.end_time.rfc3339 %>
LOCATION:<%= event_url( @event ) %>
SEQUENCE:0
UID:
DTSTAMP:<%= Time.zone.now.rfc3339 %>
DESCRIPTION:<%= event_url( @event ) %>\n<%= @event.full_title %>
SUMMARY:<%= @event.synopsis %>
PRIORITY:5
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR
Sharp eyes will note the unusual rfc3339 helper method I've provided to make it easy to get date/times in RFC3339 format as required by the iCal and vCal standards. You could extend Time::DATE_FORMATS, but here I've simply added the method to ActiveSupport::TimeWithZone
class ActiveSupport::TimeWithZone
def rfc3339
utc.strftime("%Y%m%dT%H%M%SZ")
end
end
To support vCalendar, we also implement views/events/show.vcs.erb
BEGIN:VCALENDAR
PRODID:-//AddToCal Example//EN
VERSION:1.0
BEGIN:VEVENT
SUMMARY:<%= @event.full_title %>
PRIORITY:0
CATEGORIES:SHOW
CLASS:PUBLIC
DTSTART:<%= @event.start_time.rfc3339 %>
DTEND:<%= @event.end_time.rfc3339 %>
URL:<%= event_url( @event ) %>
DESCRIPTION;ENCODING=QUOTED-PRINTABLE:<%= event_url( @event ) %> =0A<%= @event.synopsis %>
LOCATION;ENCODING=QUOTED-PRINTABLE:<%= event_url( @event ) %>
END:VEVENT
END:VCALENDAR
Depending on your Rails version and web server, you may have to teach it about these MIME types e.g. add to config/initializers/mime_types.rb:
Mime::Type.register "application/hbs-vcs, text/calendar, text/x-vcalendar", :vcs
Blogarhythm: Remember - Jimi Hendrix
12 Things Every Programmer Should Know
Samnang Chhun posted his neat little presentation from BarCamp Phnom Penh 2010. It's a good summary of the leading memes of the moment..

Blogarhythm: everybody wants the same thing - scissor sisters
Blogarhythm: everybody wants the same thing - scissor sisters
RFC 3339 / ISO 8601 dates in javascript
Many server-side languages (e.g. Ruby and Python JSON encoders) and encoding formats like ATOM send dates in RFC 3339 / ISO 8601 format. The standard Javascript Date object cannot parse these values, which can make client-side scripting involving dates a pain.
There have been snippets of code floating around the net for ages, and various libraries that include necessary support. rfc3339date.js is my attempt at rolling the best into an standalone, unobtrusive, and open-sourced Date extension that plays well with other libraries that also extend the Date class.
It lets you do things like:
The readme in the project repository on github has more information about the range of date formats supported and other methods available.
Blogarhythm: Too Many Times - Mental as Anything
There have been snippets of code floating around the net for ages, and various libraries that include necessary support. rfc3339date.js is my attempt at rolling the best into an standalone, unobtrusive, and open-sourced Date extension that plays well with other libraries that also extend the Date class.
It lets you do things like:
var d = Date.parse( "2010-07-20T15:00:00.333Z" );
d.toRFC3339UTCString();
=> "2010-07-20T15:00:00.333Z"
d.toRFC3339UTCString(true);
=> "20100720T150000.333Z"
d.toRFC3339LocaleString(true);
=> "20100720T230000.333+0800" // assuming current timezone is GMT+8
The readme in the project repository on github has more information about the range of date formats supported and other methods available.
Blogarhythm: Too Many Times - Mental as Anything
Sunday, July 25, 2010
DHH, Lars, and the Quality of Water
Just for the record:
Blogarhythm: Smoke on the Water - Metallica covering Deep Purple.
- David Heinemeier Hansson: born in Denmark 1979. Partner at 37signals
- Lars Ulrich: born in Denmark 1963. Drummer for Metallica
- DHH: outspoken proponent for building businesses from revenue.
- Lars: outspoken proponent for exploiting copyright for money.
Blogarhythm: Smoke on the Water - Metallica covering Deep Purple.
Subscribe to:
Posts (Atom)

















