Scripts posted recently by garaolaza in Kelpi

1- 8 of 8.

Add Google Analytics code to links

to analytics javascript google html by garaolaza

<a href="fitxategia.pdf" onclick="javascript:urchinTracker('/pdfak/fitxategia.pdf');">Fitxategia</a>

Check existence of elements in XML

to xml javascript check by garaolaza

// When XML processing with JavaScript, sometimes void XML elements give strange answers about them
// I needed to check if the element was void, just like <item/>

if (somewhere.getElementsByTagName('item')[0].childNodes.length) {  dothis();  }

XML to list of dict parsing

to python xml parsing bigfiles by garaolaza

from lxml import etree
coords = etree.parse("/path/to/your/xml/file").getroot()
coords_list = []
for coord in coords:
        this = {}

Find and remove files

to ssh system bash remove by garaolaza

# So easy as:
find . -name '*.pyc' -exec rm -rf {} \;

rsync in local dirs

to rsync local backup bash by garaolaza

# With linux filesystem
sudo rsync -rlptD --delete andoni /media/SWISNIFE1/
# With NTFS backup
sudo rsync -rtv --delete Videos /media/SWISNIFE1/

How to create ISO images from CD/DVD

to bash iso cd dvd scsi by garaolaza

# You need to unmount if the drives are mounted
# More in http://ubuntuforums.org/archive/index.php/t-6509.html

dd if=/dev/dvd of=dvd.iso # for dvd
dd if=/dev/cdrom of=cd.iso # for cdrom

Audio stream recording with mplayer

to audio stream recording mplayer bash by garaolaza

mplayer -dumpstream -dumpfile myfile.mp3 mms://yoururl_here
# myfile.mp3's extension depends on the format of the original stream.

Convert asf file to mp3 in Ubuntu

to audio stream recording convert mplayer bash ubuntu lame by garaolaza

# First convert .asf to wav:
mplayer -ao pcm:file=destination.wav source.asf
# Then encode it to mp3
lame destination.wav
hits counter