James Crisp

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

Dance Dance Dance

Just finished reading Dance Dance Dance by Haruki Murakami. Amazing novel. Not exciting, but totally gripping. I couldn’t put the thing down. The plot is a little unconventional to say the least, but my empathy with the narrator was overridingly strong and it is really this that made the novel so gripping.

Our narrator is 34, and in many ways, leads a normal and boring life. The boring parts of his life are described in detail. If you counted the pages devoted to descriptions of his every day life such as cooking, eating etc, I think you’d count about 1/3 of the novel. Rather than making the novel boring, as you would expect, it instead makes our narrator more real and human. And since he is so real, and so like you and me, even the “boring” parts of his life are interesting and enjoyable. For example, having a good meal and reading a book are nothing “exciting” in the traditional sense. However, since the narrator is so real, and so human, you can easily remember your own feelings when doing a similar thing.

There is something so real in the mediocrity of our narrator that strikes a chord with me. Our narrator is a good, fair guy, playing his part in an “advanced capitalist society”. He’s not amazingly talented at anything, he doesn’t fit in and he’s not very socially ept. He “shovels cultural snow” writing pieces for magazines. He has a few friends and romantic interests. He tries not to hurt people but doesn’t know where his life is going or what he really wants. When you look at him, and think about him, it forces you to look at yourself, in a very similar advanced capitalist society, shovelling virtual snow, or whatever you do. At the end of the day though, he’s the best of the bunch. He’s responsible and he cares. Maybe that’s cause for hope.

Dance Dance Dance follows on from A Wild Sheep Chase, although you could probably get by without reading the earlier novel. It’s a great book, go forth and read it 🙂

Rails and the initialize() method

I spent a bit of time this weekend on a pet rails project. I came across a strange error when trying to create new records through the application. Editing was working just fine, but creating a new record just seemed to hang.

Breakpoints came to my rescue. In Ruby, they’re really handy. You can put a ‘breakpoint’ call anywhere in your code, and if you have a breakpointer process running (start this with the command ‘ruby script/breakpointer’), you jump straight into an interactive ruby console debug session when the breakpoint is hit.

Using the development log and a few breakpoints, I found the that the error was:

ArgumentError: wrong number of arguments (1 for 0)

And that it was caused by a line similar to this:

@order = order.new(params[:order])

Ie, the controller was creating a new order from the post parameters.

Then all became clear – some time earlier, I’d overridden the initialize() method in the order to default some dates. My code was similar to this:

def initializesuper()
  if (@new_record)
    self.validFrom = Date.today
    self.validTo = 1.year.from_now.to_date
  end
end

Great for creating new objects in my tests and console sessions where I always just created the object and then set properties. However, the controller was relying on passing in the post parameters in the constructor.

The solution is to accept any number of params and pass these to the base class:

def initialize(*params)super(*params)
  if (@new_record)
    self.validFrom = Date.today
    self.validTo = 1.year.from_now.to_date
  end
end

That way, the order can accept the post parameters in its constructor.

I’m very pleased to say that I can now create new records again!

How to do Tax Deductions for an Investment Property in NSW, Australia

Last year I bought a house. Recently, I’ve been doing my tax. It is much more complex this year with the property, but there are a lot more deductions. Here’s some tips:

Renting a out part of your property
If you rent some of your property, you are eligible for tax deductions for a proportion of your expenses. This proportion is based on the floor area that is rented, compared with the floor area which is not rented. Make sure you include common areas in your calculation.

Keep receipts and record all expenses
They then need to be classified into areas such as:

  • Interest on loan
  • Advertising
  • Insurance
  • Rates
  • Repairs
  • Postage
  • Cleaning
  • Garden
  • Borrowing expenses
  • Legal Expenses
  • Depreciation
  • Capital Works


Most of these are straight forward, and immediate write offs in the year they are incurred.
I’ll go into more detail on the complex ones below.

Borrowing Expenses
Generally, you will need to spread these over 5 years, or the length of your loan, whichever is shorter. In most cases, this will mean you’ll tax deduct 1/5 of them each year for the first 5 years of your loan. They include things like government stamp duty on the loan and bank charges.

