Skip to content

Instantly share code, notes, and snippets.

@sdouglas
sdouglas / ifttt_rss2md.py
Last active Aug 29, 2015
find PMID in txt file, fetch XML from pubmed, parse into jekyll post, write markdown file to ~/Desktop
View ifttt_rss2md.py
#!/usr/bin/env python
# encoding: utf-8
"""
ifttt_rss2md.py
Created on 2014-07-14.
The MIT License (MIT)
Copyright (c) 2014. Shawn Douglas
@sdouglas
sdouglas / dna_rcomp.py
Created Jul 26, 2011
DNA reverse complement
View dna_rcomp.py
import string
complement = string.maketrans('ACGTacgt','TGCATGCA')
def rcomp(s):
"""Returns the reverse complement of the sequence in s."""
return s.translate(complement)[::-1]
@sdouglas
sdouglas / timeit.py
Created Jul 26, 2011
Performance comparisons using timeit
View timeit.py
#!/usr/bin/env python
# encoding: utf-8
import random
import string
from array import array
from timeit import Timer
repeats = 3 # report the best of these repeats
executions = 100000
@sdouglas
sdouglas / parseJson
Created Dec 6, 2011
Parses a cadnano file and prints the [helix, index] for each base in all strands.
View parseJson
#!/usr/bin/env python
# encoding: utf-8
"""
parseJson.py
Created by Shawn M. Douglas on 2011-12-06.
"""
import sys
import os
@sdouglas
sdouglas / gist:1502896
Created Dec 20, 2011
Default cadnano colors (hex and decimal)
View gist:1502896
Colors are stored in decimal format in the json output. RGB values included for reference.
<br><font style="color:#cc0000;">#cc0000</font> = 13369344 = (204,0,0)
<br><font style="color:#f74308;">#f74308</font> = 16204552 = (247,67,8)
<br><font style="color:#f7931e;">#f7931e</font> = 16225054 = (247,147,30)
<br><font style="color:#aaaa00;">#aaaa00</font> = 11184640 = (170,170,0)
<br><font style="color:#57bb00;">#57bb00</font> = 5749504 = (87,187,0)
<br><font style="color:#007200;">#007200</font> = 29184 = (0,114,0)
<br><font style="color:#03b6a2;">#03b6a2</font> = 243362 = (3,182,162)
<br><font style="color:#1700de;">#1700de</font> = 1507550 = (23,0,222)
@sdouglas
sdouglas / gist:3209877
Created Jul 30, 2012
Display "View Source" link in MediaWiki for logged out users
View gist:3209877
if ( !$wgUser->isAllowed('edit') ) {
# if ( $wgUser->isAnon() ) {
# $this->userNotLoggedInPage();
# return;
# } else {
# $wgOut->readOnlyPage( $this->mArticle->getContent( true ), true );
# return;
# }
# Make source available to anon users
@sdouglas
sdouglas / makewikis.sh
Created Jul 30, 2012
Clones a MediaWiki database
View makewikis.sh
#!/bin/sh
if [ $# -ne 2 ]; then
echo 1>&2 Usage: $0 firstdb lastdb
exit 1
fi
START=$1
END=$2
View keybase.md

Keybase proof

I hereby claim:

  • I am sdouglas on github.
  • I am smd (https://keybase.io/smd) on keybase.
  • I have a public key whose fingerprint is 111F BCB7 C7D6 4FB5 8B24 E9DF 0773 C632 375A 0C83

To claim this, I am signing this object:

@sdouglas
sdouglas / print-upgrade.pl
Created Jul 30, 2012
Runs mediawiki update and rebuildall scripts for each wiki instance in a wikifarm
View print-upgrade.pl
#!/usr/bin/perl
# Copyright (c) 2007 Shawn M. Douglas (shawndouglas.com)
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
View .bash_profile
PS1="\[\033[38;5;11m\]\u\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]\[\033[38;5;12m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]\[\033[38;5;11m\]\\$\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]"
alias ls='ls -G'
export WORKON_HOME=$HOME/.venvs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
source /usr/local/bin/virtualenvwrapper.sh