Page 65
Rock stars and their parents
January 19, 2009
0 comments
Nasty surprise of Django and gettext
January 18, 2009
3 comments Django
I've done a site that is initially only going to be in Swedish. So I set the LANGUAGE_CODE
like this:
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'sv-SE'
I then go ahead and mark my templates and code and run django-admin.py makemessages -l sv-SE
. Then I fire up Poedit to translate the .po
file and then compile to make the .mo
file, so now I had a file called <my project>/locale/sv-SE/LC_MESSAGES/django.mo
but it just wouldn't work!! I tried debugging django.utils.translation
with little success. Eventually through trial-and-error I found that if I change it to "sv" instead of "sv-SE" it works.
Is this a problem with gettext or a problem somewhere in Django? It might cause equally much headache for other developers so I wouldn't mind that we get to the bottom of this.
Formatting numeric amounts in Javascript
January 16, 2009
1 comment JavaScript
Dear Lazyweb,
Is there a better method than this to format numeric amounts? Here's a solution I picked up from somewhere and slightly modified. It's heavily string based but passed the tests:
function format_amount(i) {
if(isNaN(i)) { i = 0.00; }
var minus = '';
if(i < 0) { minus = '-'; }
i = Math.abs(i);
i = parseInt((i + .005) * 100);
i = i / 100;
s = new String(i);
if(s.indexOf('.') < 0) { s += '.00'; }
if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
s = minus + s;
return s;
}
The "tests" are:
format_amount(100) == "100.00";
format_amount(100.0) == "100.00";
format_amount(100.05) == "100.05";
format_amount(100.051) == "100.05";
format_amount(-100) == "-100.00";
format_amount(-100.0) == "-100.00";
format_amount(-123.45) == "-123.45";
format_amount(-123.450) == "-123.45";
So functionally it's OK but I'm not sure it's the best way to do it.
Earth, observed - The Big Picture - Boston.com
January 16, 2009
0 comments
Boston.com has done it again. Warning! Some of these images makes you dizzy.
Hellsongs
January 14, 2009
2 comments Music
Swedish band that plays classic heavy metal songs slower and acoustic. It wasn't until I listened to their songs that I actually stopped to think about the lyrics in some of the classics I thought I knew the lyrics to already but found out I didn't. It makes for a very cute blend that is irresistible. It's kind of like watching a hot girl changing the oil on a truck.
Their latest album has an equally "cute and catchy" title: Hymns in the key of 666
For Spotify users here's Paranoid on the album Lounge
Does Semen Have Antidepressant Properties?
January 9, 2009
0 comments Misc. links
A hard blow for the condom manufacturing business
"Abstract In a sample of sexually active college females, condom use, as an indirect measure of the presence of semen in the reproductive tract, was related to scores on the Beck Depression Inventory. Not only were females who were having sex without condoms less depressed, but depressive symptoms and suicide attempts among females who used condoms were proportional to the consistency of condom use. For females who did not use condoms, depression scores went up as the amount of time since their last sexual encounter increased. These data are consistent with the possibility that semen may antagonize depressive symptoms and evidence which shows that the vagina absorbs a number of components of semen that can be detected in the bloodstream within a few hours of administration."
No, I didn't read the paper. Just the abstract.
Secrets of success from Google co-founder Larry Page
January 7, 2009
0 comments
A great quote:
"We don't have as many managers as we should, but we would rather have too few than too many."
The Big Storm Picture: November 2008
January 5, 2009
0 comments
Amazing photography of various storms and tornadoes.
The Jesus story - A serious case of plagiarism
January 3, 2009
66 comments Misc. links
Is the story about Jesus in the bible just a serious case of plagiarism. Yes is the answer if you acknowledge the fact that the story of Horus came first; and that it did.
"Stories from the life of Horus had been circulating for centuries before Jesus birth (circa 4 to 7 BCE). If any copying occurred by the writers of the Egyptian or Christian religions, it was the followers of Jesus who incorporated into his biography the myths and legends of Horus, not vice-versa."
It's quite shocking read actually. I don't believe in the Bible or the character they call Jesus but if I did and studied the story of Horus I'd right now feel pretty damn pranked.
Ultimate Banksy Art & Graffiti Gallery | WebUrbanist
January 3, 2009
0 comments
Nice collection of Banksy art