Skip to content

Instantly share code, notes, and snippets.

View smacarthur's full-sized avatar

Stewart MacArthur smacarthur

View GitHub Profile
alias todo.now='geeknote create --tags @work,1-Now --title '
alias todo.next='geeknote create --tags @work,2-Next --title '
alias todo.soon='geeknote create --tags @work,3-Soon --title'
alias todo.later='geeknote create --tags @work,4-Later --title'
alias todo.someday='geeknote create --tags @work,5-Someday --title'
alias todo.waiting='geeknote create --tags @work,6-Waiting --title'
alias show.todo.all='geeknote find --tags @work --notebooks "Actions Pending" '
alias show.todo.now='geeknote find --tags @work,1-Now --notebooks "Actions Pending" '
alias show.todo.next='geeknote find --tags @work,2-Next --notebooks "Actions Pending" '
alias show.todo.soon='geeknote find --tags @work,3-Soon --notebooks "Actions Pending" '
@smacarthur
smacarthur / R LSF Example
Created December 16, 2010 12:02
Example code for using LSF job Arrays
### Generate a random big file that we want to sort, 10 Million lines
perl -e 'for (1..1E7){printf("%.0f\n",rand()*1E7)};' > bigFile
### Split the file up into chunks with 10,000 lines in each chunk
split -a 3 -d -l 10000 bigFile split
### rename the files on a 1-1000 scheme not 0-999
for f in split*;do mv ${f} $(echo ${f} |perl -ne 'm/split(0*)(\d+)/g;print "Split",$2+1,"\n";');done
### submit a job array, allowing 50 jobs to be run at anyone time
ID=$(bsub -J "sort[1-1000]%50" "sort -n Split\$LSB_JOBINDEX >Split\$LSB_JOBINDEX.sorted" |perl -ne 'm/<(\d+)>/;print "$1"')
### merge the sorted files together once all the jobs are finished using the –w dependency
ID2=$(bsub -w "done($ID)" "sort -n -m *.sorted >bigFile.sorted" |perl -ne 'm/<(\d+)>/;print "$1"')
@smacarthur
smacarthur / splitAndPlot.R
Created December 10, 2010 12:33
Example code to split and plot a data.frame
if (!require(RColorBrewer)){
install.packages("RColorBrewer")
library(RColorBrewer)
}
### Generate a random data set
data <- data.frame(names=c("Type1","Type2")[as.numeric((runif(n=100)>=0.5))+1],data=rnorm(100,100,sd=25))
### Use the aggregate function to split and get the mean of the data
aggregate(data$data,list(data$names),mean)
@smacarthur
smacarthur / gist:733313
Created December 8, 2010 14:05
RColorBrewer Example
### Load the package or install if not present
if (!require("RColorBrewer")) {
install.packages("RColorBrewer")
library(RColorBrewer)
}
### Set the display a 2 by 2 grid
par(mfrow=c(2,2))
### Show all the colour schemes available