This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
from functools import partial | |
from collections import namedtuple | |
import tensorflow as tf | |
import tensorflow_datasets as tfds | |
import jax | |
import jax.numpy as jnp | |
import jax.random as jr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun nadvice/ivy--flx-sort (name cands) | |
"Sort according to closeness to string NAME the string list CANDS." | |
(condition-case nil | |
(let* (;; an optimized regex for fuzzy matching | |
;; "abc" → "\\`[^a]*a[^b]*b[^c]*c" | |
(fuzzy-regex (if (= (elt name 0) ?^) | |
(concat "^" | |
(regexp-quote (substring name 1 2)) | |
(mapconcat | |
(lambda (x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Base: GLOBAL_RNG, isslotfilled, rand | |
using Gadfly | |
function rand(r::AbstractRNG, s::Set) | |
isempty(s) && throw(ArgumentError("set must be non-empty")) | |
n = length(s.dict.slots) | |
while true | |
i = rand(r, 1:n) | |
isslotfilled(s.dict, i) && return s.dict.keys[i] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my/helm-elscreen-find-file-or-marked (candidate) | |
"Open file CANDIDATE or open helm marked files with elscreen. | |
Called with a prefix arg open files in background without selecting them." | |
(let ((marked (helm-marked-candidates :with-wildcard t)) | |
(url-p (and ffap-url-regexp ; we should have only one candidate. | |
(string-match ffap-url-regexp candidate))) | |
(ffap-newfile-prompt helm-ff-newfile-prompt-p) | |
(find-file-wildcards nil) | |
(make-dir-fn | |
(lambda (dir &optional helm-ff) |