Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Leo Dutra leodutra

🏠
Working from home
View GitHub Profile
@leodutra
leodutra / .gitlfstracks
Created Dec 25, 2020 — forked from bdombro/.gitlfstracks
Git LFS Default Tracks - Common binary file extensions
View .gitlfstracks
"To include this, run `cat .gitlfstrack | xargs git lfs track`"
"*.3ds"
"*.3g2"
"*.3gp"
"*.7z"
"*.a"
"*.aac"
"*.adp"
"*.ai"
"*.aif"
@leodutra
leodutra / git-delete-local-branches.sh
Last active Aug 28, 2021
Delete unused local branches ( Git )
View git-delete-local-branches.sh
#!/bin/sh
# Good ref: https://devconnected.com/how-to-clean-up-git-branches/
# lists branches that can be deleted/pruned on your local. An option --dry-run is needed
git remote prune origin --dry-run
# In order to clean up remote tracking branches,
# meaning deleting references to non-existing remote branches,
# use the “git remote prune” command and specify the remote name
git remote prune origin
@leodutra
leodutra / leo-pulseeffects-preset.json
Last active Apr 2, 2020
Leo's PulseEffects preset (Sony MDR-7506)
View leo-pulseeffects-preset.json
{
"spectrum": {
"show": "true",
"n-points": "150",
"height": "100",
"use-custom-color": "true",
"fill": "true",
"show-bar-border": "true",
"scale": "1",
"exponent": "1",
@leodutra
leodutra / waitToDisappear.swift
Last active Mar 27, 2020
waitToDisappear Swift UI Test
View waitToDisappear.swift
func waitToDisappear(_ element: XCUIElement, timeout: TimeInterval) -> Bool {
let startTime = Date().timeIntervalSinceReferenceDate
let remainingTime = { () -> Double in
let diff = timeout - (Date().timeIntervalSinceReferenceDate - startTime)
return diff > 0 ? diff : 0
}
repeat {
if !element.exists || !element.isHittable {
return true
}
@leodutra
leodutra / waitForHittable.swift
Created Mar 27, 2020
waitForHittable Swift UI Test
View waitForHittable.swift
static func waitForHittable(_ element: XCUIElement, timeout: TimeInterval) -> Bool {
let startTime = Date().timeIntervalSinceReferenceDate
let remainingTime = { () -> Double in
let diff = timeout - (Date().timeIntervalSinceReferenceDate - startTime)
return diff > 0 ? diff : 0
}
if element.waitForExistence(timeout: remainingTime()) {
repeat {
if element.isHittable {
return true
@leodutra
leodutra / reducer-lib.js
Last active Feb 26, 2020
Reducer library for JS
View reducer-lib.js
const sumReducer = (sum, x) => sum + x;
const minReducer = (min/* =null */, x) => {
if (min == null) return x;
return min < x ? min : x;
};
const maxReducer = (max/* =null */, x) => {
if (max == null) return x;
return max > x ? max : x;
};
@leodutra
leodutra / ThinkAboutMonads.md
Created Jan 10, 2020 — forked from brayoh/ThinkAboutMonads.md
How to think about monads
View ThinkAboutMonads.md

How to think about Monads

Initially, Monads are the biggest, scariest thing about Functional Programming and especially Haskell. I've used monads for quite some time now, but I didn't have a very good model for what they really are. I read Philip Wadler's paper Monads for functional programming and I still didnt quite see the pattern.

It wasn't until I read the blog post You Could Have Invented Monads! (And Maybe You Already Have.) that I started to see things more clearly.

This is a distillation of those works and most likely an oversimplification in an attempt to make things easier to understand. Nuance can come later. What we need when first learning something is a simple, if inaccurate, model.

This document assumes a beginner's knowledge of pure functional programming and Haskell with some brief encounters of Monads, e.g. [Functors, Applicatives, And

@leodutra
leodutra / kernel.js
Created Nov 26, 2019 — forked from Carreau/kernel.js
A node.js kernel for IPython notebook. You can see the explanation of the ipynb rendered in http://nbviewer.ipython.org
View kernel.js
zmq = require("zmq")
fs = require("fs")
var config = JSON.parse(fs.readFileSync(process.argv[2]))
var connexion = "tcp://"+config.ip+":"
var shell_conn = connexion+config.shell_port
var pub_conn = connexion+config.iopub_port
var hb_conn = connexion+config.hb_port
@leodutra
leodutra / how-much-water-per-day.js
Last active Nov 24, 2019
How much water should you drink per day? ( JavaScript )
View how-much-water-per-day.js
// WARNING!
// Water Intoxication.
// This is rare but it can happen.
// What happens is that when too much water enters the cells, the tissues swell.
// This causes an electrolyte and salt imbalance which can cause irregular heart
// beat and allow fluid to enter the lungs.
// The pressure due to swelling will also put pressure on the brain and nerves,
// which can also cause problems.
// Swelling in the brain can cause coma, seizures, and even death.
@leodutra
leodutra / fast-array.js
Created Oct 23, 2019
Fast/elastic array for bad JavaScript engines ( FastArray )
View fast-array.js
'use strict';
// TODO implement .splice()
// TODO implement .reduce()
// TODO implement .indexOf()
// TODO implement .lastIndexOf()
// TODO implement ECMA5+ <Array> functions