Varnish cache: how to detect IPv6

The following VCL code detects if the client is connected using IPv6:

acl isipv6{                     
        "::"/0;
}                      
sub vcl_recv {          
    # [... whatever rules you like ...]
    if(server.ip ~ isipv6){
        # [... whatever rules you like ...]
    }
    # [... whatever rules you like ...]
}

You may want to use that for example for a "you're ipv6 enabled" banner.

© GeekLabInfo Varnish cache: how to detect IPv6 is a post from GeekLab.info. You are free to copy materials from GeekLab.info, but you are required to link back to https://www.geeklab.info

(No Ratings Yet)

GTK and KDE: unreadable fonts

I just found a note from several years back. Since it may someday be handy to someone, I'm posting it here:

KDE somewhat integrates GTK applications. These applications will get the color schemes from KDE. Sometimes fonts in menu's get rendered unreadable by this.

Wrong styles are defined in /opt/gnome/share/themes/Qt/gtk-2.0/gtkrc:

style "default"
{
  engine "qtengine"
  {
  }
}
class "GtkWidget" style "default"

Disabling this whole block fixed my problem.

© GeekLabInfo GTK and KDE: unreadable fonts is a post from GeekLab.info. You are free to copy materials from GeekLab.info, but you are required to link back to https://www.geeklab.info

(No Ratings Yet)

3Com OfficeConnect factory reset

