Skip to content

Instantly share code, notes, and snippets.

View Colelyman's full-sized avatar

Cole Lyman Colelyman

View GitHub Profile
@Colelyman
Colelyman / gist:4049013
Created November 9, 2012 23:30
Simon 124 Cole Lyman
// Beginning of our code
int beat_counter = 0;
int rand_array[] = 100;
bool fail = true;
setrandSeed();
do { // loop for each round
rand_array[beat_counter] = rand16();
@Colelyman
Colelyman / AndroidManifest.xml
Created April 7, 2016 19:45
Orientation hack for activities.
<activity android:name=".ui.activities.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize">
android:label="Main Activity"
android:name=".MainActivity"
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
@Colelyman
Colelyman / jupyter.sh
Last active October 24, 2018 11:07
Get Jupyter Notebook Running in SSH Tunnel
user@server$ jupyter notebook --no-browser --port=8889
# run client side
user@client$ ssh -N -f -L localhost:8000:localhost:8889 remote_user@remote_host
firefox http://localhost:8000
# source: https://coderwall.com/p/ohk6cg/remote-access-to-ipython-notebooks-via-ssh
@Colelyman
Colelyman / View Aligned Reads
Last active October 17, 2018 03:34
This gist is a mini tutorial on how to view aligned reads in the command line using samtools tview.
# Convert .sam file to .bam file
$ samtools view -b -S -o [outputted bam file] [inputted sam file]
# Sort and index the .bam file
$ samtools sort [inputted bam file] > [output prefix of bam file].sorted
$ samtools index [inputted bam file].sorted.bam
@Colelyman
Colelyman / tibble-dplyr-tricks.R
Last active March 25, 2017 22:02
Useful tricks for manipulating tibbles with dplyr that I have found useful.
library(tibble)
# create a tibble with no rows, but defined columns
tbl <- tibble(name=character(), age=numeric(), gender=factor())
# add a row to the tibble. The values can even be vectors!!
tbl <- add_row(tbl, name='Steve', age='24', gender='male')
@Colelyman
Colelyman / sbatch_tricks.sh
Created December 9, 2017 07:15
Some tricks for doing cool things with sbatch scripts.
# start a job after another job succeeds
JOBID=$(sbatch --parsable job1.sh) && sbatch --dependency=afterok:$JOBID job2.sh
# start a job after another job fails
JOBID=$(sbatch --parsable job1.sh) && sbatch --dependency=afternotok:$JOBID job2.sh
# get the time and memory of a running node
sstat --format="CPUTime,Elapsed,MaxRSS" -j $SLURM_JOB_ID
@Colelyman
Colelyman / install.sh
Created January 2, 2018 21:02
How to link software installed in a custom location using autotools.
# to be run within your project that is built with autotools (aka has a configure script)
# replace the text within '<...>' with the respective paths
export LD_LIBRARY_PATH=<lib directory of the library>:$LD_LIBRARY_PATH
./configure CPPFLAGS="-I<include directory of the library> -L<lib directory of the library>"
make CPPFLAGS="-I<include directory of the library> -L<lib directory of the library>" LDFLAGS="-I<include directory of the library> -L<lib directory of the library>"

Keybase proof

I hereby claim:

  • I am colelyman on github.
  • I am colelyman (https://keybase.io/colelyman) on keybase.
  • I have a public key ASDSxAqaZq-uEWXfjlA7FumgaGXm47CeKWxqphX0ITlVMQo

To claim this, I am signing this object:

@Colelyman
Colelyman / file-defer-close.lisp
Last active October 23, 2018 03:39
A Common Lisp macro that opens a file and closes it after some computation is done.
(defmacro open-file-defer-close (file-path file-handle &body body)
"Opens FILE-PATH as FILE-HANDLE, executes BODY and finally closes FILE-HANDLE."
`(let ((,file-handle ,(open file-path)))
,@body
(close ,file-handle)))
d_grimshawi
d_virilis
d_mojavensis
d_willistoni
d_persimilis
d_pseudoobscura
d_ananassae
d_erecta
d_yakuba
d_melanogaster