Skip to content

Instantly share code, notes, and snippets.

@axiomsofchoice
axiomsofchoice / query-all.sparql
Created August 31, 2011 15:33
How to select *everything* in a triplestore containing several different named graphs
# How to select *everything* in a triplestore containing several different named graphs
SELECT * { { ?s ?p ?o . } UNION { GRAPH ?g { ?s ?p ?o } } }
@axiomsofchoice
axiomsofchoice / schedule.owl
Created August 12, 2011 11:25
Chaos Communication Camp Schedule as Linked Data
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY schedule "http://events.ccc.de/schedule.owl#" >
<!ENTITY owl2xml "http://www.w3.org/2006/12/owl2-xml#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
@axiomsofchoice
axiomsofchoice / command.ll
Created June 5, 2011 10:35
Annotated llvm bytecode for the cubescript example in the tests suite in emscripten
; ModuleID = 'command'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-linux-gnu"
%0 = type { i32, void ()* }
%struct.__class_type_info_pseudo = type { %struct.__type_info_pseudo }
%struct.__type_info_pseudo = type { i8*, i8* }
%struct.__va_list_tag = type { i32, i32, i8*, i8* }
%struct.cline = type { i8*, i32, i32 }
%"struct.hashset<hashtableentry<const char*, ident> >" = type { i32, i32, %"struct.hashset<hashtableentry<const char*, ident> >::chain"**, %"struct.hashset<hashtableentry<const char*, ident> >::chainchunk"*, %"struct.hashset<hashtableentry<const char*, ident> >::chain"* }
@axiomsofchoice
axiomsofchoice / hello.c
Created June 5, 2011 01:48
Simple hello world C prog for testing emscripten's handling of stdio.h
#include <stdio.h>
int main(int argc, char **argv) {
FILE *fp;
char mc ;
fp = fopen(argv[1],"r") ;
printf("Reading contents of file\n");
while((mc = (char) fgetc (fp)) != EOF) {
@axiomsofchoice
axiomsofchoice / irc_clients.sparql
Created June 4, 2011 22:31
Query DBpedia for GPL licensed IRC clients
## An attempt to query the data here: http://en.wikipedia.org/wiki/Comparison_of_Internet_Relay_Chat_clients
## via http://dbpedia.org/spraql to determine which IRC clients for Windows are GPL licensed
prefix dbo: <http://dbpedia.org/ontology/>
prefix dbpprop: <http://dbpedia.org/property/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix yago: <http://dbpedia.org/class/yago/>
select distinct ?client ?label ?license ?os
@axiomsofchoice
axiomsofchoice / prime_birthday.php
Created May 30, 2011 20:47
Prime Birthday Computation Script
<html>
<body>
<form action="prime_birthday.php" method="post">
Day: <input type="text" name="day" />
Month: <input type="text" name="mon" />
Year: <input type="text" name="year" />
<input type="submit" />
</form>
@axiomsofchoice
axiomsofchoice / SimpleHTTPServer.sh
Created May 17, 2011 12:32
Serve current directory via local webserver
python -m SimpleHTTPServer
@axiomsofchoice
axiomsofchoice / sparcurl.sh
Created May 17, 2011 12:27
Using curl to query SPARQL endpoints
curl -H "Accept: application/sparql-results+xml" "http://localhost:8000/sparql/" --data-urlencode "query=SELECT ?s ?p ?o { ?s ?p ?o . }"
@axiomsofchoice
axiomsofchoice / crossrefexample.py
Created April 20, 2011 16:50
Use content negotiation with a certain DOI to obtain linked data about that resource.
"""Use content negotiation with a certain DOI to obtain linked data about that resource.
See also:
http://myemail.constantcontact.com/CrossRef-and-International-DOI-Foundation-Collaborate-on-Linked-Data-Friendly-DOIs.html?soid=1102390657767&aid=eTYx65PAErU
http://www.crossref.org/CrossTech/2011/04/content_negotiation_for_crossr.html
"""
import urllib
exampleDOI = 'http://dx.doi.org/10.1126/science.1157784'
@axiomsofchoice
axiomsofchoice / binarysearch.py
Created April 18, 2011 15:29
An attempt at Jon Bently's binary search algorithm challenge from his book "Programming Pearls"
"""
An implementation of binary search, based on the challanges in the following blog posts:
http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html
http://reprog.wordpress.com/2010/04/19/are-you-one-of-the-10-percent/
http://www.solipsys.co.uk/new/BinarySearchReconsidered.html?tw
This was not my first attempt however, there was a broken version (of course)
that I wrote prior to running it for the first time. Sadly I didn't take a
snapshot before I fixed it but the bug was fairly major; although I'd worked