Thursday, August 27, 2009

How to stop unix read command escape backslashes

If you want to pipe any output that has backslashes in it (or make 'read' take a string with backslashes) to the read command then you will need to stop the read command treating backslash as escape character by using read -r
e.g.
cleartool ls | while read -r file
do
# do something to file
done

Monday, August 24, 2009

Software design or code design

Software design

Generally high level, a.k.a.
  • architecture
  • infrastructure
    e.g. 3-tiers or client server, ejb or not

Code design

  • domain design
  • flow design
  • good code design means clean, maintainable code
  • code design issues are easier to fix than software design
The following extract from Domain Driven Design applies regardless the type of project (waterfall or agile).
Any technical person contributing to the model must spend some
time touching the code, whatever primary role he or she plays on
the project. Anyone responsible for changing code must learn to
express a model through the code. Every developer must be
involved in some level of discussion about the model and have
contact with domain experts. Those who contribute in different
ways must consciously engage those who touch the code in a
dynamic exchange of model ideas through the Ubiquitous
Language.
A solution consultant should touch the code (or at least know the code if they don't want to touch it).

Rails Rumble after thoughts

Building an application in 48 hrs is hard. Time flies when you are not prepared.


Here are some of the things that you want to touch on before the competition starts.

  • application security / access - who has access to what
  • model / resource routes - what models are required and how are they connected from browser / UI perspective
  • fields & columns in models
  • model validation / mandatory fields

For the initial first few models that you add to the application, the effort to add each one does not increases in linear fashion.

Because with each model, you need CRUD pages / functionality. Each additional page needs to be styled therefore more visual design required, also more thoughts required for workflow / navigation design.


Often we have to just implement some crude pages to test / visualise our app (particular for workflow) while our designer work thru the markup, which means we usually have to go back and cleanup those pages' markup to fit with the design.


Overall, it was exhausting but I learnt heaps of cool tricks this year building TechMeets.com.


Monday, August 17, 2009

Using google_ajax_library when offline.

As I mentioned in How do I automatically revert to local javascript when offline?, I eventually forked google_ajax_library gem and added support for working offline.

I sent a pull request to Ryan Heath, the original author the gem and he liked the feature but implemented it slightly differently to what I have done.

How to use WinMerge as ClearCase compare & merge tool?

WinMerge made ClearCase much more bearable to work with.

When installing WinMerge make sure you tick the 'Integrate with ClearCase' option.
That will make ClearCase use WinMerge as the compare program but ClearCase still uses its own merge program when resolving conflicts.
To change that setting you have to modify ClearCase configuration file manually.
The configuration file is usually in the lib managers' folder of the ClearCase installation.
e.g. C:\Program Files\Rational\ClearCase\lib\mgrs\map

The change to the map file is based on what WinMerge did to the xcompare value
;text_file_delta xmerge ..\..\bin\cleardiffmrg.exe
text_file_delta xmerge C:\work\tools\WinMerge\WinMergeU.exe

Tuesday, August 4, 2009

How to validate money amount in ActiveRecord?

This is how I validate money amount in Romey.
Basically an regex that allows up to 2 decimal points or whole integers.

validates_format_of :amount, :with => /^\d+$|^\d+\.\d\d?$/