Skip to content

Instantly share code, notes, and snippets.

View wikier's full-sized avatar

Sergio Fernández wikier

View GitHub Profile
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "missing directory"
echo "Usage: ./flat_directory.sh DIR"
exit -1
fi
DIR=$1
@wikier
wikier / gist:728e234bb998158bf9ec
Created September 19, 2014 12:51
Requesting Geonames RDF data with Marmotta LDClient
LDClientService ldclient = new LDClient();
ClientResponse response = ldclient.retrieveResource("http://sws.geonames.org/2658434/about.rdf");
RepositoryConnection connection = ModelCommons.asRepository(response.getData()).getConnection();
connection.begin();
System.out.println("Triples retrieved: " + connection.size());
connection.commit();
connection.close();
@wikier
wikier / SPARQLWrapper-HTTP-Digest-Auth-example.py
Last active March 29, 2018 20:30
SPARQLWrapper HTTP Digest Auth example
from SPARQLWrapper import SPARQLWrapper, JSON, DIGEST
sparql = SPARQLWrapper("http://example.org/sparql")
sparql.setHTTPAuth(DIGEST)
sparql.setCredentials('login', 'password')
sparql.setQuery("...")
sparql.setReturnFormat(JSON)
@wikier
wikier / sparql.py
Last active August 29, 2015 14:04
SPARQLWrapper example
from SPARQLWrapper import SPARQLWrapper, JSON
sparql = SPARQLWrapper("http://dbpedia.org/sparql")
sparql.setQuery("""
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?label
WHERE { <http://dbpedia.org/resource/Asturias> rdfs:label ?label }
""")
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
@wikier
wikier / gist:57c92f9f280d28a71bc9
Created July 31, 2014 15:44
Joshua Dunham turtle example at users@marmotta.a.o
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix maront: <http://my.server.domain/ont/1/#> .
@prefix mar: <http://my.marmottaDB.domain/marmotta/resource/> .
mar:server a maront:linuxserver ;
maront:amountRamGB "4"^^xsd:decimal ;
maront:amountHDTB "2"^^xsd:decimal ;
maront:runs [
@wikier
wikier / gist:9031298
Created February 16, 2014 08:49
Load Redlink SSL certificate with RESTEasy Client 3.x
// load the certificate
InputStream fis = this.getClass().getResourceAsStream("/path/to/redlink-CA.crt");
CertificateFactory cf = CertificateFactory.getInstance("X.509");
Certificate cert = cf.generateCertificate(fis);
// load the keystore that includes self-signed cert as a "trusted" entry
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null, null);
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
keyStore.setCertificateEntry("redlink-CA", cert);
from SPARQLWrapper import SPARQLWrapper, JSON
sparql = SPARQLWrapper("http://dbpedia.org/sparql")
sparql.setQuery("""
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?label
WHERE { <http://dbpedia.org/resource/Asturias> rdfs:label ?label }
""")
sparql.setReturnFormat(JSON)
from SPARQLWrapper import SPARQLWrapper, JSON
sparql = SPARQLWrapper("http://dbpedia.org/sparql")
sparql.setQuery("""
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?label
WHERE { <http://dbpedia.org/resource/Asturias> rdfs:label ?label }
""")
sparql.setReturnFormat(JSON)
results = sparql.query().convert()