• Skip to site navigation
  • Skip to content
  • Skip to sidebar
  • Skip to footer
  • Go to archive page
Shadowmaster’s Lair
A light in the darkness, where everything is possible...
  • Home
  • Projects
  • About
  • Contact
  • Blog [ frontpage ]

Stop the planet Earth, I want to get off!

Sunday, February 28, 2010

The Wi-Fi WLAN router I use for connecting to the Internet stopped working last night (that dreaded “No route to host”). It's back now, but I'd have liked to post an update yesterday. Anyway, no news is good news, no? Er, well, assuming that the communication systems work, that is...which sadly seems not to be the case for the location of the epicenter, Cobquecura.

It's been more than 30 hours after the earthquake that caught me in the bathroom some minutes after 3:30 am yesterday. The aftershocks, while generally small, continue every 5-90 minutes, and at this point it just feels like one long ride on a bus through a badly deteriorated road — and it's getting fucking annoying.

I'd said that we were okay before. First I was scared when all this happened, and then I was sad after the news. Next, I was worried about the aftershocks. Now I'm just annoyed. Really annoyed.

Nonetheless, I'm not letting an earthquake and a never-ending sequence of aftershocks stop me. There's some groundbreaking work going on here — which you can't see, but I can, and I must say it looks really nice.

Now, could we just stop this madness and allow the rescue groups do something in the most affected locations near the epicenter without having the ruins of the buildings shaken every few minutes by a whimsical force of nature? That's not nice, really. Not nice at all. And you've got our dogs and cats panicking for too many hours a day and a half already. Stop it! I mean it!

Posted in Miscellaneous, Personal at 16:55 UTC | No comments »

Earthquake in Chile

Saturday, February 27, 2010

As you probably know (if not, Google “earthquake in Chile”), Chile's been struck by an earthquake approx. 8.8 in the Richter scale in the region near Concepción. I live in Santiago, and we have also been affected by this unfortunate event.

(Following comes from this Wesnoth.org forum post, now missing due to the former autopruning mechanism.)

I am OK right now, but I got trapped in the house during the earthquake (I was in the bathroom and some _really_ heavy objects were in the way to the kitchen, which is the closest way to exit from my bedroom) and thought I wouldn't be able to get out in time. I did (about right at the end of the earthquake, not knowing at the moment if its intensity would continue increasing...), but we are not sure whether the house deteriorated further* or not and do not really believe it'd resist a real earthquake with epicenter near Santiago.

There's a good distance between Concepción and Santiago, so it was about 7 in the Richter scale in Santiago according to the authorities last time I checked — about 10 am via FM radio on the car, we didn't have electricity, tap water or Internet at all until around 2 pm and I fell asleep around 1:16 pm after being unable to sleep the whole night with the strong and continuous tremors that followed. I originally posted this around 6:40 pm.

While everything's fine for us here right now, sadly, other areas of this same region didn't have this luck. Including areas where some of our family lives.

Naturally, everything to the south is chaos according to the news and there are still isolated people in coastal areas closer to the epicenter.

* (To elaborate, this wood house was built on 2000-2001. However, we know that the concrete floor structure wasn't properly finished or secured, there are cracks everywhere that have appeared over time since we moved here; heck, I've even seen grass grow in the middle of my bedroom in 2002. The wood structure of the second floor isn't finished and there are heavy materials left above since a few days ago that made me worry that the house would fall on me when I was walking into the approximate center of gravity in middle of the earthquake, hearing them dancing on the floor (huh) above. All the animals are nervous after the earthquake but everyone's okay and I'm thankful for that.)

***

There are still tremors as of this writing. There was a small one which cut the power lines for 1 second some minutes ago, followed by a stronger one with lots of underground noise. The movement pattern continues being the same as the original earthquake. Internet is flaky.

If anyone's really interested in speaking to me, I've temporarily opened ##shadowm on irc.freenode.net.

Posted in Miscellaneous, Personal at 22:41 UTC | No comments »

Dorset3

Saturday, February 27, 2010

Almost two months after the completion of the “Dorset2” template, the website's appearance has changed again! This time it's “Dorset3”, with soft borders and shadows!

A couple of screenshots for comparison:

  • Dorset2 r1
  • Dorset3

There's not much new besides the aforementioned (or is there?). IE 6 support was surprisingly easier to provide this time — except for a few template glitches in the blog which I haven't yet solved. Anyway, it's 2010 and you don't really want to use a 8-years old browser, do you? :)

Posted in Miscellaneous, Personal, Site updates, Web design at 04:02 UTC | No comments »

