Skip to content

Instantly share code, notes, and snippets.

View ptgolden's full-sized avatar

Patrick Golden ptgolden

View GitHub Profile
@ptgolden
ptgolden / filter_genes.py
Created June 21, 2017 13:39
Filter genes for whitelist on http://tintori.bio.unc.edu
#/usr/bin/env python
import os
import json
import sys
import subprocess
whitelist_url = 'https://raw.githubusercontent.com/ptgolden/ma-browser/master/src/gene_whitelist.json'
if __name__ == '__main__':
@base <file:///home/patrick/Code/projects/annot/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix oa: <http://www.w3.org/ns/oa#> .
@prefix bibo: <http://purl.org/ontology/bibo/> .
<#annotation1>
rdf:Type oa:Annotation ;
oa:hasBody <#body1> ;
oa:hasTarget <#target1> .
@ptgolden
ptgolden / crawl_w3_list.py
Last active November 24, 2015 16:12
Python script to crawl a W3 mailing list and add it to an mbox file.
#!/usr/bin/python3
import html
import mailbox
import re
import sys
import time
from urllib.parse import urljoin
import requests
@ptgolden
ptgolden / start.sh
Created June 1, 2015 18:36
Browserify project setup
# Initialize project
npm init -y
# Install dependences
npm install --save-dev browserify watchify babelify
# Set browserify commands
BROWSERIFY_ARGS='src/index -o dist/bundle.js'
@ptgolden
ptgolden / index.html
Last active August 29, 2015 14:09
Drag drop lines
<!DOCTYPE html>
<meta charset="utf-8">
<style>
html, body { margin: 0; padding: 0; }
#message { height: 3em; width: 800px; text-align: center; padding: 1em 0; box-sizing: border-box;}
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<div id="message"></div>
<script>
var NUM_BINS = 2;
var data = [
[5, 15, 25, 35],
[25, 35, 5, 15],
[25, 25, 15, 5],
[0, 10, 20, 40]
]
var all = Array.prototype.concat.apply([], data)
@ptgolden
ptgolden / test.jsonld
Last active August 29, 2015 14:04
Testing data indexing
{
"@context": {
"periodization": {
"@id": "http://perio.do/#periodization",
"@container": "@index"
},
"label": "schema:name",
"definitions": "http://perio.do/#period"
},
"@id": "http://perio.do/data",
@ptgolden
ptgolden / query
Last active August 29, 2015 14:03
DBPedia SPARQL query for countries
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbprop: <http://dbpedia.org/property/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT ?place, ?label, ?geonamesURI, ?depiction WHERE {
?place a dbo:Country .
?place rdfs:label ?label .
?place foaf:depiction ?depiction .
FILTER langMatches(lang(?label), 'en') .
@ptgolden
ptgolden / years.js
Last active August 29, 2015 14:03
Simple PegJS year parser
// vim: set filetype=javascript
{
function zeroPadded(number) {
var numberInt = parseInt(number)
, numberStr = '' + Math.abs(numberInt)
, sign = numberInt < 0 ? '-' : '+'
if (numberStr.length < 4) numberStr = ('0000' + numberStr).substr(-4, 4);
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import sys
from blessings import Terminal
from lxml.html import parse
RECENTLY_PLAYED_URL = 'http://www.wxyc.info/playlists/recent.html'