Archive for the ‘Personal’ Category

2011w18

Sunday, May 8th, 2011

META section
I thought I’d try something new, like batching up things I discover along the week, and append it to a post to be published at the end of the week.

I am pretty certain that it will prove to be more diverse than previous posts, and with summarized points, it might actually be shorter than my “regular” posts.

If you like my longer, but more irregularly scheduled posts, fear not, those will continue, with about the same irregularity as usual ;P

Content section

Modernizr

Modernizr is a javascript library designed to detect what html5 capabilities a visiting browser has. This enables a kind of “progressive enhancement” which I find very appealing.

Using this one could first design a site which works with most browsers (I consider MSIE6.0 a lost cause) and then extend the capabilities of the site for those browsers that can handle it.

 

timetrack and timesummer

I recently started working on a small project aimed to help me keep track of the hours I put into various (other) projects, and the result is two scripts, timetrack and timesummer (I am desperately trying to find a better name for the last one, suggestions welcome). I promise to have it in a public repository soonish. timetrack can now be found at bitbucket

timetrack stores current date and time in a “timetrack file” whenever it is called, and at the same time determines if the current invocation will close an ongoing session, or start a new one.

If it is determined that the script is closing the session, it will also ask that I briefly describe what I have been working on.  The script then calculates how long the session was and writes this to the file as well along with the brief session summary.

timesummer simply reads the same timetrack file, and sums up the hours from all the sessions, and prints it to STDOUT.

It is multi-user capable-ish, since each file is created and stored in the format “.timetrack.$USER”. All in all it serves me pretty well.

 

switch-hosts.sh

Another project of mine is switch-hosts.sh, a script created to live in /etc/wicd/scripts/postconnect/ and copy /etc/hosts-home or /etc/hosts-not-home into /etc/hosts depending on my location (inside or outside of my home network).

Why I do this is a long-ish kind of story, but if you have ever cloned a mercurial repository from inside a private network and then tried to access it from outside the network, you should be able to figure it out.

The script stopped working. That’s twice now this has happened, but sufficiently far apart that I couldn’t remember why it happened without investigating it.

It all boiled down to me using GET (found in perl-libwww package) to fetch my external IP-address so that I could determine if I am inside my network, or outside it.