Rewriting the past, and the woes of SVN

Wednesday, February 10, 2010

Long ago, I wrote a little Bash script — set-properties — for the Wesnoth-UMC-Dev project, to ensure the correctness of SVN properties such as svn:keywords and svn:executable on files. It was pretty simple:

#! /bin/sh

# Set properties on PNG files
for f in $(find -iname *.png); do
    svn propdel svn:executable $f
    svn propset svn:mime-type image/png $f
done

# Set properties on Ogg files
for f in $(find -iname *.ogg); do
    svn propdel svn:executable $f
    svn propset svn:mime-type audio/x-vorbis
done

# Set properties on PCM files
for f in $(find -iname *.wav); do
    svn propdel svn:executable $f
    svn propset svn:mime-type audio/x-wav
done

# Set properties on JPEG files
for f in $(find -iname *.jpg); do
    svn propdel svn:executable $f
    svn propset svn:mime-type image/jpeg $f
done
for f in $(find -iname *.jpe); do
    svn propdel svn:executable $f
    svn propset svn:mime-type image/jpeg $f
done
for f in $(find -iname *.jpeg); do
    svn propdel svn:executable $f
    svn propset svn:mime-type image/jpeg $f
done

# Set properties on CFG file
for f in $(find -iname *.cfg); do
    svn propdel svn:executable $f
done

# Set properties on scripts
for f in $(find -iname *.sh); do
    svn propset svn:executable '*' $f
done
for f in $(find -iname *.cmd); do
    svn propset svn:executable '*' $f
done
for f in $(find -iname *.bat); do
    svn propset svn:executable '*' $f
done
for f in $(find -iname *.py); do
    svn propset svn:executable '*' $f
done

Some time after I learned Perl with my work on Shikadibot 0314, I rewrote that script in Perl to arrange the “ideal” property values in a neat table (hash), check current properties instead of blindly overwriting them in the working copy, and cover plenty of other file types. It also gained a blinking progress bar to display the search progress for some reason.

To have an idea of how known file types are defined in the source, let's take a look at these bits:

#
# proptab:
#   extension => [svn:executable, svn:mime-type, svn:eol-style, svn:keywords]
#   properties set to the empty string '' (except svn:executable) are left unchanged;
#
my %proptab = (
    cfg     => [FALSE, '', 'native', ''],
    ign     => [FALSE, '', 'native', ''],
   "map"    => [FALSE, '', 'native', ''],
# [...]
    pl      => [TRUE,  '', 'native', 'Author Date Id Revision'],
# [...]
    gif     => [FALSE, 'image/gif', '', ''],
    png     => [FALSE, 'image/png', '', ''],
# [...]
    xcf     => [FALSE, '', '', ''],
# [...]
);

The table we have used since then (around Sept. 2008) has always contained more than 10 extensions with their minimum required property sets. As of this writing, it covers approximately 57 file types. Keep this on mind.

It would be overkill to fork-exec find processes to discover paths that could require SVN property changes, right? So, instead, I used find2perl to generate File::Find client code to embed it into set-properties. So far, so good. But how about running that code (scalar keys %proptab) times (e.g. number-of-extensions-times) anyway? Overkill?

No! It's plain stupid. But definitely less stupid than what you are about to read.

I apparently decided, for some reason, that any matching paths in each cycle should be added to a plain scalar (a text string to be exact) separating individual paths with newlines, of all things. Then, another cycle is performed at the end, (scalar keys %proptab) times again, to put each array of paths matching a certain extension into another hash, then iterating over the newly inserted hash element (array of paths) checking and fixing SVN properties in the same cycle.

Very roughly summarized as the following pseudocode:

FOREACH extension FROM file_extensions
    FIND IN ./ AS file
        ; all while displaying a cute blinking bar!
        IF file MATCHES extension
            APPEND file TO file_list_string
        END IF
    END FIND
END FOREACH

FOREACH extension FROM file_extensions
    ; split 'file_list_string' every newline
    FOREACH path FROM (SPLIT /\n/ file_list_string)
        INSERT path IN file_index[extension]
    END FOREACH

    FOREACH path FROM file_index[extension]
        fix_properties( extension, path )
    END FOREACH
END FOREACH

Careful readers will quickly realize that something is horribly wrong with this pseudocode. I wish I was making it up. This algorithm has actually been in use by the Wesnoth-UMC-Dev set-properties script for one year and 4 months! I must have been on something when I wrote this shit. I've honestly never seen any program so awful as this in my life. Not even build-external-archive.sh (a.k.a. “Scrappy”) can compete with this abomination.

