Skip to content

Instantly share code, notes, and snippets.

@nicholsn
nicholsn / update_github_default_branch.py
Created June 16, 2020 23:40
Update your default branch in GitHub (default: main)
"""Update your default branch in GitHub (default: main).
This script will rename the master branch (default: main), push the new branch to GitHub,
optionally delete the master branch (default: True, delete master).
python update_github_default_branch.py
Installation
------------
@nicholsn
nicholsn / ncanda_data_dictionary.ipynb
Last active December 3, 2015 00:51
An ipython notebook for working with redcap data dictionaries
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nicholsn
nicholsn / batch.py
Created October 22, 2015 01:30
processing records in batches
def batch(iterable, n=1):
"""
For batch processing of records
:param iterable:
:param n: batch size
:return: generator
"""
l = len(iterable)
for ndx in range(0, l, n):
<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:afni="http://purl.org/nidash/afni#" xmlns:crypto="http://id.loc.gov/vocabulary/preservation/cryptographicHashFunctions#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:dctype="http://purl.org/dc/dcmitype/" xmlns:fsl="http://purl.org/nidash/fsl#" xmlns:nfo="http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#" xmlns:nidm="http://purl.org/nidash/nidm#" xmlns:nlx="http://neurolex.org/wiki/" xmlns:obo="http://purl.obolibrary.org/obo/" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:prov="http://www.w3.org/ns/prov#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:spm="http://purl.org/nidash/spm#" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns="http://www.semanticweb.org/owl/owlapi/turtle#">
<rdf:Description rdf:nodeID="genid1">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Ontology"/>
@nicholsn
nicholsn / peak_query.ipynb
Created October 13, 2015 22:11
Example nidm query
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nicholsn
nicholsn / mk_std_dir.md
Created July 23, 2015 05:31
Command to copy a directory structure without copying the files

Script to create a standard directory structure based on existing

cd /new/dir
(cd /old/dir; find . -type d ! -name .) | xargs mkdir
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"metadata": {
"name": "",
"signature": "sha256:b52d91c59219130c59f60a3b4d38f44bf63c0bb281cf4e10c43b025291a31537"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
http PUT http://glia.ibic.washington.edu:8890/DAV/test.txt Content-Type:text/plain -a dav:dav < test.txt
@nicholsn
nicholsn / virtuoso-connect.py
Created November 13, 2014 16:24
Use rdflib to update a graph on virtuoso
# connect to virtuoso
g = rdflib.ConjunctiveGraph('SPARQLUpdateStore', identifier='http://graphtoupdate')
g.open((sparql_uri, update_uri))
g.store.setCredentials(update_usr, update_pwd)
g.store.setHTTPAuth(update_auth)
#​ create a graph to parse update file​
update = rdflib.graph()
update​.parse('file.ttl', format='turtle')
update​.skolemize(new_graph=​g.​store)