Skip to content

Instantly share code, notes, and snippets.

XQueryCall.run("""declare namespace mp='http://musicpath.org';
declare namespace r='http://www.w3.org/2005/sparql-results#';
mp:sparql('SELECT * WHERE {<http://musicpath.org/people/melissa> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?t }')//r:result[1]""")
import module namespace _xsparql = "http://xsparql.deri.org/XSPARQLer/xsparql.xquery"
at "http://xsparql.deri.org/XSPARQLer/xsparql.xquery";
declare namespace mp = "http://musicpath.org" ;
declare namespace _sparql_result = "http://www.w3.org/2005/sparql-results#";
declare namespace foaf = "http://xmlns.com/foaf/0.1/" ;
declare variable $_NS1 := "prefix foaf: &#60;http://xmlns.com/foaf/0.1/&#62;";
<html> <head> </head><body> {
let $_aux1 := _xsparql:_serialize(( $_NS1, "
@LeifW
LeifW / plotSchema.sh
Created October 17, 2010 21:04
Make a picture showing the entities in the schema linked together by their described properties.
roqet schema_diagram.sparql -r dot -D $1 | dot -Tsvg -o pic.svg
@LeifW
LeifW / groups.pxsl
Created January 3, 2011 23:51
FOAF 'em all
#!/usr/local/bin/pxsl
stylesheet -version=1.0 -xmlns:xsl=http://www.w3.org/1999/XSL/Transform -xmlns=http://xmlns.com/foaf/0.1/ -xmlns:bio=http://purl.org/vocab/bio/0.1/ -xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns# -xmlns:rdfs=http://www.w3.org/2000/01/rdf-schema# -xmlns:epdx=http://epdx.org/schema
import util.xsl
output -indent=yes
template /
rdf:RDF
rdf:Description -rdf:about=http://twitter.com -rdfs:label=Twitter
rdf:Description -rdf:about=http://github.com -rdfs:label=GitHub
apply-templates
@LeifW
LeifW / GitHub_languages.pxsl
Created February 21, 2011 09:58
A listing of what languages are used per project.
-- Call this on e.g. http://github.com/api/v2/xml/repos/show/leifw
stylesheet -xmlns:xsl=http://www.w3.org/1999/XSL/Transform -version=1.0
output -method=text
template repository
text <<
>>
apply-templates name
apply-templates document(concat(owner,'/',name,'/languages'),.)
@LeifW
LeifW / gist:1015583
Created June 8, 2011 22:21
Comparison of languages.
Earlier I said Haskell/Scala/Python/Ruby/CoffeeScript are all pretty much the same.
By that I meant you can write much the same code in all of them, just the syntax might look a bit more weird or arbitrary in some cases.
Of course there are fundamental differences in the type of things you write in static versus dynamic languages, just as there are fundamental differences between what you write in a lazy vs eager language.
Print the numbers one through ten:
Python:
for i in range(1,11):
print(i)
@LeifW
LeifW / conneg.scala
Created July 6, 2011 20:55
Content negotiation
header("Accept").flatMap(
_.split(',').
map(
_.trim.split(';') match {
case Array(t) => 1F -> t
case Array(t, q) => q.split('=')(1).toFloat -> t
}
).
sortWith(_._1 > _._1).
map( _._2 ).
@LeifW
LeifW / Treeify.scala
Created July 15, 2011 22:27
Turn RDF graphs into JSON trees.
import org.scardf._
object Treeify {
def localName(res:UriRef) = ".*[#/]".r.split(res.uri)(1)
def apply(start:GraphNode) = {
val graph = start.graph
def treeify(subject:SubjectNode, visited:Set[SubjectNode]):Map[String,Any] = Map(
@LeifW
LeifW / gist:1130833
Created August 7, 2011 21:51
Find all xmlns:declarations from JS in text/html
$("*").map(function(){return $.grep(this.attributes, function(a){return a.name.slice(0,5) === "xmlns"})})