Wednesday, June 4, 2008

Script for removing orphans in Arch Linux

Shell scripting is fun, so I created a small function that removes all orphaned packages as reported by Pacman. It calls itself recursively if removing the current orphans revealed any new ones. Tested with zsh since that is my personal preference the best shell around :) - but it probably runs under bash as well. Here is the code:


remove_orphans() {
for pkg in `pacman -Qdt|awk -F ' ' '{ printf("%s\n", $1) }'`; do
sudo pacman -R $pkg
done
if [ `pacman -Qdt|wc -l` -gt 0 ]; then remove_orphans; fi
}

Tuesday, June 3, 2008

Arch Linux: Alt+gr not working in Java apps

I got quite confused when my good old trusty Alt+gr key did not work in NetBeans (since I use Norwegian keyboard layout, this key is essential for progamming). The key worked everywhere except in Java apps, actually. Luckily, I figured out how to fix it:

  1. Install scim.
  2. Add your locale to the scim global config (/etc/scim/global).
  3. Start scim from your xinitrc.
  4. Restart your X server - it now should work!
For good measure, here's my .xinitrc file:


# SCIM
export XMODIFIERS='@im=SCIM'
export GTK_IM_MODULE="scim"
export XIM_PROGRAM="scim -d"
export QT_IM_MODULE="scim"
scim -d
# OPENBOX
exec openbox-session

Monday, June 2, 2008

Arch Linux: First impressions

So, I finally got fed up with Ubuntu. I really wanted to use FreeBSD again - but unfortunately the hardware in this box is not compatible. Arch Linux looked like a decent alternative so I downloaded the 2007.08-2 image and started installing. Misfortune struck again as I had to spend a couple of hours trying to get wireless working, but everything worked well as soon as I switched to the 2008.04-RC image. I wonder why they don't link to the RC image on the "Get Arch" page.

After some configuration I ended up with a really slick system - It's amazing how much faster stuff runs on OpenBox! Also, the BSD inspired rc.conf and init system made my day. The only real problem I encountered was when I tried to install an older version of a library. Pacman (Arch's package manager) doesn't support this. I consider this to be a flaw in the package manager (which all over feels immature compared to apt or BSD ports), and I predict the devs will realize this sooner or later - even though they currently consider it to be a "feature".

I find it amusing how things tend to move in cycles. When I started out with Linux ~8 years ago Slackware was the coolest thing around. Then we somehow ended up with Ubuntu. And now the "KISS"-distros are turning into the hippest kids on the block again. If you're fed up with the bloat, give Arch a try. :)

Sunday, May 18, 2008

(str)tr for JavaScript

I couldn't find a function resembling Ruby's tr or PHP's strtr in JavaScript, so I created one. Here's the code:


function tr(str, from, to) {
var subst;
for (i = 0; i < from.length; i++) {
subst = (to[i]) ? to[i] : to[to.length-1];
str = str.replace(new RegExp(str[str.indexOf(from[i])], 'g'), subst);
}
return str;
}

Tuesday, May 6, 2008

Java oddity

I really don't like the fact that you can run static class-methods from an object in Java. In effect, object.staticMethod(); gets translated into something like object.getClass().staticMethod();. AFAIK, no other language has this "feature". Is there any reason behind this madness?

Tuesday, January 15, 2008

Nginx 0.5.35 released

I don't know of any feeds that track nginx releases, so this is just a heads up for people that missed the release of nginx 0.5.35. Release notes:


*) Change: now the ngx_http_userid_module adds start time microseconds
to the cookie field contains a pid value.

*) Change: now the uname(2) is used on Linux instead of procfs.
Thanks to Ilya Novikov.

*) Feature: the "If-Range" request header line support.
Thanks to Alexander V. Inyukhin.

*) Bugfix: in HTTPS mode requests might fail with the "bad write retry"
error; bug appeared in 0.5.13.

*) Bugfix: the STARTTLS in SMTP mode did not work.
Thanks to Oleg Motienko.

*) Bugfix: large_client_header_buffers did not freed before going to
keep-alive state.
Thanks to Olexander Shtepa.

*) Bugfix: the "limit_rate" directive did not allow to use full
throughput, even if limit value was very high.

*) Bugfix: the $status variable was equal to 0 if a proxied server
returned response in HTTP/0.9 version.

*) Bugfix: if the "?" character was in a "error_page" directive, then
it was escaped in a proxied request; bug appeared in 0.5.32.


Now go and upgrade your servers!

Thursday, December 6, 2007

Public domain?

I'm currently reading "Fundamentals of database systems" by Elmasri & Navathe as part of the curriculum in a database course at my University. The book overall isn't all that bad, but their take on open source databases is really horrid. Quote:

"Personal computers and database system-like software products such as Excel, Visual FoxPro, Access (Microsoft), or SQL Anywhere (Sybase), and public domain products such as MySQL and PostgreSQL are being heavily utilized by users who previously belonged to the category of casual and occasional database users."
Wow. Public domain? I think they should at least invest two minutes to read up about open source software and open source licences, before they wrote about it. Excel and PostgreSQL in the same sentence? That's pretty fucked up if you ask me. And they have this highly patronizing tone which goes something like "commercial dbms > *, lol!". Someone should ship the authors a copy of PostgreSQL, I'm sure they would've been amazed if they tried it.