Skip to content

Instantly share code, notes, and snippets.

@Akeboshiwind
Akeboshiwind / script.sh
Last active May 13, 2024 14:15
POST large file to xtdb v2
# Run the docker container w/ /tmp/xtdb-data-dir as the data folder
docker run --pull=always -tip 6543:3000 -v /tmp/xtdb-data-dir:/var/lib/xtdb ghcr.io/xtdb/xtdb-standalone-ea
# Verify the initial size:
du -h /tmp/xtdb-data-dir
# (should be 0B)
# Construct a large input file (around 1MB)
echo -n '{"txOps":[{"putDocs":[{"xt/id":1,"doc":"' > /tmp/file
dd if=/dev/urandom bs=786438 count=1 | base64 >> /tmp/file
@Akeboshiwind
Akeboshiwind / entity-history.clj
Created February 19, 2024 11:01
xtdb-v1 entity-history
; Add some sensor readings for sensor :a
(xt/submit-tx xtdb-node
[; Day 1: You get a reading of 1
[::xt/put
{:xt/id :a :value 1}
#inst "2024-01-01"]
; Day 2: You get a reading of 2
[::xt/put
{:xt/id :a :value 2}
#inst "2024-01-02"]
@Akeboshiwind
Akeboshiwind / sakila-playground.edn
Last active February 13, 2024 17:31
Datasets for xt-fiddle
This file has been truncated, but you can view the full file.
; Source: https://github.com/xtdb/sakila-playground/tree/a5a202364b023bac7de17c9a4acf820423a4d22c
[:put-docs :actor {:first_name "PENELOPE", :last_name "GUINESS", :xt/id 1}]
[:put-docs :actor {:first_name "NICK", :last_name "WAHLBERG", :xt/id 2}]
[:put-docs :actor {:first_name "ED", :last_name "CHASE", :xt/id 3}]
[:put-docs :actor {:first_name "JENNIFER", :last_name "DAVIS", :xt/id 4}]
[:put-docs :actor {:first_name "JOHNNY", :last_name "LOLLOBRIGIDA", :xt/id 5}]
[:put-docs :actor {:first_name "BETTE", :last_name "NICHOLSON", :xt/id 6}]
[:put-docs :actor {:first_name "GRACE", :last_name "MOSTEL", :xt/id 7}]
[:put-docs :actor {:first_name "MATTHEW", :last_name "JOHANSSON", :xt/id 8}]
[:put-docs :actor {:first_name "JOE", :last_name "SWANK", :xt/id 9}]
;; >> No errors
;; Works as expected
(defn ^:gen foo []
(js-yield 1)
(js-yield* [2 3])
(let [x (do (js-yield 4)
5)]
(js-yield x)))
@Akeboshiwind
Akeboshiwind / sites.txt
Last active October 31, 2022 12:19
Leechblock Sites
+reddit.com/comments
+reddit.com/gallery
+reddit.com/message
+reddit.com/r/*/comments
+reddit.com/r/*/wiki
reddit.com
youtube.com
@Akeboshiwind
Akeboshiwind / keybase.md
Created August 10, 2022 10:35
Keybase GitHub Proof

Keybase proof

I hereby claim:

  • I am akeboshiwind on github.
  • I am olivermarshall (https://keybase.io/olivermarshall) on keybase.
  • I have a public key ASDLJs6hPFndnzWlsd3LtY9n4d0Pa18vZtsF-TzHF7ZIzQo

To claim this, I am signing this object:

@Akeboshiwind
Akeboshiwind / echarts.clj
Last active May 6, 2019 15:31 — forked from ribelo/echarts.clj
clojuypter & echarts
(ns clojupyter.echarts
(:require [clojupyter.misc.display :as display]
[cheshire.core :as json]
[cuerdas.core :as str]))
(defn init []
(let [code "
require.config({
paths: {
@Akeboshiwind
Akeboshiwind / lastfm-analysis.clj
Last active September 16, 2018 02:01
Lastfm Analysis
;; gorilla-repl.fileformat = 1
;; **
;;; # LastFM Analysis
;; **
;; @@
(ns lastfm-analysis
(:require [gorilla-plot.core :as plot]))
@Akeboshiwind
Akeboshiwind / reservoir-sample.clj
Created July 27, 2018 20:00
An implementation of the reservoir sampling algorithm
;; Todo: write as a transducer
(defn reservoir-sample
"Uniformly choose a sample of k elements from lst"
[k lst]
(first
(reduce
(fn [[sample length] next]
(let [r (rand-int length)]
[(if (< r k)
(assoc sample r next)
@Akeboshiwind
Akeboshiwind / heavy-hitters.clj
Last active July 27, 2018 20:03
Heavy Hitters algorithm
(defn heavy-hitter
"Output the lement in the list that came up more than 50% of the time, nil otherwise."
[lst]
(let [heavy (heavy-hitter* lst)]
(when (->> lst
(filter (partial = heavy))
(count)
(<= (/ (count lst) 2)))
heavy)))