Skip to content

Instantly share code, notes, and snippets.

View ashleysommer's full-sized avatar

Ashley Sommer ashleysommer

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / proxy.py
Created September 30, 2021 06:18
A simple reverse-proxy server in Sanic using HTTPX streaming responses
#!/bin/python3
#
"""Example Sanic Reverse Proxy"""
from urllib.parse import urlsplit, urlunsplit
from sanic import Sanic, Request
from sanic.response import stream, HTTPResponse
import httpx
env = {"hostname-from": "localhost", "port-from": 8000, "port-to": 8080}
@ashleysommer
ashleysommer / make_vrt_stats.py
Created September 28, 2021 02:14
Walk directories, make VRT files, add stats and overviews to the VRT files
from collections import defaultdict
from math import e
from re import L
import sys
from glob import glob
from pathlib import Path
from types import new_class
from lxml import etree
from os.path import commonprefix
from os import unlink