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

Upda­te 2009-11-18, using Ubun­tu 9.10 now

  • Wine has final­ly font anti-alia­sing, to ena­ble do this in rege­dit: ============ REGEDIT4 [HKEY_CURRENT_USER\Control Panel\Desktop] "FontSmoothing"="2" "FontSmoothingType"=dword:00000002 "FontSmoothingGamma"=dword:00000578 "FontSmoothingOrientation"=dword:00000001 ============

Main­ly notes to myself, but may­be some ran­dom Googlers will find some of them use­ful. I may add more in time.

  • If many of texts in your sys­tem, inc­lu­ding Fire­fox are not in your nati­ve lan­gu­age, make sure you have instal­led appro­pria­te lan­gu­age-pack-XX pac­ka­ge (lan­gu­age-pack-pl for Polish). It sho­uld be down­lo­aded by Ubun­tu instal­ler but it never ful­ly wor­ked for me sin­ce 5.04.
  • Pid­gin has a plu­gin for Tlen pro­to­col. Just down­lo­ad the newest .tar.gz, unpack and make. You sho­uld have pid­gin-dev pac­ka­ge instal­led for it to suc­ce­ed. I did­n’t try make install, just copied over resul­ting lib​tlen​.so to /usr/lib/purple‑2 and .png files to /usr/share/pixmaps/pidgin/protocols, one file — rena­med to just tlen.png — to each folder.
  • Nice Pid­gin smi­ley pack which has ori­gi­nal emo­ti­kons for pro­to­cols I use. Just go to Pid­gin set­tings, smi­ley sets tab and click add. 
  • Fire­tray con­tra­ry to what its name sug­ge­sts, also works in Thun­der­bird, allo­wing it to mini­mi­ze itself to sys­tem tray. Just open Thun­der­bir­d’s Add-ons win­dow and drag install link the­re from Fire­fox to install this extension.
  • Polish set of Adblock fil­ters I’ve been using for some time now.
  • Instal­ling Auro­ra GTK The­me engi­ne (most good the­mes 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
    
  • Down­lo­ad Myriad Pro font. Here­’s Myriad in TTF ver­sion (thanks Misiek) which looks bet­ter in Java pro­grams (think OpenOffice).
  • Fresh Dark — a very nice dark the­me for Gno­me. Also see mat­ching icons. If Metacity/Emerald (win­dow bor­ders) the­me doesn’t work, just check file and direc­to­ry per­mis­sions of the unpac­ked the­me. If win­dows run as root look ugly, make sure you copy the the­me to /usr/share/themes inste­ad of just ~/.themes.
  • Wine repo­si­to­ry which usu­al­ly has newer ver­sion than default Ubun­tu repos.
  • A nice way to inte­gra­te MS Offi­ce (I have a licen­se so I use it thro­ugh Wine inste­ad of Ope­nOf­fi­ce, same goes to Pho­to­shop which I pre­fer over Gimp in spi­te of all tho­se holy wars abo­ut it) is to cre­ate /opt/wine-start.sh script with fol­lo­wing contents
    #!/bin/bash
    wine start "z:$1"
    
    and then chmod +x it and use it with Gno­me­’s Open With func­tion on .doc, .xls and .ppt files. That way I’m able to open tho­se files in Word, Excel and Power­Po­int just by double clic­king them.
  • The­re is Java Plu­gin for Fire­fox on AMD64 at last (just install sun-java6-plu­gin package).
  • Wam­mu (nice mobi­le pho­ne mana­ger with a gre­at featu­re of copy­ing your SMSes to your e‑mail inbox) just works in Jaun­ty with my Nokia 6021 over blu­eto­oth which was never a case before.
  • SSH Menu is a nice lit­tle gno­me applet to build a fast-access menu of SSH servers you con­nect to. Ubun­tu repo­si­to­ry is also there.
  • I always for­get that Eclip­se PDT (PHP Deve­lop­ment Tools) all-in-one down­lo­ad is for 32bits only. To install it on AMD64 archi­tec­tu­re, down­lo­ad 64-bit ver­sion of Eclip­se for Java­EE 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 Eclip­se, just use the­ir instruc­tions on instal­ling 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 Sub­c­lip­se plu­gin work in Eclip­se (to be able to use Sub­ver­sion repo­si­to­ries), apti­tu­de install lib­svn-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 final­ly found a way to chan­ge Gno­me­’s clock appe­aran­ce, fire up gconf-edi­tor, go to /apps/panel/applets/clock_screen0/prefs, chan­ge „for­mat” to „custom”, „custom_format” to some­thing 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 tho­ugh daily­strips (a script that down­lo­ad comic strips for you) at sour­ce­for­ge seems to be aban­do­ned, they have upda­ted daily­strips and strips.def at Mister­Ho­use project. 

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

Howe­ver gre­at LVM is in Linux, allo­wing one to span sin­gle „par­ti­tion” over seve­ral hard dri­ves, if the under­ly­ing „dri­ves” are real hard dri­ves and not RAID volu­mes, You can get pret­ty fuc­ked when one of tho­se disks fails.

It took me seve­ral hours of googling aro­und and trials to find out how to reco­ver as much data as is possi­ble (meaning: all the data that is on rema­ining disks, the data on failed dri­ve is obvio­usly lost). So let’s try to add a short and wor­king reci­pe to Google.

  1. You do NOT have to pvcre­ate any bogus emp­ty PVs with fake UUIDs to repla­ce the failed dri­ve. LVM2 can be used in „par­tial” mode witho­ut all the drives.
  2. To use par­tial mode, You need to cre­ate /dev/ioerror devi­ce like this (I use Ubun­tu, in other distros it might be different): 
    • nano filename to cre­ate a text file whe­re a sin­gle line „0 9999999999 error” sans quotes sho­uld be placed
    • dmsetup create ioerror filename to cre­ate a devi­ce LVM will read inste­ad of mis­sing PV
    • ln -s /dev/mapper/ioerror /dev/ioerror so it’s just whe­re LVM will look for it
  3. After ioer­ror is cre­ated, just acti­va­te your volu­me gro­up in par­tial mode using vgchange -P -ay VOLNAME
  4. Mount it (it will mount in read only mode) and copy your pre­cio­us data

Che­ers to the­se guys who final­ly writ­ten some­thing I could use inste­ad of pvcre­ate and bogus hard dri­ves discussions.

Virtualmin on Ubuntu 8.04 Server

Notes to myself and Googlers on instal­ling a vir­tu­al hosting con­trol panel Vir­tu­al­min (a gre­at add-on to Webmin) on Ubun­tu server:

  • wget http://software.virtualmin.com/gpl/scripts/install.sh
    chmod 755 install.sh
    ./install.sh
     — installs Vir­tu­al­min auto­ma­ti­cal­ly with all depen­den­cies, with a nice skin which is also used by Webmin (which I remem­ber used to be quite ugly by default) 
  • chmod 711 /var/spool/postfix/var/run/saslauthd  — fixes login failu­re when try­ing to send mail thro­ugh vir­tu­al server
  • it seems apa­che vhost, ftp, e‑mail and DNS is pro­per­ly con­fi­gu­red auto­ma­ti­cal­ly, will add more info here as I move on with my hosting migra­tion to Vir­tu­al­min probably

dostaje automatycznie „display: none” w Firefoksie?

Stra­ci­łem nad tym wię­cej cza­su niż chcę się przy­znać; mia­łem dodać mały ele­ment gra­ficz­ny o nazwie pli­ku zspon.png do stro­ny jed­ne­go z Klien­tów i jakimś cudem nie poja­wiał się on nigdy na stro­nie, a Fire­bug poka­zy­wał że ma on „display: none”, choć żad­ne­go CSSa nie przypisywałem.

Oka­za­ło się, że Adblock z fil­tra­mi Filterset.g wyci­na mi obraz­ki któ­re mają w nazwie „spon” :> Wyłą­cze­nie Adbloc­ka na czas deve­lop­men­tu to dobry pomysł, choć ja zosta­wiam włą­czo­ny — jak ktoś będzie go uży­wał to wolę zawcza­su wie­dzieć co mu znik­nie i zmie­nić nazwę pli­ku 🙂 zs-pon.png się wyświetla 😀

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

Google wasn’t awful­ly help­ful whi­le I was sear­ching for solu­tion to word wrap­ping a text when dra­wing 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;
            }
        }
    }