Skip to content

Instantly share code, notes, and snippets.

View timhodson's full-sized avatar

Tim Hodson timhodson

View GitHub Profile
@timhodson
timhodson / ExampleKasabiSparqlApiUse.java
Created February 20, 2012 16:27
JAVA: Retrieve Kasabi API key from shell environment.
package example;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.ResultSetFormatter;
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
@timhodson
timhodson / Kasabi-search-API-example.sh
Created February 20, 2012 16:46
Execute a sample search against the food dataset
# assumes you have set the value of KASABI_API_KEY in your shell session or .profile
curl -v -X GET "http://api.kasabi.com/dataset/nasa/apis/search?apikey=$KASABI_API_KEY&query=apollo" | xmllint --format -
@timhodson
timhodson / gist:1875891
Created February 21, 2012 11:08
Kasabi: Quick example of using the Attribution API
#############################################
## Quick and dirty curl
#############################################
# Get a snippet of javascript
curl -v -X GET "http://api.kasabi.com/dataset/nasa/attribution"
# Get the attribution as JSON
curl -v -X GET "http://api.kasabi.com/dataset/nasa/attribution?output=json"
@timhodson
timhodson / gist:1877329
Created February 21, 2012 16:49
Kasabi: Quick example of using the lookup api
########################################
## Quick curl commands
########################################
# get the response as RDF
curl -v -X GET "http://api.kasabi.com/dataset/airlines/apis/lookup?about=http://data.kasabi.com/dataset/airlines/MYL&output=rdf&apikey=$KASABI_API_KEY"
# get the response as JSON
curl -v -X GET "http://api.kasabi.com/dataset/airlines/apis/lookup?about=http://data.kasabi.com/dataset/airlines/MYL&output=json&apikey=$KASABI_API_KEY"
@timhodson
timhodson / gist:1884117
Created February 22, 2012 10:52
Kasabi: Quick example of using the sparql API
########################################
## Quick curl commands
########################################
# get the response as RDF
curl -v -X GET "http://api.kasabi.com/dataset/airlines/apis/sparql?query=describe%20?s1%20where%20%7B%0A%20%20?s1%20a%20%3Chttp://xmlns.com/foaf/0.1/Organisation%3E%20.%0A%20%20%7D%0ALimit%2010&output=rdf&apikey=$KASABI_API_KEY"
# get the response as JSON
curl -v -X GET "http://api.kasabi.com/dataset/airlines/apis/sparql?query=describe%20?s1%20where%20%7B%0A%20%20?s1%20a%20%3Chttp://xmlns.com/foaf/0.1/Organisation%3E%20.%0A%20%20%7D%0ALimit%2010&output=json&apikey=$KASABI_API_KEY"
@timhodson
timhodson / gist:1941372
Created February 29, 2012 15:03
Kasabi: Standard Search API examples
########################################
## Quick curl examples
########################################
# Search for Queen Victoria in the Government Art Collection - JSON results
curl -v -X GET "http://api.kasabi.com/dataset/government-art-collection/apis/search?apikey=$KASABI_API_KEY&query=Queen+Victoria&output=json"
# Search for Queen Victoria in the Government Art Collection - XML results
curl -v -X GET "http://api.kasabi.com/dataset/government-art-collection/apis/search?apikey=$KASABI_API_KEY&query=Queen+Victoria&output=xml" | xmllint --format -
@timhodson
timhodson / gist:1949665
Created March 1, 2012 12:50
Kasabi: Solr Search API examples
########################################
## Quick curl examples
########################################
# Search for Queen Victoria in the Government Art Collection - JSON results
curl -v -X GET "http://api.kasabi.com/dataset/government-art-collection/apis/search/solr?apikey=$KASABI_API_KEY&q=Queen+Victoria&wt=json"
# Search for Queen Victoria in the Government Art Collection - XML results
curl -v -X GET "http://api.kasabi.com/dataset/government-art-collection/apis/search/solr?apikey=$KASABI_API_KEY&q=Queen+Victoria&wt=xml" | xmllint --format -
<?php
/**
* This example script will search for a term in the government art collection, and
* retrieve some more RDF about a particular type of thing we are interested in.
* This demonstrates the Follow-Your-Nose Paradigm possible with Linked Data.
*
* The program runs like this:
* - Use the SPARQL API to find some things which have an image and filter out
* only those which have a certain term in the title
@timhodson
timhodson / commit-status.sh
Created March 2, 2012 14:55
Kasabi: example curl commands for exploring the /status API
# This request is only successful if you are the dataset owner.
# i.e. your API key is the same as the owner of the dataset's API key.
curl -v -X GET "http://api.kasabi.com/dataset/government-art-collection/status/1?apikey=$KASABI_API_KEY"
@timhodson
timhodson / gist:2302411
Created April 4, 2012 15:08
loop through files and feed contents to a script to process them
# where patterns are in files numbered like pattern_file_01.txt
for pattern in `ls pattern_file_??.txt`
do
STRING=`cat $pattern`
php -f myCleverScipt.php -- $STRING
done
# where patterns are single lines of a single file
while read line