Skip to content

Instantly share code, notes, and snippets.

View birkin's full-sized avatar

Birkin James Diana birkin

View GitHub Profile
@birkin
birkin / availability_logic.py
Created March 1, 2018 20:07
ezb availability logic excerpt
AVAILABLE_LOCATIONS = [
"ANNEX",
"ONLINE",
"ONLINE BOOK",
"ORWIG",
"ORWIG STORAGE",
"ROCK",
"ROCK CHINESE",
"ROCK JAPANESE",
"ROCK KOREAN",
@birkin
birkin / shib_tunneler.py
Created December 20, 2017 20:22
python3 tunneler through shib for test-accounts.
"""
Shib tunneler.
Assumes non-two-factor-authentication acount
"""
import json, logging, os, pprint
from urllib.parse import urlparse, parse_qs
import requests
from bs4 import BeautifulSoup
@birkin
birkin / execnet_example.py
Last active September 8, 2017 15:04
example calling a python2 module from python3
import pprint, sys
import execnet # <http://execnet.readthedocs.io/en/latest/>
## todo...
## compare & contrast with:
## <https://github.com/Brown-University-Library/xsl_transformer_project/blob/61f4a0e7f6dacd6fdc50e87e09b0ead88b35e958/transformer_app/models.py#L215-L217>
assert sys.version_info >= ( 3,0 )
gw = execnet.makegateway( 'popen//python=python2.7' )
@birkin
birkin / type_and_kinds.go
Last active September 7, 2017 01:25
detects TypeOf() and Kind() of types
package main
import "fmt"
import "reflect"
func main() {
var a int = 2
var b []int
var c [10]int
@birkin
birkin / node_fuseki_notes.md
Created June 4, 2017 15:21
serving html via node

install node.js & npm

bbox-2015:~ birkin$
bbox-2015:~ birkin$ brew doctor
Your system is ready to brew.
bbox-2015:~ birkin$

bbox-2015:~ birkin$
bbox-2015:~ birkin$ node -v

-bash: node: command not found

@birkin
birkin / bad_marc_handling.py
Last active April 27, 2017 17:57
experiments with reading bad marc records, using io (on-the-fly)
# -*- coding: utf-8 -*-
"""
Experimentation for how to handle bad marc records.
<https://gist.github.com/birkin/dc657b15f64704ed03126d556317da3c>
"""
import io, pprint, time
import pymarc
@birkin
birkin / offsite_storage_wishlist.md
Last active March 22, 2017 14:33
offsite-storage wishlist...

offsite storage wishlist

  • Main wishes...

    • logging

      • When I was implementing annex-requesting, it would have been nice to see detailed logging of whether my submitted data was good. Same for troubleshooting; updating code.
      • Related: some process I can check to see if a submission was successfully submitted/processed.
    • post requests

  • Right now, I put a data-file, and a related count-file, in a particular place on the server. I would like to be able to post required data to a url -- and get back an appropriate status code indicating the submission was valid.

@birkin
birkin / c4lcon17_lightning.md
Last active March 7, 2017 22:05
notes for lightning talk

lightning talk...

I'll note a problem, and a solution I wanted to share, and speak a little more broadly...

The problem was a workflow. A Digital Humanities Librarian and her graduate-students would intermittently work on a faculty project, which, at its core, has a website showing translated inscriptions. Their xml data was stored in a private subversion repository. I had set up a script to periodically check to see if inscriptions in the subversion repository had been updated, and, if so, to then process them for display. Many months could go by without any data changes being made, followed by brief bursts of updates. So the problem was, I tended to want my script to check for changes relatively infrequently, but during work-bursts, the data-updaters wanted to see their changes flow into the website as immediately as possible.

We tried a couple things, but the eventual solution: we've moved the xml data-files to a public github repository, and use github's webhooks feature. This allowed us to m

@birkin
birkin / suggestions.md
Last active February 22, 2017 23:48
book group suggestions for march 2017

Book Group suggestions for March 2017

(finishing up theme of strong women)


  • Americanah, by Chimamanda Ngozi Adichie
@birkin
birkin / output.sh
Last active February 8, 2017 14:09
install python3 in virtual-env on macOS 10.12.1
######
## - the problem: on macOS 10.12.1, trying to install a virtual-env specifying python 3 does not work
## - cause of problem seems to be an old version of `virtualenv`
## - this is a work-around...
######
## if you need to install python 3...
## ensure you can run brew doctor with no errors/warnings