Smokes your problems, coughs fresh air.

Author: Rowan Rodrik (Page 22 of 27)

Rowan is mainly a writer. This blog here is a dumping ground for miscellaneous stuff that he just needs to get out of his head. He is way more passionate about the subjects he writes about on Sapiens Habitat: the connections between humans, each other, and to nature, including their human nature.

If you are dreaming of a holiday in the forests of Drenthe (the Netherlands), look no further than โ€œDe Schuilplaatsโ€: a beautiful vacation home, around which Rowan maintains a magnificent ecological garden and a private heather field, brimming with biological diversity.

FlashMQ is a business that offers managed MQTT hosting and other services that Rowan co-founded with Jeroen and Wiebe.

Change ext3’s reserved block count and gain Gigabytes

Wiebe was looking over my shoulder while I was running df to check the disk space that was still available on my Lenovo ThinkPad:

# df -h /dev/sda2
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              90G   79G  7.3G  92% /

He noticed that there was a huge gap between the total space (79 used + 7.3 available = 88.3) and the actual size of the file system. According to him this was due to the reserved block count, which is set to five percent by default in ext2 and ext3 file systems—clearly a legacy from a time where disks were smaller.

# dumpe2fs /dev/sda2|grep -i 'reserved block count'
dumpe2fs 1.40.8 (13-Mar-2008)
Reserved block count:     1196559

# dumpe2fs /dev/sda2|grep 'Block count'
dumpe2fs 1.40.8 (13-Mar-2008)
Block count:              23931180

# echo 'scale = 2; 1196559 / 23931180'|bc
.05

I changed the reserved block count with tune2fs:

# tune2fs -m 1 /dev/sda2
tune2fs 1.40.8 (13-Mar-2008)
Setting reserved blocks percentage to 1% (239311 blocks)
# dumpe2fs /dev/sda2|grep -i 'reserved block count'
dumpe2fs 1.40.8 (13-Mar-2008)
Reserved block count:     239311
# df -h /dev/sda2
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              90G   79G   11G  88% /

Now, the reserved blocks take up roughly 934 MiB; I’ve freed 3.7 GiB with this little file system tweak. ๐Ÿ™‚

Update 14 nov 2010: I finally fixed two errors in my final calculations spotted by Den. He noticed that the numbers (700 MiB and 13 GiB) were wrong. Thanks, Den!

png2ico: converting favicons to Windows’ ICO format

Even though, strictly speaking, I should be using favicons in anything but Windows’ ICO format and refer to them from a <link>-tag at any location other than /favicon.ico, I sometimes like to help Microsoft break the web by putting an ICO file at the location that they reserved for it (/favicon.ico).

My tool of choice for converting PNG’s to ICO is Matthias Benkmann’s png2ico. To generate an ICO file with this program, you just need to feed it one or more PNG files. The possibility to include differently sized PNG files can help you make sure that the icon will steal look good when being dragged to the desktop or some other non-miniature context.

$ png2ico
png2ico 2002-12-08  (c) Matthias S. Benkmann
USAGE: png2ico icofile [--colors ] pngfile1 [pngfile2 ...]

Here’s an actual example which creates an ICO file from a single PNG file:

$ file favicon.png 
favicon.png: PNG image data, 16 x 16, 8-bit/color RGBA, non-interlaced
$ png2ico favicon.ico favicon.png 

Of course, we should discourage browsers from doing useless requests for /favicon.ico by actually telling them when it is available: (as if…)

<link type="image/x-icon" rel="shortcut icon" href="/favicon.ico" />

Now we can go back to pretending that: No, we’re not encouraging the practice of link squatting. We just happen to have put our favicon in that location.

For the less tech savvy

Update 30 sep 2012: There’s a free online service to convert PNG to ICO: www.pngtoico.com. It doesn’t require you to do anything complicated (like installing Unix stuff). Just pick your original and get the converted image. ๐Ÿ™‚

Using wget to download all files on a page

Just a quick one-liner I used to download a bunch of MIDI files from an on-line listing of Chopin MIDIs:

$ wget http://www.piano-midi.de/chopin.htm -q -O - \
| grep 'href=".*\.mid"' \
| sed -e 's/^.*href="\(.*\)".*$/\1/' \
| xargs -i{} wget http://www.piano-midi.de/{}

Maybe not so useful to you, but it’s a good demonstration of applying the hacker’s mentality to one of those moments where, after clicking the fourth link or so, I find myself thinking: Wouldn’t spending a few moments on a one-liner be much more fun than clicking through and saving 44 more links?

Useful or not, I am now testing timidity’s piano sound with a nice rendition of Chopin in the background whereas, without this trick, I’d still be right-click-click-saving links instead of writing this post. It’s up to you to decide whether this is actually good or bad. ๐Ÿ˜›

