Skip to content

Instantly share code, notes, and snippets.

Niklas Lindström niklasl

Block or report user

Report or block niklasl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View neverwhere-works.ttl
## WORKS
</work/neverwhere-0> a :Work ;
#:identityType :Hub ;
:title [ a :Title ; :mainTitle "Neverwhere" ] ;
:contribution [ a :PrimaryContribution ;
:agent </person/Neil_Gaiman> ] ;
:language </language/eng> .
</work/neverwhere-1> a :Text ;
@niklasl
niklasl / rsync-to-unison.sh
Created Oct 28, 2017
Crude fallback when unison isn't available on your local machine. (Note that this method stores duplicates of the files of interest on the server.)
View rsync-to-unison.sh
# Paths of interest
LOCALDIR=syncdir
HOST=user@example.org
LANDINGDIR=landingdir
TARGETDIR=syncdir
# Sync files from local device to the server landing dir
rsync -auv --delete $LOCALDIR/ $HOST:$LANDINGDIR
# Two-way-sync the landing dir with the target dir
@niklasl
niklasl / make_summary.py
Created Feb 3, 2017
Flat KBV vocabulary summary
View make_summary.py
from __future__ import unicode_literals, print_function
from rdflib import *
g = Graph().parse("https://id.kb.se/vocab/")
with open('select-summary.rq') as f:
select = f.read()
print('Term', 'Bases', 'Domain', 'Range', sep='\t')
for row in g.query(select):
@niklasl
niklasl / illustrated-text-class.ttl
Created Oct 7, 2016
Just an OWL sketch for possibly inferring some BibFrame details from other details...
View illustrated-text-class.ttl
prefix : <http://www.w3.org/2002/07/owl#>
prefix bf: <http://id.loc.gov/ontologies/bibframe/>
prefix kbv: <https://id.kb.se/vocab/>
prefix marcrel: <http://id.loc.gov/vocabulary/relators/>
kbv:IllustratedText a :Class;
:equivalentClass [
:intersectionOf (
bf:Text
[ a :Restriction;
@niklasl
niklasl / get-saogf-from-idkbse.py
Last active May 30, 2016
Get SAOGF from id.kb.se
View get-saogf-from-idkbse.py
#!/usr/bin/env python3
from urllib.parse import urljoin
from urllib.request import urlopen, Request
import json
import codecs
reader = codecs.getreader("utf-8")
def crawl(collection_url):
while True:
View synesthesia.js
/**
* To level up your synesthesia, choose colors, apply on web pages and read
* some 100 000 words. Purportedly. :)
* http://www.theatlantic.com/technology/archive/2012/07/can-you-teach-yourself-synesthesia/259519/
*/
var charColorMap = {
a: 'darkred',
e: 'green',
s: 'blue',
View tstamprot_test.py
import string
import math
CHARS = string.digits + string.lowercase
assert len(CHARS) == 36
CHARS += string.uppercase
assert len(CHARS) == 62
BASE64_CHARS = string.uppercase + string.lowercase + string.digits + "+/"
@niklasl
niklasl / schemaorg_to_jsonldcontext.py
Last active Dec 30, 2015
Generates a JSON-LD Context for Schema.org.
View schemaorg_to_jsonldcontext.py
from rdflib import *
SDO = Namespace("http://schema.org/")
datatype_coerce_map = {
#SDO.Number: XSD.double,
SDO.Date: 'xsd:date',
SDO.DateTime: "xsd:dateTime",
}
View rdfa-about-table.html
<!DOCTYPE html>
<html>
<head>
<title>Using about with a table</title>
</head>
<body>
<table vocab="http://schema.org/">
<tr>
<th>Who</th>
@niklasl
niklasl / schemabibex-examples-dcterms.ttl
Created Jul 16, 2013
Using the Dublin Core terms isFormatOf and isVersionOf to interlink some SchemaBibEx examples
View schemabibex-examples-dcterms.ttl
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix dc: <http://purl.org/dc/terms/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix pto: <http://www.productontology.org/id/> .
@prefix : <http://schema.org/> .
## Altered parts of <http://www.oclc.org/content/dam/research/publications/library/2013/2013-05.pdf> ##
You can’t perform that action at this time.