Table of Contents

Elan Ruusamäe

Some ideas to do in PLD Linux

Detect X application locale

xprop -id $WINDOWID -notype WM_LOCALE_NAME

Detect PuTTY

xterm-249/vttests/title.sh
old=$(stty -g)
stty raw -echo min 0 time 5
echo -ne '\005'
read xapp
stty $old
 
echo "xapp: $xapp"

Kmail & Crypto

 poldek -u gpgme gnupg-agent keychain pinentry-qt
$ cat ~/.gnupg/gpg-agent.conf
pinentry-program /usr/bin/pinentry-qt
keychain -q --agents gpg
if [ -f ~/.keychain/$HOSTNAME-sh-gpg ]; then
  . ~/.keychain/$HOSTNAME-sh-gpg
fi
* start new shell and start kmail/kpg/whatever
$ bash -l

irssi & screen

i've configured my screen and irssi that they use utf-8 internally but are able to display other encodings properly.

defencoding iso8859-15
/set term_charset utf-8
/set recode_autodetect_utf8 ON
/set recode_fallback iso8859-15
/set recode ON
/set recode_out_default_charset iso8859-15
/set recode_transliterate OFF
/recode add #linux.ee utf-8
/recode add #metal iso8859-15
/recode add #pld iso8859-2
:encoding utf-8

controlling screen window encoding from scripts

first you need to enable interpreting of commands, add to ~/.screenrc:

# disable all screen commands but encoding
addacl :window: -rwx #?
# allow 'encoding' command
addacl :window: +x encoding

and to set encoding from script:

$ echo -ne '\033]83;encoding utf8\007'

for example my ~/.bash_profile on carme contains:

# force screen utf8 encoding
if [[ "$TERM" = screen* ]]; then
  echo -ne '\033]83;encoding utf8\007'
  echo -ne "\033k$HOSTNAME\033\\"
fi

PHP via FastCGI in Apache

# the server name is bogus actually, to satisfy mod_fastcgi
FastCgiExternalServer /bin/true -socket /var/run/php/fcgi.sock
ScriptAlias /php-fcgi /bin/true
<Location "/php-fcgi">
    SetHandler fastcgi-script
    Allow from all
</Location>
 
AddType application/x-httpd-fastphp .php
Action application/x-httpd-fastphp /php-fcgi

unfortunately /php-fcgi will be available for download (/bin/true binary in this case)

Capture desktop as video.ogg

Using gstreamer:

$ poldek -u gstreamer-ximagesrc gstreamer-theora gstreamer-vorbis
$ gst-launch -v ximagesrc ! video/x-raw-rgb,framerate=10/1 ! ffmpegcolorspace ! theoraenc ! oggmux ! filesink location=desktop.ogg

thx Patrys for this :-)

also worth to check: cankiri and istanbul

mysql comments out

perl -pe 'undef $/;s#/\*!\d{5} ([^*]+)\s?\*/#$1#gs'

Chrome Killing your EARS

Ever having headphones on and listening your favourite music, and hitting <END> button on url location and wondered wtf beeped so loud that you can't hear for next five minutes anything!? It is chrome bell reaching to speaker, which on recent hardware is connected to soundcard with MAX volume, ARGH!

TURN THE BEEP MIXER ON MUTE on some mixer to save your ears!

$ amixer set 'Beep' 0% mute
$ sudo alsactl store

Resubmit POST data

Such pity happened to me, that I filled bunch of form fields and found that Chrome does not download the result. I fired up Wireshark and captured the POST data (Export Selected Packet Bytes) and resubmited it with curl.

$ curl -H 'Expect: ' http://example.org/posthandler.php -d @postdata.raw > result.zip

Kernel modules used by network drivers

lspci to get kernel module and pci description:

$ lspci | awk '/Ethernet/{print $1}' | xargs -l1 lspci -k -s
03:00.0 Ethernet controller: Broadcom Corporation NetXtreme II BCM5708 Gigabit Ethernet (rev 12)
        Subsystem: IBM Device 0342
        Kernel driver in use: bnx2
        Kernel modules: bnx2
06:00.0 Ethernet controller: Broadcom Corporation NetXtreme II BCM5708 Gigabit Ethernet (rev 12)
        Subsystem: IBM Device 0342
        Kernel driver in use: bnx2
        Kernel modules: bnx2

or with ethtool:

# ethtool -i eth0
driver: e1000
version: 6.3.9-k4-NAPI
firmware-version: N/A
bus-info: 0000:03:07.0

Growing WinXP VirtualBox image

I needed to grow WinXP disk, as 2GiB was too short for it. It's all pretty basic, but with few quirks. VBoxManage can extend disks, but only it's VDI format (here and here). WinXP can grow NTFS partions, but only non-boot ones (here).

So first is to clone image and extend it

$ VBoxManage clonehd winxp_1-disk1.vmdk --format VDI winxp_1-disk1.vdi
$ VBoxManage modifyhd winxp_1-disk1.vdi --resize 4096

now boot with both disks attached and run diskpart.

DISKPART> list volume
DISKPART> select volume 2
DISKPART> extend

now remove the old disk and voila!

PLD Linux VM images

See vm-info for more details

Upgrading PHP 5.3 -> PHP 5.4

poldek --sn carme --up -u $(rpm -qa --qf '%{N} %{V}-%{R}\n' | awk -vv=$(rpm -q php-common --qf '%{V}-%{R}') '$2 == v {sub(/php/, "php54", $1); print $1}')

Dropbox as picture share service

Any file saved to ~/Pictures/Screenshots gets renamed based on timestamp and moved to ~/Dropbox/Public folder.

When the move is done, URL for the image is copied to clipboard and image viewer is opened so you can see your image before you paste the url to IM, e-mail, etc…

See: https://github.com/glensc/dropbox-watch

PLD svn and Subversion under ac

Ac has old openssl that can't do SNI properly, therefore accessing svn over https gives errors:

svn: OPTIONS of 'https://....': Certificate verification error: certificate signature failure (https://svn.pld-linux.org)

A Workaround possible:

~/.subversion/servers
[groups]
pld = svn.pld-linux.org
 
[pld]
ssl-trust-default-ca = no