Skip to content

Instantly share code, notes, and snippets.

@justin2004
justin2004 / a.rq
Created September 19, 2025 02:10
ontology to table
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
prefix bfo: <http://purl.obolibrary.org/obo/>
prefix cco: <https://www.commoncoreontologies.org/>
prefix owl: <http://www.w3.org/2002/07/owl#>
select * where {
?s a owl:ObjectProperty .
# ?s a owl:DatatypeProperty .
# ?s a owl:Class .
@justin2004
justin2004 / a.txt
Last active July 22, 2025 20:29
bit mask over interior chars (of words)
# APL
v←'RAFT DATA PLATFORM'
f←1∘⌽⍤(0 0∘,)⍤(' '∘(3∧/≠))
f v
0 1 1 0 0 0 1 1 0 0 0 1 1 1 1 1 1 0
⍉v(,⍤0)f v
R A F T D A T A P L A T F O R M
0 1 1 0 0 0 1 1 0 0 0 1 1 1 1 1 1 0
@justin2004
justin2004 / a.apl
Last active August 25, 2025 15:28
numpy broadcasting in APL
⎕IO←0
m←2 3 4 3⍴⍳72
⍝ the goal is to reproduce this numpy broadcasting behavior in APL
⍝ m/m.sum(axis=0, keepdims=True)
normalize_and_keepdims←{⍵÷(⍴⍵)⍴(⍺⌷⍴⍵)/[(0⌈⍺-1)]+/[⍺]⍵}
0 normalize_and_keepdims m
0 0.02631578947 0.05
@justin2004
justin2004 / pizza.ttl
Created May 31, 2025 13:55
veggie pizza better definition
@prefix : <http://example.org/pizza#> .
@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 xsd: <http://www.w3.org/2001/XMLSchema#> .
:hasTopping a owl:ObjectProperty .
:VegetablePizza a owl:Class ;
owl:equivalentClass [
@justin2004
justin2004 / a.sh
Created May 21, 2025 00:41
wikipedia article histogram
# using https://github.com/justin2004/apl_in_the_shell
justin@parens:~/Downloads$ curl "https://en.wikipedia.org/w/api.php?action=query&prop=extracts&explaintext&format=json&titles=St._Louis" | jq '.query.pages[].extract' | apl '{a←{⍺,≢⍵}⌸⎕C∊⍵⋄a⌷⍨⊂⍒⌽a}' -
1956
e 1119
t 915
i 844
s 781
a 735
@justin2004
justin2004 / newsapi_everything.json
Last active April 16, 2025 20:32
newsapi_everything.json
{
"openapi": "3.0.3",
"info": {
"title": "News API",
"version": "1.0.0",
"description": "Simple OpenAPI spec for /everything endpoint"
},
"servers": [
{
"url": "https://newsapi.org"
@justin2004
justin2004 / test.csv
Last active February 3, 2025 20:06
test
name height
bob 213
fred 41
@justin2004
justin2004 / a.md
Last active December 4, 2024 01:45
Advent of Code Day 1 Part 1 using APL

Advent of Code 2024 Day 1 Part 1

Using apl_in_the_shell which makes the APL language command line friendly.

Full Solution

The answer using the sample data is 11.

Here is the full solution:

@justin2004
justin2004 / a.rq
Created October 22, 2024 18:41
wd labels
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
optional {?p ^(wikibase:claim|wikibase:directClaim|wikibase:statementProperty|wikibase:qualifierValue|wikibase:qualifier) ?pEntity}
@justin2004
justin2004 / a.sh
Created September 10, 2024 16:56
TDB2 parallel loader example
# first download https://dlcdn.apache.org/jena/binaries/apache-jena-5.1.0.zip
# then unzip it
% mkdir /tmp/db1
% ls ~/Downloads/labels.ttl
/Users/justin/Downloads/labels.ttl
% ~/Downloads/apache-jena-5.1.0/bin/tdb2.tdbloader --loader=parallel --loc /tmp/db1 ~/Downloads/labels.ttl
11:52:38 INFO loader :: Loader = LoaderParallel
11:52:38 INFO loader :: Start: /Users/justin/Downloads/labels.ttl
11:52:38 INFO loader :: Finished: /Users/justin/Downloads/labels.ttl: 5 tuples in 0.11s (Avg: 46)