Skip to content

Instantly share code, notes, and snippets.

View timhodson's full-sized avatar

Tim Hodson timhodson

View GitHub Profile
require 'rubygems'
require 'kasabi'
require 'json'
#change to your API key
APIKEY = "YOUR_API_KEY"
dataset = Kasabi::Dataset.new("http://kasabi.com/dataset/nasa", :apikey => APIKEY )
#Search for "Apollo", limiting to 5 results
require 'rubygems'
require 'kasabi'
require 'json'
#change to your API key
APIKEY = "YOUR_API_KEY"
dataset = Kasabi::Dataset.new("http://kasabi.com/dataset/nasa", :apikey => APIKEY )
#Search for "Apollo", limiting to 5 results
require 'rubygems'
require 'kasabi'
require 'json'
require 'rdf'
require 'rdf/json'
#Demonstration api key
APIKEY = "YOUR_API_KEY"
dataset = Kasabi::Dataset.new("http://kasabi.com/dataset/nasa", :apikey => APIKEY )
require 'rubygems'
require 'kasabi'
#Demonstration api key
APIKEY = "YOUR_API_KEY"
dataset = Kasabi::Dataset.new("http://kasabi.com/dataset/nasa", :apikey => APIKEY )
#SPARQL query to find name of spacecraft launched on 16th July 1969, as JSON"
QUERY = <<-EOL
require 'sinatra'
require 'kasabi'
get '/' do
dataset = Kasabi::Dataset.new("http://data.kasabi.com/dataset/nasa", :apikey => ENV["KASABI_API_KEY"])
@query = params[:query] || "apollo"
@results = dataset.search_api_client.search(@query)
template =<<-EOL
<html>
require "rubygems"
require "bundler"
Bundler.require
require "./app"
run Sinatra::Application
source :rubyforge
gem 'rack'
gem 'sinatra'
gem 'kasabi'
@timhodson
timhodson / kasabi_apikey_proxy.conf
Created February 20, 2012 16:01
Create an apache proxy with Kasabi apikey header injection
# Create an apache proxy with Kasabi apikey header injection
# Requests to http://127.0.0.1/kasabi will be forwarded and have the X-KASABI-APIKEY header set.
# e.g.
# http://127.0.0.1/kasabi/dataset/food/apis/search?query=fish
# will be forwarded to
# http://api.kasabi.com/dataset/food/apis/search?query=fish
# and responses will be passed back to the client
NameVirtualHost *
@timhodson
timhodson / kasabi_apikey_user_env.sh
Created February 20, 2012 16:07
Set an environment variable for the Kasabi apikey
# add this to your user's .profile
KASABI_API_KEY="123MYSECRETKEY" ; export KASABI_API_KEY
@timhodson
timhodson / kasabi_apikey.php
Created February 20, 2012 16:15
PHP: Retrieve Kasabi apikey from shell environment
// set some kasabi variables
$kasabi_api_base = "http://api.kasabi.com";
$kasabi_api_key = getenv('KASABI_API_KEY');
// now use the key in anger
$my_query = "grilled fish";
$my_url = $kasabi_api_base."/dataset/food/apis/search?query=".urlencode($my_query)."&apikey=".$kasabi_api_key;
// now do something amazing...