Virtual Surreality

It's too real to be true

A plethora of useless answers out there. Here it is:

On an iOS device

  1. Scroll page so you go past the top of the Facebook page and can see the browser address bar
  2. Change the m to www
  3. Remove the ?_rdr#~!/
  4. Press Go
  5. You may have some fiddling to get the auto-appearing drop down tools on posts but they will come.

    Enjoy.

Because I keep doing this…

  1. Download the Java zip
  2. unzip to /opt
  3. ln -s /opt/yed-XXX /opt/yed
  4. cd /opt/yed && jar -xf yed.jar com/yworks/yfx/resource/24/yicon.png && mv com/yworks/yfx/resource/24/yicon.png . && rm -rf com
  5. echo "[Desktop Entry]
    Encoding=UTF-8
    Name=yEd Graph Editor
    Comment=Edit graphm files in yEd
    Exec=java -jar /opt/yed/yed.jar %u
    Terminal=false
    Type=Application
    Icon=/opt/yed/yicon.png
    Categories=Application;Office
    StartupNotify=false
    MimeType=application/xml;
    NoDisplay=false" > ~/.local/share/applications/yed.desktop
  6. right-click on a .graphml file -> Properties -> Open With -> Add -> yEd Graph Editor -> Add -> select yEd Graph Editor -> Close

(would be nice to command-line the last one, but .local/share/applications/mimeapps.list isn’t quite all)

The JAOO conference has changed it’s spelling, but not its excellent multi-technology, multi-discipline, deep, pragmatic content.

Apart from the great conference lineup, I’m particularly excited to see the Erlang tutorial (by Ulf Wiger) and the F# tutorial (by Amanda Laucher and Joel Pobar). This continuing investment into functional programming by the conference organizers shows a real dedication to the advancement of the software industry.

Even if you don’t think you’re going to ever be paid to write an Erlang or F# program (I initially thought the same of the dinky C++-like language for writing browser applets that rhymes with ‘palaver’), you will be delighted at what you’ll learn about more straightforward approaches to parallel computing, highly reliable systems, declarative expressions, and concurrent execution. Most all of the material will be applicable to similar languages, and some of the techniques are idiomatically used by good OO developers (particularly in languages like Ruby, C#, and Scala).

Go on, add some flavour to your profession and learn from the best about these two languages! Sign up for a workshop now at http://yowconference.com.au/melbourne/registration/index.html

See you back downunder for YOW!

PS: The Rails workshop by Obie should be great too – I rewrote a couple of chapters of his book for The Rails 3 Way, so I’m looking forward to it!

PPS: I’m not paid to pimp the conference, I just think that it’s one of the best in the world, and Australia very much needs this conference (and more like it) which is why I’ve supported it and been to it each year.

“This spec is something more than devs, I tell you. It’s the monster. Devs made it, but they can’t control it.” – with apologies to Steinbeck

Ahh, factory-forged random values for fields of unique constraint. How thee vex me with thine probabilistic usefulness and definite indeterminacy.

Keep thyselves with ephemeral values of algorithmic parameters and hasten from my database.

Factory girls and fabricators, hide only the mundane. Let the uniqueness of preconditions of this specification shine forth for all to see. Be clever not in your data generation, be reproducible and explicit within your own bounds. Do not clammer to be prolific and abusive in unit tests, as the abstraction of records active leaks not into my domain. Sloths thee are, and my build shall be green before my mind is diverted and seduced by the sirens of tweets and blogs.

The avengers akephalos and specjour are mine to wield for making the good amazing, not for making the lame almost tolerable.

The tools being used:

  • Cucumber
  • Capybara
  • selenium-webdriver
  • Firefox
  • OS/X or Unix

We have a web application with some javascript that has onChange event handlers. One example is entering a date in a text field (overlayed with a date picker widget). When the field changes, the form is automatically submitted through AJAX and the results list is filtered using that date.

Unfortunately, for now (?) and perhaps only when driving Firefox, selenium-webdriver (aka Selenium 2) doesn’t fire the onChange event when you enter some text into a field. You need to leave the field (blur) for the onChange event to fire. Blah.

As an aside, Simon Stewart let me know that Firefox fires the event if the window is active. Alas, this is a) not reliable (I have seen it work and fail), and b) not achievable in an automated parallel test run where multiple browsers are hammering away (we also wisely use Sandro’s awesome specjour).

Fortunately, we are using a date picker widget. To simulate the behaviour in a way that is pretty much what the user would usually do, we click the field (letting the date picker widget get activated), fill in the date with the value we want to testwith (date picker uses key events to jump to the right month in the calendar), and then we click the day link in the date picker.

