Skip to content

Instantly share code, notes, and snippets.

View PythonNut's full-sized avatar
🚀
Hmm

Jonathan Hayase PythonNut

🚀
Hmm
  • University of Washington
View GitHub Profile
@PythonNut
PythonNut / jax_cifar_dawnbench.py
Created June 25, 2022 00:41
CIFAR10 94% test accuracy in 125s using JAX
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
@PythonNut
PythonNut / ivy-advice.el
Last active December 29, 2016 01:15
Ivy smart flx sorting
(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)
@PythonNut
PythonNut / set_rand_perf.jl
Last active May 19, 2016 14:49
Performance benchmarking for a implementation of rand(s::Set) in Julia
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
(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)