Monday, July 30, 2012

HTML select elements by css selectors

var arr = element.querySelectorAll( css_selector );
var first_elm = element.querySelector( css_selector );

https://developer.mozilla.org/en/DOM/Document.querySelectorAll

Wednesday, July 25, 2012

Linux: Calculate directories size

# du -h
# du -h --max-depth=1
# du -h | tail -n 1

Saturday, July 7, 2012

Linux: Mount USB drive

- Plug the USB drive
- fdisk -l
- create a mounting folder. i.e. /media
- mount -t vfat /dev/sdb1 /media

To unmount
- umount /media

Tuesday, July 3, 2012

Compress and split large files


# create archives
$ tar cz my_large_file_1 my_large_file_2 | split -d -b 1024MiB - myfiles_split.tgz_
# uncompress
$ cat myfiles_split.tgz_* | tar xz
This solution avoids the need to use an intermediate large file when (de)compressing. Use the tar -C option to use a different directory for the resulting files. btw if the archive consists from only a single file, tar could be avoided and only gzip used:
# create archives
$ gzip -c my_large_file | split -d -b 1024MiB - myfile_split.gz_
# uncompress
$ cat myfile_split.gz_* | gunzip -c > my_large_file