Archive for the 'Personal' Category

"Worriors" – worries outsourced

Wednesday, January 25th, 2006

Everybody has worries, which stay in our minds. For example, Currently, I am worrying about at least a dozen of things (maybe Poles are a worrying nation, or it is just me, don’t know) and, you must admit, it’s hard to stay productive being occupied with worrying.

Hence, during our lunch discussion yesterday we came up with the idea of worriors, to whom you can outsource your worries. To be completely honest this idea came from My Outsourced Life, I think the notion of “worriors” is ours ;-)

The idea is to have a website, where you can submit your worries, which a professional worrior (human or automated) can worry about. You can log in and check what they are currently worrying about or maybe even sign up for a comforting e-mail:

Don’t worry.
We are currently worrying about <> for you.
Yours professional worriors”

This can also be a “worries outlet”: discussions, support groups and of course a great chance for advertising.

TaskJuggler – a project planner software

Tuesday, January 24th, 2006

TaskJuggler is an extremely powerful open-source project management software. Unlike other tools of this sort it is almost completely text-file driven and batch mode (yes, it has a nice GUI as well, but the operation is editing of the text project file). Also, the reports it generates are completely scriptable (actually there’s no other way of doing them). This is different from you’d expect, but maybe for us geeks it’s better to have something that works this way? ;-)

It is really powerful and looks actually usable (unlike some other open-source projects like planner, which aspire to be but are IMO not even close).

Additional advantages I see are: - easy to track changes if you keep the project file in CVS/SVN - can easily script it, so that you can see your project status on the website?

Maybe I will use one day? ;-)

BetterShoppper FireFox plugin

Saturday, January 21st, 2006

Bettershopper is a really cool plugin showing doing automatic price comparisons on amazon.com for a number of amazon.XX, alibris or other sites and converts them to your favorite currency. Saves a lot of time and money ;-)

I’ve been using version 1.1, which at some point stopped working :-( Now I discovered that version 1.2 is on its way and you can download 1.2beta2, which works great for me (you can get it here). BTW: it also works with FireFox 1.5.

Great idea and execution. Well done! Looking forward to trying 1.2 out!

Gallery2 – removing "302 redirects".

Monday, January 16th, 2006

I noticed that our Gallery2 webpage has been ignored by Google Images. I researched this topic a bit and found the list of search engine optimization tips for Gallery, among which there was a line about avoiding “302 redirects”.

As it turns out Gallery uses a “302 redirect” to load main.php on the initial load and it is also redirected from index.php, which is claimed to incur some anti-spam penalties for the Google engine. I don’t know whether this is true or not, but to be on the safe side, I decided to remove the reidirects.

Here’s what I did:

  1. Move my site-specific index.php somewhere else.
  2. ln -s main.php index.php
  3. Add the following line in the site-specific config.php:

    define('GALLERY_MAIN_PHP', 'index.php');
    

Everything seems to work now. We will see in a couple of weeks how well it works for the search engines ;-)

Upgrading WordPress1.5.2 to WordPress2.0—my account

Sunday, January 15th, 2006

The new WP2.0 has been out for more than two weeks now and seeing there haven’t been any urgent patches/bug fixes/etc I assumed it is mature enough to be upgraded. Other than that, it seems like a perfect Sunday procrastination task ;-)

I basically followed the official WP upgrade instructions, but as my WP has been somewhat customized, I had to do some extra steps. Here’s what I did:

  1. Backup the database, disable the plugins (SK2 and Markdown).
  2. Move the old WP directory to blog-old.
  3. Install a new blog directory, fix permissions, copy the configuration files.
  4. Upgrade the blog using upgrade.php script.
  5. Check that everything almost works ;-)

That was easy. Now the difficult part.

First, my theme has been somewhat customized (including Diego’s “linky” patch). However, even if WP2.0 still uses WP1.5 theme, some things have been changed (don’t know exactly what and why). To port my changes, I used the following procedure:

  1. Create a diff against “vanilla” WP1.5.2.
  2. Apply the patch on the new WP2.0.
  3. Fix those little changes that didn’t merge.

Second, I once fixed a bug in WP1.5.2 concerning categories counts on the main page. Basically the problem is that the counts reflect only the “posted” posts and the private posts are not counted. However, when you are logged in and click on a given category you get to see all the posts, also including the private ones. Similarly, (sub)categories containing only private items do not show. The patch for WP1.5.2 was basically a one-liner, but it doesn’t work in WP2.0 :( Looking at the relevant file, it turned out that the new version uses precached counts stored in the database, instead of computing them dynamically. Hence, the patch doesn’t and cannot work. There also doesn’t seem to be an easy way of fixing it, so it has to stay the way it is.

Third, I had to upgrade SpamKarma2.0 to SpamKarma2.1 (I still doesn’t want to use Akismet, which is shipped by default in WP2.0).

Fourth, I upgraded Markdown plugin, to a new verison and disabled the new WYSIWYG editor (seems to conflict with Markdown).

Finally, I made a small fix to “linky” code, as it also conflicts with Markdown plugin. As the linky doce uses wptexturize to get the content of the entry Markdown is not converted correctly. I changed wp_texturixe to apply_filters('the_content',...) as the latter calls the plugin conversion function. However, in this case I had to remove extra p tags, or more precisely, remove all p tags alltogether. Finally the code looks like this:

<li id="p<?php the_ID(); ?>">
    <?php echo preg_replace('{</?[pP]>}', '',apply_filters('the_content',$post->post_content)); echo ' '; comments_popup_link('(0)', '(1)', '(%)')?> <?php edit_post_link('(e)'); ?></li>
</ul>

Actually, this had nothing to do with the upgrade, but it was high time I did it.

Now WP2.0 works well for me. It’s slightly more polished on the editorial side, uses some flashy AJAX stuff and has a new theme. It is probably a bit faster, but other than that looks very much like the old version to me ;-)

