Software dev, tech, mind hacks and the occasional personal bit

Author: James Page 17 of 21

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

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

Introduction
If 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.

UPDATE
Please check out information about using the contact form plugin with Mephisto Drax 0.8.

License
This 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.

Requirements

  • Mephisto 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.

Installation

ruby script/plugin install http://github.com/jcrisp/mephisto_contact_form/tree/master

or in your vendor/plugins directory for Mephisto:

git clone http://github.com/jcrisp/mephisto_contact_form/tree/master mephisto_contact_form

Make sure you restart your web server at this point so that the plugin is loaded.

Setup
1. Create a new template called ‘contact_us.liquid’ though the admin web interface (under the ‘Design’ tab).
Paste in the following code:

<H1>Contact Us</H1>
{% contactform %}
<p>{{ form.name }}<label for="author"><small>Your name</small></label></p>
<p>{{ form.email }}<label for="email"><small>Email address</small></label></p>
<p>{{ form.phone}}<label for="phone"><small>Phone number (optional)</small></label></p>
<p>{{ form.subject}}<label for="subject"><small>Subject</small></label></p>
<p>{{ form.body }}</p>
<p>{{ form.submit }}</p>
{% endcontactform %}

Feel free to modify labels, layout etc.

2. Edit

{MEPHISTO_ROOT}/vendor/plugins/mephisto_contact_form/lib/contact_notifier.rb

and 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 Info
The 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

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

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

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

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 xtermset
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

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
<ArgumentError: Anonymous modules have no name to be referenced by>
[“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

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

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.





 

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

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.

Page 17 of 21

Powered by WordPress & Theme by Anders Norén