GET (and POST and HEAD) doesn’t live in /usr/bin or /usr/local/bin or some place nice like that. No, GET lives in /usr/bin/vendor_perl (or at least it does now, Before a system upgrade it lived somewhere else…

I don’t know why someone (package maintainer, the perl community, whoever…) felt it was necessary to move it (twice now), but I guess they had their reasons, and since I used absolute paths in switch-hosts.sh so that I wouldn’t need to worry about what environment variables had been set when the script was executed, renaming the directory GET lived in meant breakage…

This isn’t me passive aggressively blaming anyone, but it did kind of irk me that the same thing has happened twice now.

Plz to be can haz makingz up of mindz nao, plz, kthxbai.

I love GET and HEAD, and will continue using them, manually. For the script, the obvious solution was to switch to something which by default lives in /usr/bin and doesn’t move, something like… curl.

 

Savant3

I have found myself working with PHP again. To my great surprise it is also rather pleasant. I have however found myself in need of a templating system, and I am not in control of the server the project is going to be deployed on, and so cannot move outside the document root.

From what I gather, that disqualifies Smarty, which was my first thought. Then I found Savant, and although I am sure that Savant doesn’t sport nearly all the bells and whistles that Smarty does, for the time being, it seems to be just enough for me.

I am going to enjoy taking it for a spin and see how it will fare.

 

Unhosted

I do not enjoy bashing well-meaning projects, especially not projects I know I could benefit from myself, but after reading the material on the unhosted site, I remain sceptically unconvinced.

The idea is great, have your data encrypted and stored in a trusted silo controlled by you or someone you trust enough to host it, henceforth called “the storage host”.

Then an “application host” provides javascripts which in turn requests access to your data, which you either grant, and then the application code does something for you, and you see that it is good, and all is well, or you don’t grant access and you go on your merry way.

The idea is that since everything is executed on the client side, the user can verify that the code isn’t doing anything naughty with your data. Like storing it unencrypted somewhere else to sell to advertisers or the like.

For me, this premise is sound, because I am a developer, a code monkey. I can (with time) decipher what most javascripts do.

Problem: the majority of people aren’t developers (well that is not a problem, they shouldn’t have to be), but what I’m saying is that of all people only a subset knows that there exist a language called javascript, and it is only a subset of that subset which can actually read javascript (i.e. in perspective VERY FEW).

For me personally, this concept rocks! I could use this and feel confident in it. But requiring the end user to the first, last and only line of defense against malicious application providers… (well, of course, the situation right now is at least as bad) isn’t going to fly.

One could experiment with code-signing, and perhaps a browser add-on, and make a “fool-proof” user interface, hiding away the underlying public key cryptography that would be needed, but somewhere along the line the user would still need to know someone who could read the code, could sign it, and then act as a trusted verifier.

My thoughts on what would be easier to teach the end user; public key cryptography or javascript? Neither… :(

 

Links

Finally, a random assortment of links I found in various places during the week:

The Bun Protocol
Laptop Bubbles
Hybrid Core, A WordPress Theme Framework
201 ways to arouse your creativity

 

Revelation of the week: Thanks to the “Laptop Bubbles” post I realized that I now consider bash (shell scripting) my primary language, thus displacing Python to a second place.

Introducing NightSky2

Saturday, March 19th, 2011

I have had a small hobby project in the pipe for a while now (several actually, I am very good at starting new things, and now I am working up the skill to actually finish them as well), and now I have finally gotten around to finish it.

It has been near completion for a while, but I managed (two times that I can remember) to find fault with it, and then tear it all down and start anew.

None of this matters now, for now I am going live. I will get around to setting up a mercurial repository on bitbucket for it, but for the time being it will be made available in The source is available through a mercurial repository at bitbucket.org as well as through tarballs and zip-archives.

So without further ado, I give you: NightSky2

So then, what is NightSky2? It’s an homage to a website that taught me the (very) basics of identifying constellations in a very pedagogical way.

When I tried to find it again last year, I found that I couldn’t. It had disappeared off the net. It made me quite sad, because it was truly a great introductory source of knowledge, and I wanted to show it to a dear friend of mine.

Scouring through the Internet, I finally remembered something that mk told me one morning on the ride in to FSCONS about a site named archive.org. I found remnants of it there, the latest (partial) working set having been mirrored in 2008.

But it gave me enough of my waning knowledge back to be able to build a site of my own, so… here we are :)

Hope it is of use to someone.

Update: Added link to repository.

:wq

Försvarsmakten…

Monday, June 14th, 2010

Credit: Mikael Hedberg
Licens: CC BY-NC-SA

I get all the fun questions

Sunday, March 14th, 2010

A friend just pinged me wondering if I knew of a way to convert “windows file names” to “Linux file names” (i.e. the character encoding of the file names).

My first thought (stupidly) was “surely this must be solvable using ls > dirlist and some hackery involving tr or sed“.

A quick test on a string (actual file name) sent over from my friend luckily shattered that idea.

So my next thought was simply “surely other people have had this problem before me (us).”

My google-fu was with me on this day, as I soon found convmv, a nifty little tool for changing the character encoding of filenames, pretty much what my friend wanted to do :D

He could of course just have searched for it himself, but I am quite glad that he didn’t as then I wouldn’t have gotten to know about it, this might save me valuable time some other day when my google-fu isn’t with me ;D

Reading habits…

Tuesday, January 12th, 2010

Inspired by Mathias, here is my own, rather poor, list. I do much like Mathias come to the same conclusion; it is rather scary that I don’t care to read most of the books on this list. :/

“The BBC apparently believes most people will have only read 6 of the 100 books here. Please copy and paste your bolded books read, italicized books as ”want to read”, and then sum up with a head count, so to speak. What does the list say about your reading habits?”

  1. Pride and Prejudice – Jane Austen
  2. The Lord of the Rings – JRR Tolkien
  3. Jane Eyre – Charlotte Bronte
  4. Harry Potter series – JK Rowling
  5. To Kill a Mockingbird – Harper Lee
  6. The Bible
  7. Wuthering Heights – Emily Bronte
  8. Nineteen Eighty Four – George Orwell
  9. His Dark Materials – Philip Pullman
  10. Great Expectations – Charles Dickens
  11. Little Women – Louisa M Alcott
  12. Tess of the D’Urbervilles – Thomas Hardy
  13. Catch 22 – Joseph Heller
  14. Complete Works of Shakespeare
  15. Rebecca – Daphne Du Maurier
  16. The Hobbit – JRR Tolkien
  17. Birdsong – Sebastian Faulk
  18. Catcher in the Rye – JD Salinger
  19. The Time Traveller’s Wife – Audrey Niffenegger
  20. Middlemarch – George Eliot
  21. Gone With The Wind – Margaret Mitchell
  22. The Great Gatsby – F Scott Fitzgerald
  23. Bleak House – Charles Dickens
  24. War and Peace – Leo Tolstoy
  25. The Hitch Hiker’s Guide to the Galaxy – Douglas Adams
  26. Brideshead Revisited – Evelyn Waugh
  27. Crime and Punishment – Fyodor Dostoyevsky
  28. Grapes of Wrath – John Steinbeck
  29. Alice in Wonderland – Lewis Carroll
  30. The Wind in the Willows – Kenneth Grahame
  31. Anna Karenina – Leo Tolstoy
  32. David Copperfield – Charles Dickens
  33. Chronicles of Narnia – CS Lewis
  34. Emma – Jane Austen
  35. Persuasion – Jane Austen
  36. The Lion, The Witch and The Wardrobe – CS Lewis
  37. The Kite Runner – Khaled Hosseini
  38. Captain Corelli’s Mandolin – Louis De Bernieres
  39. Memoirs of a Geisha – Arthur Golden
  40. Winnie the Pooh – AA Milne
  41. Animal Farm – George Orwell
  42. The Da Vinci Code – Dan Brown
  43. One Hundred Years of Solitude – Gabriel Garcia Marquez
  44. A Prayer for Owen Meaney – John Irving
  45. The Woman in White – Wilkie Collins
  46. Anne of Green Gables – LM Montgomery
  47. Far From The Madding Crowd – Thomas Hardy
  48. The Handmaid’s Tale – Margaret Atwood
  49. Lord of the Flies – William Golding
  50. Atonement – Ian McEwan
  51. Life of Pi – Yann Martel
  52. Dune – Frank Herbert
  53. Cold Comfort Farm – Stella Gibbons
  54. Sense and Sensibility – Jane Austen
  55. A Suitable Boy – Vikram Seth.
  56. The Shadow of the Wind – Carlos Ruiz Zafon
  57. A Tale Of Two Cities – Charles Dickens
  58. Brave New World – Aldous Huxley
  59. The Curious Incident of the Dog in the Night-time – Mark Haddon
  60. Love In The Time Of Cholera – Gabriel Garcia Marquez
  61. Of Mice and Men – John Steinbeck
  62. Lolita – Vladimir Nabokov
  63. The Secret History – Donna Tartt
  64. The Lovely Bones – Alice Sebold
  65. Count of Monte Cristo – Alexandre Dumas
  66. On The Road – Jack Kerouac
  67. Jude the Obscure – Thomas Hardy
  68. Bridget Jones’s Diary – Helen Fielding
  69. Midnight’s Children – Salman Rushdie
  70. Moby Dick – Herman Melville
  71. Oliver Twist – Charles Dickens
  72. Dracula – Bram Stoker
  73. The Secret Garden – Frances Hodgson Burnett
  74. Notes From A Small Island – Bill Bryson
  75. Ulysses – James Joyce
  76. The Bell Jar – Sylvia Plath
  77. Swallows and Amazons – Arthur Ransome
  78. Germinal – Emile Zola
  79. Vanity Fair – William Makepeace Thackeray
  80. Possession – AS Byatt
  81. A Christmas Carol – Charles Dickens
  82. Cloud Atlas – David Mitchell
  83. The Color Purple – Alice Walker
  84. The Remains of the Day – Kazuo Ishiguro
  85. Madame Bovary – Gustave Flaubert
  86. A Fine Balance – Rohinton Mistry
  87. Charlotte’s Web – EB White
  88. The Five People You Meet In Heaven – Mitch Albom
  89. Adventures of Sherlock Holmes – Sir Arthur Conan Doyle
  90. The Faraway Tree Collection – Enid Blyton
  91. Heart of Darkness – Joseph Conrad
  92. The Little Prince – Antoine De Saint-Exupery
  93. The Wasp Factory – Iain Banks
  94. Watership Down – Richard Adams
  95. A Confederacy of Dunces – John Kennedy Toole
  96. A Town Like Alice – Nevil Shute
  97. The Three Musketeers – Alexandre Dumas
  98. Hamlet – William Shakespeare
  99. Charlie and the Chocolate Factory – Roald Dahl
  100. Les Miserables – Victor Hugo

9 read out of 100, that pretty much sucks. 6 that I know I want to read (I could probably expand the “want to read” list a little, but frankly, most of the books I haven’t heard of, and the ones I have heard of, only 6 have sparked an interest.)

In Case of Emergency — ICE

Saturday, July 18th, 2009

Igår inträffade en sak, som fick mig att komma ihåg något jag läste på någon räddningstjänsts hemsida för något år sedan. Det är dock inte en sida jag lyckas hitta till igen, men Google presenterade mig med en massa individuella räddningstjänsters hemsidor[1] från runtom hela landet. I princip allihopa säger samma sak:

ICE i mobilen

Lägg in dina närmaste anhöriga i din mobiltelefons adressbok under namnet ICE. Då kan de snabbt kontaktas om du skulle hittas akut skadad eller sjuk och inte kan tala.

ICE är en förkortning av engelskans In Case of Emergency.

Så här gör du för att lägga in ICE i mobilen:

  1. Lägg till en ny kontakt i telefonboken.
  2. Skriv in ICE1 följt av vilken relation du har till personen t ex wife, dennes namn, +46 och sedan telefonnumret utan den första nollan.
  3. Vill du lägga till fler kontakter, skriv ICE2 etc.

Tänk på att använda landsnummer +46 för Svenska kontaktpersoner och Engelska som språk så att funktionen även fungerar när du är utomlands. Du bör självklart berätta för de personer du lagt in under namnet ICE så att de vet om det.

Ett exempel:
ICE1 wife Rut
+46 703 123456

[1] Västra götaland, Räddningstjänsten Syd och Östra Blekinge m.fl.

Battling Pidgin

Wednesday, July 1st, 2009

I like Pidgin. I like it a lot, and have done so since the days when it was named Gaim. Add plugins like Off-The-Record and hook it up to TOR,  and we have a pretty powerful communications package.

Pidgin doesn’t support audio or web cam conversations, which is a bummer, but nothing I personally need or use, so it isn’t a big deal, it just means I can’t promote it to other people who do use/need those features.

But, on to the “battle”. You see, while Pidgin is a great piece of software, it has ugly sides as well. Tonight I upgraded my Pidgin installation. I don’t upgrade Pidgin as often as I should. There is a reason for this. Until this evening I’ve lived with Pidgin 2.4.1. A customized version of 2.4.1.

Most of the time, regarding most issues, I consider the developers of Pidgin to be awesome. Their software is awesome. Most of the time…

So I don’t upgrade very often, because I customize my Pidgin, which means that I go through all the trouble of downloading the source, customize the code, and go through the build-process. What is this customization which I require so badly you wonder? What would be so hard to reconcile with, as to trigger this kind of response?

It is actually quite silly. Silly of the developers, and silly of me. I have loads of respect for them and they have posted arguments for their “improvement” but to this day, 16 months later, I still cannot see it as anything less than a usability regression.

I am of course talking about Issue #4986“closed enhancement: wontfix” a bug which yielded 325 comments, some users registering just to voice their malcontent with this “feature”, where the message input area “grows”, upwards, as you type long messages. No more manually resizeable input area.

I know this is a free software project, I know that if I don’t like it I can either fork the project or… well… “fork off”.

And rather than learning to live with that “feature”, for me it is still a usability regression, I’d rather download their source, hard code the textarea to 4 lines high, and accept that neither they, nor I, have control over the resizing of the input area. I much prefer this option to the alternative.

Silly… (you can laugh at me now) and sad, at the same time.

My operating system of choice: Ubuntu

Tuesday, June 9th, 2009

During the wee hours of yesterday archie wrote a post which got me thinking about a topic I’ve been meaning to write for so long. Truth be told I’ve written about half a dozen drafts about this topic, but never been able to finish it. I think it’s about time I did something about this.

I use Ubuntu. Why? I got tired with small… shall we say “peculiarities”… about Windows.

With the help of fireworx (who made me put my money where my mouth was), mra (who more or less became my mentor) and some unknown second- or third-year student (who had placed Ubuntu cds in our square at ITU) I tried out Ubuntu.

As with most things there was a learning curve, but I was willing to give it a shot, despite my WLAN card being manufactured by Broadcom, and the entire application repository was a mess when it came to what sound architecture apps were using. Mind you, this was in the day of Breezy Badger. Ubuntu was not as… “polished” as it is today.

But as the “attraction of the new” slowly faded with time, it was replaced with the realization of all the small things which are cool about GNU/Linux, which Windows lack.

I mean, installing applications and upgrades without having to reboot (with the exception of new kernels and stuff) is cool. Having more than one (virtual) workspace, once you get used to it, can be awesome. But it is the small things, things like being able to grab and drag a window no matter where in the window the mouse cursor is, just by pressing the alt-key while you do it, or likewise, resizing a window without having to zero in on one of the borders of the window.

Not needing to scour the net for drivers and installers, just doing a search in the repositories, very appreciated. And when the Gnome team, or if it was the Ubuntu team, decided to “dumb down” Gnome, taking away options, it was nice to be able to switch window manager, to something else, something like wmii.

I left Windows out of frustration, Ubuntu happened to be there, and I stayed… well mostly because it felt like I’d found my way “home”. I suppose I shouldn’t stop here, I should continue trying new distributions and I have been thinking a while about archlinux, but at the same time, Ubuntu works, I am a happier more productive person with it.

It will have to wait until either a.) Ubuntu makes me disappointed, or b.) I have enough free time to experiment with other distros.

