Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Leonardo Dutra leodutra

🏠
Working from home
View GitHub Profile
@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
View .zshrc
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/home/home/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
@leodutra
leodutra / -install-linux-devenv.md
Last active Jan 13, 2020
Install Linux devenv with .zshrc + Powerlevel9k + Oh My Zsh + plugins + VSCode mode + Nerd Font + NVM
View -install-linux-devenv.md

Installing Terminator, Zsh, Oh My Zsh, Powerlevel9K, Node.js and VSCode (+extensions)

Preview

Requirements

  • Ubuntu 18.04 (as reference)

Steps

You can’t perform that action at this time.