Skip to content

Instantly share code, notes, and snippets.

package com.hp.hpl.jena.sparql.path;
import static org.junit.Assert.assertEquals;
import java.io.File;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@harschware
harschware / SSHJConnect.java
Created November 21, 2014 22:00
A class for connecting via public key exchange using SSHJ
package harschware.sandbox;
import java.io.IOException;
import java.security.Security;
import java.util.concurrent.TimeUnit;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.common.IOUtils;
import net.schmizz.sshj.connection.channel.direct.Session;
import net.schmizz.sshj.connection.channel.direct.Session.Command;
@harschware
harschware / Triplet.java
Created February 20, 2010 07:22
A Triplet container class
package harsch.sandbox;
import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
/**
*
* @author Tim Harsch
*
* @param <L>
@harschware
harschware / data.owl
Created February 19, 2011 00:46
Jena Rules from OwlMicro Reasoner + OWL ontology
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:univ-bench="http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns="http://example.org/unnamed0#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xml:base="http://example.org/unnamed0">
<Uncle rdf:ID="UncleSam">
@harschware
harschware / schema.ttl
Created March 8, 2011 16:25
TTL file that produces parse error when loaded into Jena 2.6.4
# Saved by TopBraid on Tue Mar 08 08:20:27 PST 2011
# baseURI: http://example.org/unnamed0
@prefix : <http://example.org/unnamed0#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix univ-bench: <http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@harschware
harschware / paris_worship.ru
Created April 1, 2011 17:57
Places of worship in Paris - Good example DBPedia Query
##### Found this query in an email posted by @kidehen (since lost to me)
##### query LOD cloud at http://lod.openlinksw.com/sparql/
##### -or- via iSPARQL at http://lod.openlinksw.com/isparql/ <== can use Google maps to visualize
### construct a custom Linked Data Mesh (graph) about:
### places of worship, within 5 km of Paris, that have cafes in close proximity(0.2 km)
### Note: we have distinct pin colors that identify for places of worship distinct from cafes
PREFIX rtb: <http://www.openlinksw.com/schemas/oat/rdftabs#>
CONSTRUCT { ?cafe geo:geometry ?cafegeo ;
rtb:useMarker '01' ;
@harschware
harschware / fileToString.c
Created April 7, 2011 16:27
shows code to read a file into a correctly sized string buffer using malloc
// adapted from stackoverflow post: http://stackoverflow.com/questions/3233645/read-multiples-lines-from-file-to-a-string-in-c/3233744#3233744 by user http://stackoverflow.com/users/346905/faisal
char * readFile( const char * fileName ) {
// open the file
FILE* fp = fopen( fileName, "r");
if (fp == NULL) {
fprintf(stderr,"ERROR: couldn't open file\n");
exit(1);
}
@harschware
harschware / TesteProp.java
Created April 13, 2011 02:56
Code is response to answers.semanticweb.com question at http://answers.semanticweb.com/questions/8497
package testejena;
import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.util.FileManager;
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
import java.io.InputStream;
import java.util.Iterator;
@harschware
harschware / lebmFriends_Query1.txt
Created June 29, 2011 21:06
LEBM Friends Query 1
PREFIX ub: <http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#>
PREFIX cray: <http://www.cray.com/ontologies/lebm#>
SELECT *
WHERE {
?n0 cray:hasFriend ?n1 .
?n1 cray:hasFriend ?n0 .
?n0 ub:takesCourse ?n3 .
?n1 ub:takesCourse ?n3 .
}
@harschware
harschware / DomPrinter.java
Created June 30, 2011 22:16
lets you print a W3C DOM Object
package com.cray.utils;
import java.io.StringWriter;
import javax.xml.transform.Result;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;