Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am MikeInnes on github.
  • I am onemoreminute (https://keybase.io/onemoreminute) on keybase.
  • I have a public key whose fingerprint is DBF9 C2D0 9AEA 16E5 6A95 FAEF DFD3 2796 D8FD 8A25

To claim this, I am signing this object:

isexpr(x::Expr, ts...) = x.head in ts
isexpr{T}(x::T, ts...) = T in ts
macro with(exprs...)
exprs = collect(exprs)
target = nothing
if length(exprs) > 1 && !isexpr(exprs[end], :(::))
target = esc(exprs[end])
pop!(exprs)
end
[
;; The app tag is kind of like global scope. You assign behaviors that affect
;; all of Light Table to it.
[:app :lt.objs.style/set-skin "dark"]
[:app :lt.objs.plugins/load-js "user_compiled.js"]
[:app :lt.objs.langs.julia/julia-path "C:\\Users\\Mike\\Julia 0.3.0-prerelease\\bin\\julia.exe"]
;; The editor tag is applied to all editors
[:editor :lt.objs.editor/no-wrap]
[:editor :lt.objs.style/set-theme "june"]
function rand_first_index(n, k)
r = rand()
p = k/n
i = 1
while p < r
i += 1
p += (1-p)k/(n-(i-1))
end
return i
end
SetAttributes[Dictionary, Orderless];
Dictionary[key_ -> val_, ___][key_] := val;
Dictionary[___][key_] := key;
d_Dictionary.key_ ^:= d[key];
x_ /. Dictionary[rs___] ^:= x /. {rs};
Dictionary[{rs___}] := Dictionary[rs];
Assoc[Dictionary[key_ -> _, rs___], key_ -> val_] :=
Dictionary[key -> val, rs];
Assoc[Dictionary[rs___], key_ -> val_] := Dictionary[key -> val, rs];
@MikeInnes
MikeInnes / startup.jl
Last active February 5, 2023 12:54
Some useful macros for Julia
# Repeat an operation n times, e.g.
# @dotimes 100 println("hi")
macro dotimes(n, body)
quote
for i = 1:$(esc(n))
$(esc(body))
end
end
end
;; Paredit's features (http://www.youtube.com/watch?v=D6h5dFyyUX0)
;; in clojure/clarity.
;; All examples can be done quickly with the keyboard in e.g.
;; Sublime Text - no plugins required.
defn my-command []
(interactive)
save-excursion
(do-some-things)
(ns cueball
(:use [cljs.compiler :exclude [munge macroexpand-1]]
clojure.walk))
;; Implementation of `quote` with unquoting
(defn seqable? [e]
(if-not (string? e)
(try (seq e)
(catch Exception e false))))