Skip to content

Instantly share code, notes, and snippets.

@justin2004
justin2004 / a.apl
Created January 20, 2026 19:08
torus vowels
torusVowels←{
v← ⎕av ⍝ vector of chars (that we index into)
c← v⍳⍵ ⍝ c as in cipher text (using indexes instead of chars)
m←c∊v⍳'aeiou' ⍝ mask of vowels
v[(m\¯1⌽0~⍨m×c)+ c×~m]
⍝ ^ keep the consonants
⍝ ^ select the only vowels
⍝ ^ then do a ¯1 rotate to shift them to the right
⍝ ^ finally expand using the mask so we can recombine vowels and consonants
}
@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 September 17, 2026 14:00
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.

The Problem

Calculate the total distance between two lists of location IDs by sorting both lists and summing the absolute differences between paired elements.

Link

@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}