The user doesn’t “click” or “tab” anywhere else. They just type the date, or click it in the date picker widget. They remain on the date field and the form auto-submits. You may find this annoying and a silly thing to do. I may agree with you. The users of this application do not.

The following code as a step definition for When I pick a "start_date" of "2010-09-21" works great. Events are fired and waiting for readiness is obeyed.

When /^I pick a "([^"]*)" of "([^"]*)"$/ do |field, text|
  find_field(field).click
  fill_in(field, :with => text) # Make calendar jump to correct month
  within(".ui-datepicker-calendar") do
    day = text.to_date.day.to_s
    click_link(day)
  end
end

I have a strong feeling akephalos would be fine, but we happen to be running on Ruby Enterprise Edition on OS/X which is unreliable in the area of inter-process communication with Ruby object marshalling (needed for akephalos to communicate between it’s C Ruby and JRuby components).

I also believe it would be fine on another browser. Possibly also with Firefox on Windows, but then we’d be running Ruby on Windows: frying pan -> fire.

You can hear my dulcet tones at Ruby5 eposide 106 hosted with Jon “Lark” Larkowski.

It was great fun – he made me do the accent at the beginning and we had a lot of laughs over the “it’s gonna rain” part.

Hope you find it of use and if you have some Ruby news, please do submit stories to Lark.

Came across this twice in the past two weeks.

How NOT to do it:

$('form :submit').click(function() {
    $(this).attr("disabled", true);
    $(this).val("wait...");
    $(this).addClass("disabled");
});

Doing it the above way, the click event will indeed fire, but on some browsers the submit event will not.

The event to bind to is submission of a form, not clicking of a submit button.

How to do it:

$('form').submit(function() {
    $(":submit").attr("disabled", "disabled");
    $(":submit").val("wait...");
    $(":submit").addClass("disabled");
});

Also, the :submit selector is a jQuery cross-browser selector for input and button elements that could submit the form, used in preference to input[type="submit"]

A little “remember me later” for conditionally deploying a Rails 3 app running on Ruby 1.9 on Heroku.

$ruby_version = `ruby --version`.split[1].to_f

source :rubygems
source 'http://gems.github.com'

gem 'rails', '~> 3.0.0'

gem 'bson_ext'
gem 'decent_exposure'
gem 'haml'
gem 'mongoid'

group :development, :test do
  if $ruby_version < 1.9
    gem 'ruby-debug'
  else
    gem 'ruby-debug-base19', "0.11.24"
    gem 'ruby-debug19', "0.11.6"
  end
  gem 'rspec-rails'
  gem 'rails3-generators' #for HAML
end

Update: Mongoid changed gem versioning for lexicographical sorting (a "dot" between "beta" and the number
Update: Latest mongoid (beta.16 and something after beta.9) requires Rails 3.0.0.rc which doesn't support Ruby 1.9.1 which isn't yet on Heroku
Update: Heroku user doesn't have "repo" in it anymore and USER env var isn't available - find new mechanism if bundler config WITHOUT option doesn't work
Update: All is good now! No need to put any Heroku detection in the Gemfile. Just issue the following command heroku config:add BUNDLE_WITHOUT="development:test"

Also:

  • Only the --colo(u)r and --format options work in the .rspec file
  • use_transactional_fixtures=false in spec_helper.rb (talk to Chelimsky about transactional fixtures in non-ActiveRecord environments)
  • In application.rb:
    • require 'mongoid/railtie'
    • require 'decent_exposure/railtie'
    • g.orm :mongoid
    • g.template-engine :haml
    • g.text_framework :rspec, :fixture => false, :views => false

WindyCityDB – great conference!

I did a lightning talk on squealer, and here is the PDF of the slides (1.7MB)

squealer Lightning Talk slides

One evening in May, 2006 at a ThoughtWorks Sydney company meeting, Richard McLaren (then a Senior VP of ThoughtWorks) and I made a bet with Jon Tirsen (now Google überwunderkind) and Roy Singham (still Chairman of ThoughtWorks) about Ruby in the Enterprise.

The claim from Roy and Jon was that within five years, 10% of applications running in the Enterprise would be written in Ruby. Richard and I bet against that. The prize is a case each of the winners’ favourite potable.

I’ve since been steadily working to try to lose that bet, and now code daily in Ruby at Hashrocket.

Alas, with just one year to go, I think Richard and I are going to win. Although there’s been a decent growth in Ruby’s adoption in the Enterprise, my esteemed colleagues underestimated the lack of capability, talent, and intellect of the majority of corporate IT decision makers.