Skip to content

Instantly share code, notes, and snippets.

View srenatus's full-sized avatar
🍉

Stephan Renatus srenatus

🍉
View GitHub Profile
@srenatus
srenatus / Caddyfile
Created April 15, 2024 10:06
use @styra/opa from a browser -- for experiments! It's not somethng you want to do in most cases. ⚠️ Run OPA on http://localhost:8181, and `caddy run --config Caddyfile`
:8000 {
handle_path /opa/* {
reverse_proxy http://localhost:8181
}
handle {
root * .
file_server
}
}
@srenatus
srenatus / deno.json
Last active April 15, 2024 09:14
example: use opa-typescript from deno -- run via `deno task dev`
{
"tasks": {
"dev": "deno run --allow-net --watch main.ts"
},
"imports": {
"opa": "https://esm.sh/@styra/opa@0.2.5"
}
}
@srenatus
srenatus / make.bb
Last active April 10, 2024 13:47
babashkba make helper, to be called as `make`
#!/usr/bin/env bb
(require '[babashka.fs :as :fs]
'[babashka.process :refer [shell]])
(def make "/usr/bin/make")
(defn find-root
([] (find-root (fs/cwd)))
([wd] (cond
(fs/exists? (fs/path wd "Makefile")) {:dir wd}
const events = await db.sql`select
    created_at,
    last_updated_at,
  from events
`;
const stackPeriod = () => {
@srenatus
srenatus / query.md
Created March 4, 2024 10:54
custom SQL query page for Observable Framework + DuckDB

Custom Queries

const db = await DuckDBClient.of({
  table_one: FileAttachment("data/table_ond.parquet"),
  table_two: FileAttachment("data/table_two.parquet"),
});
diff --git a/topdown/arithmetic.go b/topdown/arithmetic.go
index c75f816a4..b0061074f 100644
--- a/topdown/arithmetic.go
+++ b/topdown/arithmetic.go
@@ -6,6 +6,7 @@ package topdown
import (
"math/big"
+ "strconv"
require 'oso'
$polar=<<POLAR
add(x: String, y: String, x.concat(y));
add(x: List, y: List, x.concat(y));
add(x: List, y: String, x0.concat(y)) if x0 in x;
add(x: String, y: List, x.concat(y0)) if y0 in y;
POLAR
class Example
def initialize
@o = Oso.new
package ms bytes allocs
internal/bytealg 0.002 0 0
runtime 0.097 0 0
errors 0.007 0 0
math 0.002 0 0
strconv 0.006 32 2
sync 0.003 16 1
unicode 0.096 12456 11
reflect 0.002 0 0
io 0.002 144 9
{:deps {djblue/portal {:mvn/version "0.37.1"}}}