irssi encoding problem.

If you have a problem with encoding in irssi there is an easy way to fix it.
In my setup I am running irssi inside a screen session and connecting from windows7 computer via Putty.

First of all you have to make sure your Putty has correct encoding set, you can check it in configuration dialog under Window -> Translation page.

Second thing you need to do is to start screen with unicode support, you can do this with -U switch.

Third and the last thing you need to do is to set correct encoding in irssi itself, just do /set term_charset utf-8 in chat window.

From now on your irssi should have full unicode support.

WordPress 3.3.1 update.

Yesterday an security update for wordpress has been released. It fixes 15 minor issues and one XSS vulnerability. It is strongly advised to update your wordpress if you have installed your blog using an IP address (http://x.x.x.x/wp-admin/) instead of domain name (
This flaw can render your blog an “infected” nasty place which could serve your users unwanted content.
In my case it was a real issue so this blog is already patched up, I advise you to do the same!


Today I’ve encountered a very strange error which was quite similar to Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in….
At the first look I thought it’s a joke from the second programmer I’ve been working with but I was wrong.

This error is addressing to Scope Resolution Operator (::).
The problem is that this error can happen in quite unpredictable places – like in my example:

	$mediumlimit = " AND (Media=0 OR Media=2)";
} else {
	$mediumlimit = " AND (Media=0 OR Media=1)";

Line if(defined(IPHONE)){ was throwing an error.
When I’ve added quotes around IPHONE constant name the error was gone!

Sometimes error messages can cause headache when they are weird and completely not related to actual code – god bless google for letting me fix it in no time!

UTF-8 filenames under Windows / PHP

If you read this, probably you have problems with files with names containing unicode characters.

My scenario was simple:

  1. User uploads own file with unicode characters (ex. my_unicode_ąść.jpg)
  2. PHP handles the upload and moves uploaded file to a directory on your server and creates a database record with original filename(ex. my_unicode_ąść.jpg)
  3. Because lack of unicode support in PHP filename is saved with wrong encoding (multibyte string is split into one-byte characters, which in case of unicode multibyte encoding renders wrong, ex. my_unicode_ść.jpg)
  4. Any future call using database stored name fails because two names are different.

To get rid of this problem I have used PHP UTF8 library.

It is as simple as that:


From now on, before working with filename, first we change any unicode character to it’s closest ASCII version.

We have to do this and patiently wait for PHP6 release, which promises native UFT-8 support.

Windows 7 full screen games problem.

If you own a computer with realtek audio chip, probably you experienced an issue with full screen games (like GTA:SA or NFS:MW).

My games, when ran fullscreen were minimizing every few seconds preventing me to play. No solution I found on the internet was working in my case so I decided to try my luck on my own.

After countless restarting / killing processes I could find a process which receives focus each few seconds causing my games minimize to desktop.

Malicious process name is:


You have to kill that process in order to have uninterrupted gameplay, this saved me alot of time and allows me to play again my favourite games!

SA-MP 0.3d released!

Few days ago new version of SA:MP has been shared with us, here is a list of changes:

  • Support for Shoutcast/Icecast audio streams.
  • Major performance improvements and smoother game-play.
  • Improvements to sync, including vehicle passengering and motorbikes.
  • New models, including a replacement mall, hot air balloon, fireman hats.
  • You can surf on objects attached to moving objects and objects attached to vehicles.
  • Servers can remove static buildings from the map.
  • Moving objects can now rotate smoothly.
  • Many new scripting functions and callbacks for SA-MP servers.

From my point of view, synchronization is much improved in comparison to previous versions. Also interesting new features are support for shoutcast streams and removing static buildings from map – both can lead to totally new experience in GTA:SA world!

Looking forward to see gamemodes taking advantage of those new features, it will be interesting!

You can download it from here.

Flash dropping session cookies

If you have ever used SWFupload with PHP application using session authentication you could run into similar problem.

SWFUpload is a small JavaScript/Flash library to get the best of both worlds. It features the great upload capabilities of Flash and the accessibility and ease of HTML/CSS.

Your users are able to upload multiple files using flash uploader after they log into your website. While their browser have no problem with cookie / session handling, flash application ignores session id and in the result, instead of typical ajax result – your reply from server will contain a page with a login form.

This is a very old bug(?), reported back in 2007 (or even before), still available in newest flash player.

Bug affects following browsers / versions:

  • Firefox / Opera / Chrome
  • Flash player 9
  • SWFUpload v2.2.0.1
I have no information on other versions but it seems like bug affects every non-IE browser and every flash player version

There are few workarounds out there, according to Evert Pot and his blog.

In case you are working on a bigger project, where you cannot simply override authorisation I suggest simply upgrading SWFUpload to SWFUpload v2.5.0 Beta 3 – it should do the trick, but beware that it is still beta, unstable version!

I’ve spent too much time to debug this, so for all of you going the same way – please follow my guidelines so you can spend additional hours with your family.

Drop huge amount of emails under linux

Last days I’ve run into an issue with customers email server. It was running very slowly so I’ve had to take a look at it.
Problem was caused by cron jobs sending error emails – 2 errors every 10 minutes.. since ’09..
This caused over 138,000(!) unwanted emails. I didn’t want to spend months at webmail deleting ~30 emails at once so I’ve quickly jump to shell and run rm *. I was quite suprised (I’m a linux noob) that it caused an Argument list too long error. find command ended up with the exactly same error message.

I thought I would try the workaround – bash script.

[~/mail]# nano remove.all
for file in ./cur/*
rm $file
echo removed $file
[~/mail]# chmod +x remove.all
[~/mail]# ./remove.all

After about 20 minutes script has ended and it worked as it supposed to. Hooray!

I know there should be much easier way like drop whole directory instead, point of this way is to try out bash loops.