Grinning Cat

468
  • Home

Movemeber

Posted by robert in October 28th 2008  

I have decided (foolishly?) to grow a mo for movember. Its all for good causes and lets see what happens when I grow a mo…

Mind you, this could all go hideously wrong, particularly I’ve never grown a mo before so I have no idea how to care for a mo. I’m also worried that I may become un-snoggable. Let’s hope not eh?

if you’d like to follow along or even donate I’d be delighted :) Also you too can register at www.movember.com.

No Comment
under: Personal
Digg it Add to del.icio.us Stumble it add to technorati

Getting a decimal RGB value converted to hex

Posted by robert in October 6th 2008  

Some days I just despair over apple OS X, its so close to a great operating system but drops the ball time and again with its software. Take a for instance, I had some graphics files that contained wireframes for a web application. I needed to get the RGB values for some colours in said wireframes so I loaded them into preview. Now I simply refuse to pay for Photoshop, I just don’t have the skills to use it and the price tag is enough to dissuade all but the professional graphics market away from Photoshop. So all I have is the Preview decimal RGB values. Bobbins.

So I wrote this small Ruby snippet to get the value converted to hex. Its not clever, its not elegant. However it gets the job done and I wrote it in fifteen minutes, result :) In order to invoke this simply call the script with

script_name.rb red green blue
and watch it spit out the result ready to paste in your CSS:

#!/usr/bin/env ruby
if ARGV.size < 3 then
puts "Wrong number of arguments you need 3 groups of values"
exit
end
output_string = []
for arg in ARGV do
arg_as_number = arg.to_i
output_string << arg_as_number.to_s(16)
end
puts "##{output_string.join}"

So there you go. Although I may recommend the Gimp for some fine graphics editing as it does have a hex value colour picker. One more reason to use Linux if you ask me.

No Comment
under: Ruby
Tags: ruby development colours script
Digg it Add to del.icio.us Stumble it add to technorati

Just in case you were wondering … Oracle and Ruby

Posted by robert in March 13th 2008  

Sometimes you can be seduced by shiny things. I was very seduced by Ruby and Rails (well ActiveRecord really). The premise is so simple, the reailty matches the premise for so long… It’s the development equivalent of finding out Santa Claus doesn’t exist when it becomes hard work. So what happened? Well to begin with no one knew about the Oracle license situation…we wanted to be the quick result people so we started on Postgresql. Coming to our senses we briefly spiked Oracle and found that all was good with migrations and basic data. Excellent, lets pack Oracle in a box untill much further down the line I thought.

Twelve weeks later and the model has grown from about eight objects to twenty. OK, no biggie there. So then I started looking in the code…ah, there’s a lot of erm, SQL in there isn’t there? OK, no biggie Oracle and Postgres aren’t worlds apart as dialects of SQL. Well maybe not but the differences are important. A classic example is how many arguments can you put in a where clause? Answer:
Postgres: As many as you’d like (we passed 10000+ in some queries)
Oracle: 1000
Bobbins! OK, we were being lazy with our use of ActiveRecord, so lets refactor the SQL queries (oh and Oracle? Thanks for that ROWNUM implementation, there is nothing as straightforward as wrapping one select in another). Indexes, on Oracle you’re talking about a thirty character limit, on Postgres there appears to be a limit greater than 256 characters. Migrations now need custom names, harumph!

Then there’s the drivers. In postgres land there’s a pure ruby driver called postgres-pr, which turns out to be pretty nifty, installs everywhere, never chucked an error. Mind you it was slow enough that I wouldn’t use it to run production. In oracle land theres ruby-oci8, which is a wrapper around the OCI libs. The biggest thing here is that the ruby-oci8 lib can deadlock ruby. Now I’m not certain because our environments are a lovely mix of Solaris and Oracle releases and patch levels but I think what happens is that if you use DB backed sessions then the OCI driver tries to create two sessions with the DB and gets in a knot with rails. After two weeks of battling the forces of evil we went to file backed sessions and the problem disappeared. I do see that the ruby-oci project has a version two in the offing, lets hope that sorts out some of the nastiness there. I’ve also noticed that query 1 is mighty expensive, it’s probably a connection setup thing but lordy it’s annoying when you have to stop your dev server every two minutes to hack a model object fix.

