Tuesday, March 16, 2010

Adding alternate-row shading to your LaTeX Tables

Two steps,

  1. In the preamble:

    \documentclass{article}

    \usepackage[table]{xcolor}
    \definecolor{tableShade1}{HTML}{F1F5FA}
    \definecolor{tableShade2}{HTML}{ECF3FE}

    \begin{document}

  2. Just before \begin{tabular}, add

    \rowcolors{1}{tableShade1}{tableShade2}

    The first argument is which row to start on. This is useful (e.g.) if your header row is actually multiple rows.


Source: http://www.cv-templates.info/2009/07/alternate-row-shading-latex/

Sunday, January 17, 2010

Creating a Ringtone for your iPhone from an MP3 using Garage Band

This uses Garage Band, which comes with Mac OS's.



  1. Open Garage Band, create a new project
  2. (You can delete the piano track by selecting it and then choosing Track → Delete Track from the Menu.)
  3. Drag your .mp3 file from Finder to Garage Band. This creates a new Garage Band track.
  4. (I sometimes need to click and drag the track off to the left so it starts at time zero.)
  5. Play the track and find the start/stop portion you want. This must be less than 30 seconds (If it is slightly more, you can shrink it down later, but this will affect the sound quality a bit.)
  6. Drag the end of the track (a colored box showing the volume of each portion of the audio--probably two lines for stereo) to the beginning and end of your portion.

    • You can zoom in with the logscale slider in the lower-left corner
    • You can double-click the track to see a larger version at the bottom of the screen

  7. From the menu, choose Track → Show master track
  8. Click on the master track to create points near the beginning and end of the track, and move the appropriate points down to fade the volume in and out.
  9. Adjust the master volume (far right of the play controls) if necessary
  10. If you need to, you can speed up or slow down your music with the following proceedure (source):

    1. Drag your audio file (MP3, M4A, ...) in GarageBand. It's shown as an orange track.
    2. Press Ctrl+Alt+G
    3. Click the audio track. It is now blue [Ed: purple]
    4. Check "Follow Tempo & Pitch" (this is in the wave editor section, which you get by clicking the scissors symbol next to the eye) [Ed: This is already open if you double-clicked the track earlier]
    5. Now change the tempo (next to the song time display) [Ed: Actually click the "tempo" number in the time display window]

  11. Save your file. From the menu, choose Share → Export Song to Disk and save as an .m4a file.
  12. Rename the .m4a file to .m4r (I had to do this in a terminal)
  13. Import your .m4r file to iTunes, it shows up under the Ringtones category (in iTunes 8, at least)
  14. Update the track info if you like
  15. Sync with your iPhone

Monday, December 28, 2009

Enable X11 Forwarding in MacOS

e.g. to use the GIMP,
edit field `X11Forwarding' in file `/etc/sshd_config'

See: http://developer.apple.com/qa/qa2004/qa1383.html.

Showing all files in MacOS Finder


defaults write com.apple.finder ShowAllFiles TRUE
killall Finder

Monday, December 21, 2009

Normalizing Affymetrix Data with bioconductor


#!/usr/bin/env Rscript
# Normalize a set of CEL files

## Note: To use biocLite packages (i.e. 'affy,' 'rma()', ...), it may be
# necessary to do a one-time [re-]install of the related packages. This can be
# done with the following sequence:

# > source("http://bioconductor.org/biocLite.R"); # Tell R where to download package info from
# > biocLite(); # Update biocLite package grounds. This turns out to be necessary 1-time step before a call to rma(...), which requires up-to-date biocLite library functions
# > biocLite("affy"); # d/l, install 'affy' package (1-time req. only)

library("affy");
# We'll be using this library

# Read CEL files
filenames <- list.files("path/to/CEL", full.names=TRUE);
affy.data <- ReadAffy(filenames=filenames, verbose=TRUE);

## Normalize using RMA
write.table( exprs( rma(affy.data, verbose=TRUE)), file="rma.matrix", sep='\t', quote=FALSE); # file="" to write to stdout, but watch for verbose output from rma(...) and/or ReadAffy(...)

## Using Quantile Norm (this post is edited--the old way didn't collapse measurements per probe)
library("affyPLM")
eset <- threestep (affy.data, background.method="IdealMM", normalize.method="quantile", summary.method="tukey.biweight" )
write.table(eset, file="qnorm.matrix", sep='\t', quote=FALSE)
# for some reason, this transposes the data and adds an "X" in front of every numeric probe ID?

Friday, December 4, 2009

Recursively downloading from an FTP site


  1. ncftp

    $ sudo port install ncftp
    $ cd ~/Downloads/uci
    $ time ncftpget -R -v -u "anonymous" ftp.ics.uci.edu ~/Downloads/uci pub/machine-learning-databases


    So far, I'm not finding this to be doing a very good job of being recursive.

    Source:
    http://www.cyberciti.biz/tips/linux-download-all-file-from-ftp-server-recursively.html

  2. wget


    $ sudo port install wget
    $ cd ~/Downloads/uci2
    $ time wget -r ftp://ftp.ics.uci.edu/pub/machine-learning-databases

    Source: http://www.editcorp.com/Personal/Lars_Appel/wget/v1/wget_7.html, http://www.gnu.org/software/wget/manual/html_node/Recursive-Download.html.
    See also: gwget


Tuesday, December 1, 2009

Installing LaTeX on a Mac

Download and unzip MacTeX.mpkg.zip from http://www.tug.org/mactex
and run the mkpg.

Followers