VIM modelines for per-file configuration

The MediaWiki developers use tabs instead of spaces for indentation. This can be annoying for someone like me who has configured VIM to work with spaces by default—annoying because I don’t want to enter something like :set tabstop=4 noexpandtab shiftwidth=4 every time that I open a file. Adding different conditions for each project to my .vimrc is probably possible but not much fun.

The other minute, when I opened the sources of my Semantic Gallery extension for MediaWiki, I noticed that I had been mixing tabs and spaces again. So it was time to look up the VIM feature which allows you to put a configuration line in a comment at the bottom of a file. This quote is another perfect example of why it’s good practice to blog about such things. I remembered that the last time that I had wanted to do this, I could not find a useful search string at all and resorted to finding back an example in the code where I had first seen it and modifying that. Now, I thought I’d have to do the same, but from a quick googling I learned that I’m not the only one to use his blog as a memory extension. ๐Ÿ™‚

Good. Hopefully, from now on, I’ll remember that this configuration-thingy-at-the-bottom-of-a-file is called a modeline, so that I can just enter :help modeline in VIM the next time that I forget where the colons have to go.

An example for when I do forget:

# vim:set ts=4 sw=4 noexpandtab:

This reminds me of my many searches for Heredoc syntax when I didn’t know that they were called Heredocs.

Remote pair programming with GNU Screen

I like pair programming. So much, in fact, that I want to do it even if I can’t look over the other person’s shoulder due to some geographical offset. Since I’m a real command-line freak, I can get what I want easily by using GNU Screen.

GNU Screen rehash

If you don’t know GNU screen yet and you ever find yourself using the command-line for an extended period of time, learn it. Now. I’ll name just a few advantages:

  1. You can manage multiple “windows” conveniently even if you don’t have a tabbed terminal emulator, or even when you’re not within a graphic environment such as X.
  2. You can “detach” and “reattach” your Screen sessions and continue exactly where you left. This is very useful if you do your work on a remote server, through SSH, for example. Never by stumped by instable connections again!
  3. But, the feature which is most useful for pair programming is the ability to attach to the same session from multiple terminals.

Starting GNU Screen is very easy. Just type screen at your shell prompt (or screen -S SESSION_NAME if you want your session to have an easy-to-remember name).

Press CTRL+A followed by d to detach. Exit your terminal. Start a new terminal, type screen -r and be amazed that you have your session back. screen -r can take as an argument the name or PID of the screen, which is useful if you have more than one screen running. To get a list of current screen sessions, type screen -ls.

Inviting your observer

The first thing you have to do is to add the following command to your .screenrc file:

multiuser on

If you don’t want to enable multiuser by default, you can also choose to type the command from within Screen each time that you need it. This is done by pressing Ctrl+A, followed by : and the command.

Myself, I prefer to have the command in my .screenrc. You need to admit users explicitly anyway. Admitting full access to a user is done by typing the :acladd USERNAME command (after pressing Ctrl+A). Then the given user can join this session by starting screen with screen -x SESSION_OWNER/ where SESSION_OWNER is the driver.

Get out of my driver’s seat! (Dealing with annoying observers)

The :acladd USERNAME command will give the observer full read-write access. Maybe, if you have to deal with an observer who insists on taking the driver seat, you want to limit his or her access to read-only. This can be done just as easily: press Ctrl+A; then type :aclchg USERNAME -w "#".

Make your terminals match

Using a shared screen, it can be kind of annoying if your terminal sizes don’t match. As an observer, I fix this by asking the driver to tell me the values of the $ROWS and $COLS environment variables. If then, for example $COLS=110 and $ROWS=40, I start my xterm with this in mind: xterm -geometry 110x40

Have fun with Screen!

I’ve only touched upon some of the things you can do with screen. The manual page contains much more information—perhaps a bit too much even. ๐Ÿ˜•

One of the things I also like to do with a shared screen session is remote system administration. If I want to perform delicate tasks as root, I find it kind of comforting if someone can stop me in time, before I do anything stupid. Besides, if you’re both root, you don’t even have to set permissions. ๐Ÿ™‚ So, it’s easy to.

Hardwood Investments Wiki

Before the company was forced by the Netherlands Authority for the Financial Markets (AFM) to seize most of its activities, Sicirec had always used it website to provide teak investors with a somewhat independent view of the hardwood investment market. It has to be said that Sicirec’s critical view on the management of various teak plantation made the company a little unpopular with said managers (such as Ebe Huizinga of Flor y Fauna fame).

Screenshot of my Hardwood Wiki

