Subscribe: James Crisp
http://jamescrisp.blogspot.com/feeds/posts/default
Added By: Feedage Forager Feedage Grade A rated
Language: English
Tags:
contact form  contact  form  good  mephisto  new  people  plugin  project  quantity quantity  quantity  rails  set  svn  time 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: James Crisp

James Crisp



Ruby on Rails, C#, .NET, book reviews, film reviews, mind hacks, Wing Chun and the occasional personal bit.



Updated: 2018-01-16T03:29:53.525+11:00

 



This Blog Has Moved!

2007-07-30T23:34:53.938+10:00

After more than a year on Blogger, I've bitten the bullet, bought myself a domain and installed WordPress. It's been good so far. Please update your feeds and links. Hope you like the new site and feel free to send me some feedback - the new site even has a contact form :-)

New Address
My blog is now to be found at:

http://jamescrisp.org


New Feeds
  • Full (http://jamescrisp.org/feed)
  • Technical (http://jamescrisp.org/category/technical/feed)
  • Personal (http://jamescrisp.org/category/personal/feed)

This Address
My previous posts will still be hosted on Blogger, but any new posts will be at the new address (http://jamescrisp.org).




Ultimate Laptop Protection

2007-07-24T21:01:01.316+10:00

(image)
(image)

Better than money can buy.

Made by my dad :-)



Consulting

2007-07-16T00:08:40.271+10:00

(image)
A present from my adorable fiancée :-)



Adding a New Rails Project under Subversion

2007-07-02T10:22:01.472+10:00

I generally use Subversion for source control when given the choice. In day to day usage, I like to use Tortoise SVN as it gives you a GUI with tick boxes for files to check in. However, it's handy to use the command line tool for project setup and automation.

Often, there is a subversion repository already set up and running on another machine. In this situation, I generally:
  1. Check out the repository at the top level into a temporary directory through Tortoise, add a new directory ([appname]) for the new project, and check it in.
  2. Generate the new rails app (rails [appname]).
  3. Check out [appname] from the repository into the local directory [appname] which contains the Rails project.
  4. Add and check in all files through Tortoise.
  5. Run the following commands from the command line to remove logs and tmp from the repository:

svn remove log/*
svn commit -m "removing all log files from subversion"
svn propset svn:ignore "*.log" log/
svn update log/
svn commit -m "Ignoring all files in /log/ ending in .log"
svn remove tmp/*
svn propset svn:ignore "*" tmp/
svn update tmp/
svn commit -m "Ignoring all files in /tmp/"

There's more Rails/Subversion info to be found on the Rails wiki.



The Castle Project - Rails for .NET

2007-06-13T00:09:19.634+10:00

The Castle Project is an interesting open source alternative to ASP.NET / ADO.NET. Among other things, the Castle Project provides a Rails-like development framework for .NET. It has an ActiveRecord implementation built on top of NHibernate, a very Rails-like MVC setup called MonoRail, and uses NVelocity for template style views. It's worth checking out. This screencast gives a bit of an overview.

There's tough competition around the corner though, with Orcas already in beta, providing XAML, LINQ and O-R mapping.



Is .NET or Java dying?

2007-06-05T19:49:18.842+10:00

Are C# and .NET losing ground as Martin Fowler suggests? Or is Java's market share dropping? What about Ruby? And what about the Australian market in particular?Here's what I've been able to find.Job TrendsWhich technologies have the most demand for people?From Indeed.com, which claims to search "millions of jobs from thousands of job sites", but I suspect may have a USA focus:"Best Talent Index May 2007" from Best People Solutions gives an Australian perspective:Here's job counts from the (largest?) primarily Australian job search site Seek on 5 June 2007, 3pm (today):Keyword(s)Number of positions foundJava3,414".NET" or "dot net"2,744"c#" or "c sharp"1,722ruby100As an aside, I remember doing a search on Seek for "ruby" about 6 months ago, and getting under 20 jobs mentioning it.Search Engine Number of HitsExtract from the TIOBE Programming Community Index for June 2007: PositionJun 2007PositionJun 2006Delta in PositionProgramming LanguageRatingsJun 2007DeltaJun 2006Status 1 1 Java 20.025% -1.10% A 2 2 C 15.967% -2.29% A 3 3 C++ 11.118% +0.45% A 4 4 (Visual) Basic 9.332% -0.85% A 5 5 PHP 8.871% -0.72% A 6 6 Perl 6.177% +0.17% A 7 8 C# 3.483% +0.25% A 8 7 Python 3.161% -0.30% A 9 10 JavaScript 2.616% +1.16% A 10 19 Ruby 2.132% +1.65% AI think this gives a good idea of web buzz, but suggest that most non-IT companies do not publish information about their projects and chosen technologies and languages on the web.ConclusionThe data collected suggests that:Both .NET and Java are major players in the job market with thousands of positions advertised, implying wide industry adoption of both.Neither .NET nor Java seem to be undergoing any significant decline in jobs.Java has much more information about it on the internet, although .NET is slowing gaining ground and Java slowly losing it.Ruby is comparatively tiny but growing rapidly in terms of jobs and information on the internet.ThanksThanks to Jason Yip and Suzi Edwards for their help finding/sourcing information.[...]



Can you spot the bug?

2007-05-20T17:39:27.325+10:00

In a model class which has 'quantity', 'quantity_already_taken' and 'quantity_requested' properties, I add the following:

def before_save
quantity = 1 if quantity == 0
if quantity + quantity_already_taken > quantity_requested
......

Tests blow up everywhere with:

TypeError: nil can't be coerced into Fixnum
(on the line with the addition)

Why?

After a little more debugging, it is clear that 'quantity' is nil. How could that happen?

The answer lies in the fact that Ruby requires an explicit self reference when using attribute writers (aka, property setters) within the class itself. This feels clunky to me, but for your information, here's a rationalisation of the explicit self requirement.

So, in case you're wondering, what happened above is that the 'if' line created a nil local variable called 'quantity'! This local variable then had higher scope precedence than the class attribute with the same name. The addition line was then using the local 'quantity' rather than the class attribute and hence failed with the nil error.

All fixed by explicity referencing self:

def before_save
self.quantity = 1 if (quantity == 0)
if quantity + quantity_already_taken > quantity_requested
......



Fixing a Palm Treo's Digitizer (Touch Screen)

2007-05-18T22:18:41.398+10:00

Let me tell you a sad tale. One day, out of the blue, the digitizer on my palm started to drift. Every hour, it got worse. This meant that when you tried to click a button like 'Add' the Palm thought you clicked 'Delete' - no fun at all! It was possible to temporarily improve the situation by running the re-calibration program built into the system, but within a few hours, where you clicked again had very little relation to where the Palm thought you had clicked. After about a week, it was not possible to run the re-calibration program, as the digitizer was so far out (program just looped forever so I had to reboot the Palm). I discovered that there are actually keyboard shortcuts for just about everything, and that the 4-way nav button gets you most places, so the device wasn't a total write off. However, it was slow and cumbersome to use.

Now, one month later, I'm sure you'll be thrilled to know that things are better, the sorry tale has had a happy ending (touch wood!). Much googling led to many suggested approaches to fixing the problem including:
  • Various auto-calibration programs (AutoDigi, DigiFix, etc).
  • Running paper around the screen under the casing to remove gunk.
  • Cleaning the insides by putting a vacuum cleaner to all openings.
However, all of these approaches ended with disappointment and no noticeable improvement.

Finally, near buying myself a new device (aside: it is a shame that Palm has not managed to produce a device significantly better than my several year old Treo 600), I came across a site selling replacement Treo 600 digitizer/screen modules. They kindly provide a very useful movie on pulling your Treo apart to help you replace your digitizer/screen module. With little to lose, I decided to open up the case of my Treo and see if there was anything I could fix.

Following the instructions in the movie was not too difficult. I didn't have a small star alan key myself (required for opening the case), but I borrowed one from my dear dad, who has an amazing tool collection. Also, lacking a plastic case opening tool, I used a butter knife - this worked OK, but did damage the plastic of the case a little. If you have something made from thin and strong plastic, like the case opener in the movie, it would be a better tool for the job. I had a great time pulling everything apart and finally had all the components spread out before me. I cleaned the screen carefully (there was a fair bit of grot around the edges), fixed the buckled taping on the side of the screen, and put everything back together, carefully re-seating the various cables.

And now, almost a month later, the digitizer still seems to be working fine! Hurrah! So if you are contemplating what to do about your Palm's broken or drifting digitizer, I recommend pull it apart, clean it all and re-seat cables and then hope for the best!



Experience of an International Amazon Virgin

2007-04-29T15:07:22.751+10:00

Recently I ordered 12 books from Amazon. It was my first time.The process started really well - quite easy and pleasant to find the books I was after. Not to mention that amazing range and the great option of getting cheaper second hand books. Adding to the shopping cart was also a breeze.I was pretty impressed, good prices, nice process. But then the honeymoon was over. Time to check out - stream of consciousness. First, I need to enter address details. Fine, as expected. Then I get a message (from memory) "There is a slight problem with your order. Some of the books you have chosen cannot be shipped to your address. Change your delivery address or change the quantity to 0 on these books.". Not happy! One third of my books (second hand ones) cannot be sent. That means I need to cancel the check out process, remove 4 books from my cart and then try and find the same books from other more expensive suppliers which can be shipped international. So I try again, adding the same book from multiple suppliers to my cart, in the hope of finding one which can deliver to Australia. Then it's back to the checkout process again.. Problem - I missed one book and have to cancel the process and go back to basket process again. Great, all books are OK, finally time to complete the order. So I get to review my order, and it says at the top something like "With an Amazon credit card, this order would be $324 rather than $368". No other total including postage is provided. So is my order $368? Maybe? Further screens finally confirm that this is the case. Nowhere is it possible to see how much postage is per book - you have to work it out yourself doing best guesses and following the Amazon formula. Maybe it would have been better to get a new book rather than a second hand book, as second hand books have twice the postage charge.. ah well, too late now, I'm not going to go through the whole process yet another time! So finally I can check out and my credit card is charged. However, since my credit card is hit by a multitude of different vendors that use Amazon as a front, within seconds of each other, some transactions are rejected as my credit card does not allow too many transactions in too short a time (some sort of security feature?). Finally, after getting a few emails from Amazon saying the card could not be charged, and then telling Amazon to retry, my order is at last paid for and on the way.Okay, so what could be done to make this better?Allow buyers to filter their results so they only see books that can be delivered to their addresses.Do not use patronising messages like "there is a slight problem".Do not suggest that people change their delivery address to another country.. that is clearly not going to happen!Show the cost of postage all throughout the process. Book buyers know they are going to have to pay postage and want to optimise their orders taking it into account.Do not show the order total including postage for the first time as a confusing advertisement ("With an Amazon credit card, this order would be $324 rather than $368"). Instead, provide a simple breakdown in a table, including postage on each book.Hit the credit card once per order, and divvy up the money at Amazon internally, rather than allowing each book vendor to do it and having credit card rejections as a result.UPDATE: My books arrived about two weeks after I ordered them. Delivery was smooth and on time. Unfortunately, one of the CDs that came with a book was broken. Amazon has kindly agreed to replace it and the book.[...]



Tips for Developing Mephisto Plugins with Liquid and Rails

2007-04-12T14:44:53.471+10:00

When I was writing a contact form plugin for Mephisto, I had a lot of trouble finding documentation and ended up reading lots of code and experimenting. That was fun, but fairly slow, so I hope this post can save future plugin developers time, and help them avoid some of the gotchas I stumbled over.Repository Directory StructureAt the most macro level, your repository needs to have a 'plugins' directory, and then a directory named after your plugin. Eg,.../plugins/my_new_plugin/...If this is not set up correctly, your plugin will not be able to be installed via 'ruby script/install plugin ' method.Liquid Plugins Directory and Init.rbAs you probably know, Mephisto uses Liquid for page templates. Liquid can be extended with new tags/blocks. The way to do this in a plugin is to set up a 'mephisto/liquid' directory with your extensions in it. See example here. So that's great, but you also need to register it in init.rb. Here's the contact form's init.rb - check out the line about 'register_tag'.Mephisto Plugin ClassMephisto trunk now has a base class for plugins - Mephisto::Plugin. Inheriting from this allows you to set up routes to brand new controllers you create. See contact form example here. This opens the door to writing Mephisto plugins which do postback and processing. It is also possible to add in tabs and forms in the administration interface. Rick's feedback plugin shows how to do this.Using Liquid Templates from Your PluginOne of the trickiest bits was getting the plug-in controller to render a liquid template. This is important if you want your additions to Mephisto to have the same layout and colours as the rest of the site. The way I'll outline below works fine, but it is not ideal. Hopefully there is a better way to do this (eg, some sort of Liquid API for Mephisto plugins).. if you know how a better way, please let me know!I had my plugin controller inherit from the Mephisto ApplicationController to gain access to the method 'render_liquid_template_for'. You can see the code here. However, this led to thorny problems where the plug-in classes were getting loaded only once when the server started, but Mephisto (and the ApplicationController) were getting reloaded for every request. First request worked fine, but nasty errors were spat out on the second and subsequent requests. To resolve this, I removed the plug-in from the 'load_once_paths'. You can see how to do this in the init.rb.Models, Views & Controllers Directories and Init.rbOkay, this is open to personal taste. I like to have similar directories in my plugin to a normal app. Eg, separate directories for controllers, model, etc. This causes a bit more work, as you need to add the extra directories to various global path variables. For an example of how to do this, take a look at 'models_path' and 'controllers_path' in this init.rb and the physical directory structure of the contact form's lib directory.[...]



Improve Rails Performance Through Eternal Browser Caching of Assets

2007-04-04T00:24:38.062+10:00

I've been working on a rails app which has got quite a number of pages that share the same two css files and 3 javascript files. However, every time I visited any page of the app, all of javascripts and css files were being loaded from the server. Not good - site was very slow. Mucking around with 'about:cache' command in Firefox revealed that the css and javascript files had expiry dates set in the past - ie, no caching of them at all. Also, all the links to sylesheets and javascript files generated by rails had ?[some long number] after them. Some research on the web revealed that this is a new rails feature for caching - the long number is a timestamp for when the asset was last modified.

Okay, so why were these assets not being cached? A quick check with wget --save-headers revealed that the web server was sending a nocache directive to the browser. This seems to be the default setup for webrick and also for my shared apache hosting on railsplayground. Considering the new rails asset management system with the ?[last modified timestamp] in the URLs, nocache seems wrong. The browser should never expire the cache since rails will handle cache invalidation by updating the asset url with a new timestamp.

So, how can we implement no/very long cache expiry? In apache, you can use mod_expires or mod_headers to do this. My shared hosting does not support mod_expires, so I went for mod_headers in my .htaccess file.

Using mod_headers:

Header set Cache-Control "max-age=29030400"


OR using mod_expires:
ExpiresActive On
ExpiresDefault "access plus 1 year"

Either of the the above will set up a cache expiry time of one year for all content (best you only do this for your rails app directories).

With a cache expiry time of one year in place, my rails apps run much much faster.



Naked Economics by Charles Wheelan

2007-04-03T23:08:49.634+10:00

Just finished reading 'Naked Economics: Undressing the dismal science'. It was a present from a friend, and I've been meaning to read it for a while. Glad I finally got around to it.From the title, I assumed the book aimed to point out the failures of economics as a science. Not so at all - it was written by an economist and provides a high level overview of capitalism in layman's terms.Here's some interesting questions and explanations from the book:Why do we have money? So that we can indirectly swap our labour or goods for the things we want, even if the person with the things we want is not interested in our labour or goods. Without money, we would need to barter. That's fine if you're swapping chickens for rice. But what happens if you do web design, and you want meat for dinner, and the butcher does not want a website?Money has value only because we all believe it does. We have faith that if we sell something (ie, convert it to the common value unit), we will then be able to swap that money for something we want.Why have markets anyway? Markets produce what people want - ie, what people are willing to pay for (or at least what we are convinced into wanting through advertising etc).Why not set the price of everything rather than letting it get worked out in a market? Well, it would be an enormous job, and things would not reflect the cost of production. Eg, bird flu wipes out half of the chickens in the world. There are now less chickens to go around so chicken becomes more expensive. People who really want chicken can still get it, but it costs them more. People who don't care as much or can't afford it eat fish or beef instead. If the cost of chicken was a constant mandated by the state, chicken distribution would need to be mandated in some other way. If there's not enough chicken for everyone who wants it, who should get it? First come first served? Political clout? Personal connections?Markets destroy. A new way to mechanize weaving may make thousands unemployed and destroy towns and communities. But according to Wheelan, the country as a whole is better off as we are able to produce more for less cost, hence increasing our standard of living. Ie, as a consumer, you may now be able to buy a shirt for half the price.In politics, small motivated groups often drive policy. Eg, the general population does not care much one way or other on a subsidy on growing alfalfa. It might cost each person in Australia 0.01c per year. However, if the subsidy was to be removed, and the alfalfa farmers would care a lot. It may well mean their livelihoods so they would demonstrate, make campaign donations, vote as a block and generally make as much fuss as possible to make sure the subsidy was not removed.Why do people work in sweatshops? According to Wheelan, the pay is generally better than for other jobs available - ie, sweatshops are not the cause of the problem, rather a symptom of the general poverty and lack of opportunity in the area.Why is free trade good? So that everyone can do what they do best - ie, specialise to the max. The idea being that if everyone works on what they are most good at, then productivity overall is higher.Why are tariffs bad? Because they support local industries that are not viable - ie, a poor uses of resources.Why do we need governments? To provide the rails for capitalism. Eg, to enforce laws (so you can't just kill me and take my stuff), to regulate the excesses of the free market and to provide goods and services that people need but that free markets will never provide. Also, to do things that individuals cannot do alone, but are in the interest of the population as a whole - eg, build infrastructure.Care for the environment is a luxury good - ie, if you and your family are starving, cutting dow[...]



Mango Liqueur - Fruition

2007-03-31T23:57:43.859+10:00

(image)
The mango liqueur started about a month ago has now reached fruition. After filtering with cheese cloth, and adding a little sugar (much less than a cup), it is quite tasty. It should improve further as it ages over the next month or so, assuming it lasts that long :-)



Starting at ThoughtWorks: First Five Weeks

2007-03-27T17:00:07.468+10:00

Well, I've been with ThoughtWorks for just over 5 weeks now, and I thought I'd write down some thoughts before the hiring and joining process got lost in the misty swamp of my memory.Hiring processTo cut a long story short, I did a phone screen with HR, a coding test and then some fairly quick aptitude and personality tests and finally 3 interviews. You have something like a week to do the coding test and then submit your code for review. I had the other tests and interviews on a single day. Although this sounds pretty horrendous, it actually wasn't too bad. Tests were pretty quick and the interviewers were astoundingly friendly. I finished by something like 3pm in the afternoon, including a lunch break, and surprisingly didn't feel too bad or stressed afterwards.InductionAs a fairly impressive start, I had 2 days of induction in Melbourne (I live in Sydney). ThoughtWorks arranged drivers, hotel and flight so it was all very smooth. This was lucky as I was pretty jet lagged and confused - I'd just flown back from an overseas holiday not long before. Induction was largely getting a company provided laptop, meeting people and getting an introduction to various internal systems and procedures. As an aside, I've heard that there is now an "immersion" process where you get sent to India for a week or two for induction but can't comment on that.A few weeks on the beachWhen you're not assigned to a client project, you are "on the beach". This means you go into your local office with your laptop. It's really great - there's no particular tasks assigned to you, but the opportunity is there to get involved in a lot of interesting stuff. To give you some examples, here's some of the stuff I've had the chance to do:Write an open source plug-in for Mephisto for ThoughtWorks StudiosBe involved in scoping out and estimating for a RFI from a new clientPair with another developer to do code reviews of potential new recruitsHelp out briefly with a fun project to develop a driver for a USB build light for continuous integration servers (red for broken build, green for good build, etc)Help out on client projects - I was asked to whip up a little proof of concept for JRuby and Java integration and learnt a bit getting this set upDo a little bit of Google Maps integrationMeet colleagues and learn more about procedures etcGet invited to lunch with the managing director - this is something that happens for all new hires and I think it's really greatAlmost go out on a pre-sales call (I've got to go back to Melbourne and will miss this unfortunately)Catch up on tech reading such as blogs, books etcGo to a swanky talk given by Martin Fowler and Kristan VingrysEat lots of free lunches (usually twice a week) and attend various talks at the office given by other consultantsDrink lots of free coffee (ThoughtWorks has a coffee tab with a local cafe)First projectMuch fun as it is on the beach, after a few weeks, I was itching to join the big boys and go on a project. Getting assigned to a project is the purview of your professional services manager, and can be pretty changeable. The saying is that "you don't really know what project you're on till you walk in the door of the client site" and I've even heard "you don't really know what project you're on till you're on the plane home". There's a grain of truth in these - it can look like you are going to go on a project and then it doesn't come through, or some other project becomes more important or whatever. I almost went on several different projects before finally ending up on quite a cool Ruby / Rails project with a startup in Melbourne. So, I got to join the jet set and have been flying down to Melbourne during the week, and back for the weekends. Th[...]



A few choice quotes from "The Unbearable Lightness Of Being" by Milan Kundera

2007-03-27T00:21:31.755+10:00

Starts slowly with quite a philosophical bent, but becomes really compelling once the main characters are introduced. Some memorable quotes:Happiness"If Kerenin had been a person instead of a dog, he would surely have long since said to Tereza, 'Look, I'm sick and tired of carrying that roll in my mouth every day. Can't you come up with something different?' And therein lies the whole of man's plight. Human time does not turn in a circle; it runs ahead in a straight line. That is why man cannot be happy: happiness is the longing for repetition."Love"The brain appears to possess a special area which we might call poetic memory and which records everything that charms or touches us, that makes our lives beautiful... Their love story did not begin until afterwards: she fell ill and he was unable to send her home as he had the others. Kneeling by her as she lay sleeping in his bed, he realized that someone had sent her downstream in a bulrush basket. I have said before that metaphors are dangerous. Love begins with a metaphor. Which is to say, love begins at the point when a woman enters her first word into our poetic memory."A feeling of importance"We all need somebody to look at us. We can be divided into four categories according to the kind of look we wish to live under. The first category longs for the look of an infinite number of anonymous eyes, in other words, for the look of the public...The second category is made up of people who have a vital need to be looked at by many known eyes. They are the tireless hosts of cocktail parties and dinners...Then there is the third category, the category of people who need to be constantly before the eyes of the person they love. Their situation is as dangerous as the situation of people in the first category. One day the eyes of their beloved will close, and the room will go dark..And finally there is the fourth category, the rarest, the category of people who live in the imaginary eyes of those who are not present. They are the dreamers."Kitsch"Kitsch is the absolute denial of shit, in both the literal and the figurative senses of the word; kitsch excludes everything from its purview which is essentially unacceptable in human existence...Kitsch causes two tears to flow in quick succession. The first tear says: How nice to see children running on the grass! The second tear says: How nice to be moved, together with all mankind, by children running on the grass! It is the second tear that makes kitsch kitsch. The brotherhood of man on earth will be possible only on a basis of kitsch...And no one knows this better than politicians. Whenever a camera is in the offing, they immediately run to the nearest child, lift it into the air, kiss it on the cheek. Kitsch is the aesthetic ideal of all politicians and all political parties and movements...In the realm of totalitarian kitsch, all answers are given in advance and preclude any questions. It follows, then that the true opponent of totalitarian kitsch is the person who asks questions...From that time on, she [Sabina] began to insert mystifications into her biography, and by the time she got to America she even managed to hide the fact that she was Czech. It was all merely a desperate attempt to escape the kitsch that people wanted to make of her life."[...]



Contact / Feedback Form Plugin for Mephisto

2007-04-17T13:14:15.012+10:00

IntroductionIf you use Mephisto, a content management / blogging system written in Rails, you may well be interested in using this new plug-in. It provides a form that lets visitors to your site leave their contact details and send you messages or feedback via email.LicenseThis plug-in was developed for the new ThoughtWorks Studios site. As I wrote it at and for work, it is copyright ThoughtWorks, 2007. However, ThoughtWorks, being generous souls, is happy for me to open source it under the Apache 2.0 licence, which pretty much means you have free reign to use it as you want.RequirementsMephisto Edge (the latest stable 0.7.3 release does not have support for Mephisto plugins)Rails Edge (required by Mephisto edge)ActionMailer (comes with Rails) correctly configured with SMTP server etc, so that emails can be delivered. See "Configuration" section here for more details.Installationruby script/plugin install http://mephisto-contact-form-plugin.googlecode.com/svn/plugins/mephisto_contact_formor in your vendor/plugins directory for Mephisto:svn checkout http://mephisto-contact-form-plugin.googlecode.com/svn/plugins/mephisto_contact_form mephisto_contact_formMake sure you restart your web server at this point so that the plugin is loaded.Setup1. Create a new template called 'contact_us.liquid' though the admin web interface (under the 'Design' tab).Paste in the following code:

Contact Us

{% contactform %}

{{ form.name }}

{{ form.email }}

{{ form.phone}}

{{ form.subject}}

{{ form.body }}

{{ form.submit }}

{% endcontactform %}Feel free to modify labels, layout etc.2. Edit{MEPHISTO_ROOT}\vendor\plugins\mephisto_contact_form\lib\contact_notifier.rband put in the email address you want contact form submissions to go to.3. Link to "/contact_form" from your site.Any issues / questions / suggestions?Best to post comments on this blog.Technical InfoThe contact form plugin is actually a combination of a rails plugin, a liquid block plugin and a Mephisto plugin. See this post about developing Mephisto plugins for more information.[...]



Wing Chun: Bong Sau Tips

2007-03-08T23:20:28.462+11:00

Today my class was visited a very talented high level instructor. Although he only spent a few minutes looking at my bong sau, he gave two invaluable tips:
  1. When bringing your hand and arm up into bong sau, you need to be moving both upwards, forwards and inwards towards the centre simultaneously. A good way to do this is to imagine your elbow tracing an arc through the air from start to end point.

  2. When moving from bong sau to tan sau when rolling, move into fook sau first, and then roll your wrist over. This will stop your hand from dropping and will leave your hand on the centre line.



The Secrets of Consulting by Gerald Weinberg

2007-03-06T17:50:19.537+11:00

The Secrets of Consulting by Gerald Weinberg is one of the most entertaining (largely?) non-fiction books that I have read - a heady mix of How to Win Friends and Influence People, Fear and Loathing in Las Vegas (just look at the illustrations!) , and the 10 Commandments. The book provides general advice, case studies/stories and then derives general "rules" and recommendations from these.

Personally, I found the chapter on the pricing of consulting to be particularly interesting. Thinking about setting a price previously, I would have suggested it should be enough to cover costs and make a bit of a profit. Weinberg points out that price is more than this - it is a big factor in the relationship and the level of respect for the consultant.

The Weinberg's consulting "rules" are quite numerous - my personal favourites are:
  • "If you can't fix it, feature it."
  • "It may look like a crisis, but it's only the end of an illusion."
  • "You'll never accomplish anything if you care who gets the credit."
  • "If something's faked, it must need fixing."
  • "The name of the thing [label] is not the thing."
  • "It tastes better when you add your own egg."
  • "You don't get nothin' for nothin'. Moving in one direction incurs a cost in the other."
  • "Whatever the client is doing, advice something else."
  • "What you don't know may not hurt you, but what you don't remember always does."
  • "Clients always know how to solve their problems and always tell the solution in the first five minutes."
  • "When change is inevitable, we struggle most to keep what we value most."
  • "The biggest and longest lasting changes usually originate in attempts to preserve the very thing ultimately changes most."
  • "Effective problem-solvers may have many problems, but rarely have a single, dominant problem."
  • "Make sure they pay you enough so they'll do what you say. The most important act in consulting is setting the right fee."
  • "The more they pay you, the more they love you. The less they pay you, the less they respect you."
  • "Spend at least one day a week getting exposure." and "Spend at least 1/4 of your time doing nothing." and make sure your fee covers this.
  • "Set a price so you won't regret it either way."
  • "If they don't like your work, don't take their money."
  • "Cucumbers get more pickled than brine gets cucumbered."
  • "Give away your best ideas."
  • "Look for what you like in the present situation and comment on it."
  • "Study for understanding, not for criticism."
  • "Never promise more than 10% improvement.. if you happen to achieve more than 10% improvement, make sure it isn't noticed."
  • "Consultants tend to be the most effective on the third problem you give them."
  • "The child who receives a hammer for Christmas will discover that everything needs pounding."



Mango Liqueur

2007-03-05T00:08:30.218+11:00

Started a quick mango liqueur this evening. Two large fresh mangoes worth of pulp (approx 500ml) mixed with 500ml of vodka in a jar. Planning to shake every few days for the next few weeks, filter and then add about 1 cup of sugar, before maturing for a few months. I have high hopes, as a similar recipe worked well with bananas in the past.



_vimrc for Ruby

2007-03-01T22:49:59.627+11:00

In the past I've used gvim for Ruby coding. It's been pretty good, especially with the new tabbed editing and omni complete (bit like intellisense in Visual Studio) introduced in vim 7. However, when I downloaded vim at work, I was missing the secret sauce - a good vimrc. Here's my usual vimrc for ruby:
set nocompatible
behave xterm
set selectmode=mouse
set nu
set tabstop=2
set shiftwidth=2
set softtabstop=2
set ai
set columns=100
set lines=70
set guifont=Courier:h10
set expandtab
set smarttab
let g:rubycomplete_rails = 1
Among other things, it makes the default window size bigger, uses a prettier font, sets up auto indenting ruby style, and turns on omni-complete.

By the way, on windows, assuming a default install, vimrc is to be found here:
C:\Program Files\Vim\_vimrc



JRuby Setup

2007-02-27T22:54:23.127+11:00

Recently got a JRuby/Rails system with Java integration up and running. Unfortunately, it took quite a few hours, as most of the docs and code you find through Google are out of date.

If you use JRuby 0.9.2 from Codehaus, you will get an error similar to this when you try to access a rails application:

[2007-02-26 17:54:59] INFO WEBrick::HTTPServer start: pid=22540508 port=3000

["c:/jruby-0.9.2/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/
active_support/dependencies.rb:402:in `to_constant_name'...

If you're stuck in this rut, fear not! Nick Sieger has written very helpful instructions which outline how to get and set up the latest development snapshot. Please note that in addition to the instructions, you need to set your JRUBY_HOME environment variable. Under Windows, do something like this:

set JRUBY_HOME=c:\jruby

If you'd prefer not to use the snapshot, you can get the source code through subversion from:

http://svn.codehaus.org/jruby/trunk/jruby

but at the time of this post, you need to run svn checkout or update with "--ignore-externals" to avoid the following error:

Error: URL 'svn://rubyforge.org/var/svn/bfts/bfts/trunk' doesn't exist

Many thanks to Nick Sieger and the JRuby user mailing list for their help.



Holiday 2007 - Venice and Padua

2007-02-26T21:46:56.660+11:00

It was a sudden decision to take a sleeper train to Venice. We didn't really know what to expect. By chance, we arrived at Carnivale (mask and costume festival), probably the busiest time of the year. Venice was filled to the rafters with tourists, prices were high and it was difficult to walk in many areas due to the number of people in the narrow streets! The solution was to take to the water - catching the ferry was fun and it got you out of the crowds.Venice is really beautiful. The Doges (ruler's) palace and nearby Cathedral in St Marco square are amazing. The palace has huge painted ceiling murals by famous artists and enormous open halls. In the Cathedral, there are golden mosaics over the whole ceiling, and even the floor is an artwork in tiles. There's also some impressive golden relics from when the Venetians sacked Constantinople during the crusades.In Venice, most streets lead to the water, and the best facades are turned towards the canals. It really is a city designed to be traversed on the water. The buildings are mainly standing on foundations made from hundreds of pine trees hammered into the silty mud under Venice. Historically, Venice's influence peaked in the 13th century or so, and from then on, it was a slow decline in power. But to make up for this, the wealthy families spent lavishly on buildings, clothes and decorations.On our last day in Italy, we went to Padua to take a look at a more typical Italian city. It was a friendly and fun place with few tourists, but good food and a nice atmosphere. Last picture is of Padua, all the rest are from Venice![...]



Holiday 2007 - Monaco

2007-02-26T21:04:28.456+11:00

Monaco is easily accessible from Nice - about 1/2h by train. We spent an enjoyable afternoon and evening there, visiting the cactus "exotic" garden, castle, casino and cave. The cave was particularly interesting - it was about 18degC inside (despite winter temperatures outside), and walkways for visitors had been made using explosives and diamond drills! Despite the damage, it was still a lovely cave. Monaco was clean and tidy, and felt almost like a movie set.

(image)
(image)
(image)
(image)
(image)



Using floating point variables to represent money => not a good idea!

2007-02-25T22:36:48.787+11:00

I was reading through some code the other day and was surprised to find that it was using doubles to represent dollar amounts. Reason for the alarm bells is that doubles and floats cannot accurately represent many decimal fractions (eg, 0.1), since doubles and floats internally work with powers of 2 rather than powers of 10. These inaccuracies are likely to lead to significant errors, especially when performing arithmetic (eg, adding up a table of dollar amounts). See this IBM article for a more in depth explanation and examples. The solution is to use types that work with powers of ten internally. In C#, you can use 'decimal' and in Java or Ruby, 'BigDecimal', to avoid these problems.



Holiday 2007 - Provence & Cote D'Azure in the South of France

2007-02-25T19:46:41.409+11:00

France supposedly is the number 1 tourist destination in the world, and certainly it is one of my personal favourites! Besides the pleasure of speaking French, we had the opportunity to eat a lot of good food, and visit really pretty coastal areas, medieval towns, castles and ancient Roman remains.Our itinerary looked roughly like this:Marseilles -> Aix En Provence -> Avignon -> Nimes -> Arles -> Tarascon -> (Italy) -> Nice -> Antibes -> (Monaco)In terms of hotels, it was very much 'get what you pay for'. We tended to stay in two star places around 40-50 euros per night. Our first hotel in Marseilles was only 37E per night, and it convinced us that the extra 10E or so was really worth it! Hotels were fairly easy to find (well sign posted), though often not too close to transport.We tried the random approach to finding good restaurants to start with, but this led to a number of disappointments. The solution was to ask our hoteliers for their favourite restaurants - this led to some really great meals :-)We had planned to rent a car for some parts of the trip.. however, make sure you learn to drive a manual before attempting this! Autos in France are horribly expensive to rent, so we ended up doing everything by public transport - bit tricky in winter time especially, but we managed. Tourist offices were generally very helpful.[...]