Tag Archives: Ruby

Random graph

Random graph, from playing around with RGL in Ruby.
Random graph

Tagged ,

How to find if two nodes are connected in an RGL graph

Say you have a graph like this:

graph

How do you find out if there is a path between any of the two nodes? By using a breadth-first search:

Tagged , ,

Testing Github commit hook one liners

A couple of ruby one-liners for dumping out the content of a github commit hook payload:

For hooks that use type application/json:

$ ruby -rpp -rjson -rsinatra -e 'set :port, 8000; post "/*" do; pp JSON(request.body.read); end'

For hooks that use type application/x-www-form-urlencoded:

$ ruby -rpp -rjson -rsinatra -e 'set :port, 8000; post "/*" do; pp JSON(params[:payload]); end'
Tagged ,

Basic zeroMQ Ruby example

Update: As Jake pointed out in the comments you obviously need zero MQ installed for this example to work. Just ‘brew install zeromq’ or ‘port install zmq’ on OS X, or use your Linux package manager.

I couldn’t find may examples of zeroMQ usage in Ruby so here is a basic sender/consumer I made to test it. First install the ‘zmq’ gem:

gem install zmq --no-ri --no-rdoc

Now start a worker, you can start as many as you want:

Now stick some messages on the queue:

You should get messages distributed to all the worker processes you started up. Pretty simple!

Tagged ,

NWRUG 16th July – Source control Stand-off

This month Tekin Suleyman and Ashley Moran will be helping us get started with, and comparing, the Git and Darcs SCM systems.

Sponsorship is kindly provided this month by Liquidbronze, so free pizza will once again be available.

Schedule

  • 6:00pm :: Welcome & Pre-session bar visit.
  • 6:30pm :: How to do things in Git by Tekin Suleyman
  • 6:50pm :: Break
  • 7:00pm :: How to do things in Darcs by Ashley Moran
  • 7:30pm :: Free pizza sponsored by Liquidbronze
  • 8:30pm :: Drinks at the BBC bar afterwards, then somewhere else nearby after that closes at about 21:00.

If you want more information email nwrug@willj.net, call Will on 07939 547 962 or tweet @will_j.

Sign Up

If you would like to attend this event please sign up here.. as the BBC need a list of attendees before the event and I really need to know the numbers so I can order the right amount of food and drink. There’s an Upcoming event page but please use the form above. This month I shall be publicly coating people with squeezy cheesy peas who turn up without signing up. You have been warned.

Location

This meeting is being held at one of our regular venues, the BBC Manchester main building on Oxford Road in central Manchester (Directions). If you get lost call Will on 07939 547 962.

Tagged , ,

Blocking Internet Explorer 5.5

IE 5.5 is dead. The number of people using it are tiny, at least according to the stats on the most popular sites I run. Here are the numbers.

Jokes-o-matic

Has a larger proportion of Firefox users than Internet Explorer users due to the high level of traffic from some social bookmarking sites, meaning a more web-savvy crowd who are more likely to be using alternative browsers:

jokes-o-matic.com browser breakdown

jokes-o-matic.com browser breakdown

The level of IE usage is still pretty high though, but even so only a single hit from IE 5.5 recently:

jokes-o-matic.com IE versions

jokes-o-matic.com IE versions

Recycling Group Finder

A much more broad and ‘average’ user base with Internet Explorer dominant:

Recycling Group Finder browser breakdown

Recycling Group Finder browser breakdown

Still, only 6 Internet Explorer hits recently, a tiny proportion of overall visits:

Recycling Group Finder IE versions

Recycling Group Finder IE versions

What does this mean?

Yahoo.com as seen in Internet Explorer 5.5

Yahoo.com as seen in Internet Explorer 5.5

These statistics, and others I have seen suggest that almost no-one uses Internet Explorer 5.5 or below any more. The small minority that do must be used to the internet breaking in unique and interesting ways due to the lack of support for more recent developments in CSS and really bad Javascript support (see right for yahoo.com as seen in Internet Explorer 5.5). I predict that a fair number of sites just don’t work in any usable way on anything less than Internet Explorer 6.

Time is money

Designing for multiple browsers takes time. The more browsers you need to support the more time you need to spend supporting them.

A recent project I worked on required a redesign of the site from the ground-up (aswell as a bunch of other stuff) and making the site work in any version of Internet Explorer lower than 6 just wasn’t worth the time, and therefore money, put into it. The return just wasn’t there and I decided that IE 5.5 was gone, dead, obsolete and I wasn’t going to try and mangle the design to work in it. Rather than just display a really crappy looking site to the user I decided I would let them know via a short and to-the-point message that their browser was not up to displaying the site and directing them to upgrade to a new version of their browser.

Give them the good news

IE 5.5 advice message

Message displayed to all users visiting project in anything below IE 6

But how to do this? The site was developed in Ruby on Rails and I’d heard of a neat gem called rack-noie6 that provides a piece of Rack middleware that blocks Internet Explorer 6 and below, but that isn’t going to work in most cases. Hard as it may be to make your site look good in Internet Explorer 6 you can see from the stats above there’s still a large proportion of users using it and to turn them away would be crazy, at least while the pool of IE 6 users out there is still so large.

So a quick fork and patch later (github we <3 you so much) and the new noie6 was accepting an option for a minimum version of Internet Explorer it should accept instead of just rigidly blocking version 6 and below. Configuration is really simple:

Now any users visiting the site in anything below Internet Explorer 6 gets the message above helpfully directing them to update their browser. Not bad for a two line config update.

Tagged , , ,