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
@caioaao
caioaao / collisions.clj
Last active May 4, 2022 23:09
Solution to Nubank's collision exercise, in Clojure
(ns collisions.core
(:require [clojure.string :as str])
(:gen-class))
(defn str->edge [s]
(->> (str/split s #" ")
(map #(Integer/parseInt %))))
(defn file-contents->edges [s]
(->> (str/split s #"\n")
FROM tensorflow/tensorflow:1.4.0
ENV HOME /root
RUN echo 'export LC_ALL=C.UTF-8' >> /etc/profile
RUN echo 'export LANG=C.UTF-8' >> /etc/profile
RUN pip install enigma-catalyst
RUN jupyter nbextension enable --py --sys-prefix widgetsnbextension
@caioaao
caioaao / heal_conn.sh
Created November 13, 2017 21:37
Bash script for connection self-healing (to use on my raspberry pi/beaglebone)
#!/usr/bin/env bash
set -euo pipefail
HEARTBEAT_INTERVAL=3
EXPONENTIAL_BACKOFF_POWER=2
EXPONENTIAL_BACKOFF_MAX_TIMEOUT=60
EXPONENTIAL_BACKOFF_INITIAL_TIMEOUT=1
@caioaao
caioaao / boxplot_buys2.png
Last active June 22, 2017 20:06
Docs showing how to plot NMR buy prices
boxplot_buys2.png
@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)))
@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

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 / 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
@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>