Like I said, Sicirec had to suspend most of her activities as an intermediary by mandate of the AFM. In order to survive and to continue the realization of their philosophy the company had to reorganize and focus on new projects. Where previously they had been focused on servicing the interests of a investments in third-party projects over which they had little to no control, they’re now developing their own projects (and also are still offering investments in the Sicirec Forestry Mixfund, which is the only investment option that remains of the old organization form).

As a previous Webmaster of www.sicirec.org, I had never been entirely satisfied by the limited possibility to really effectively inform all types of hardwood plantation investors within the constraints of a company website. That is why, during the final website cleanup round, before I resigned as Webmaster, I started a wiki about hardwood investments independently of Sicirec. With permission by Popko van der Molen, my dad and then director of Sicirec SA, I used much of the existing information about the various plantation companies that Sicirec maintained on their website as the seed content for this wiki.

Actually, most of the seed content was in Dutch, so after translating some of it for the English language wiki, I started a Dutch language version sister wiki and copied most of the content there. Since then (May, 2007), the Dutch version has grown to 500 pages, while the English version has remained at a meager 77 pages.

If you have anything you want to know or say about hardwood investments, you might like one of my wikis:

Using Caps Lock as an extra Control key

With me mostly posting about computer stuff on this weblog, it might surprise you that, until May this year, I hadn’t owned a personal computer in years while the last one that I did own was a slow pig grown from some old parts of an even slower pig and some second-hand replacements. So, you can image my joy when I got a shiny, new Lenovo Thinkpad 61 this spring.

One of the joys of once more owning a personal computer is that I don’t have to live through PuTTY anymore. (I used to SSH to the local Debian server here if I wanted to get anything done.) I’ve reacquainted myself with Gentoo and I’m loving it. Of course, there’s a lot more to configure than with Ubuntu (which supports the T61 very neatly out of the box), but that’s the whole point; I want to be able to configure everything my way and I want to update my knowledge about how Linux systems are made up these days. Control.

On the topic of control, the Control key on the Lenovo keyboard, as with many laptop keyboards that I’ve encountered, is in a bit of an awkward position, squeezed to the right by the Function key. Since, I very much depend on the Control key for shortcuts (in just about anything, but especially in libreadline-based programs), I decided to change the Caps Lock key to be an extra Control key. I’ve never actually used the CapsLock key in my life, I probably never will, older keyboards used that very spot for the Control Key, and why not? It’s a much better spot, requiring less gymnastics for my little pinky to reach. Once I considered this I was actually puzzled about why I’ve always wasted such an well-accessible key position.

X

On to the configuration. I wanted this to work in both Console mode and in X. But first X. In the xorg.conf, I went to the InputDevice section for my keyboard and added ctrl:nocaps to XkbOptions. The full XkbOptions line now reads:

Option "XkbOptions" "ctrl:nocaps,altwin:menu,compose:ralt,eurosign:e"

That’s it. I had to take a few more steps to get it to work in the console also.

Console

First, I created a file called “/etc/extra-key-conf” with the following contents:

keymaps 0-15
keycode 58 = Control

Then I added the following to /etc/conf.d/local.start. This is a Gentoo specific script that is loaded by /etc/init.d/local.

[ -z "$DISPLAY" -a -e /etc/extra-key-conf ];
        loadkeys /etc/extra-key-conf &>/dev/null

What this does is to check if the $DISPLAY variable isn’t set (of which we can be sure in this context, but may be useful if you plan to copy this snippet). It also checks if /etc/extra-key-conf exists. If both conditions are satisfied, loadkeys is called with that file as its argument.

In conclusion

I can really recommend this configuration even if your Control key is not awkwardly positioned on your keyboard. Do you use your Caps Lock key? Regularly? If you don’t, this will make your keyboard use more effective.

Reference

If you want to read into this more extensively, I recommend the Remap Caps Lock article from the Portland Pattern Repository.

My CD-RW drive can read everything it writes

The HL-DT-ST CD-RW/DVD drive in my Lenovo T61 laptop, has a certain peculiarity. I was burning an ISO image, wich exceeded the supported size of a standard 80 minute CD by 7 MB. (The image was 707 MB.) Using cdrecord with the -overburn option seemed to work, until I tried to mount the CD-ROM. It would inevitably—

# mount /dev/cdrom /mnt/cdrom -t iso9660
mount: block device /dev/sr0 is write-protected, mounting read-only

Well, that is unexpected! I was going to write that it would refuse with some errors in dmesg about trying to access data beyond some boundary. But I probably messed up something very trivial, because I just can’t seem to reproduce the error in any way as the mount result above shows.

Let’s backtrack everything I did to try to fix this problem.

First, after numerous attempts to mount the 700 MB sized CD, I gave up and asked my little sister to bring me my stack of 800 MB CDs next time she’d come. Of course, over a week went by without her remembering to take the CDs. But eventually, I picked them up myself.