To reset a 3Com OfficeConnect to factory defaults:

  • Power off the device
  • Connect a cross cable between the wan port and any of the lan ports
  • Power on the device
  • © GeekLabInfo 3Com OfficeConnect factory reset is a post from GeekLab.info. You are free to copy materials from GeekLab.info, but you are required to link back to https://www.geeklab.info

    (No Ratings Yet)

    Hide the mouse cursor with X

    I recently got myself a touch screen, that I mounted near the entrance to welcome visitors. The device was really hard to install, as the drivers for 4 different Linux distros were broken, and only binary drivers are released. The fifth distro finally worked.

    One thing that does annoy me however, is that X always shows the cursor. To hide the cursor on a touch screen, you can use the program unclutter:

    yum install unclutter
    unclutter -idle 0

    Unclutter with such a short delay (0 seconds) also makes it impossible to select texts, but for this application, that's just perfect.

    © GeekLabInfo Hide the mouse cursor with X is a post from GeekLab.info. You are free to copy materials from GeekLab.info, but you are required to link back to https://www.geeklab.info

    (No Ratings Yet)

    Backup your phone with zero keypresses

    I created some scripts to backup my Samsung Galaxy S2 to my Fedora 16 system without pressing any keys or even touching the mouse. It works like this:

    To backup a SGS2, you go to settings > applications > usb tools on the phone, and click the button. You then connect it to a usb cable. At that moment, two removable devices become visible to the Linux system: one for the SD card, one for the built-in memory. But they still contain no media. Only when you press another button on the phone, the "media are inserted in the devices", triggering a "change" action with the udev daemon.

    Configuration of the udev daemon

    Create a file /etc/udev/rules.d/71-android-backup.rules:

    SUBSYSTEM=="block", ACTION=="change", ENV{ID_SERIAL}=="Android_UMS_Composite_XXXXXXXXXXXXXXXX-0:0", ENV{DISK_MEDIA_CHANGE}=="1", ENV{ID_FS_TYPE}=="vfat", RUN+="/usr/local/bin/androidbackup"

    Whenever a (virtual) medium is inserted, a udev change action is triggered. Actually, it gets triggered multiple times, but we only need the one that has the environment variable DISK_MEDIA_CHANGE=1 set.

    Action to perform

    The action triggered is /usr/local/bin/androidbackup and all parameters are in the environment. So let's create that file. I use a rsnapshot-like operation to backup my data, but without actually using rsnapshot.

    #!/bin/bash
     
    function msg {
            /usr/bin/logger -t android "$1"
            DISPLAY=:0 qdbus $dbusRef setLabelText "$1"
            DISPLAY=:0 qdbus $dbusRef Set "" value $2
    }
     
    if [ "$1" != "FORKED" ]; then
            $0 FORKED &
            exit 0
    fi
     
    if [ -f /etc/sysconfig/androidbackup ]; then
            . /etc/sysconfig/androidbackup
    else
            echo /etc/sysconfig/androidbackup does not exist
            exit 0
    fi
     
    #debug disabled:
    #set > /tmp/android/`date +%s`.$RANDOM
     
    dbusRef=`kdialog --display :0 --progressbar "Backup android..." 100`
     
    msg "Attach $DEVNAME $ACTION $ID_SERIAL" 0
     
    if [ ! -e $DESTINATION ]; then
            # I could mkdir -p, but sometimes $DESTINATION could just be a network location that's offline
            msg "Android will not be backed up: $DESTINATION is not okay" 0
            exit 0
    fi
     
    mkdir -p /mnt/android
     
    mount $DEVNAME /mnt/android 
    rc=$?
    if [ $rc -ne 0 ]; then
            msg "Problem mounting $DEVNAME to /mnt/android: $rc " 0
            mount | grep android 2>&1 | logger -t androidbackup
            exit 0
    fi
     
    if [ "`mount |grep -i /mnt/android`" == "" ]; then
            msg "Cannot find /mnt/android in mount table" 0
            exit 0
    fi
     
    msg "Remove old backup" 8
    [ -e $DESTINATION/backup.30 ] && rm -rf $DESTINATION/backup.30
     
    msg "Start backup" 10
    for i in `/usr/bin/seq 30 -1 2`; do 
            if [ -e $DESTINATION/backup.$((i-1)) ]; then
                    msg "mv $DESTINATION/backup.$((i-1)) $DESTINATION/backup.$i" 11
                    mv $DESTINATION/backup.$((i-1)) $DESTINATION/backup.$i
            fi
    done
     
    msg "Copy" 40
    [ -e $DESTINATION/backup.0 ] && /bin/cp -al $DESTINATION/backup.0 $DESTINATION/backup.1
    mkdir -p $DESTINATION/backup.0/
     
    msg "Start rsync" 40
    /usr/bin/rsync -az --numeric-ids --delete --hard-links /mnt/android/ $DESTINATION/backup.0/
    touch $DESTINATION/backup.0/
     
    chown -R $CHOWN $DESTINATION/backup.0
     
    umount /mnt/android
     
    msg "Done" 100
    exit 0

    Since that file refers to /etc/sysconfig/androidbackup, let's also make that file:

    #next line defines the location of all backups
    DESTINATION=/home/geeklab/.androidbackup
     
    #next line defines the owner of all files copied
    CHOWN=geeklab
    © GeekLabInfo Backup your phone with zero keypresses is a post from GeekLab.info. You are free to copy materials from GeekLab.info, but you are required to link back to https://www.geeklab.info

    (No Ratings Yet)

    Use dsacls to gain access to active directory policies

    I've locked myself out of group policies a couple of times. When this happens to you, you can gain access again running the following command:

    dsacls.exe "CN={GUID},CN=Policies,CN=System,DC=local" /R "Authenticated users"

    © GeekLabInfo Use dsacls to gain access to active directory policies is a post from GeekLab.info. You are free to copy materials from GeekLab.info, but you are required to link back to https://www.geeklab.info

    (No Ratings Yet)

    Konsole is driving me crazy!

    Konsole, the terminal emulator of KDE, is driving me crazy! Version 4.8 made a slight change, that breaks an essential feature I'm using.

    Up to version 4.7.x, I used the command konsole --profile=Profilename to open a terminal. Then I used ctrl+alt+N to open several terminals with the same profile. For some reason, this broke in version 4.8. Since I use this feature like every minute, I'm getting very frustrated by this.

    Here comes the beauty of open source: since Konsole is open source, I can fix it myself.

    My changes

    First, I downloaded the current version of the konsole source RPM and installed it, using rpm -i konsole-4.8.1-1.fc16.src.rpm. In ~/rpmbuild/SOURCES I created a new file named newtab.patch, containing:

    --- konsole-4.8.1/src/MainWindow.cpp    2012-02-29 23:56:57.000000000 +0100
    +++ konsole-4.8.1/src/MainWindow.cpp    2012-04-03 19:47:52.397594047 +0200
    @@ -397,7 +397,8 @@
     
     void MainWindow::newTab()
     {
    -    Profile::Ptr defaultProfile = SessionManager::instance()->defaultProfile();
    +    Profile::Ptr defaultProfile = MainWindow::defaultProfile();
    +              //SessionManager::instance()->defaultProfile();  //Geeklab fix
         emit newSessionRequest(defaultProfile , activeSessionDir() , _viewManager);
     }

    Then I editted konsole.spec, adding a line after the one that starts with Patch50:

    Patch99: newtab.patch

    After that, I added a line after the one that starts with %patch50:

    %patch99 -p1 -b .newtab

    And we're done. Build the RPM using the command rpmbuild -ba konsole.spec --define "dist geeklab" and install it.

    Somehow, this RPM doesn't cover all of the problems, but enough for me to be happy.

    © GeekLabInfo Konsole is driving me crazy! is a post from GeekLab.info. You are free to copy materials from GeekLab.info, but you are required to link back to https://www.geeklab.info

    (No Ratings Yet)