UPDATE: My old “press it” bookmarklet stopped working. I generated a new one (from the bottom of “Write Post” page) and… it doesn’t look that cool anymore, but it works.

Messing up with command-line arguments in Bash: $*, $@, "$*", "$@",…

Thursday, January 5th, 2006

It’s stupid, but it took me a good hour to figure this out, so maybe I’m not the only one…

I’ve recently had a problem with command-line arguments in my Java program. The problem was that command line arguments containing spaces were parsed incorrectly, i.e. chopped into individual arguments. My initial suspect was gnu.Getopt package I use for parsing arguments, but as it turned out I was wrong.

The real culprit was a shell wrapper script I used to wrap my java code. The code was the following:

java <some parameters> <programm.class> $@

See the problem? I didn’t. You need quotes around "$@" in which case the parameter gets expanded to: "$1" "$2" "$3"... With no quotes the shell expands it to $1 $2 $3, hence all parameters containing spaces get chopped (also globbing takes place in this case).

BTW: There’s also "$*" which is used to combine all parameters into a single one, i.e, "$*" expands to "$1c$2c$3c..., where c is $IFS (or space). Here it’s also important to have it enclosed in quotes.

Thinkpad power supply replacement

Thursday, December 22nd, 2005

Coming back home for Christmas I forgot to bring my power supply for my Thinkpad, which made me very unhappy. Hesitating between not switching my computer on at all (BTW: I forgot my books as well ;-) ) and getting an expensive power supply, I come up with a home-grown solution.

Thinkpads are quite power-demanding beasts: the power supply has to deliver as much as 16V DC at 4.5A, which rules out most of the non-impulse power supplies you can get. Also 16V is a bit uncommon for any supplies. Fortunately, I noticed that our hallogen lamp uses a 50W transformer, which was almost ideal for my purposes. So I built a simple rectifier and… voila ;-)

Thinkpad Power supply Replacement

BTW: 4Amps is quite a current so need to make sure that you use proper diodes, large capacitor and thick cables (there’s about 0.5V voltage loss on my cables).

Converting JARs to executables (JAR to EXE)

Thursday, December 22nd, 2005

Recently, I found out that Java the program I wrote ages ago has been alive and kicking and, even more, distributed as a single EXE with an install program. I was a bit surprised, as the last stage I left it it, was only a JAR file (with no sources available) ;-)

Looking a bit into it I found out how it can be easily done, which may be useful one day. Not that I want to write Windows programs, but…

  • The installation can be done using Install Creator. The freeware version displays a small ad at the end of the process, but otherwise is free and looks ok.
  • For the Java-to-EXE conversion there’s a nice comparison and discussion. In this particular case they used exe4j, which is commercial, but there’s a number of other free tools around.

All in all, I must admit they did a good job making my program more user friendly and easier to use. It’s probably a good idea if your target users use a Windows platform (my original program is portable, but I’ve never seen anyone use it on anything but Windows)…

Meaningful plots from connection statistics (using conn2db2csv.pl)

Monday, November 28th, 2005

Now that I have the infrastrucutre for asking meaningful queries, here’s what I could be interesting in. These can be nicely scripted and shown on the webpage using CGI (all these are sliding windows with no input parameters, thus no worries about SQL injections).

BTW: I know this SQL is ugly like hell, but the framwork is really flexible and these queries are very easy to write. Here they go:

(more…)

Storing and plotting connection summaries in the database

Monday, November 28th, 2005

Since a while I have been (experimentally) running Bro on my server collecting connection summaries. This is a very nice feature of Bro, generating really accurate TCP flows (including information whether the connection was terminated correctly or not and others). The big advantage of connection summaries (over e.g. NetFlow) is their high accuracy and yet compact representation (for over 2 months ov data, I have only 21MB (250k lines) of data.

I wrote a simple perl parser parsing Bro’s connection status and writing it to a relational database (in this case Postgres). The parser can also run in “query” mode, producing a comma/space separated data for easy visualization (using AfterGlow or even GnuPlot).

Here’s how I run my collection: sudo bin/bro -i eth0 -f "host 85.10.194.212" conn

And parsing: tail -f conn.log | ../conn2db2csv.pl -i -d "dbi:Pg:dbname=bro;host=localhost" -u bro -p <password>

And plotting: ./conn2db2csv.pl -q "select time::date,dport, sum(brecv) from conn where dip='85.10.194.212' group by 1,2 having(sum(brecv) >0) order by 1,2" -d "dbi:Pg:dbname=bro;host=localhost" -u bro -p <password>

This can be nicely used by gnuplot. For example to plot daily traffic on let’s say port 22: ./conn2db2csv.pl -q "select time::date, sum(brecv) from conn where dip='85.10.194.212' and dport = 22 group by 1 having(sum(brecv) >0) order by 1" -d "dbi:Pg:dbname=bro;host=localhost" -u bro -p <password> -s ' ' > testplot

gnuplot set timefmt "%Y-%m-%d %H:%M:%S" set xdata time plot 'testplot' using 1:3