Browsing arekm‘s posts
Saving magnet links as torrent files in kde
$ cat .kde/share/kde4/services/magnet.protocol
1 2 3 4 5 6 7 8 9 10 11 |
[Protocol] exec=/path/to/magnet2torrent.py "%u" protocol=magnet input=none output=none helper=true listing=false reading=false writing=false makedir=false deleting=false |
$ cat bin/magnet2torrent.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#!/usr/bin/python import os import sys def torrent_name(magnet): for i in magnet.split('&'): if i.startswith('dn='): return i + ".torrent" return magnet.replace(':', '-') + ".torrent" if len(sys.argv) != 2: print >> sys.stderr, "Usage: %s <magnet url>" % sys.argv[0] sys.exit(1) magnet = sys.argv[1] torrent = "d10:magnet-uri" + str(len(magnet)) + ":" + magnet + "e" f = open(os.path.expanduser("~/test/%s" % torrent_name(magnet)), 'w') f.write(torrent) f.close() $ </magnet> |
Mounting DOS HDD image
Mounting dos hdd image, first partition:
mount -o loop,offset=32256 dos-hdd.img dir
I’m using such image to update BIOSes in machines where bios doesn’t fit into floppy image. Such hdd image can be places inside iso image to be booted at virtual or real cdrom.
mkisofs -v -r -T -J –hard-disk-boot -b dos-hdd.img -o ../test.iso .
Eating power – Intel GM45 vs Radeon HD 3400
ThinkPad T400 switched into integrated gpu mode – running Intel GM45 eats ~12W of power.
ThinkPad T400 switched into discrete gpu mode – running Radeon HD 3400 eats … ~28W of power!
Which means that radeon itself eats more than 16W of power (meausred with powertop). That’s more than whole notebook in integrated gpu mode. Nightmare!
Note that HD 3400 was driven by open source radeon driver which doesn’t have any power management support at this moment.
200904 update: ati driver in git contains updated power management and it’s eating ~16W here instead of ~28W now with DynamicPM turned on.
Tabs, vim and 256 colors – tips
Having tabs and spaces visible as separate entities in vim is very neat feature especially if you use colors to differentiate.
Switch TERM to konsole-256color in kde konsole terminal emulator (or whatever emulator you use – rpm -ql ncurses terminfo | grep 256 for more) and put into .vimrc:
colorscheme darkblue
highlight TabGroup ctermbg=233 guibg=233
match TabGroup /\t/
Now tab characters are a bit brighter than spaces.
Very fast IPv6 setup on PLD/Linux Th
If you need IPv6 on some PLD Th machine, like in my case laptop, you can just do:
poldek -uGv miredo-client-teredo
service miredo-teredo start
and verify that IPv6 works by doing for example:
mtr -6 www.pld-linux.org
This solution doesn’t require any configuration (well, there are some options that can be altered). It should work even if you are behind some NATs and other weird gateways thanks to Teredo.
Working setup causes new interface to appear, for example:
20: teredo:
link/[65534]
inet6 2001:x:xx:xx:xx:xx:xx:e4b6/32 scope global
valid_lft forever preferred_lft forever
inet6 fe80::ffff:ffff:ffff/64 scope link
valid_lft forever preferred_lft forever
Of course there are other solutions for non-native IPv6 like 6to4 (pure rc-scripts are enough), ISATAP (see miredo-client-isatap package) or just typical SIT tunnel.
DNS vulnerability testing
How to test if your caching nameserver is vulnerable to recently hot cache poisoning issue:
dig @ip_of_your_caching_ns +short porttest.dns-oarc.net TXT
Example:
$ dig @192.168.1.254 +short porttest.dns-oarc.net TXT
z.y.x.w.v.u.t.s.r.q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a.pt.dns-oarc.net.
"x.y.z.q is GOOD: 26 queries in 5.0 seconds from 26 ports with std dev 17652.90"
How to format your source code files using vim?
… in a batch mode:
find . -name '*.somepattern' -exec vim -c 'norm gg=GZZ' "{}" ";"
Booting PLD/DOS from USB pendrive
Create partition on your flash drive (using fdisk or cfdisk). Mark one of partitions bootable in fdisk/cdisk. Format that partition with FAT/FAT32 filesystem:
mkfs.vfat -F 32 /dev/sdXY
where sdXY is your partition.
Mount it and copy contents of PLD RescueCD like x86 and x86_64 ISO image to that partition, to /rcd subdirectory.
Make MBR record:
ms-sys -s /dev/sdX
(where sdX is entire flash disk; ms-sys comes from ms-sys package)
Copy syslinux configuration for USB to root directory of your flash drive as syslinux.cfg. DOS/Windows image should be placed in /rcd/boot/dos.gz (compress it with gzip first).
Run:
syslinux -s /dev/sdXY
to load syslinux onto your flash drive.
Reboot your system and check if it boots correctly 🙂
Note that some systems have problems with booting from flash driver (especially big like 1G or 2G flash drives).