Skip to content

Instantly share code, notes, and snippets.

View peterk's full-sized avatar

Peter Krantz peterk

View GitHub Profile
@peterk
peterk / styles.less
Created February 15, 2016 12:02
styles.less turtle
/*
* Your Stylesheet
*
* This stylesheet is loaded when Atom starts up and is reloaded automatically
* when it is changed.
*
* If you are unfamiliar with LESS, you can read more about it here:
* http://www.lesscss.org
*/
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
select DISTINCT ?name ?title ?book
WHERE {
?book <http://purl.org/dc/elements/1.1/creator> ?creator .
?creator <http://dbpedia.org/property/deathYear> "1945" .
?book <http://purl.org/dc/elements/1.1/title> ?title .
?creator foaf:name ?name .
# coding: utf-8
import unicodecsv as csv
import networkx as nx
csvdata = csv.reader(open('query_result.csv', 'rb'), delimiter=',', encoding='utf-8')
next(csvdata) #skip headers
graph=nx.DiGraph(label="swepub")
for row in csvdata:
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
select DISTINCT ?name ?title ?book
WHERE {
?book <http://purl.org/dc/elements/1.1/creator> ?creator .
?creator <http://dbpedia.org/property/deathYear> "1945" .
?book <http://purl.org/dc/elements/1.1/title> ?title .
<h1>Tools for Everyone</h1>
<p>
This session looks at two tools that help to manage public sector metadata:
</p>
<p>
Scribe: Peter K
</p>
<h1>Tools for Everyone</h1>
<p>
This session looks at two tools that help to manage public sector metadata:
</p>
<p>
Scribe: Peter K
</p>
@peterk
peterk / hydrate.groovy
Created October 27, 2015 14:04
Map local authority records to libris URI:s
@Grab('com.github.albaker:GroovySparql:0.9.0')
import groovy.sparql.*
@Grab('commons-lang#commons-lang;2.4')
import org.apache.commons.lang.WordUtils
import groovy.json.StringEscapeUtils
// Tab separated file with ids and names to look up in Libris.
// Example line format:
import sys
from os import listdir
from os.path import isfile, join
import os
import re
import gensim, logging
model = gensim.models.Word2Vec.load("gensim2.model")
model.most_similar(positive=['skola', 'vuxen'], negative=['elev'])
@peterk
peterk / wplinkcheck.py
Last active September 21, 2015 17:46
Checks Swedish Wikipedia for pages containing links from domain specified and then checks link availability
import requests
import argparse
from lxml import html
class bcolors:
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'