Skip to content

Instantly share code, notes, and snippets.


Rory Kirchner roryk

View GitHub Profile
roryk /
Created May 31, 2022
Download a range of PGN files from The Week In Chess
mkdir -p ${TMPDIR}
parallel -j 4 wget -P download{} ::: $(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
View gist:a3e7381d65a819eb8831db9b1137f5c9
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.
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"
View gist:318b347128bf5df8fee5
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
View gist:4476452
# 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) {
gist_url = ''
#gist_url = ''
tmp = tempfile()
knit(rmd, tmp)
f = file(md, "w")
View gist:4476421
<style TYPE="text/css">
code.has-jax {font: inherit; font-size: 100%; background: inherit; border: inherit;}
<script type="text/x-mathjax-config">
tex2jax: {
inlineMath: [['$','$'], ['\\(','\\)']],
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'] // removed 'code' entry
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"
View gist:3a28ede54cc2af6825f1
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:
roryk / gist:4291793
Created Dec 15, 2012
Steps through elisp to find an error.
View gist:4291793
; from saved for posterity
(defalias 'puffer-lesen 'eval-buffer-or-region-step-by-step)
(defun eval-buffer-or-region-step-by-step ()
"Stepps through region if activated, otherwise takes the whole buffer
evaluating last-sexp and messaging point. As `eval-last-sexp' exits
encountering an error, you may easily pick the last point.
Attention: Commands changing the current-buffer as `find-file' will
derail the check."
roryk / gist:fda5c55fb732ea06a1b5
Created Sep 21, 2015
View gist:fda5c55fb732ea06a1b5
[ 51%] Performing build step for 'libsparsehash'
cd /tmp/sailfish20150920-18016-i304l8/sailfish-0.7.4/external/sparsehash-sparsehash-2.0.2 && /Applications/
[ -d src/sparsehash/internal ] || mkdir -p src/sparsehash/internal
echo "/*" > src/sparsehash/internal/_sparsehash_config
echo " * NOTE: This file is for internal use only." >> src/sparsehash/internal/_sparsehash_config
echo " * Do not use these #defines in your own program!" >> src/sparsehash/internal/_sparsehash_config
echo " */" >> src/sparsehash/internal/_sparsehash_config
awk '{prevline=currline; currline=$0;} \
/^#/ {in_second_file = 1;} \
!in_second_file {if (currline !~ /^ *$/) {inc[currline]=0}}; \