Having retrieved the 800 meg CDs, it came time to test them. Burning went well. Then mounting… A failure with dmesg showing the familiar error (which I now can’t look up because I can’t reproduce the problem ๐Ÿ˜› ). Mounting it in the local server’s drive worked fine, though, leading me to think that my burner can’t read CD-ROMs it has written with overburn enabled.

Luckily, I was wrong. But I really don’t understand why I did get the errors at first. Sure, I did notice a faulty entry in my fstab, but I had also tried mounting it without relying on the fstab (i.e., with mount -t iso9660 /dev/cdrom /mnt/cdrom), which begot me the same error… Also, I had mounted plenty of CDs before this adventure.

All I can do to explain this is to concede that this is one of those problems where you usually call a geek friend telling them you can’t get something to work. They’ll reply by asking you have you tried this and that? Of course I have, at least twice, in the exact same sequence as you describe! Well, humour me then, and try it once more… Fuck! Fuck! Fuck! And why didn’t it work 10 minutes ago?! Don’t tell me you’ve never had this happen to you. Please?

In conclusion, after finding out that the 800 MB CD did work on my laptop, I reclaimed the 700 MB CD as well (which was now serving as a hawk-deflector in the coop) to find out that, even after being exposed to lots of rain and sun for over a week, this CD also mounted without hesitation.

New theme

After upgrading to WordPress 2.5.x, I had to fall back on a stock theme because my old customization of the Sandbox theme no longer worked with the upgrade. But, then, it was time to redo my theme anyway. So here you’re looking at the first version of my new theme. I might have let it stabilize some more before putting it on-line, but who cares? My reader maybe? Let’s just hope he or she doesn’t use IE. ๐Ÿ˜‰

Screencap of my new WP theme Screencap of my new WP theme Screencap of my new WP theme Screencap of my new WP theme Screencap of my new WP theme

Vertical navigation

Ever since the first time that I saw a blog which featured vertical navigation instead of the typical columns, I’ve wanted to implement this for myself. Well, finally…

Site-wide elements use the complete width of the page. The page content is centered in the middle at 87.5%. The identity stuff in the header and the navigation in the footer sits against a back blackground while the content area has the proven black on white for easy reading. I hope that the strong color-contrast as well as the clear difference in with between site-wide elements and page content makes it easy to keep focused on either reading or navigating without distractions.

… and a talkative footer

With this theme, I didn’t want another footer which consist of the odd logo and some loose copyright statements. I wanted a footer which you can actually read, even understand. And who cares if it takes up a little space? It’s at the bottom of the page.

Related posts

I’ve written an (unpublished, unpolished) plug-in which can generate a list of posts that are chronologically related. Traditionally, most blogs have a next/previous post link at the top and bottom of each post. This works very well if you limit your blog to one subject (which is really a very good idea anyway), but if, like mine, your blog is a little bit messy, you could say that someone who stumbled here searching for an article about Subversion is not necessarily interested in the next post if this is a photo of my baby niece.

Hence the chronologically related posts plugin. With this plugin I can say wether I want a link to the first, previous and next post in the blog, within the same category, or matching a given number of tags. (The tag matching isn’t implemented yet, though. Also, matching on meta fields would be a kick-ass ass way to support explicit sequences.)

I put the list generated by this plug-in on top of a blue background besides the various context links of the post.

Issues left

I hope to have the first major revision of my theme ready soon. Here’s a list of some issues that I might address:

  • The CSS renders a bit psychedelically in MSIE 6 (only version I tested) at the moment. Sigh… Let’s just hope that IE 7 will give better results. Then I’ll gladly drop the IE 6 support.
  • When viewing a category, the tag cloud in the navigation panel at the bottom only shows tags for that category. This has to do with the use with me calling the st_tag_cloud() from within the category template.
  • Some of the elements that I just showed to you don’t really look that good and most elements that I didn’t can be said to be … hideously ugly. ๐Ÿ˜• Some highlights: the header (should really be a few cool images), the comment form, and the Next/Previous Page links.

Comment!

I’d almost forget all about the clean, new look of the comment list. And, if you register a Gravatar, your comments will be accompanied by your avatar. Try it. Please!

The joys of being well-known to Google

The “Places” system in the new Firefox 3 is great. I’m still getting more effective usage out of just the location bar every day. But, sometimes I’m on a different computer, or I haven’t been to one of my web pages for a very long time.

How cool is it then that I can just Control+K to my Google search box and enter: bypassing smart completion to get my own page on the top of the result list?

Since my blog is literally a log that I mostly use to keep track of what I think and do while problem-solving, it’s great that I can rely on Google to find my way through memory lane.

« Older posts Newer posts »

© 2024 BigSmoke

Theme by Anders NorenUp ↑