[en] Fix PNG images dark in IE

IE can’t do anything right. If you save some graphical elements to PNG, and try to put them on an area with CSS-defined color, there will be a difference even if you used the same color in the PNG — IE renders PNGs darker than it should. The reason for this is misinterpretation of gAMA frame saved in PNGs that makes it possible to better color-match pictures. The fix is to remove this frame, and doing it on Ubuntu is as easy as:

aptitude install pngcrush
cd your-graphics-directory
mkdir fixed
find . -type f -exec pngcrush -d fixed -rem cHRM -rem gAMA -rem iCCP -rem sRGB {} \;

Now you have a „fixed” directory where you have PNGs that will work properly in IE (and are a bit smaller which is a nice side effect). If you’re sure they’re ok, just do

mv fixed/* ./
rmdir fixed

That’s all.

[en] Fix irregularity of Java Timer and ScheduledThreadPoolExecutor

Using Java Timer class one can schedule a task for recurring execution. Even though ScheduledThreadPoolExecutor makes it possible to create timers with nanosecond resolution (but beware of underlying operating system clock precision!), regularity of task execution is by default awful.

I have run into this once and had to explain the customer that it’s not fixable. When I measured the delay between timer executions, etc. it turned out that doing as much as new Thread(runnable).start() usually takes 1-5 milliseconds, but at times it takes two orders of magnitude longer: even half a second!

Same customer, other project and this time I thought of a reason for this behaviour: garbage collection. I started with calling System.gc() explicitly inside measured code and it takes 200-500 milliseconds! So it must be it.

Is there a solution? Of course there is. It’s called The Concurrent Low Pause Collector and has been in Java since version 5. Read the linked article for many, many details, but shortly just add:

-XX:+UseConcMarkSweepGC

to the usual java -jar command and the garbage collection will be done in parallel with your code execution. Of course it’s no golden bullet, it makes overall performance worse (now instead of 1-5 milliseconds, a single loop pass takes 4-10 milliseconds), but for this particular use, it makes Timer regularity better by two orders of magnitude.

[en] Solution to SIL3124-2 „no valid device”

SIL3124 is a PCI (as in old PCI, not PCI express) SATA-II controller which I had to buy because my NAS’ old Gigabyte motherboard supports (downspeeded) SATA-II drives only to 750GB size. Of course I got to know this AFTER buying 1,5TB drive 😉

Anyway, it’s always uphill and even though SIL3124 card sees the drive and I’ve installed Ubuntu Server with no problems to it, I couldn’t boot the card. It kept saying „no valid device”. Turns out it has a RAID-only BIOS by default so if someone – like me – wants to use it as an JBOD (Just a Bunch Of Disks) controller, BIOS upgrade is needed. How user friendly not to mention it in a – Czech-language – manual.

Of course, being mainly a Linux user with no CD- or DVD-drive, I have it even more uphill. BIOS flashing tools are available for Windows and DOS. Soooo the solution is:

  1. Use HP USB Disk Storage Format Tool to create bootable DOS pendrive, here’s Polish language tutorial: http://forum.purepc.pl/Dyski-twarde-cdromy-dvd-pendrive-inne-pamieci-f55/Boot-Pendrive-t254005.html if You don’t speak Polish, just google „boot pendrive dos”, in the tutorial is a link to Win98 boot files You might use.
  2. Download UPDFLASH and the newest BIOS zip from http://www.siliconimage.com/support
  3. The zip file has more than one BIOS inside, read the README and see which one is „IDE” BIOS or „non-RAID” BIOS. Copy the file together with UPDFLASH to the pendrive.
  4. Boot the PC with the PCI SATA Controller from the pendrive.
  5. Run „updflash biosfile.bin”
  6. If you don’t have a UPS, pray to Atheist’s God(TM) that there’s no blackout during flashing process.
  7. Use motherboard’s (not SATA controller’s) BIOS to set Hard Drive as first boot priority, make sure there’s „Bootable Add-In Cards” enabled somewhere.
  8. Reset and enjoy bootable large drives.

Note: Drive’s UUIDs change because of that so it’s best to do it BEFORE installing Ubuntu, otherwise You get a maintanance console.

[en] Ubuntu 9.04 Jaunty on my AMD64 system – notes to myself

Update 2009-11-18, using Ubuntu 9.10 now

  • Wine has finally font anti-aliasing, to enable do this in regedit: ============ REGEDIT4 [HKEY_CURRENT_USER\Control Panel\Desktop] "FontSmoothing"="2" "FontSmoothingType"=dword:00000002 "FontSmoothingGamma"=dword:00000578 "FontSmoothingOrientation"=dword:00000001 ============

Mainly notes to myself, but maybe some random Googlers will find some of them useful. I may add more in time.

  • If many of texts in your system, including Firefox are not in your native language, make sure you have installed appropriate language-pack-XX package (language-pack-pl for Polish). It should be downloaded by Ubuntu installer but it never fully worked for me since 5.04.
  • Pidgin has a plugin for Tlen protocol. Just download the newest .tar.gz, unpack and make. You should have pidgin-dev package installed for it to succeed. I didn’t try make install, just copied over resulting libtlen.so to /usr/lib/purple-2 and .png files to /usr/share/pixmaps/pidgin/protocols, one file – renamed to just tlen.png – to each folder.
  • Nice Pidgin smiley pack which has original emotikons for protocols I use. Just go to Pidgin settings, smiley sets tab and click add.
  • Firetray contrary to what its name suggests, also works in Thunderbird, allowing it to minimize itself to system tray. Just open Thunderbird’s Add-ons window and drag install link there from Firefox to install this extension.
  • Polish set of Adblock filters I’ve been using for some time now.
  • Installing Aurora GTK Theme engine (most good themes seem to use it):
    aptitude install build-essential libgtk2.0-dev
    # download from 
    # http://www.gnome-look.org/content/show.php/Aurora+Gtk+Engine?content=56438 
    # unpack and cd to source directory
    ./configure --prefix=/usr --enable-animation
    make
    sudo make install
    
  • Download Myriad Pro font. Here’s Myriad in TTF version (thanks Misiek) which looks better in Java programs (think OpenOffice).
  • Fresh Dark – a very nice dark theme for Gnome. Also see matching icons. If Metacity/Emerald (window borders) theme doesn’t work, just check file and directory permissions of the unpacked theme. If windows run as root look ugly, make sure you copy the theme to /usr/share/themes instead of just ~/.themes.
  • Wine repository which usually has newer version than default Ubuntu repos.
  • A nice way to integrate MS Office (I have a license so I use it through Wine instead of OpenOffice, same goes to Photoshop which I prefer over Gimp in spite of all those holy wars about it) is to create /opt/wine-start.sh script with following contents
    #!/bin/bash
    wine start "z:$1"
    
    and then chmod +x it and use it with Gnome’s Open With function on .doc, .xls and .ppt files. That way I’m able to open those files in Word, Excel and PowerPoint just by double clicking them.
  • There is Java Plugin for Firefox on AMD64 at last (just install sun-java6-plugin package).
  • Wammu (nice mobile phone manager with a great feature of copying your SMSes to your e-mail inbox) just works in Jaunty with my Nokia 6021 over bluetooth which was never a case before.
  • SSH Menu is a nice little gnome applet to build a fast-access menu of SSH servers you connect to. Ubuntu repository is also there.
  • I always forget that Eclipse PDT (PHP Development Tools) all-in-one download is for 32bits only. To install it on AMD64 architecture, download 64-bit version of Eclipse for JavaEE and do the following:
    tar xzvf eclipse-jee-ganymede-SR1-linux-gtk-x86_64.tar.gz
    sudo mv eclipse /opt
    # you probably should think twice about chown and chmod, 
    # but I myself make my PC physically secure so don't care
    sudo chown -R user.group /opt/eclipse
    sudo chmod -R 770 /opt/eclipse
    sudo nano /etc/environment # put path to JDK by adding a 
    # line something like JAVA_HOME="/usr/lib/jvm/java-6-sun"
    /opt/eclipse/eclipse # choose your workspace location and start Eclipse
    
    When in Eclipse, just use their instructions on installing PDT:
    Help > Software Updates... > Available Software > Manage Sites...
      Add... > add the DLTK 1.0 interim site: http://download.eclipse.org/technology/dltk/updates-dev/1.0/
      Add... > add the PDT 2.0 interim site: http://download.eclipse.org/tools/pdt/updates/2.0/
      Enable the Ganymede Update site (if not already enabled): http://download.eclipse.org/releases/ganymede/
      Expand the DLTK site and select the Dynamic Languages Toolkit - Core Frameworks or Dynamic Languages Toolkit - 
                                                                                              Core Frameworks SDK Feature 
      Select the PDT or PDT SDK Feature
      Install...
    
  • To make Subclipse plugin work in Eclipse (to be able to use Subversion repositories), aptitude install libsvn-javahl and then nano /opt/eclipse/eclipse.ini and add a line that says (sans quotes) „-Djava.library.path=/usr/lib/jni” just under „-vmargs” line.
  • I’ve finally found a way to change Gnome’s clock appearance, fire up gconf-editor, go to /apps/panel/applets/clock_screen0/prefs, change „format” to „custom”, „custom_format” to something like „<span color=”#99ccff”><sup><b>%A, %d %B %Y</b></sup></span> <big><b><big>%H</big><sup>%M</sup></b></big>” and voila!
  • Even though dailystrips (a script that download comic strips for you) at sourceforge seems to be abandoned, they have updated dailystrips and strips.def at MisterHouse project.