Skip to content

Instantly share code, notes, and snippets.

View kasei's full-sized avatar

Gregory Todd Williams kasei

View GitHub Profile
@kasei
kasei / jena-iri-resolution-issue
Created May 24, 2019 17:57
Jena IRI resolution warning
$ cat test.ttl
@base <http://example.org/foo/bar/> .
<./../../../useless/../../../still-root> <> "not ok" .
$ riot -q test.ttl
10:56:50 WARN riot :: [line: 2, col: 1 ] Bad IRI: <http://example.org/still-root> Code: 8/NON_INITIAL_DOT_SEGMENT in PATH: The path contains a segment /../ not at the beginning of a relative reference, or it contains a /./ These should be removed.
<http://example.org/still-root> <http://example.org/foo/bar/> "not ok" .
@kasei
kasei / attean-list-access.pl
Last active April 16, 2019 16:19
Accessing RDF lists using Attean
#!/usr/bin/env perl
use v5.18;
use Attean;
use Attean::RDF;
my $ns = URI::NamespaceMap->new( {
rdf => URI::Namespace->new('http://www.w3.org/1999/02/22-rdf-syntax-ns#'),
test => URI::Namespace->new('http://example.org/'),
});
@kasei
kasei / existing-sparql-12-proposals.md
Created April 2, 2019 16:51
Existing SPARQL 1.2 Proposals and Discussion
@kasei
kasei / sqlite-swift-iterator-bug.swift
Last active March 22, 2019 16:20
SQLite.swift Iterator produced by a prepared statement fails on repeated `next` calls after exhaustion
// Bug report: https://github.com/stephencelis/SQLite.swift/issues/889
// SQLite.swift version: 0.11.5
// Xcode: 10.1 and 10.2 beta 4 (10P107d)
// macOS version: 10.14.3
// Swift Package manager
import SQLite
let testTable = SQLite.Table("test_table")
let idColumn = SQLite.Expression<Int64>("id")
subtest 'holds method' => sub {
my $graph = Attean::IRI->new('http://example.org/graph');
my $store = Attean->get_store('Memory')->new();
my $parser = Attean->get_parser('turtle')->new();
my $data = <<'END';
@prefix : <http://example.org/> .
@prefix foaf: <http://xmlns.com/foaf/> .
:alice a foaf:Person ; foaf:name "Alice" ; foaf:knows :bob .
:bob a foaf:Person ; foaf:name "Bob" ; foaf:knows :alice .
:eve a foaf:Person ; foaf:name "Eve" .
@kasei
kasei / sparql_functions.ttl
Created December 2, 2017 18:17
SPARQL 1.1 Query Function and Aggregate IRI Definitions
@prefix sparql: <http://www.w3.org/ns/sparql#> .
@prefix sd: <http://www.w3.org/ns/sparql-service-description#> .
# Functional Forms
sparql:bound a sd:Function .
sparql:sameterm a sd:Function .
sparql:exists a sd:Function .
sparql:not_exists a sd:Function .
sparql:in a sd:Function .
sparql:not_in a sd:Function .
@kasei
kasei / debian-750946-html5-parser-charset-bug.pl
Created August 5, 2017 23:31
HTML::HTML5::Parser charset issue (debian Bug report #750946)
#!/usr/bin/env perl
# Regarding https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=750946
# There are at least two issues with the code in the bugreport.
# The first looks like a bug in HTML::HTML5::Parser (or its
# dependencies) that is mis-recognizing the charset of the file being
# opened.
#
# However, the code included in the bugreport also has a bug in it:
# even with a properly loaded $doc object (as in this case from a
@kasei
kasei / sparql-exists-semantics.rq
Last active June 20, 2016 18:16
SPARQL Exists substitution vs. injection
# with default graph having 1 triple: <s> <p> <not_a_graph_name.ttl>
# result-injection into the exists will yield 1 result: {}
# variable substitution will yield 1 result: { ?x="hello", ?g=<not_a_graph_name.ttl> }
PREFIX : <http://example/>
SELECT *
WHERE {
BIND("hello" AS ?x)
BIND(<not_a_graph_name.ttl> AS ?g)
FILTER(NOT EXISTS {
@kasei
kasei / attean-pattern-matching.pl
Last active March 31, 2016 16:15
Attean algebra pattern matching
#!/usr/bin/env perl
use v5.14;
use Attean;
use Attean::Algebra qw(match);
my $algebra = Attean->get_parser('SPARQL')->parse(<<"END");
SELECT * WHERE {
?s ?p ?o
FILTER(ISLITERAL(?o))
@kasei
kasei / attean-pre-push-hook.sh
Created February 17, 2016 20:51
Git pre-push hook for running the Attean test suite
#!/bin/sh
perl Makefile.PL && make
if prove -l t/ xt/
then
exit 0
else
echo '*** Test suite failed; not committing'
exit 1
fi