Smokes your problems, coughs fresh air.

Category: Technology (Page 20 of 47)

grml

grml seems like an interesting Debian-based Linux Live CD. It seems interesting because “[it] includes a collection of GNU/Linux software especially for system administrators and users of texttools.”

C++ base 10 to base 26

Last februari/march, I’ve been working again on an old obsession from ten years ago (when I was eighteen): to write a Minesweeper program that could solve very big maps as well or better than the best human player. At the time I did this because I thought that this was actually a million dollar challenge from the Clay Mathematics Institute. Now, I understand that the problem I solved at the time was not actually what was required, but still, once upon a time (such as early this year), I like to revisit the old problem and try to redo my old segfault generator as something that benefits from the fact that I’m now working with 10 years of programming experience instead of 1.

Minesweeper is grid-based, and I wanted to be able to express a coordinate in something more natural than two numbers. My Coords class has a toString() method which I wanted to output a Spreadsheet-like coordinate comprised of a letter (for the column index) and a number (for the row index). It took me some time to find a nice method to convert an integer to hexavigesimal. (Hexavigesimal is base 26 and 26 happens to be the number of letters in the English alphabet.)

This is what I ended up with:

std::string
Coords::toString()
{
    Coord x = getCol()+1, y = getRow()+1;
    int dividend = x;
    int modulo;
    std::string base26column = "";
 
    while (dividend > 0)
    {  
        modulo = (dividend - 1) % 26;
        base26column = (char)(65 + modulo) + base26column;
        dividend = (int)((dividend - modulo) / 26);
    }
 
    char row[(y / 10) + 1];
    sprintf(row, "%d", (int)y);
 
    return base26column + row;
}

I used the following sources:

Maybe I’ll soon start fooling with this again. Finishing this draft of eleven months old actually makes my fingers ache to play with a real close-to-the-metal programming language again. An over-engineered minesweeper clone in C++ might be fun to play with some more.

Zimbra has no shutdown init script on Debian and Ubuntu

There is a K01zimbra in rc6.d for reboot, but not in rc0.d. See this bug report I made.

Workaround:

cd /etc/rc0.d/
ln -s ../init.d/zimbra K01zimbra

I noticed that after an upgrade, the bootscript was gone again, so I made this cron task and put it in cron.daily:

#!/bin/bash
#
# Zimbra bug: no rc0 bootscript: http://bugzilla.zimbra.com/show_bug.cgi?id=54099
#
# The bootscript I put there gets removed upon upgrade, so I put this script in
# place which mails root if it is missing.
#
# The bug is fixed, but in 6.0.10 it still wasn't there, so I don't know when
# it will be included in the release.
#
# Install it in /etc/cron.daily.
 ! [ -e "/etc/rc0.d/K01zimbra" -a -e "/etc/rc6.d/K01zimbra" ];
  message="Kill zimbra bootscript not found in either rc0 (shutdown) or rc6 (reboot)."
  "$message"
  "$message" | mail -s "Zimbra bootscript error" root

Enabling quota on a journalled ext3 file system on Debian

Source. And a source for non-journalled quotas.

aptitude install quota

Edit fstab to make the proper entry look like this:

/dev/sda2       /               ext3    errors=remount-ro,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0 0       1

I don’t know if errors=remount-ro is a default option that will be enabled anyway. I would guess so.

Do this:

touch /aquota.user /aquota.group
chmod 600 /aquota.*
mount -o remount /

Then:

quotacheck -avugm
quotaon -avug

WIth this command, you can set a 1GB quota for a user:

setquota -u $user 0 1000000 0 0  /

Other tools of interest: edquota, repquota. See the seealso for any quata command, I guess.

Xen console name on different kernel versions

I’ve just been struggling to get a xen console working for Ubuntu 8.04 (hardy). By default, xen-create-image uses hvc0, but that’s only since kernel 2.6.26 (don’t know if that’s only pv_ops or xen-patched). Hardy uses 2.6.24 and therefore it’s xvc0. The xen-create-image command or xen-tools.conf config file therefore need a parameter serial_device=xvc0.

« Older posts Newer posts »

© 2024 BigSmoke

Theme by Anders NorenUp ↑