So, yesterday, I took a look at set-properties after noticing how much CPU time it ate working with very scarcely populated directories of the project — and I was blaming the usage of backticks (`svn propset foo bar baz` and such) as a possible cause of overhead. Then I slowly realized what I had written. There isn't any emoticon here for the expression in my face at that moment.

Thusly, set-properties got rewritten with a much cleaner and simpler algorithm:

FOREACH file FROM (FIND IN ./)
    ; no more useless cute blinking bar!
    FOREACH extension FROM file_extensions
        IF file MATCHES extension
            fix_properties( extension, path )
        END IF
    END FOREACH
END FOREACH

So yeah. :(

But wait, there's more! While optimizing replacing the script I also replaced `svn foobar` backtick code with invocations of libsvn, via the SVN::Client module. This worked very well at the end, but I discovered a few things in the process:

  • Those SVN::Client methods I used choke on non-absolute path specifications for some reason, causing an assertion failure in libsvn's C back-end and terminating the execution of Perl and the script with a SIGABRT.
  • Despite the documentation's claims for SVN::Client::url_from_path() returning undef if the specified path is not under version control, it actually causes the module to invoke die and get the client script terminated. Which means that I cannot even check if a file is versioned or not safely (e.g. without resorting to .svn/text-base/FileName.svn-base existence checks). What the hell?
$ set-properties
perl: /tmp/buildd/subversion-1.6.9dfsg/subversion/libsvn_subr/path.c:114: svn_path_join: Assertion `svn_path_is_canonical(base, pool)' failed.
Aborted

Turns out the solution is to wrap SVN::Client method calls in eval blocks and handle whatever crap SVN comes up with. Oh, and make sure all paths are absolute using Cwd::realpath so that libsvn doesn't hit an assertion failure killing us, eval or no eval. How nice.

# No point in working with unversioned files.
my $svn_ret = undef;
eval { $svn_ret = $svn->url_from_path($path) };
if($@) {
    # fucking libsvn dies if $path isn't under version control;
    # the documentation says it should return undef above instead!
    return;
}

With this, I have absolutely lost my faith in Subversion's excellence as a version control system not only as a normal user, but also as a programmer integrating it into my own client applications. And I know I lost my faith as a user after seeing svn sit for two days doing fucking nothing because the damned connection died after 1 minute of running time — and then svn spent the next days ignoring SIGTERMs all the time, no less. It's been like this for so many versions that I'm almost convinced it's intentional.

(Ah, that was relaxing. I should do this more often.)

Wesnoth-UMC-Dev has to continue using SVN because we have several add-on authors using Windows and the few alternatives for using git (I love git, I don't think I could try anything else at the moment) on Windows seem to be rather awkward to install and/or use for the average Nonc O'mputer Person. That's a pity. It's really a pity.

Finally, set-properties got renamed to umcpropfix for a change, to mark its rebirth after I solved the algorithmic mess above last night. It doesn't have a nifty codename like the rest, though, but the new umc-prefixed name is still something to be celebrated now that we are going to have umcdist, umcstat, umcreg and umcbotd. Yes, I know I'm crazy, thank you.

Posted in Software, Wesnoth, Wesnoth-UMC-Dev at 20:50 UTC | No comments »

Throwaway code

Tuesday, February 9, 2010

It has become increasingly common for me to come up with a program for an amazing task one day, to rewrite it the next day.

umcdist, the Wesnoth-UMC-Dev Distribution Tool, has been in development hell for a year mostly for this reason; the other reason is that it seems like it will perform worse than build-external-archive.sh a.k.a. “Scrappy” due to an excessive usage of Perl's system function. I cannot make up my mind and choose between performance and maintainability; Espreon knows that build-external-archive.sh is broken, but I can't be bothered to try to understand that awful piece of Bash unholy abomination again to fix it.

Meanwhile, umcstat (Wesnoth-UMC-Dev Statistics Service) is still a work in progress, but with more emphasis in progress; there's actual code written already, and I've been using freenode's Eir bot framework to test it.

While Eir could possibly be a nice way to get rid of umcreg's Net::IRC dependency and code, it's actually a C++ program that can be compiled only with GCC 4.4 at minimum, due to at least one C++0x feature used throughout the code: auto. The target machine runs Debian lenny, unlike my laptop (Squeeze), and therefore doesn't have GCC 4.4!

Instead of sticking with Eir, I'm refactoring umcreg's IRC code into a custom Perl-only framework, umcbotd, and making creative use of eval writing an abomination code-named “Naia”, which I'm rewriting again because the first version I wrote, which worked, was very badly designed and ugly. I know it's a problem when I have three classes or modules all depending upon each other's internals.

The goal of umcbotd/Naia is producing a Net::IRC-based abstraction layer for our bots that treats them as “services” with multiple “modules” (not in the Perl sense, though) that can be easily inserted and removed from the system by adding/removing their files. umcreg already runs with a prototype implementation of this mechanism, but it needs to be generalized further before it can be usable with Naia.

Writing our bots could be this simple, if Naia gets completed:

#!/bin/true
CO_SERVICE_COMPONENT('umcreg');

sub ctcp_version_reply () { "Wesnoth-UMC-Dev Registry Service, using " . Naia::version_string() }

sub eh_ctcp_version
{
    my ($self, $event) = @_;
    $self->ctcp_reply($event->nick, 'VERSION ' . ctcp_version_reply());
}

# ...

my $bot = Naia::get_bot('umcreg');
my %eh = (
    'cversion'      => \&eh_ctcp_version,
    'msg'           => \&eh_msg_private,
    '330'           => \&eh_whoisloggedin,
    '318'           => \&eh_endofwhois,
    '331'           => \&eh_notopic,
    '332'           => \&eh_topic,
    '403'           => \&eh_nosuchchannel,
);

$bot->connect();
$bot->register_event_handlers(%eh);

And their modules would be like this, more or less the same as umcreg's modules already are:

#!/bin/true
# token, subroutine, privilege level (A: admin, H: half-admin, U: user)
CO_MODULE('RAW', \&co_raw, 'A');

sub co_raw
{
    my ($parent, $nick, $hostmask, $svaname) = (shift, shift, shift, shift);

    if(!@_) {
        $parent->notice($nick, "Not enough arguments for \002RAW\002.");
        return;
    }

    $parent->sl(join(' ', @_));

    broadcast_to_log("RAW [$hostmask]");
}

... And of course it would still involve lots of ugly stuff under the hood (eval magic), but if done right I shouldn't have to touch it whenever I wanted to add or remove a feature from any of our two services.

Posted in Personal, Software, Wesnoth, Wesnoth-UMC-Dev at 02:03 UTC | No comments »
(Page 1 of 1, totaling 5 entries)
« February '10 »
Mo Tu We Th Fr Sa Su
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
  • Recent posts
  • Archives
Twitter
  • @Grickit Ajax? http://is.gd/f3j4A1 hour ago
  • It's a sad thing that fontconfig's existence isn't helping me with keeping consistent font rendering rules here.21 hours ago
  • Apparently, the connectivity issues with my website have been solved...1 day ago
  • To #Wesnoth users who are looking at the Mainline Campaign Feedback forum right now: no, you aren't hallucinating.1 day ago
  • Connections to my website are still not working correctly here, even from the university's network. I guess some routing problem...1 day ago
  • My website, and nearlyfreespeech.net's blog, are still taking forever to load here. I guess I'll have my 1:30 minutes of sleep.1 day ago

Follow me

Categories
  • Frogatto
  • Hardware
  • Miscellaneous
  • Personal
  • Site updates
  • Software
  • Web browsers
  • Web design
  • phpBB
  • Wesnoth
  • Wesnoth-UMC-Dev
  • freenode
All categories
Syndication
  • XML RSS 1.0 feed
  • XML RSS 2.0 feed
  • ATOM/XML ATOM 1.0 feed
  • XML RSS 2.0 comments
Projects
  • Frogatto levels
  • Wesnoth add-ons
  • Wesnoth Team Colorizer
  • Wesnoth-UMC-Dev Registry Model
  • Shikadibot 0314
  • Miscellaneous
    • Irssi scripts
    • phpBB 3.0.x hacks
Links
  • Frogatto & Friends
  • Battle for Wesnoth
  • Wesnoth-UMC-Dev
  • Grickit’s blog
  • Turuk’s blog
  • The Monochrome
Frogatto & Friends
Serendipity PHP Weblog
Valid XHTML 1.0 Transitional
Copyright © 2006-2010 by Ignacio R. Morelle. All rights reserved. Powered by Poison Ivy/Dorset3 r5 and Serendipity.
Hosting by rewound.net and NearlyFreeSpeech.NET.
The opinions expressed herein do not represent those of any of the projects and organizations the author might be affiliated with, unless otherwise stated. The author is not responsible for the content hosted by external websites linked from this site. All software, documentation or instructions of any fashion are provided as is, and under its own license terms. Use/read/eat/drink at your own risk.