This post has lain dormant for a couple of months while I stewed on it and thought about whether or not I should release it, then today happened… We’ve just started a Rails 2 project using Oracle and the first thing we did was install the activerecord oracle adapter (which is now split from core rails), bug #1 was migrations (see update). Migrations for Pete’s sake! So I dusted this post off and if it generates some comments I’m thinking about starting off some sort of Oracle-Rails survivors group.

Update:
The migrations bug can be found on this thread.

No Comment
under: Development, Oracle, Postgresql, Rails
Digg it Add to del.icio.us Stumble it add to technorati

Integrating rspec and selenium part 2

Posted by robert in September 26th 2007  

Now I’m on the case. The first post was the end of some serious frustration. Once I had nipped through the tutorial for selenium-rc I had the bit between my teeth. So I knew my next step was to drive selenium from Ruby.

To begin with I created a rails project (in my case called did) using:
rails did
After installing the spec::rails plugin (the instructions for which are at this page) I ran the rake task that sets up rspec:
ruby script/generate rspec
Then I created a model and a view using the rspec generators so all the rspec gubbins was properly installed. After which I took the seleium.rb included with the selenium-rc snapshot and popped it into /lib. Then I got the example file and began to hack it for my needs. Once I’d finished I had a nice script that opened my site and then checked it displayed the right text. I started up my selenium server, then my rails server (mongrel if you’re interested) then ran spec:views. So the filesystem layout looks like:

/lib/selenium.rb - the file distributed with selenium-rc that provides ruby commands to drive selenium-rc.
/vendor/selenium-0.9.1 - the location of the selenium-rc server jar.
/vendor/selenium - a symbolic link to selenium-0.9.1

Once I did that I could run the spec you can see at Sample Spec using: spec spec/views/insecure/index_spec.rb
So with a little bit of faffing around I ended up with the spec inside view driving selenium. Whoo-hoo.

No Comment
under: Development, Rails
Tags: rails development selenium ruby
Digg it Add to del.icio.us Stumble it add to technorati

Integrating rspec and selenium

Posted by robert in September 11th 2007  

Today has been a lesson in frustration. It started with me feeling like crap because I had a cold. Moved through me spilling coffee all over my shirt and finished with a fruitless trawl through google. Essentially I found out that rspec integration with Selenium and Rails is a total black hole.

So my initial goal was to get Selenium working. After about two hours I had nothing… and was just beginning to get a little sweary. For instance I sat with my head in my hands after reading about Selenium for some 15-plus minutes only to find that actually I needed to be looking at Selenium RC. A colossal thanks for nothing there. Then I started trying my hand with the selenium-rc. What happened was I downloaded the release and got everything going with the tutorial you can find at http://www.openqa.org/selenium-rc/tutorial.html. The end of result of which was that I got a firefox message about profile being loaded, sadly no browser or test command success. So then I ask some friends and lo and behold its a well known issue. Simply use a snapshot and you’re gold.

So now I have a working Selenium on Linux and Mac OS X. Expect more posts on rspec and how to get Selenium to work with rspec.

No Comment
under: Development, Rails
Digg it Add to del.icio.us Stumble it add to technorati

Problem Installing Rails Plugins

Posted by robert in March 22nd 2007  

I’ve recently got into Rails at work and had to install a plugin for rails. The docs said I should type:

ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/REL_X_Y_Z/rspec_on_rails/vendor/plugins/rspec_on_rails

The firewall at work is configured not to allow svn:// URLs and I needed that for the install. So I had to go home and use dial-up…bobbins. Now I dial up using Windows at home because for some reason Linux PPP connections runs at a speed that takes you back to 1990 (Telstra…what is going on?) .

