Skip to content

Instantly share code, notes, and snippets.

View caioaao's full-sized avatar
🏠
Working from home

Caio Oliveira caioaao

🏠
Working from home
View GitHub Profile
error in process filter: Error in nrepl-refactor: java.util.concurrent.ExecutionException: java.lang.AssertionError: Assert failed: (instance? java.io.PushbackReader rdr)
at java.util.concurrent.FutureTask.report (FutureTask.java:122)
java.util.concurrent.FutureTask.get (FutureTask.java:192)
clojure.core$deref_future.invoke (core.clj:2186)
clojure.core$future_call$reify__6736.deref (core.clj:6683)
clojure.core$deref.invoke (core.clj:2206)
refactor_nrepl.find.find_symbol$find_symbol.invoke (find_symbol.clj:242)
refactor_nrepl.middleware$find_symbol_reply.invoke (middleware.clj:60)
refactor_nrepl.middleware$wrap_refactor$fn__29401.invoke (middleware.clj:135)
clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__11848.invoke (middleware.clj:22)
$ lein uberjar *[master]
(:repositories detected in user-level profiles! [:user]
See https://github.com/technomancy/leiningen/wiki/Repeatability)
Compiling specter-reproduce.core
Compiling specter-reproduce.core-path
nil
Exception in thread "main" java.lang.ExceptionInInitializerError, compiling:(/private/var/folders/yj/j9klbwj11zj95bz657t_x44m0000gn/T/form-init4932202852423350160.clj:1:125)
at clojure.lang.Compiler.load(Compiler.java:7391)
at clojure.lang.Compiler.loadFile(Compiler.java:7317)
at clojure.main$load_script.invokeStatic(main.clj:275)
Benchmark: get value in nested map (2500000 iterations)
Avg(ms) vs best Code
44.233 1.00 (-> data (get :a) (get :b) (get :c))
55.461 1.25 (-> data :a :b :c identity)
59.315 1.34 (-> data :a :b :c)
69.111 1.56 (get-a-b-c data)
119.58 2.70 (compiled-select-any p data)
126.31 2.86 (select-any [(keypath :a) (keypath :b) (keypath :c)] data)
131.44 2.97 (select-any (keypath :a :b :c) data)
Benchmark: get value in nested map (2500000 iterations)
Avg(ms) vs best Code
43.279 1.00 (-> data (get :a) (get :b) (get :c))
54.564 1.26 (-> data :a :b :c)
58.446 1.35 (-> data :a :b :c identity)
76.612 1.77 (get-a-b-c data)
101.11 2.34 (compiled-select-any p data)
128.99 2.98 (select-any [(keypath :a) (keypath :b) (keypath :c)] data)
132.83 3.07 (select-any [:a :b :c] data)
@caioaao
caioaao / logs.txt
Created December 2, 2016 17:24
Native implementation for CachedPathInfo
Benchmark: get value in nested map (2500000 iterations)
Avg(ms) vs best Code
42.623 1.00 (-> data (get :a) (get :b) (get :c))
49.893 1.17 (-> data :a :b :c)
53.703 1.26 (-> data :a :b :c identity)
65.554 1.54 (get-a-b-c data)
106.54 2.50 (compiled-select-any p data)
111.64 2.62 (select-any [(keypath :a) (keypath :b) (keypath :c)] data)
113.60 2.67 (select-any [:a :b :c] data)
@caioaao
caioaao / kc.cpp
Last active February 10, 2017 23:14
KC exact solution (https://www.gwern.net/Coin-flip)
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <string>
@caioaao
caioaao / stack.py
Last active June 10, 2018 15:54
Simple sklearn-compatible class to stack models
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.model_selection import cross_val_predict
from sklearn.pipeline import make_union
from sklearn.model_selection._split import check_cv
from sklearn.utils.validation import check_X_y
class BlendedClassifierTransformer(BaseEstimator, TransformerMixin):
def __init__(self, clf, cv=3):
self.clf = clf
self.cv = cv

Setup udev rule for HDMI cable

Create script that checks HDMI status and executes xrandr:

#!/usr/bin/env bash

export DISPLAY=":0.0"

USER="$(who | grep ${DISPLAY}\) | cut -f 1 -d ' ' | head -n1)"
@caioaao
caioaao / spec_either.clj
Created May 8, 2017 16:51
spec for funcool cats either monad
(ns cats-spec.either
(:require [cats.monad.either :as m.either]
[clojure.spec.alpha :as s]
[clojure.spec.gen.alpha :as gen]))
(defn either-impl
[form-r pred-r form-l pred-l]
(let [spec-r (delay (s/specize* pred-r form-r))
spec-l (delay (s/specize* pred-l form-l))]
(reify
@caioaao
caioaao / extra-split-fns.lisp
Last active May 18, 2017 01:34
StumpWM - Split frame in equal parts.
(defun split-frame-eql-parts* (group dir amt)
(when (not (eq amt 1))
(when-let ((new-frame (split-frame group dir (/ (- amt 1) amt))))
(cons new-frame (split-frame-eql-parts* group dir (- amt 1))))))
(defun split-frame-eql-parts (group dir amt)
"Splits frame in equal parts defined by amt."
(assert (> amt 1))
(let ((f (tile-group-current-frame group))
(new-frame-numbers (split-frame-eql-parts* group dir amt)))