So to summarize, I left Windows out of frustration, I ended up with Ubuntu, although this was more of a fluke. It wasn’t an informed choice, as I didn’t initially know anything about Ubuntu, but it worked out great. But during the last four years, Ubuntu has become my choice, as I’ve chosen not to return to Windows, or to seek out other distributions.

“You make your choices and you live with them and in the end you are those choices.”

Kendra Shaw — Battlestar Galactica: Razor

Drunken corrupted memory blag post

Saturday, June 6th, 2009

I was supposed to remind archie about something… a blog, about statistics I think.

Similarly he was supposed to remind me of something… Pragmatic Progammer book? graphviz? matplotlib? Wumpus AI-game? None of my guesses “feel” right… damnit…

It was an awesome party/dinner though. tuss and ak should be praised with nothing but the best and most kind words.

bbl

I do believe I have been bitten by Python

Saturday, May 30th, 2009

Lately I have found myself writing short texts in Swedish, destined to end up at a friends computer. A Windows-using friend, with all the UTF-8 / ISO-8859-1 hassles this entails. For the first file, I simply copied it onto a memory stick and rebooted into the Windows partition, and search/replaced all the offending characters (å, ä, ö and the odd é). Then rebooted again (since I don’t have my emails set up in Windows) and fired off the mail.

