Skip to content

Instantly share code, notes, and snippets.

@sebastibe
sebastibe / appointments-management.svg
Created February 27, 2026 05:12
Boutique DX product icons
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sebastibe
sebastibe / prepare.sh
Created January 20, 2022 08:33
Prepare line machine
sudo apt update
sudo apt-get install -y curl awscli wget software-properties-common
wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
sudo apt-get update
sudo apt-get install -y adoptopenjdk-11-hotspot
@sebastibe
sebastibe / vec-utils.cljs
Last active November 12, 2020 14:49
Some helpers when moving elements around in Clojure vectors
(defn vec-remove
"Remove elem in coll by index."
[coll pos]
(vec (concat (subvec coll 0 pos) (subvec coll (inc pos)))))
(defn vec-add
"Add elem in coll by index."
[coll pos el]
(concat (subvec coll 0 pos) [el] (subvec coll pos)))
@sebastibe
sebastibe / colors.cljs
Last active August 3, 2019 07:59
Some helpers when working with Colors in ClojureScript
;; Hex to RBG (.i.e #63411E -> [99 65 30])
(defn hex->rgb [s]
(->> (subs s 1 7)
(partition 2)
(map clojure.string/join)
(mapv #(js/parseInt % 16))))
(defn hex->rgba [s opacity]
(into [] (conj (hex->rgb s) opacity)))
@sebastibe
sebastibe / vowel-indices.clj
Created January 9, 2017 02:57
We want to know the index of the vowels in a given word, for example, there are two vowels in the word 'super' (the second and fourth letters).
(def vowels #{\a \A \e \E \i \I \o \O \u \U \y \Y})
;; First approach
(defn vowel-indices [word]
(let [matches (map vowels (seq word))]
(into [] (remove nil? (map-indexed (fn [idx el] (if-not (nil? el) (+ idx 1))) matches)))))
;; Better approach
(defn vowel-indices [word]
(keep-indexed #(when (vowels %2) (inc %1)) word))
@sebastibe
sebastibe / format-mac.clj
Created January 7, 2017 07:52
Format IEEE 802 MAC Address in Clojure
(defn split-string [s factor]
(->> (partition-all factor s)
(map (partial apply str))))
(defn format-mac [value]
(apply str (map clojure.string/upper-case (interpose ":" (split-string value 2)))))
@sebastibe
sebastibe / ipython_notebook_config.md
Created June 9, 2015 03:32
Indications on how to save .py files in parallel to the ipynb file

In order to view/download the latest notebook via github or nbviewer or to see how the the notebook code has changed we activate saving the .py files automatically and track both .ipynb files and the .py files.

In order to automate it, add the following code in the ipython_notebook_config.py file:

import os
app.filter('bytes', function() {
return function(bytes, precision) {
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-';
if (typeof precision === 'undefined') precision = 1;
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'],
number = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number];
}
});
# Given an array of coordinates, get the bounding box
getBounds = (coordinates) ->
xv = []
yv = []
$.each(coordinates, (i, coord) ->
xv.push(coord[0])
yv.push(coord[1])
)
return [
class _Missing(object):
def __repr__(self):
return 'no value'
def __reduce__(self):
return '_missing'
_missing = _Missing()