New Home for My Blog

I've moved my blog to my own hosting at http://bjornlindqvist.se/blog/. So I will gradually retire this one.

Kom igen nu!

Kom igen nu Lövén, kom igen nu Sjöstedt, kom igen nu Miljöpartiet, kom igen nu svenska folket! Det skulle vara så himla gött med ett regeringsskifte nu på söndag. Jag är så trött på att se Reinfeldtfjanten sabba Sverige.

Torsdags

Förra torsdagen var en riktigt jäkla bra dag! Jag löste en knivig bugg på jobbet, fick kontakt med nya trevliga personer och ett slags jobberbjudande. Fast jag har redan jobb såklart. Sådana dagar är bra att komma ihåg när man går igenom några mindre bra dagar.

Referenser

Varför är det så svårt med referenser för? Räcker det inte med att man jobbar bra, måste man vara bästa vän med alla också?

Exception Handling Best Practices

This seem to be the absolutely hardest topic for otherwise smart programmers to get. No matter what language or job I've had, most of my colleagues have failed miserably at handling exceptions correctly. What I'm talking about is code like this, following the Pokémon Exception Handling pattern (gotta catch 'em all!):

try {
    ...
} catch (Exception ex) {
    // Log and pretend nothing happened.
    Log.LogException(ex);        
}

The best programmers understand why the above is wrong. They know what fail fast means and understands the Samurai Principle. 99.9% of all don't. They look at the above code and say "What!? That's exactly how you should write your code! Error handling is important!" Those people are the reason why programs fail for random reasons, why most code bases are messy and hard to work with. Below I've compiled a list of sources that explains why the above code snippet is bad. Most programmers never change their habits, but for some there is hope:

Ett moraliskt dilemma

I Ica-butiken i Akalla har de fått in ett tillfälligt parti lösgodis som bara kostar 2.90 kr/hg. Det är det lägsta lösgodispriset jag sett på åratal. Nästan helt oemotståndigt billigt! Å andra sidan åt jag fem mazariner och en mycket krämig chockladpudding igår. Kanske skulle man bara gå in och ta en titt. Säkert är det redan någon som köpt upp hela partiet i syfte att sälja det vidare till godisbutikerna.

I natt jag drömde

Att jag var en gästskådespelare i The Big Bang Theory. Det var en ganska lustig dröm. Vi spelade in nya avsnitt som höll en mycket högre klass än de avsaknaden repriser som Sexan kör med.

Förbannade SL

Hur svårt kan det vara att ta fram en (1) fungerande reseplanerare? Testar ni ens om skiten funkar innan ni lägger den live? Eftersom den just nu inte går att använda från en androidtelefon är det svårt att tro det. Skit i bootstrap, glossy knappar och cp-autocomplete som era neandertalkodare ändå inte kan få rätt. Två textrutor där man kan fylla i till och från samt en knapp med texten "sök resa". Det räcker! Eller fixa ett api till er linjedatabas så att man själv kan köra ett interface till datan och slippa befatta sig med er inkompetens era jubelamarörer.

Det är så

Så det är en kille på jobbet. Han glänser mer än mig. Jobbigt va. Fast han är väldigt trevlig också. Ovan situation för mig med kanske bara lagom bra självförtroende. Men jag gör mitt bästa. Tänker att resultatet och att alla trivs är det viktiga. Inte vara småsint som en del gamla kollegor vart mot mig. Skulle nog behöva mer tid att vara själv och "andas ut".

Vissa dagar

Då är det bara så. Som idag är jag nedstämd och ledsen utan anledning. Visst, dagen startade inte så bra. Blev väckt halv fem av att något smällde till i hallen. Var bara tidningsbudet som slängde in dn. Jag har inte ens någon prenummeration. Antingen får jag någon annans tidningar eller så har de bestämt sig för att försöka övertyga mig om att prenummerera. Det funkar inte.

Rummet på jobbet är alldeles för varmt och kvavt. Det var bättre under semestern då jag slapp dela det med en kollega. Även om han är trevlig. Behöver fler arbetsuppgifter också. Sitta och rulla tummarna under omställningstiden passar inte mig.

Dagens goda nyhet är att jag hittade axelbandet till gitarren. Fast tom det är träligt för då får jag inte chans att köpa något nytt.

Stormy Linux

The kernel that ships with Ubuntu 13.04 is defective. There is something wrong with the 3.8.x series of kernels and it affects people using the open source radeon audio driver. The solution I've found is to upgrade to 3.9.x and add "radeon.audio=1" to the kernel parameters line. Unfortunately the broadcom bcm43xx driver isn't compatible with those kernels and fails to compile. Aaah. Just "radeon.audio=1" on a 3.8.x kernel causes it to panic at bootup.

Also, if you're having video that mysteriously plays at a much higher framerate than usual, it's probably the same problem.

There has also been other weird kernel panics I've yet to investigate. Both at startup and shutdown. Something is absolutely not right with this Linux version.

Dungeon Crawl är otroligt

Spöade Dungeon Crawl i helgen :-). Min minotaurbärsärk tog sig hela vägen ner till Zots kammare och tillbaka. Sjukt skönt att äntligen få det klart. Tyvärr har det skett på bekostnad av diskandet, städandet, dammsugandet med flera hushållssysslor. De får jag ta itu med den här veckan.