I simply figured that this file would be kindof a one-shot deal and nothing more. About two weeks later, I wrote a second file, and re-did the entire reboot-procedure. I found myself writing a third file yesterday… I can’t for the life of me remember the saying, or where I read it, but it was something along the lines of if you do the same thing more than twice, automate the shit out of it.

An audience with the great oracle lead me to this blog post and after trying it out manually (which required me to reboot one more time just to verify that the converted file had in fact been converted) I was all set to write a little shell script. I came so far as to write the first lines of error handling in the script (make sure that the script had recieved a filename) before I realized that I really didn’t want to write a shell script. Not when I could piece together a Python script in half that time, which would have better error checking. And yes, that time estimate included researching how to have Python execute a system call. (subprocess.call() is what I settled on, as per advise from StackOverflow. It took me a minute or so of reading the manual to figure out how to redirect the output from that command (the full text, in ISO-8859-1 encoding) to a new file (getting a file pointer to the new file, and redirecting stdout from the subprocess.call() to that file pointer)

Something along these lines:

fp = open('myfile.iso.txt', 'w')
args = ['iconv', '--from-code=UTF-8', '--to-code=ISO-8859-1', 'myfile.txt']
subprocess.call(args, stdout=fp)
fp.close()

No more silly rebooting to convert plaintext files for me :D