Skip to content

Instantly share code, notes, and snippets.

Avatar

Shawn Graham shawngraham

View GitHub Profile
@shawngraham
shawngraham / retrieve-theses-metadata.R
Created Jan 17, 2022
script to generate a table of metadata concerning theses in CURVE repository; curve is changing soon so this will become dated
View retrieve-theses-metadata.R
library(rvest)
library(dplyr)
library(xml2)
library(stringr)
library(purrr)
base_url <- "https://curve.carleton.ca"
theses = data.frame()
View test-neo4j.csv
Artifact Position_X Position_Y chip name
242 1110.973076 480.0500947 /Users/shawngraham/Documents/chips2/object1/0000000001.png
252 772.6520572 434.331038 /Users/shawngraham/Documents/chips2/object2/0000000001.png
1231 626.3510759 672.0701326 /Users/shawngraham/Documents/chips2/object3/0000000001.png
35 2059.369176 1630.107527 /Users/shawngraham/Documents/chips2/object4/0000000001.png
35 594.3477363 1275.56168 /Users/shawngraham/Documents/chips2/object4/0000000002.png
@shawngraham
shawngraham / getannotations.py
Last active Apr 13, 2021
extracting structured notes from PUBLIC hypothes.is annotations based on https://gist.github.com/judell/ca913dd64a29f852afd3
View getannotations.py
import requests, re, json, types, traceback
class HypothesisAnnotation:
def __init__(self, row):
"""Encapsulate relevant parts of one row of a Hypothesis API search."""
self.tags = []
if row.has_key('tags') and row['tags'] is not None:
self.tags = row['tags']
View simple-scraper.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shawngraham
shawngraham / historygen.py
Last active Oct 28, 2020
A History Generator; Also Does Timelines!
View historygen.py
#!/usr/bin/env python
# source: https://gamedev.stackexchange.com/questions/23659/is-there-a-way-to-procedurally-generate-the-history-of-a-world
# to create a visualisation, run like this:
# ./historygen.py --dot | dot -Tpng > filename.png
# brew install graphviz to get the dot files rendering
# to have the story, run like this:
# ./historygen.py
# have your state names in the names.txt file
# now, all of this *could* be done with tracery i suppose, but you can see the bones of the
# history system could be expanded to model other aspects, keep track of things, calculate new things.
@shawngraham
shawngraham / bib.xsl
Last active Oct 15, 2020
sample metadata from jstor-dfr, and an xsl file meant to turn it into a citations.tsv with: xsltproc bib.xsl *.xml > citations.tsv
View bib.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="article/front">
"<xsl:value-of select="article-meta/contrib-group/contrib/string-name/surname" />, <xsl:value-of select="article-meta/contrib-group/contrib/string-name/given-names" />" <xsl:text>&#9;</xsl:text><xsl:value-of select="article-meta/pub-date/year" /> <xsl:text>&#9;</xsl:text> "<xsl:value-of select="article-meta/title-group/article-title" />" <xsl:text>&#9;"</xsl:text><xsl:value-of select="journal-meta/journal-title-group/journal-title"/>"<xsl:text>&#9;</xsl:text> "<xsl:value-of select="article-meta/volume" />(<xsl:value-of select="article-meta/issue" />)" <xsl:text>&#9;</xsl:text> "<xsl:value-of select="article-meta/page-range" />" <xsl:text>&#9;</xsl:text>"<xsl:value-of select="article-meta/article-id" />" <xsl:text>&#9;</xsl:text><xsl:value-of select="article-meta/self-uri" /><xsl:text>&#xA;</xsl:text>
</xsl:for-each>
@shawngraham
shawngraham / entities.csv
Last active Jul 22, 2020
giving nertwork a spin on chapbooks from the national library of scotland. cancelled out of the script because my machine was running hot; did extract some 13 000 entities though
View entities.csv
doc entity entityType count
104184105 ABERDEEN organization 1
104184105 Navy organization 1
104184105 Sceptre organization 1
104184105 1 person 1
104184105 Brodie person 2
104184105 Cromar person 2
104184105 Earl person 1
104184105 Fife person 3
104184105 Glen person 1
View splitAudio.py
#!/usr/bin/python
## Split audio files into chunks
## Daniel Pett 1/5/2020
__author__ = 'portableant'
## Tested on Python 2.7.13
import argparse
import os
import speech_recognition as sr
@shawngraham
shawngraham / getNotes.scpt
Created Mar 11, 2020
extract notes from skim to clipboard
View getNotes.scpt
(* Inspired and modified based on http://drosophiliac.com/2012/09/an-academic-notetaking-workflow.html and https://gist.github.com/smargh/6068104 *)
(* PROPERTIES *)
property LF : (ASCII character 10)
property tid : AppleScript's text item delimiters
(* THE SCRIPT *)
tell application "Skim"
set the clipboard to ""
activate
View now, extract the lat,long
import json
with open('ottawadata.json') as f:
data = json.load(f)
....now, what cunning piece of code would do the trick? with jqplay I can get eg latitude with
.content.indexedStructured.geoLocation[]|.points[].latitude.content
anyway... off to read some basic python stuff I guess.