Supermind Search Consulting Blog 
Solr - Elasticsearch - Big Data

Split wav/flac/ape files with cue

Posted by Kelvin on 07 May 2012 | Tagged as: Ubuntu

If you ever need to split a disc image which has been burned as a single wav/flac/ape file with a corresponding cue file, this will help you out. Split2flac does all the tedium of splitting, renaming (according to a renaming pattern of your choosing), converting to FLAC/M4A/MP3/OGG_VORBIS/WAV, as well as adding ID3 tags. cd /usr/local/bin […]

Batch convert svg to png in Ubuntu

Posted by Kelvin on 19 Oct 2011 | Tagged as: Ubuntu

sudo apt-get install librsvg2-bin for i in *; do rsvg-convert -a $i -o `echo $i | sed -e 's/svg$/png/'`; done to rasterize the svg at 300dpi, shrinking dimensions by 50%: for i in *; do rsvg-convert -z 0.5 -d 300 -p 300 -a $i -o `echo $i | sed -e 's/svg$/png/'`; done

Mount a .dmg file in Ubuntu

Posted by Kelvin on 11 Oct 2011 | Tagged as: Ubuntu

sudo apt-get install dmg2img dmg2img /path/to/image.dmg sudo modprobe hfsplus sudo mount -t hfsplus -o loop image.img /mnt The .dmg archive is now mounted at /mnt. You can browse it either via command-line or via Nautilus. Courtesy of http://iremedy.net/blog/2010/11/how-to-mount-a-dmg-file-in-ubuntu-linux/

Delete directories older than x days

Posted by Kelvin on 04 Aug 2011 | Tagged as: Ubuntu

Great for cleaning up log directories. find . -maxdepth 1 -mtime +14 -type d -exec rm -fr {} \; Change 14 to the required age in days.

Determine if a server supports Gzip compression

Posted by Kelvin on 06 Jun 2011 | Tagged as: Ubuntu

echo "Size WITHOUT accepting gzip" curl http://www.supermind.org –silent –write-out "size_download=%{size_download}\n" –output /dev/null echo "Size WITH accepting gzip" curl http://www.supermind.org –silent -H "Accept-Encoding: gzip,deflate" –write-out "size_download=%{size_download}\n" –output /dev/null You can of course substitute the URL with a different one. On my site, this is what I get: $curl http://www.supermind.org –silent –write-out "size_download=%{size_download}\n" –output /dev/null $size_download=10560 $curl […]

Using sed to delete lines from a file

Posted by Kelvin on 21 May 2011 | Tagged as: Ubuntu

Delete line containing foo sed -i '/foo/d' filename.txt Delete last line sed -i '$d' filename.txt

Recursively find the n latest modified files in a directory

Posted by Kelvin on 18 May 2011 | Tagged as: programming, Ubuntu

Here's how to find the latest modified files in a directory. Particularly useful when you've made some changes and can't remember what! find . -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" " Replace tail -1 with tail -20 to list the 20 most recent files for example. […]

Convert fixed-width file to CSV

Posted by Kelvin on 12 May 2011 | Tagged as: programming, Ubuntu

After trying various sed/awk recipes to convert from fixed-width to CSV, I found a Python script that works well. Here it is, from http://code.activestate.com/recipes/452503-convert-db-fixed-width-output-to-csv-format/   ## {{{ http://code.activestate.com/recipes/452503/ (r1) # Ian Maurer # http://itmaurer.com/ # Convert a Fixed Width file to a CSV with Headers # # Requires following format: # # header1 header2 header3 […]

MD5 a directory recursively

Posted by Kelvin on 05 May 2011 | Tagged as: Ubuntu

Ever need to check if a directory is exactly the same as another (including file contents)?

find . –type f –exec md5sum {} + | awk '{print $1}' | sort | md5sum

 

This runs md5sum on the individual md5sum hashes of each file.

Delete files older than x days

Posted by Kelvin on 22 Mar 2011 | Tagged as: Ubuntu

Delete files older than 7 days: cd /path/to/dir find -mtime +7 -exec rm {} \; Change +7 to +14 for deleting files older than 14 days.

Next Page »