Skip to content

Instantly share code, notes, and snippets.

@sahilseth
sahilseth / cloud_formation.sh
Last active January 3, 2016 20:25
Install a new shiny server on Ubuntu (EC2)
## ------ download this file:
## wget https://gist.githubusercontent.com/sahilseth/01d5e88e431334fcd527/raw -O cloud_formation.sh
## bash cloud_formation.sh
## run this file
## chmod u+x cloud_formation.sh
## Assuming you are running this as ubuntu user
### --------- Install from apt-get
@sahilseth
sahilseth / zpanel_backup.sh
Created July 28, 2014 14:43
panel backup script from Richard Ferreira
#!/bin/sh
#----------------------------------------------------------------
# Daily Backup Routine - Backup and Sync to Dropbox
# This script creates a backup using today's date, then deleted
# any backups made 3 days ago. If run every day it will ensure
# you have a week's worth of backups of your MySQL databases and
# zPanel web directories.
#
# Uses whatever Dropbox account is running on the server.
#
@sahilseth
sahilseth / metagenomics.R
Last active August 29, 2015 14:08
flow recipes
## a vector of full paths to fastq files (mate 1)
fqs1 = rep("myfile.fastq", 20)
## a vector of full paths to fastq files (mate 2)
fqs2 = rep("myfile.fastq", 20)
## full path to bwa
bwa_exe = ""
bwa_aln_opts = ""
bwa_sampe_opts = ""
@sahilseth
sahilseth / 0_reuse_code.js
Last active August 29, 2015 14:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@sahilseth
sahilseth / installr_1.sh
Last active September 23, 2015 05:13
Installing R for RStudio on a server
## make a dir to install
sudo mkdir -m 775 /apps
chown sahilseth /apps
## download to a tmp space
cd /tmp
wget http://cran.r-project.org/src/base/R-3/R-3.2.2.tar.gz
tar -zxvf R-3.2.2.tar.gz
cd R-3.2.2
./configure --prefix /apps/R/3.2.2/ --enable-R-shlib --enable-R-profiling \
@sahilseth
sahilseth / simple_make.def
Last active September 29, 2015 16:40
simple make
jobname sub_type prev_jobs dep_type queue memory_reserved walltime cpu_reserved platform jobid
create_db serial none none short 2000 1:00 1 local 1
rna2dna1 serial create_db serial short 2000 1:00 1 local 2
echorna1 serial rna2dna1 serial short 2000 1:00 1 local 3
rna2dna2 serial create_db serial short 2000 1:00 1 local 4
echorna2 serial rna2dna2 serial short 2000 1:00 1 local 5
rna2dna3 serial create_db serial short 2000 1:00 1 local 6
echorna3 serial rna2dna3 serial short 2000 1:00 1 local 7
@sahilseth
sahilseth / progress.R
Last active October 19, 2015 17:10
progress bar in rstats
mn=1;mx=10
pb <- txtProgressBar(mn, mx, style = 3)
tmp <- lapply(mn:mx, function(x){
pb$up(x)
Sys.sleep(0.5)
#message("I am doing something...")
})
@sahilseth
sahilseth / flowr_example.R
Last active October 6, 2015 22:44
flowr simple example
setwd("~/pub/slides/rmeetup_oct2015")
# get commands ------------------------------
hello='echo Hello World !'
sleep=c('sleep 5', 'sleep 5')
tmp=c('cat $RANDOM > tmp1',
'cat $RANDOM > tmp2')
@sahilseth
sahilseth / dataframe_vars.R
Created October 7, 2015 16:08
add complex variable names to a data.frame
df = data.frame(id = 1:10, fname = paste0("name", 1:10))
nms = c(id = "the unique id which does this or that",
fname = "first name of a person")
attr(df, 'info') <- nms
## let is see how this looks
attr(df, "info")
@sahilseth
sahilseth / python_pkgs.sh
Last active October 13, 2015 00:19
installing python packages in a custom location
## add this to bashrc:
export PYTHONPATH=$PYTHONPATH:~/lib/python2.7/site-packages/
module load Python
python setup.py install --prefix=$HOME