Skip to content

Instantly share code, notes, and snippets.

@tgs
tgs / logiq.py
Last active May 1, 2019 21:19
Prototype Python library for making error messages that explain complicated conditions
# This is a work-for-hire for the Government of the United States, so it is not
# subject to copyright protection.
"""
logiq - A way to build complex conditions and evaluate them against the world.
The goal is to make the conditions easy to construct, and give them useful and
concise error messages as well.
These are some requirement nodes:
@tgs
tgs / index.html
Last active November 13, 2017 21:27 — forked from hubgit/index.html
PubMed search with jQuery
<!doctype html>
<meta charset="utf-8">
<title>PubMed Search</title>
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<ul id="output"></ul>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="pubmed-search.js"></script>
@tgs
tgs / ncbi2na.py
Last active April 19, 2023 16:06
Translate NCBI2na data from hexadecimal to standard bases
#!/usr/bin/env python
"""
Translate compact hex sequence representation to standard bases.
If you have NCBI ASN.1 data, the easiest way to get a FASTA version is to
use NCBI's asn2fasta tool, which is available here:
https://ftp.ncbi.nlm.nih.gov/asn1-converters/by_program/asn2fasta/
NCBI2na is a compact representation of sequence data, where each base just
takes 2 bits. It's commonly found in text ASN.1 files as hexadecimal strings.
@tgs
tgs / funproxy.py
Created November 25, 2015 06:18
see hidden areas in xkcd 1608 - requires bottle.py, PIL(low), numpy
#!/usr/bin/env python
import StringIO
import numpy as np
from bottle import route
from bottle import run
from bottle import abort
import Image
import requests
@tgs
tgs / hist_summary.r
Created May 26, 2015 22:20
Add median to ggplot2 histogram
library(proto)
library(ggplot2)
stat_hist_summary <- function (mapping = NULL, data = NULL, geom = "vline", position = "identity",
fun = median, ...) {
StatHistSummary$new(mapping = mapping, data = data, geom = geom,
position = position, fun = fun, ...)
}
StatHistSummary <- proto(ggplot2:::Stat, {
@tgs
tgs / gitignore.py
Created April 1, 2015 21:00
py.test: ignore the same files as git when doing test collection
import subprocess
# Usage: put it in the current directory, and run
# py.test -p gitignore [...]
def pytest_ignore_collect(path, config):
if path.basename == '.git': # Ignore .git directory
return True
child = subprocess.Popen(['git', 'check-ignore', str(path)],
@tgs
tgs / problemo.py
Last active August 29, 2015 14:09 — forked from anonymous/problemo.py
#!/usr/bin/env python
#
# Half-assed fuzzer for HTML strip-tags functions
#
from __future__ import print_function
BITS = [
'<', '</', '>', '<!--', '-->', 'a', 'div', 'p', 'i',
]
@tgs
tgs / Vagrantfile
Last active August 29, 2015 14:04
Vagrantfile for developing edx/configuration
Vagrant.require_version ">= 1.5.3"
unless Vagrant.has_plugin?("vagrant-vbguest")
raise "Please install the vagrant-vbguest plugin by running `vagrant plugin install vagrant-vbguest`"
end
VAGRANTFILE_API_VERSION = "2"
MEMORY = 2048
CPU_COUNT = 3
@tgs
tgs / README.md
Last active August 29, 2015 14:01
Star thingy

Zing, pow

Click it to make it go some more

@tgs
tgs / README.md
Last active August 29, 2015 14:00
Fun twiddly lines

Click it to make it go again.

A d3.js version of the "egyptian" effect used in Tron. A few really fun pages over here by GMUNK were the inspiration.