Skip to content

Instantly share code, notes, and snippets.

View ashleysommer's full-sized avatar

Ashley Sommer ashleysommer

View GitHub Profile
@ashleysommer
ashleysommer / example.py
Created March 12, 2022 10:20
Stackoverflow question corrected shape graph
# -*- coding: utf-8 -*-
"""
https://stackoverflow.com/questions/71443139/shacl-sparqltarget-not-validating-the-sparql-query-output-nodes
"""
import rdflib
from pyshacl import validate
@ashleysommer
ashleysommer / pyproject.toml
Created March 29, 2022 01:03
test cylc in pyproject toml
[build-system]
requires = ["poetry-core>=1.1.0a7"]
# requires pre-release poetry, bedause metomi-isodatetime uses epoch versioning
build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "my-test"
description = "testing cylc"
version = "0.0.1"
authors = ["Ashley Sommer <[email protected]"]
@ashleysommer
ashleysommer / test_141.py
Created April 7, 2022 21:45
pyshacl issue 141 alternative represenation
# -*- coding: utf-8 -*-
"""
https://github.com/RDFLib/pySHACL/issues/141
"""
import rdflib
from pyshacl import validate
shacl_file = r"""@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ex: <http://example.org/ontology/> .
@ashleysommer
ashleysommer / test_141_simple_fix
Created April 7, 2022 22:18
test_141_simple_fix
# -*- coding: utf-8 -*-
"""
https://github.com/RDFLib/pySHACL/issues/141
"""
import rdflib
from pyshacl import validate
shacl_file = r"""@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ex: <http://example.org/ontology/> .
@ashleysommer
ashleysommer / log.sh
Created April 22, 2022 03:02
Monterey output
DEVICE_MODEL: iMacPro1,1
SERIAL_SET_COUNT: 1
OUTPUT_DIRECTORY: .
Cloning into 'OpenCorePkg'...
remote: Enumerating objects: 1600, done.
remote: Counting objects: 100% (1600/1600), done.
remote: Compressing objects: 100% (1398/1398), done.
remote: Total 1600 (delta 336), reused 759 (delta 147), pack-reused 0
Receiving objects: 100% (1600/1600), 14.36 MiB | 8.58 MiB/s, done.
Resolving deltas: 100% (336/336), done.
@ashleysommer
ashleysommer / rgb_to_hsl.sh
Last active May 18, 2022 04:52
AWK RGB to HSL conversion
awk -F "[, ]+" '\
function abs(num) {
if (num < 0.0)
return num*-1.0
return num
}
function find_min(num1, num2, num3){
if (num1 < num2)
a=num1
else
@ashleysommer
ashleysommer / hsl_to_rgb.sh
Created May 18, 2022 03:57
AWK HSL to RGB conversion
awk -F "[, ]+" '\
# Returns minimum number
function abs(num) {
if (num < 0.0)
return num*-1.0
return num
}
# Main function
function to_rgb(H, S, L){
H=H%360.0
@ashleysommer
ashleysommer / alacritty_color.sh
Created May 18, 2022 05:49
Lauch alacritty with a random hue shift on foreground and background colors
#!/bin/bash
DEFAULT_BACKGROUND='#012b36'
DEFAULT_FOREGROUND='#839496'
HEX_RGB_RET=(0 0 0)
RGB_HEX_IN=("0" "0" "0")
RGB_HEX_RET=""
function _hex_to_rgb {
first=${1: 0:1}
if [[ "$first" = "#" ]]; then
@ashleysommer
ashleysommer / issue_142.py
Created June 30, 2022 00:42
Using ont_graph to mix-in ontology definitions at validation runtime
import rdflib
from pyshacl import validate
shacl_file = """\
@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 sh: <http://www.w3.org/ns/shacl#> .
@prefix ex: <http://example.com/ns#> .
@ashleysommer
ashleysommer / issue_148.py
Created June 30, 2022 00:54
Example of using ont_graph and "inplace=True"
import rdflib
from pyshacl import validate
shacl_file = """\
@prefix ex: <urn:ex#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@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#> .