Saturday, December 7, 2013

Copy a tree structure but just get all the files which match a pattern

rsync -avm --include='*.ogg*' -f 'hide,! */' parsifal parsifal-oggs

I think the hide thing was to stop it copying directories that didn't have any ogg files, but I'm not sure anymore.

Xubuntu Rip Audio CD

Sound Juicer seems to not work for me and I can't be bothered to figure out why.
Asunder seems to do exactly the same thing, only it works.

sudo apt-get install lame asunder

It needs lame to rip to mp3

Monday, August 26, 2013

Installing R and R Studio on Ubuntu 13.04 "Raring Ringtail"

Using the mirror at UCLA:

sudo add-apt-repository "deb raring/"

Installing the gpg key for R packages

gpg --keyserver --recv-key E084DAB9
gpg -a --export E084DAB9 | sudo apt-key add -

sudo apt-get update

Installing R and the libjpeg62 library needed by R Studio

sudo apt-get install r-base libjpeg62

Getting the pre-built deb package and installing it:

sudo dpkg -i rstudio-0.97.551-i386.deb

Friday, July 26, 2013

Wacom Tablet Aspect Ratio for Widescreen

Recently purchased a Wacom Bamboo Pen graphics tablet. In its default setup, tracing a coin on the tablet draws an oval (I think that's because the tablet's 4:3 and my monitor is 16:9, but it may be something more arcane due to a dual monitor setup).

This command seems to make the aspect ratio correct whilst allowing me to reach all parts of my main screen.

xinput set-int-prop "Wacom Bamboo Connect Pen stylus" "Wacom Tablet Area" 32 0 00 23175 8600

Friday, June 21, 2013

Upgrading from loop-aes to dmcrypt

Once upon a time, I had an encrypted external disk that I would mount thus:

# losetup -e AES128 /dev/loop1 /dev/sdb1
# fsck /dev/loop1
# mount /dev/loop1 /mnt/wd
# ls /wd

There are those that say that the modern way to do this is:

# apt-get install cryptsetup
# cryptsetup -c aes-plain -s 128 -h sha256 create wd /dev/sdb1
# fsck /dev/mapper/wd
# mount /dev/mapper/wd /mnt/wd

You can then remove the mount with

# umount /mnt/wd
# cryptsetup remove wd

Saturday, May 18, 2013

Copying Audio CDs on Ubuntu ( with cdrdao )

You should be able to (assuming that your cd is called foo) rip the data using:

cdrdao read-cd foo.toc

and then write it using:

cdrdao write foo.toc

For various reasons too annoying and mysterious to explain, I ended up using:

sudo cdrdao write --driver generic-mmc-raw foo.toc 

to write, but that's probably just the peculiarities of my dell mini netbook / lite-on external drive

Friday, January 11, 2013

Debian / Ubuntu Package Commands ( apt-get / apt-file / apt-cache )

sudo apt-get update
sudo apt-get upgrade --dry-run
sudo apt-get upgrade

apt-cache search maven     # too much information
apt-cache search ^maven$   # misleading information
apt-cache search mvn       # no information

apt-file search mvn            # too much information
apt-file search ^mvn$          # no information

which mvn
apt-file search /usr/bin/mvn   # glory

apt-cache show maven2          # description and dependencies
apt-cache showpkg maven2       # package info
apt-cache showsrc maven2       # source files

Thursday, January 10, 2013

Website Debugging with Curl : The Web Browser of the Gods

The Web Browser of the Gods

watch -d -n 1 curl -sv -b cookiejar.txt -c cookiejar.txt http://localhost:8080

For Gods who are mostly interested in the headers:

watch -d -n 1 curl -sv -b cookiejar.txt -c cookiejar.txt -o http://localhost:8080

Long Version

Curl's a nice way to analyse what's going on with a website:

When debugging a server running on your own machine:

curl http://localhost

If it's on port 8080

curl http://localhost:8080

If you're after a sub-path

curl http://localhost:8080/favicon.ico

I prefer:

curl -sv http://localhost:8080

-s turns off the information about download percentage, progress
-v adds the details of the header transaction

You can send both data and progress messages to a file with:

curl -sv http://localhost:8080 2&>curl.out

Poll the website every second, highlighting changes with:

watch -d -n 1 curl -sv http://localhost:8080

Pass in a cookie thus:

curl -sv http://localhost:8080 -b "yo=doom"

See the cookies that come back:

curl -sv http://localhost:8080 -c -

Save cookies that come back:

curl -sv http://localhost:8080 -b "yo=doom" -c cookiejar.txt

Or read and write cookies from a cookie file like:

curl -sv http://localhost:8080 -b cookiejar.txt -c cookiejar.txt

Finally, you can throw away the document itself and just display transaction and the cookies with:

curl -sv http://localhost:8080 -b "cook=ie" -c /dev/stderr >/dev/null

Monday, January 7, 2013

List Source for Bash Functions

If you use alias, then just typing alias will give you all the defined aliases, and alias alias_name will tell you what a particular alias does. For functions defined in .bashrc and other places, you can use:

    declare -f

which will give you the names of all functions currently defined, and:

    type function_name

which will give you the source for a particular function.

(declare -F will give names and sources, like alias does, but it's usually too much information)