Skip to content

Instantly share code, notes, and snippets.

View mwatts15's full-sized avatar
🏠
Working from home

Mark Watts mwatts15

🏠
Working from home
View GitHub Profile
@mwatts15
mwatts15 / extract.py
Created March 13, 2014 04:55
A script for extracting tags and titles from firefox bookmarks
import sqlite3
import time
import sys
from os import environ
try:
sys.setappdefaultencoding('utf-8')
except:
sys = reload(sys)
sys.setdefaultencoding('utf-8')
@mwatts15
mwatts15 / CElegansConnectome.nml
Created May 28, 2014 16:54
Generated through PyOpenWorm
This file has been truncated, but you can view the full file.
<neuroml xmlns="http://www.neuroml.org/schema/neuroml2" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.neuroml.org/schema/neuroml2 https://raw.github.com/NeuroML/NeuroML2/development/Schemas/NeuroML2/NeuroML_v2beta2.xsd" id="CElegansConnectome">
<network id="CElegansConnectome">
<population id="PVPL" component="PVPL" size="1">
<instance id="0">
<location y="0." x="0." z="0."/>
</instance>
</population>
<population id="AVFR" component="AVFR" size="1">
<instance id="0">
<location y="0." x="0." z="0."/>
@mwatts15
mwatts15 / test_graph_changes.py
Last active August 29, 2015 14:02
Testing changes to a graph
import rdflib as R
from random import randint,sample
import subprocess
from subprocess import PIPE
import os
# Load in the graph
g = R.ConjunctiveGraph(identifier=R.URIRef("http://somehost.com/default_graph"))
graph_uri = R.URIRef("http://somehost.com/default_graph")
YOUR_TEST_GRAPH = 'changes_test.nq'
YOUR_TEST_GRAPH_FORMAT = 'nquads'
@mwatts15
mwatts15 / Sleepycat_updown.py
Last active August 29, 2015 14:05
How long does it take to open and close a Sleepycat (Berkeley DB) store versus a persisted ZODB store?
import rdflib as R
from subprocess import call
from time import time
def median(mylist):
# from http://stackoverflow.com/questions/10482339/how-to-find-median
sorts = sorted(mylist)
length = len(sorts)
if not length % 2:
return (sorts[length / 2] + sorts[length / 2 - 1]) / 2.0
@mwatts15
mwatts15 / pascal_primes.rkt
Created September 1, 2014 15:39
Colors Pascal's triangle by the largest prime factor
#lang racket
(require pict)
(require racket/draw)
(require racket/fixnum)
(define (slop f l)
(cond
((null? l) '())
(#t (cons (f l) (slop f (cdr l))))))
diff --git a/PyOpenWorm/neuron.py b/PyOpenWorm/neuron.py
index d693f32..32b52e8 100644
--- a/PyOpenWorm/neuron.py
+++ b/PyOpenWorm/neuron.py
@@ -82,7 +82,6 @@ class Connection(P.Property):
int
The number of connections matching the paramters given
"""
- # XXX: Turn this into a COUNT query
options = dict()
@mwatts15
mwatts15 / README.patch
Last active August 29, 2015 14:14
See openworm/PyOpenWorm issue #91
diff --git a/PyOpenWorm/neuron.py b/PyOpenWorm/neuron.py
index d693f32..de6a7b4 100644
--- a/PyOpenWorm/neuron.py
+++ b/PyOpenWorm/neuron.py
@@ -82,7 +82,6 @@ class Connection(P.Property):
int
The number of connections matching the paramters given
"""
- # XXX: Turn this into a COUNT query
options = dict()
@mwatts15
mwatts15 / issue-92.py
Last active August 29, 2015 14:14
See openworm/PyOpenWorm #92
import sys
import PyOpenWorm as P
if len(sys.argv) > 1:
P.connect(conf={'rdf.source':'default'})
P.loadData('../WormData.n3')
else:
P.connect('default.conf')
def should_match(y, x):
@mwatts15
mwatts15 / traversals.py
Created January 30, 2015 19:07
Demo graph traversals for mapping object graphs to RDF
from __future__ import print_function
import pprint as PP
class A(object):
def __init__(self):
self.o = dict()
self.p = dict()
self.var = None
self.ident = None
@property
@mwatts15
mwatts15 / query.py
Created February 26, 2015 21:47
A thing for doing graph queries
import yarom as Y
import rdflib as R
from rdflib.tools.rdf2dot import rdf2dot
from pprint import pprint as PP
from time import time
from object_name_dict import onames as ONAMES
from object_name_dict import pnames as PNAMES
import sys