Skip to content

Instantly share code, notes, and snippets.

View sterkenburgsara-zz's full-sized avatar

Sara Sterkenburg sterkenburgsara-zz

  • Vanderbilt University
  • Nashville, TN
View GitHub Profile
xquery version "3.1";
declare function local:generate-signature($api_key, $method, $text, $auth_token, $secret, $format)
{
let $hash := $secret || "api_key" || $api_key || "auth_token" || $auth_token || "format" || $format || "method" || $method || "text" || $text
return xs:hexBinary(hash:md5($hash))
};
let $method := "flickr.photos.search"
let $secret := [INSERT SECRET KEY]

Purpose

  • Use XQuery to Batch upload images to Flickr with corresponding metadata by using POST call

Getting Started

  • Request Flickr API key here (requires Yahoo account)
  • Enter a collection for Flickr and API call(s) via postman

Creating Hash for POST requests

  • Write script to generate new API signature for each new call
  • Compare XQuery output of MD5 signature to web output using Miracle Salad
@sterkenburgsara-zz
sterkenburgsara-zz / feature-collection-json.xq
Last active February 17, 2016 17:25
Calling GBIF API for data points & editing into GeoJSON using Feature Collection. Validation with GeoJSONLint.
xquery version "3.1";
declare option output:method 'json';
let $doc := fetch:text("http://api.gbif.org/v1/occurrence/search?limit=50&offset=0scientificName=Quercus%20macrocarpa&decimalLatitude=35.81,36.45&decimalLongitude=-87.21,-86.27
") => json:parse()
let $data :=
for $record in $doc//results/_
let $lat := xs:decimal($record/decimalLatitude/text())
let $long := xs:decimal($record/decimalLongitude/text())
let $id := $record/gbifID/text()
@sterkenburgsara-zz
sterkenburgsara-zz / gbif-api.txt
Created February 12, 2016 21:32 — forked from baskaufs/gbif-api.txt
Some test API calls to get JSON with geocoordinates from the Global Biodiversity Information Facility (GBIF)
See http://www.gbif.org/developer/summary for background.
Find the single occurrence with identifier http://bioimages.vanderbilt.edu/vanderbilt/7-314#2002-06-14
http://api.gbif.org/v1/occurrence/search?occurrenceID=http%3A%2F%2Fbioimages.vanderbilt.edu%2Fvanderbilt%2F7-314%232002-06-14
Note: the occurrenceID is URLencoded.
Find occurrences
- with scientificName=Quercus%20macrocarpa (bur oak, note: space between genus and species is URLencoded as "%20")
- with decimalLatitude between 35.81 and 36.45
- with decimalLongitude between -87.21 and -86.27
let $uri := fn:encode-for-uri( "http://bioimages.vanderbilt.edu/vanderbilt/7-314#2002-06-14")
let $json := fetch:text("http://api.gbif.org/v1/occurrence/search?occurrenceID=" || $uri)
let $json := fn:parse-json($json)
let $latitude := $json?results?1?decimalLatitude
let $longitude := $json?results?1?decimalLongitude
let $identifier := $json?results?1?identifier
return map {
"type": "Feature",
"geometry": map {
"type": "Point",
@sterkenburgsara-zz
sterkenburgsara-zz / bookartists_nodes.txt
Last active July 14, 2016 15:36 — forked from brownht1/gist:807d996c35de219a806d
Neo4j Nodes for Vanderbilt Collection of Southern Artists' Books / Cypher Queries to Display Graph Relationships
= Graphing Artists’ Books: Visualizing Connections within Vanderbilt’s Collection of Southern Presses
=== OUR DATASET
This collection is based on rougly 250 of Vanderbilt University's artists' books published in the "south" (defined using the U.S. Census Bureau's definition). The gist is a part of a Vanderbilt University Dean's Fellow project by Haley Brown.
The project has also been expanded into an exhibition held within the Vanderbilt Special Collections Library. The show will be up from May 2016-May 2017.
Data encoding by Haley Brown and Sara Sterkenburg.
//hide
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix schema: <http://schema.org/Person> .
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
<---> a rdf:Person ;
foaf:name "Sara Sterkenburg" ;
#Educational Level

Vanderbilt Library Exhibitions Program

###2015 Schedule

  • September 2014 - Topics Finalized, Assigned, and Approved
  • October 2014 - Curatorial Assignments Finalized
  • November 2014
  • December 2014
  • Vanderbilt Television News Archive update installed
@sterkenburgsara-zz
sterkenburgsara-zz / batch-convert
Last active January 8, 2016 21:24
Batch convert files
#### CONVERT
rename *.log *.txt
#### DELETE
del /S *.html (or substitute other file extension)
*ensure you are in the right directory before running this command
xquery version "3.1";
declare namespace tei="http://www.tei-c.org/ns/1.0";
let $doc := fn:doc(
"draft-data-works/251.xml"
)
for $element in $doc//tei:bibl/tei:bibl
where $element/@xml:id
(:let $attribute := $element/@xml:id:)
(:where $element[@xml:id="bibl251-11"]:)