Legal Costs
Unfortunately, these do not include the cost of legal fees in acquiring your property. They are for when you need to fight with tenants in court and similar. Hopefully you won’t have any of these.

Depreciation and Capital Works
This is the most complex area. First, download the Rental Properties Guide 06 (NAT1729-06) from the ATO. This document is invaluable. I’d recommend you at least skim read it.

Capital Works
Okay, now, if your house has been built or had any significant renovations since 1979, you may well have capital works deductions. The conditions on these vary. Have at look at the guide mentioned above, page 23 of the PDF. In most cases, you will be able to claim construction costs at 2.5% for 40 years. If there was a couple of hundred thousand dollars of construction costs, 2.5% could be quite a bit of money every year. If you know the cost of the construction, this is easy to calculate. If not, you will need to get this estimated – you can’t do this yourself. I used Depreciator. They employ quantity surveyors and meet ATO requirements. I was quite happy with them – see my post on the Somersoft investment forum for more details. They also estimate costs of assets such as hot water systems, stoves, blinds etc.

Deductions
You need to classify all your assets according to their cost and depreciate accordingly:

  • $1-300: write off straight away in the current tax year
  • $301-1000: put in low value pool (deduct at 18.5% for the first year when adding to the pool, 37% for assets already in the pool)
  • $1001 or more: depreciate with straight line or curved line methods over effective life set out by ATO. You can find these in the rental guide from the ATO mentioned above.

What is a asset (can be depreciated) and what is a capital work
There is a reasonably arbitrary seeming classification of items between capital works and deductions. A hot water system, for example, is a depreciable asset but a kitchen cupboard is a capital work. Check all your items with the rental guide mentioned above. If an item is an asset, you can estimate its market value, and you can depreciate it over the effective life in the guide. If it is a capital work, then you cannot depreciate it. It is part of construction costs – see above section on capital works for more details on claiming these.

Disclaimer
I’m not a tax professional. This post is my personal opinion and interpretation. No responsibility taken for an errors or omissions. Use at your own risk.

Learn English using a Blog and Programming Tools!

My fiancee, Soosun, is brushing up on her English skills before going to uni next year. As part of the plan to improve her writing, she’s started a blog. Friends and family can write comments on her posts to help improve her written English.

She just wrote a nice article on making kimchi, and I posted a comment containing a copy of her article with English improvements. But how can she tell what I’ve suggested? The solution we decided to use is kdiff3, a tool I use at work for comparing and merging source code. You can download it here. If you turn word wrap on, it is great for comparing English – shows up the differences beautifully.

From “A Wild Sheep Chase” by Haruki Murakami

“Nor do you know where you stand. Now listen, I thought it over last night. And it struck me. What have I got to feel threatened about? Next to nothing. I broke up with my wife, I plan to quit my job today, my apartment is rented, and I have no furnishings worth worrying about. By way of holdings, I’ve got maybe two million yen in savings, a used car, and a cat who’s getting on in years. My clothes are all out of fashion, and my records are ancient. I’ve made no name for myself, have no social credibility, no sex appeal, no talent. I’m not so young anymore, and I’m always saying dumb things that I later regret. In a word, to borrow your turn of phrase, I am an utterly mediocre person. What have I got to lose? If you can think of anything, clue me in, why don’t you?”

Great passage, ya?

Engagement Party Photos

See them here:

http://gallery.maebmij.org/jamesc/EngagementParty/

