[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.

[en] How to mount LVM VG and restore data from it when one of its PV drives has failed

However great LVM is in Linux, allowing one to span single „partition” over several hard drives, if the underlying „drives” are real hard drives and not RAID volumes, You can get pretty fucked when one of those disks fails.

It took me several hours of googling around and trials to find out how to recover as much data as is possible (meaning: all the data that is on remaining disks, the data on failed drive is obviously lost). So let’s try to add a short and working recipe to Google.

  1. You do NOT have to pvcreate any bogus empty PVs with fake UUIDs to replace the failed drive. LVM2 can be used in „partial” mode without all the drives.
  2. To use partial mode, You need to create /dev/ioerror device like this (I use Ubuntu, in other distros it might be different):
    • nano filename to create a text file where a single line „0 9999999999 error” sans quotes should be placed
    • dmsetup create ioerror filename to create a device LVM will read instead of missing PV
    • ln -s /dev/mapper/ioerror /dev/ioerror so it’s just where LVM will look for it
  3. After ioerror is created, just activate your volume group in partial mode using vgchange -P -ay VOLNAME
  4. Mount it (it will mount in read only mode) and copy your precious data

Cheers to these guys who finally written something I could use instead of pvcreate and bogus hard drives discussions.

Virtualmin on Ubuntu 8.04 Server

Notes to myself and Googlers on installing a virtual hosting control panel Virtualmin (a great add-on to Webmin) on Ubuntu server:

  • wget http://software.virtualmin.com/gpl/scripts/install.sh
    chmod 755 install.sh
    ./install.sh
    — installs Virtualmin automatically with all dependencies, with a nice skin which is also used by Webmin (which I remember used to be quite ugly by default)
  • chmod 711 /var/spool/postfix/var/run/saslauthd — fixes login failure when trying to send mail through virtual server
  • it seems apache vhost, ftp, e-mail and DNS is properly configured automatically, will add more info here as I move on with my hosting migration to Virtualmin probably

dostaje automatycznie „display: none” w Firefoksie?

Straciłem nad tym więcej czasu niż chcę się przyznać; miałem dodać mały element graficzny o nazwie pliku zspon.png do strony jednego z Klientów i jakimś cudem nie pojawiał się on nigdy na stronie, a Firebug pokazywał że ma on „display: none”, choć żadnego CSSa nie przypisywałem.

Okazało się, że Adblock z filtrami Filterset.g wycina mi obrazki które mają w nazwie „spon” :> Wyłączenie Adblocka na czas developmentu to dobry pomysł, choć ja zostawiam włączony – jak ktoś będzie go używał to wolę zawczasu wiedzieć co mu zniknie i zmienić nazwę pliku 🙂 zs-pon.png się wyświetla 😀

[en] How to word wrap text in Graphics2D.drawString in Java

Google wasn’t awfully helpful while I was searching for solution to word wrapping a text when drawing in Java, so let’s teach Google this: 😉

    private void drawStringRect(Graphics2D graphics, int x1, int y1, int x2, int y2, 
        float interline, String txt) {
        AttributedString as = new AttributedString(txt);
        as.addAttribute(TextAttribute.FOREGROUND, graphics.getPaint());
        as.addAttribute(TextAttribute.FONT, graphics.getFont());
        AttributedCharacterIterator aci = as.getIterator();
        FontRenderContext frc = new FontRenderContext(null, true, false);
        LineBreakMeasurer lbm = new LineBreakMeasurer(aci, frc);
        float width = x2 - x1;

        while (lbm.getPosition() < txt.length()) {
            TextLayout tl = lbm.nextLayout(width);
            y1 += tl.getAscent();
            tl.draw(graphics, x1, y1);
            y1 += tl.getDescent() + tl.getLeading() + (interline - 1.0f) * tl.getAscent();
            if (y1 > y2) {
                break;
            }
        }
    }