Tillbaks i Tjockhult

Det är något alldeles speciellt med att komma hem till storstan. Allt folk, de labyrintlika fångarna i centralen, lukten av damm i tunnelbanan. Det är rogivande eftersom det är bekant. Jag är säker i civilisationen. Nu ska jag hem, dricka mjölk, äta sallad och spela gitarr. Sedan sova.

testpost

This article describes my experiences trying out various emacs module for managing your blog.

My requirements for a great blogging solution for emacs should support the following:

  • Write blog posts in Markdown, preferably using markdown-mode.el.
  • Syntax highlighting. Stackoverflow's online editor does it in a nice way.
  • Keybinding to upload the current buffer to blogspot. This is not a critical point and I'm prepared to move to another host if it's not possible to work with blogspot.
  • Easy way to attach images to the post.

Here are the various blogging solutions I tried out:

Blogging with org-mode and org2blog

org-mode is great for dealing with tabular data. I use it all the time for time series data, like keeping track of my weight, my score in Vem vet mest? and my work hours. It's also not bad for writing todo lists of all kinds. The org-mode syntax does not appear to be Markdown, but something close enough.

My information about org2blog comes from an old blog post written by Irreal.

Apparently, blogger uses the Atom API, so what I need is something called Org2BlogAtom.

The first problem is how to get org-mode to export to html with syntax highlighting. I'm often inserting code snippets in my posts, so getting that to work correctly is definitely a must. Two things are needed for that to happen:

  1. htmlize.el need to be installed.
  2. .emacs must contain:
(setq org-src-fontify-natively t
        org-export-htmlize-output-type 'css)
        

Then just press C-c C-e h to generate an html file of your org buffer. That's the first step, the next is to get the generated html file published online on my blog.

There are two different versions of org2blog, a fact that struck me after some googling. One for posting to Wordpress blogs and a different module for Blogger ones. Since I'm currently with the latter, what I need is org2blog/atom which is found at the sparsely documented git repo.

It depends on g-client, which has its own EmacsWiki page, but no obvious way to download the module. Checking out and building the Subversion reposity seem to have worked:

            svn co http://emacspeak.googlecode.com/svn/trunk/lisp/g-client/
            cd g-client
            make
            cp g-cus-load.el* g.el* gcal.* g-utils.el* g-app.el* gblogger.el* \
            ~/.site-lisp/
        

(~/.site-lisp/ is on load-path ofcourse).

org2blog/atom itself has an installation procedure that depends on "elinstall" which seem to be a custom installation module created by same author. But copying all elisp files from the ./atom and ./common to my ~/.site-lisp directory sems to work.

Next error "Requires a different version of org-mode. See README.org". The one shipped with emacs 24.3 isn't enough? But I think it should be since emacs 24.3 was released after the last commit was made to the org2blog repository. Let's check the code.

(unless (boundp 'org-html-cvt-link-fn)
        (error 
        "Requires a different version of org-mode.  See README.org"))
        

Aha! So where does org-html-cvt-link-fn come from? After some heavy google, I think the answer is that it was defined in a file called org-html.el that is no longer part of org-mode. Additionally, there is a mailing list thread which seem to imply that the function is used for converting links when exporting to HTML. Commenting out the references to it in main.el in org2blog helps – I should be able to do without that features.

Next error:

            File error: Cannot open load file, org2blog/common/l2r
        

This time the missing dependency is tinydb/persist. Installation is quick:

            git clone http://repo.or.cz/r/tinydb.git
            cd tinydb
            cp *.el ~/.site-lisp
        

Hopefully, I should be able to do without that feature. And finally! I'm able to load org2blog using this configuration:

(load-library "asynq")
        (load-library "persist")
        (load-library "l2r")
        (load-library "g")
        (load-library "main")
        (require 'org2blog/atom/main)
        

But running M-x org2blog/atom:post emits yet another problem:

            Symbol's function definition is void: org-mode-p
        

Googling for it produces a pull request with a patch for a different project that I think I can adapt. Easily fixed by commenting out these two superfluous lines in main.el in org2blog:

(unless (org-mode-p)
        (error 
        "Only useful in an org-mode buffer"))
        

Then I get to the next error:

            org-export-as-html: Wrong type argument: stringp, t
        

At this point, someone wiser than me would probably give up. Conclude that org2blog/atom isn't salvagable and that there's better uses for ones time. But.. I'm not that person. What's required is another simple change in main.el:

(org-export-as-html nil nil))
        ;; 
        (org-export-as-html nil nil nil t nil))
        

The next error message is encouraging, because it seem to complain about a missing configuration variable which makes me think the final is near:

            let*: Symbol's function definition is void: gblogger-blog->posting-url

The symbol is a function that is called with the return value of a function call to gblogger-ensure-blog. There are no search results for the symbol name. I'm done with org2blog/atom, at least for now. org2blog/atom probably needs to be rewritten anyway because it needs to be updated to org-mode's and Bloggers latest API changes. g-client could probably be salvaged though.

Bloggarkiv