Skip to content

Instantly share code, notes, and snippets.

(ns aiba.util.dofor)
(defmacro dofor {:style/indent 1} [& stuff]
`(doall (for ~@stuff)))
@aiba
aiba / keybase.md
Last active August 21, 2021 20:26
keybase.md

Keybase proof

I hereby claim:

  • I am aiba on github.
  • I am aaroniba (https://keybase.io/aaroniba) on keybase.
  • I have a public key ASCPkhZQJ5BkHO0RDNqPaG-_fi71nDhiBlwjQ3_qaruQogo

To claim this, I am signing this object:

@aiba
aiba / url_linking.cljs
Created May 17, 2020 13:00
use-url-linking hook for react-navigation
(ns myapp.url-linking
(:require ["@react-navigation/native" :as rnav]
["react" :as react]
["react-native" :as rn]
[applied-science.js-interop :as j]
[cemerick.url :as url]
[clojure.string :as str]
[helix.core :as helix]
[helix.hooks :as hooks]
[kitchen-async.promise :as p]
@aiba
aiba / gongtimer
Created December 21, 2019 03:36
Plays gong sound at random interval, repeatedly.
#!/usr/bin/env clojure
(require '[clojure.java.io :as io])
(import 'javax.sound.sampled.AudioSystem)
(defn url->bytes [^String url]
(with-open [xin (io/input-stream (java.net.URL. url))
xout (java.io.ByteArrayOutputStream.)]
(io/copy xin xout)
(.toByteArray xout)))
@aiba
aiba / linear_interpolate.clj
Last active October 17, 2019 20:30
linear interpolation transducer
(defn linear-interpolate
([]
(fn [rf]
(let [rrf (#'clojure.core/preserving-reduced rf)
skipped (volatile! 0) ;; n of contiguous nils
prev (volatile! nil)] ;; most recent value seen
(fn
([] (rf)) ;; init
([result] ;; completion -- skipped stay nils since no endpoint
(rf (reduce rf result (repeat @skipped nil))))
(ns virgil.repl
(:require [clojure.set :as set]
[clojure.tools.namespace.dir :as ctn-dir]
[clojure.tools.namespace.file :as ctn-file]
[clojure.tools.namespace.find :as ctn-find]
[clojure.tools.namespace.parse :as ctn-parse]
[clojure.tools.namespace.repl :as ctn-repl]
[virgil.compile :refer [compile-all-java]])
(:import java.io.File
java.util.Arrays))
@aiba
aiba / countries.txt
Created July 23, 2017 16:35
Countries sorted by ratio of word length to number of vowels
Kyrgyzstan
Cyprus
St Kitts & Nevis
Egypt
Chad
Marshall Islands
Myanmar, {Burma}
Netherlands
Switzerland
Czech Republic
@aiba
aiba / gist:91d330df7e98f25d23ab9e75cfb0d6eb
Created September 29, 2016 19:44
cpu-profiler-report-2
- redisplay_internal (C function) 19334 90%
- debug 19334 90%
- recursive-edit 15689 73%
- nrepl-client-filter 10656 50%
- nrepl--dispatch-response 10159 47%
- nrepl-log-message 9813 46%
- nrepl--pp 9800 46%
- nrepl--pp 9798 46%
- nrepl--pp 9712 45%
- nrepl--pp 9056 42%
- redisplay_internal (C function) 3653 87%
- debug 3653 87%
- recursive-edit 3372 80%
- nrepl-client-filter 2894 69%
- nrepl--dispatch-response 2728 65%
- nrepl-log-message 2722 65%
- nrepl--pp 2698 64%
- nrepl--pp 2698 64%
- nrepl--pp 2597 62%
- nrepl--pp 2346 56%
@aiba
aiba / fastrepl.sh
Created November 18, 2012 03:42
Fast lein repl using drip
#!/bin/bash -e
if [ ! -f ./project.clj ]; then
echo "Run from a lein project directory."
exit 1
fi
mkdir -p ./.fastrepl/
if command -v md5 >/dev/null 2>&1; then
MD5=`md5 -q project.clj`