Skip to content

Instantly share code, notes, and snippets.

@prefix : <http://globe.org#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix fn: <http://www.w3.org/2005/xpath-functions#> .
@prefix grddl: <http://www.w3.org/2003/g/data-view#> .
@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 sesame: <http://www.openrdf.org/schema/sesame#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@pwin
pwin / ProductForge_SPARQL_exploration_1.md
Last active May 2, 2019 08:46
A script of an introduction to SPARQL and http://statistics.gov.scot for the ProductForge Hack event - 26 Jan 2018
@pwin
pwin / GolspieDayHalfHour.html
Created January 24, 2018 20:46
Illustration of using javascript and AMCharts to access and present data from RDF data cube
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html id="Scottish_Government" xmlns="http://www.w3.org/1999/xhtml" lang="en-GB" xml:lang="en-GB">
<head>
<title>Golspie Half Hourly</title>
<!--
This produces plots of half hourly consumption values
The dropdown for the buildings shows 45 consumers
-->
@pwin
pwin / splitFolder.sh
Created September 24, 2015 13:42
Linux Bash command line routine for splitting large folders into folders of up to n files [useful for Github which doesn't allow more than 1000 files per folder]
let fileCount=1000
let dirNum=1
for f in *
do
[ -d $f ] && continue
[ $fileCount -eq 1000 ] && {
dir=$(printf "%03d" $dirNum)
mkdir $dir
let dirNum=$dirNum+1
@pwin
pwin / FindLinkedFiles.bas
Created September 18, 2015 09:38
Routines for crawling a folder, finding MS Office documents, and finding external references (links) in Excel, Powerpoint or Word documents
Option Explicit
Const strLogPath As String = "C:\PathForLogFiles\"
Const crawlStart As String = "J:\StartingDirectoryPath"
'
Const MaskPP = "*.pp*"
Const MaskXL = "*.xl*"
Const MaskDoc = "*.doc*"
import requests
import matplotlib.pyplot as plt
from wordcloud import WordCloud, STOPWORDS
import sys
uris = [
'http://www.w3.org/2013/share-psi/wiki/Best_Practices/Cross_Agency_Strategy',
'http://www.w3.org/2013/share-psi/wiki/Best_Practices/High_Level_Support',
@pwin
pwin / best_practices_cluster.py
Created June 29, 2015 18:14
hierarchical clustering of docs
from __future__ import print_function
import numpy as np
import pandas as pd
import nltk
import re
import os
import codecs
from sklearn import feature_extraction
import mpld3
### Query to find all postcodes that reference Glasgow City as their District
### and return postcode uri, label and geocoding
### 2014-03-03
### Peter Winstanley
PREFIX admingeo: <http://data.ordnancesurvey.co.uk/ontology/admingeo/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX gaz: <http://data.ordnancesurvey.co.uk/ontology/50kGazetteer/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX geometry: <http://data.ordnancesurvey.co.uk/ontology/geometry/>
PREFIX georss: <http://www.georss.org/georss/>
@pwin
pwin / REST-API.py
Last active October 18, 2024 13:43
A REST-ful API script using Bottle.py
#!/usr/bin/env python
"""
REST-API.py
The MIT License (MIT)
Copyright (c) 2014 P.Winstanley, C.Taylor
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@pwin
pwin / utilityByBldgYearMonthDay
Created December 14, 2013 00:06
SPARQL query to get utility consumption for each building by year, month and day
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix gol: <http://cofog01.data.scotland.gov.uk/def/golspie/>
prefix qb: <http://purl.org/linked-data/cube#>
prefix buildingCode: <http://cofog01.data.scotland.gov.uk/id/facility/>
prefix fn: <http://www.w3.org/2005/xpath-functions#>
prefix util: <http://cofog01.data.scotland.gov.uk/def/golspie/>
prefix skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>