This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo(object): | |
def __init__(self): | |
self.history = {"var1": [], "var2": [], "var3": [], "var4": []} | |
def update(self, to_update): | |
for k, v in self.history.iteritems(): | |
if k == to_update: | |
v.append(1) | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tempfile | |
import gffutils | |
import os | |
from argparse import ArgumentParser | |
def get_gtf_db(gtf, in_memory=False): | |
""" | |
create a gffutils DB | |
""" | |
db_file = gtf + ".db" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style TYPE="text/css"> | |
code.has-jax {font: inherit; font-size: 100%; background: inherit; border: inherit;} | |
</style> | |
<script type="text/x-mathjax-config"> | |
MathJax.Hub.Config({ | |
tex2jax: { | |
inlineMath: [['$','$'], ['\\(','\\)']], | |
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'] // removed 'code' entry | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# to add latex equations to a Rmd file, enclose the equations using the $ $ syntax | |
# and run knit_equation on the Rmd file instead of knit | |
knit_equation = function(rmd, md) { | |
require('knitr') | |
require('RCurl') | |
gist_url = 'https://gist.github.com/roryk/4476421/raw/d08080c206b5663e0451a5ef6c56635a0c6f0f17/gistfile1' | |
#gist_url = 'https://gist.github.com/raw/4476421/d08080c206b5663e0451a5ef6c56635a0c6f0f17/gistfile1' | |
tmp = tempfile() | |
knit(rmd, tmp) | |
f = file(md, "w") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# Figure out where this script is located. | |
SELFSCRIPT="`readlink -f \"$0\"`" | |
SELFDIR="`dirname \"$SELFSCRIPT\"`" | |
SELFDIR="`cd \"$SELFDIR\" && pwd`" | |
# Temporarily set PATH and LD_LIBRARY_PATH | |
export PATH=$SELFDIR/bin:$PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import subprocess | |
from argparse import ArgumentParser | |
def find_parallel_environment(queue): | |
"""Find an SGE/OGE parallel environment for running multicore jobs in specified queue. | |
""" | |
base_queue = os.path.splitext(queue)[0] | |
queue = base_queue + ".q" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tom Knight and the Lisp Machine | |
A novice was trying to fix a broken Lisp machine by turning the power off and on. | |
Knight, seeing what the student was doing, spoke sternly: “You cannot fix a machine by just power-cycling it with no understanding of what is going wrong.” | |
Knight turned the machine off and on. | |
The machine worked. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TMPDIR=download | |
START=1161 | |
END=1438 | |
mkdir -p ${TMPDIR} | |
parallel -j 4 wget -P download https://theweekinchess.com/zips/twic{}g.zip ::: $(seq ${START} ${END}) | |
unzip -d ${TMPDIR} ${TMPDIR}/'*.zip' | |
cat ${TMPDIR}/*.pgn > twic_pgn_${START}_${END}.pgn | |
zip twic_pgn_${START}_${END}.zip twic_pgn_${START}_${END}.pgn | |
rm twic_pgn_${START}_${END}.pgn |
OlderNewer