Skip to content

Instantly share code, notes, and snippets.

@baskaufs
baskaufs / jQuery-get1.htm
Created June 1, 2015 13:27
test using jQuery to retrieve JSON cross-domain
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>test HTTP GET from cross-domain URL using jQuery</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
var uri = "http://api.gbif.org/v1/occurrence/search?occurrenceID=http%3A%2F%2Fbioimages.vanderbilt.edu%2Find-baskauf%2F28747%232003-07-25";
//var uri = "http://tdwg-rdf.phylodiversity.net/store3/sparql?query=SELECT%20DISTINCT%20%3Fimage%20WHERE%20%7B%3Chttp%3A%2F%2Fbioimages.vanderbilt.edu%2Find-baskauf%2F00000%3E%20%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2Fdepiction%3E%20%3Fimage.%7D";
$(document).ready(function(){
$("button").click(function(){
@baskaufs
baskaufs / 930739851.json
Created June 1, 2015 14:32
example JSON returned from GBIF web api for an occurrence documented by several images
{"offset":0,"limit":20,"endOfRecords":true,"count":1,"results":[{"key":930739851,"datasetKey":"0096dfc0-9925-47ef-9700-9b77814295f1","publishingOrgKey":"1df2cfdc-3b09-4076-861d-f56389927d9b","publishingCountry":"US","protocol":"DWC_ARCHIVE","lastCrawled":"2014-07-22T12:51:23.415+0000","lastParsed":"2014-07-22T12:51:23.438+0000","extensions":{},"basisOfRecord":"HUMAN_OBSERVATION","establishmentMeans":"NATIVE","taxonKey":2685318,"kingdomKey":6,"phylumKey":101,"classKey":194,"orderKey":640,"familyKey":3925,"genusKey":2684876,"speciesKey":2685318,"scientificName":"Abies fraseri (Pursh) Poir.","kingdom":"Plantae","phylum":"Pinophyta","order":"Pinales","family":"Pinaceae","genus":"Abies","species":"Abies fraseri","genericName":"Abies","specificEpithet":"fraseri","taxonRank":"SPECIES","dateIdentified":"2002-05-28T22:00:00.000+0000","decimalLongitude":-83.49968,"decimalLatitude":35.56291,"continent":"NORTH_AMERICA","stateProvince":"North Carolina","year":2002,"month":5,"day":29,"eventDate":"2002-05-28T22:00:00.000+00
@baskaufs
baskaufs / http-get-json-test.htm
Created June 1, 2015 14:36
HTML file that uses javascript to make HTTP GET call to GBIF API then display stuff based on the returned JSON data
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>test HTTP GET from cross-domain URL using Javascript</title>
</head>
<body>
<div id="div1">text goes here</div>
<script type="text/javascript">
var http = new XMLHttpRequest();
var url = "http://api.gbif.org/v1/occurrence/search?occurrenceID=http%3A%2F%2Fbioimages.vanderbilt.edu%2Find-baskauf%2F11420%232002-05-29";
@baskaufs
baskaufs / failed-jsonp.html
Created June 2, 2015 02:53
failed jsonp query to callimachus localhost url
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>test HTTP GET from cross-domain URL using jQuery</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
var uri = "http://localhost:8080/sparql?query=SELECT%20DISTINCT%20%3Fimage%20WHERE%20%7B%3Chttp%3A%2F%2Fbioimages.vanderbilt.edu%2Find-baskauf%2F00000%3E%20%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2Fdepiction%3E%20%3Fimage.%7D";
$(document).ready(function(){
$("button").click(function(){
$.ajax ({
@baskaufs
baskaufs / gist:8b7f4e8dedb2e59cfffd
Created June 2, 2015 16:16
Use case 3: List scientific names of taxa documented in 2 states in Bioimages
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dcmitype: <http://purl.org/dc/dcmitype/>
PREFIX dwc: <http://rs.tdwg.org/dwc/terms/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX ac: <http://rs.tdwg.org/ac/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dwciri: <http://rs.tdwg.org/dwc/iri/>
PREFIX dsw: <http://purl.org/dsw/>
@baskaufs
baskaufs / uc4.sparql
Created June 2, 2015 16:34
Use case 4: find access URLs for Good Quality SAPs of white oak leaves
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dcmitype: <http://purl.org/dc/dcmitype/>
PREFIX dwc: <http://rs.tdwg.org/dwc/terms/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX ac: <http://rs.tdwg.org/ac/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dwciri: <http://rs.tdwg.org/dwc/iri/>
PREFIX dsw: <http://purl.org/dsw/>
@baskaufs
baskaufs / jquery-sparql-test.htm
Created June 3, 2015 01:08
jQuery SPARQL test using a Callimachus "page"
<!DOCTYPE html>
<html>
<head>
<title>jQuery SPARQL test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
// function to turn XML object into a string
function getXmlString(xml) {
if (window.ActiveXObject) { return xml.xml; }
@baskaufs
baskaufs / prototype-webpage.html
Created June 4, 2015 02:51
Hack of jQuery SPARQL test using a Callimachus "page" using Sean's query
<!DOCTYPE html>
<html>
<head>
<title>jQuery SPARQL test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
// function to turn XML object into a string
function getXmlString(xml) {
if (window.ActiveXObject) { return xml.xml; }
@baskaufs
baskaufs / sparql-query-with-bootstrap.html
Last active August 29, 2015 14:22
Copy of the gist Sean posted
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery SPARQL test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootswatch/3.3.4/united/bootstrap.min.css">
<link rel="stylesheet" href="/stylesheets/style.css">
http://localhost:8080/sparql?query=SELECT%20DISTINCT%20%3Fimage%20WHERE%20%7B%3Chttp%3A%2F%2Fbioimages.vanderbilt.edu%2Find-baskauf%2F00000%3E%20%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2Fdepiction%3E%20%3Fimage.%7D