Rasmus.krats.se

svenska

Reminiscing this and that, on the web since 1995

Tagged python

Destruktorer och defer

Published tagged , , , , , .

En av de saker jag verkligen gillar i c++ är att man kan ha lokala variabler som är objekt i kombination med att objekt har destruktorer. När man lämnar ett scope där det finns lokala variabler kommer deras destruktorer omedelbart att köras, oavsett hur man lämnar scopet. Det ger ett trevligt sätt att hantera öppna filer, databaskoppel, mutexar och annat som behöver stängas. Andra språk har andra, ofta krångligare, sätt att få motsvarande resultat.

Språket go har en helt annan aproach, som är värd att titta lite närmare på.

Läs och kommentera inlägget Destruktorer och defer

Tech update on Rasmus.krats.se

Published tagged , , , .

I've run a little django on this site for a long time beside the actual content (which was static files, created with make and xslt). Now I've gone all out and run the entire site in django.

At the same time, I've modernized the markup using some semantic html5. Some javascript and css should make it work even in browsers that doesn't really support it (like MSIE 8 and older). The graphical design has got an update to, even if it remains rather similar to the way it has looked since 2009. I hope it is both nice looking and useable on both big screens and small phones.

This also means that comments is enabled on the site again, after having been disabled for a while.

Write a comment

Comment on rasmus.krats.se

Published tagged , , , .

Now you can write comments on my pages! I only allow comments from logged-in users. Of course, you don't want to create yet another web account that you have to remember the password for. I understand that. I don't want to administrate yet another user database either.

The solution is OpenID. Now one account, in a central place you select, is enough for any number of web sites! (or one for each pseudonym you choose to use).

Maybe you don't even have to create a single account — chances are you have one already! If you have an account at e.g. KTH, LiveJournal or WordPress, you can use that! If not, there is a rather long list of providers that you can use.

django

Since I am the geek I am, I don't use any ready-made blogging software. My pages are static html, built width XSLT. The comments are stored in a separate system, which I've written on the django platform. Comments are loaded onto each page by a little AJAX hack (if a browser lacks javascript, they are available as an <object> instead, and failing that as a link to a separate page).

For a small service like this, django was very nice to work with. Python continues to be a programming language I enjoy, even if it's still rather new to me.

Write a comment

Chordlab: chopro to pdf

Published tagged , , , , .

Chordlab is a command line program I wrote to create pdf songbooks from chopro source.

Normal usage is to give chordlab a list of chopro files (each containing one or more songs). Chordlab then produces a pdf of one page for each song. Long songs can span several pages, as needed. Since the lines of a song test is often short, chordlab supports pages with multiple columns.

Läs och kommentera inlägget Chordlab: chopro to pdf