What made ten minutes of pain into a good hour was the lack of any feedback from the command. For instance the follwoing should install the rspec plugin:
D:\wom-rails\wom\deliverable\ruby\trunk\wom>ruby script\plugin install svn://rub
yforge.org/var/svn/rspec/tags/REL_0_8_2/rspec_on_rails/vendor/plugins/rspec_on_rails

D:\wom-rails\wom\deliverable\ruby\trunk\wom>ruby script\generate rspec
Couldn't find 'rspec' generator

Erm, can we have an error message on install please? Well, it turns out if you use the -x option then the following appears:
D:\wom-rails\wom\deliverable\ruby\trunk\wom>ruby script\plugin install -v svn://rub
yforge.org/var/svn/rspec/tags/REL_0_8_2/rspec_on_rails/vendor/plugins/rspec_on_rails

Then you get:
Cannot install using subversion because `svn' cannot be found in your PATH
Result! I haven’t installed the subversion client. SO lets give it another shot:

C:\rails-apps\test>ruby script\plugin install svn://rubyforge.org/var/svn/rspec/
tags/REL_0_8_2/rspec_on_rails/vendor/plugins/rspec_on_rails
A C:\rails-apps\test\vendor\plugins\rspec_on_rails
A C:\rails-apps\test\vendor\plugins\rspec_on_rails\Rakefile
[loads of lines snipped]
A C:\rails-apps\test\vendor\plugins\rspec_on_rails\spec\spec_helper.rb
A C:\rails-apps\test\vendor\plugins\rspec_on_rails\README
Exported revision 1641.

Something appeared! Now let’s give it a pop:

C:\rails-apps\test>ruby script\generate rspec
create spec
create spec/spec_helper.rb
create spec/spec.opts
create script/rails_spec_server

C:\rails-apps\test>

I hope that spares you some pain.

2 Comments
under: Rails
Digg it Add to del.icio.us Stumble it add to technorati

A little more Australia

Posted by robert in November 16th 2006  
The media here is hilarious. On Monday morning I heard the local commercial radio breakfast show, which stopped me in my tracks. They were having a phone in to accuse people of being gay! So in one hilarious exchange we had:
PRESENTER: We’ve got Ray on line 2, who do you reckon is gay Ray?
RAY: [in a tone suggesting it's as plain as day] John Howard, he’s as bent as a row of tents.
[stunned silence]
PRESENTER: [incredulously] John Howard, how do you make that one Ray?
RAY: It was that green and yellow tracksuit he wears. Only poofters co-ordinate colours like that.
PRESENTER: [reaching for the cut-off switch] Great, thanks Ray!
After that we had the prank call where the presenter pretended he had tourette’s and swore at the guy on the other end of the phone for a five minutes. Also I saw “Pumped – with Michael Kunn” on the TV. This is a show designed to help you get into a healthy lifestyle and Michael is in charge for the whole ride. First up we had some tips on how to build your biceps, followed by an interview with a lady who is disabled and still has a healthy lifestyle. The interview was great as Michael crashed straight into Alan Partridge mode. Starting by asking some questions about her routine he gleefully seized on her answers by proclaiming “See, even she can do a full workout!” He then asked some questions about her disability which obviously made her uncomfortable, finishing off with “Even through these disabilities Paula (I think that was her name) can still be active”. The end shot was of him beaming and her scowling. Then we had another helpful segment as Michael showed us some healthy cooking. After turning a lamb chop into a New York Yankees pitcher Michael whipped up a fruit salad for desert. No one had told Michael that using the same knife for meat and fruit is a no-no so he proceeded to use a large meat knife to masticate some strawberries. Then came the “special ingredient”, as Michael waxed lyrical about how he’d “come up with this himself” and “how this really helps if you have a sweet tooth like me”. He suddenly grabbed a bottle of Amaretto and proceeded to slosh it on until the strawberries in the fruit salad began to float. Smiling to camera he said “just a little adds a real something to that salad”, now I’ve been frugal about my spirit measures but I can tell you now I’d never put that amount of spirit in anything. I think Michael was keener on the Amaretto than the fruit if I’m honest. Now you may be thinking cable TV channel trash but no, this was on free to air TV, so this loon is getting national coverage! You just couldn’t make this stuff up, you really couldn’t.One major difference I’ve noticed is that people are much chattier in shops. For instance I went shopping and the cashier asked how I was, I replied I was good and she remarked on my accent. I said I was English and from Yorkshire, which is in the north of the country. She nodded at this and then asked if I had a speech impediment! Tartly I replied no, this was the way I always spoke. Maybe there is something in being treated like dirt at the shops after all…
The food is fabulous, sadly this may mean that I need to buy new trousers, as the combination of food and the larger portions is having a distinct rounding effect on my belly. I have been particularly into the Asian cuisine, which is abundant and cheap. I went to South Melbourne market on Saturday and got a spring roll, which had the following admirable qualities:
1) It was hot
2) It was the size of my fist
3) It had identifiable pieces of pork in it.
I could get very spoiled on this diet ;)
No Comment
under: Personal
Digg it Add to del.icio.us Stumble it add to technorati

Disaster Recovery and Linux

Posted by robert in November 16th 2006  

Recently I went to the mighty LugRadio Live (LRL) event. Ever since last year’s LRL (when I did a lightening talk on DR) I’ve been thinking about concentrating on Linux disaster recovery and really trying to expand the information on getting Linux running again after a disaster. Afer a couple of chats this year I’ve decided to pull my finger out and start committing some of this stuff to web. Expect to see more as the time goes on.

No Comment
under: Disaster Recovery
Digg it Add to del.icio.us Stumble it add to technorati

Moved To Australia

Posted by robert in October 20th 2006  

Yup, it’s done (well actually I did it a few weeks ago). I have been unpacking my crap and getting around Melbourne, which has been very pleasant. I just can’t believe how friendly people are out here. For instance, I was coming out of Southern Cross station and needed to cross the road. At the intersection I saw a bump between a van and a taxi. Both drivers were OK (at least OK enough to cusss each other for the smash) so there was no real drama. Then as I crossed the intersection I discussed the rights and wrongs of the matter with a guy in a suit, a woman and a hobo. Where else do you get people this freindly?

No Comment
under: Personal
Digg it Add to del.icio.us Stumble it add to technorati

Dawn Of A New Site

Posted by robert in August 9th 2006  

Hi,
After various abortive attempts to get something running on grinning-cat I’ve taken the advice of the chaps on WYLUG and gone for Wordpress. I’m now going to try and figure out the following:

  • whether a decent theme exists for wordpress – that is different from the perfectly passable initial theme
  • how to upload content
  • what tweaks I wish to make to the site – cue downtime

So hello and welcome, I hope you find what you came for :)
Robert.

No Comment
under: Site News
Digg it Add to del.icio.us Stumble it add to technorati

Categories

    • Development
    • Disaster Recovery
    • Oracle
    • Personal
    • Postgresql
    • Rails
    • Ruby
    • Site News

Disaster Recovery

    • Contingency Planning and DR Guide
    • Sungard

Food & Drink

    • Hot Hot Chocolate

Linux

    • Backing Up UNIX
    • LugRadio
    • MLUG
    • Nottingham LUG

Ruby

    • Ruby Inside
    • Ruby Language

Feeds

feeds
get latest updates on news and subscribes to our feeds
feeds

Recent Entries

  • Movemeber
  • Getting a decimal RGB value converted to hex
  • Just in case you were wondering … Oracle and Ruby
  • Integrating rspec and selenium part 2
  • Integrating rspec and selenium
  • Problem Installing Rails Plugins
  • A little more Australia
  • Disaster Recovery and Linux
  • Moved To Australia
  • Dawn Of A New Site

Recent Comments

  • Seanzyclonmccaf… in Problem Installing Rails Plugins
  • bit-shifter in Problem Installing Rails Plugins

Most Comments

  • Problem Installing Rails Plugins  (2)
Box-Tube Box Modulize WordPress Theme By Dezzain Studio
©2006-2009 Grinning Cat
Powered by WordPress 2.8    Valid XHTML    Valid CSS