(thanks Jim for the hosting 🙂

Litost in Le Petit Prince

I was reading a post on Phillip Eby’s blog recently which quoted a little of “Le Petit Prince” by Antoine de Saint-Exupéry (“The Little Prince” in English). It’s been a long time since I read it (I studied it in French class at school), so I got hold of my old copy and have been re-reading it. It’s really great – both funny and serious, and I’ve been enjoying exercising my atrophied French muscles a bit. If you haven’t read it, I recommend you get it and have a read in either French or English. Wikipedia has got some more information on the novel here.

Anyway, I came across an interesting passage that seems to dove tail very well with my recent post on Litost. Here we go:

“Elle serait bien vexée, se dit-il, si elle voyait ça… elle tousserait énormément et ferait semblant de mourir pour échapper au ridicule. Et je serais bien obligé de faire semblant de la soigner, car, sinon, pour m’humilier moi aussi, elle se laisserait vraiment mourir…”

And here’s my rough translation into English:

“She would be very vexed, he said to himself, if she could see that… she would cough violently and pretend to die to escape being laughed at. And I would be obliged to pretend to heal her, so that I could humiliate myself as well, otherwise, she would really let herself die.”

PS – Found the full-text available online in English, French and some other languages!

Engagement Party!

Last night was our engagement party! It went really well 🙂

We had it at the Royal Exchange Hotel in Marrickville. The weather was great, and the venue was really nice, and our guests were awesome!

Many thanks to my mum and grandma for the cakes, my family for being so helpful on the night, to Dennis Building for the drinks tab, and to everyone for coming along to celebrate our engagement with us. We had a really great time and I hope everyone else did too 🙂

Litost

For some reason, while doing the washing up today, my mind was wandering and I remembered reading “The Book of Laughter and Forgetting” by Milan Kundera. A colleague and friend of mine gave me the book for my 24th birthday. It was a fun and interesting read with a good story. The passage I was day dreaming about was “What is Litost?”. I was thinking I might take a stab at explaining it in my own words, but having read the passage again, I’m sure Milan Kundera has done a better job than I could hope to achieve. Hence I give you the passage verbatim:

What is Litost?
Litost is an untranslatable Czech word. Its first syllable, which is long and stressed, sounds like the wail of an abandoned dog. As for the meaning of this word, I have looked in vain in other languages for an equivalent, though I find it difficult to imagine how anyone can understand the human soul without it.

Let me give an example: The student went swimming in the river one day with his girlfriend, a fellow student. She was athletic, but he was a very poor swimmer. He could not time his breathing properly and swam slowly, his head held tensely high above the surface. She was madly in love with him and tactfully swam as slowly as he did. But when their swim was coming to an end, she wanted to give her athletic instincts a few moments’ free rein and headed for the opposite bank at a rapid crawl. The student made an effort to swim faster too and swallowed water. Feeling humbled, his physical inferiority laid bare, he felt litost. He recalled his sickly childhood, lacking in physical exercise and friends and spent under the constant gaze of his mother’s overfond eye, and fell into despair about himself and his life. They walked back to the city together in silence on a country lane. Wounded and humiliated, he felt an irresistible desire to hit her. “What’s the matter with you?” she asked him, and he started to reproach her: she knew about the current near the other bank, and that he had forbidden her to swim there because of the risk of drowning – and then he slapped her face. The girl began to cry, and when he saw the tears on her cheeks, he took pity on her and put his arms around her, and his litost melted away.

Or take an instance from the student’s childhood: His parents made him take violin lessons. He was not very gifted and his teacher would interrupt him to criticize his mistakes in a cold, unbearable voice. He felt humiliated, and he wanted to cry. But instead of trying to play in tune and not make mistakes, he would deliberately play wrong notes, the teacher’s voice would become still more unbearable and harsh, and he himself would sink deeper and deeper into his litost.

What then is litost?

Litost
is a state of torment created by the sudden sight of one’s own misery.

One of the customary remedies for misery is love. Because someone loved absolutely cannot be miserable. All his faults are redeemed by love’s magical gaze, under which even inept swimming, with the head held high above the surface, can become charming.

Love’s absolute is actually a desire for absolute identity: the woman we love ought to swim as slowly as we do, she ought to have no past of her own to look back on happily. But when the illusion of absolute identity vanishes (the girl looks back happily on her past or swims faster), love becomes a permanent source of the great torment we call litost.

Anyone with wide experience of the common imperfection of mankind is relatively sheltered from the shocks of litost. For him, the sight of his own misery is ordinary and uninteresting. Litost, therefore, is characteristic of the age of inexperience. It is one of the ornaments of youth.

Litost works like a two-stroke engine. Torment is followed by the desire for revenge. The goal of revenge is to make one’s partner look as miserable as oneself. The man cannot swim, but the slapped woman cries. It makes them feel equal and keeps their love going.

Ruby on Rails Hosting, Setup And Migration

I’ve been doing a little rails of late.. Here’s a summary of the stuff that I’ve learnt.

What hosting should I use in Australia for rails?

NOT JUMBA – SEE UPDATED REVIEW BELOW

I’m using jumba (http://www.jumba.com.au). Jumba is very cheap (~$30AUD/year), and they give you shell access, mysql etc. However, there was a period of several weeks when they moved me to some server without an install of rails and kept promising to install rails and never did. I finally got them to move me back to their main server which has rails installed. It was a painful process, so I’m not sure if I would recommend them. That being said, things are going OK at the moment, and I’ve got a few development apps up and running on their service.

UPDATE 29 March 2006: Jumba summarily stopped rails support without notice and was rude when I contacted them about it. I would not recommend Jumba for web hosting anything – they have frequent down time, server switches and reboots and their low price is made up for by the amount of time you waste. They used to be OK, but no longer. I’m in the market for a new host, will post on how it goes.

How to set up rails applications in your home directory (in public_html) under a UNIX/Apache/cgi/fcgi environment

  1. Upload or create your application in your home directory. Eg, ~/MyRailsApp/
  2. In your public_html directory, create a soft link to the public directory of your app. Eg,
    ln -s ~/MyRailsApp/public ~/public_html/MyRailsApp
  3. Make sure dispatch.fcgi in the ~/MyRailsApp/public directory is executable. If not, chmod it a+x.
  4. Confirm that dispatch.fcgi has a valid path to ruby on the first line. If you’ve created this project on another machine, you’ll quite possibly need to update the path. The path is often something like ‘#!/usr/local/bin/ruby’, but check what it is under your system with ‘which ruby’. Special note for InstantRails users – you’ll always need to update the path when uploading to unix hosting, as instant rails uses a windows style path with the slashes the other way around.
  5. Update your ‘database.yml‘ file (in the ‘config‘ directory of your app) with correct database names, user names and passwords.
  6. Run ‘dispatch.fcgi‘ (in the ‘public’ directory of your app). If you see an ‘Internal Server Error’ message, you know things are going OK. If you’ve got the path to ruby wrong on the first line, or some other similar problem, you’ll find out about it here, where as if you run through the web, you don’t get these sorts of problems reported in an easy to understand way.
  7. Check out your running system in the browser (eg, browse to http://myhostingcompany.com/MyRailsApp/)

Tips for trouble shooting rails errors

  1. A good place to start is by reading your logs in the ‘log’ directory of your rails app. If you’re running a development configuration, have a read of ‘development.log’.
  2. Try manually running ‘dispatch.fcgi‘ in the ‘public’ directory of your app. If you get an ‘Internal Server Error’ message printed out on the console, it’s probably working ok. Alternatives to this are reports of missing files and unable to find ruby – often these aren’t shown when browsing to your web site.


Rails problems and solutions

1. Browser and logs show: Application Error – Rails app failed to start properly

I got this after my app was moved from one unix host to another by my hosting company. I tried heaps of stuff to try and resolve this. Eventually I created a brand new dummy project on the unix host called ‘Test’ and Test worked fine from the browser. I then tried my original project again and suddenly it worked fine! It has been working fine since. I can only imagine that there was some sort of problem in temporary files or similar which got flushed. No good explanation for this currently.

2. in `start_engine’: undefined method `add_path’ for Controllers:Module (NoMethodError)

I got this one when migrating a project from rails 1.1 to a later version of rails. The solution is to force update your rails engines:

script/plugin source http://svn.rails-engines.org/plugins
script/plugin install engines –force
script/plugin install login_engine –force

3. My app works fine if there is a trailing slash on the url. Otherwise, I get a ‘Bad Request’ error page. Eg, ‘http://myhost.com/myapp/’ works, but ‘http://myhost.com/myapp’ does not work.

Add a RewriteRule to the .htaccess file in your application’s public folder:
RewriteRule ^.*myapp$ http://%{HTTP_HOST}/myapp/ [R=301,L]

My basic .htaccess rewrites are as follows:
RewriteEngine On
RewriteRule ^.*myapp$ http://%{HTTP_HOST}/myapp/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

I tried removing the RewriteCond !-f, and my pages lost their styles. I think the condition allows the rails framework to load .css files directly without having the requests go through dispatch.fcgi.

Page 19 of 20

Powered by WordPress & Theme by Anders Norén