Skip to content

Instantly share code, notes, and snippets.

@thiagoh
thiagoh / actions.js
Last active February 3, 2018 00:45
redux asynchronous actions dispatching one after the other
// oneAction could be setCountry
export const oneAction = params => {
return {
type: "ONE_ACTION",
payload: Promise.resolve(`(value from oneAction ${params})`)
};
};
// otherAction could be fetchRegions
export const otherAction = params => {
@thiagoh
thiagoh / monads.js
Last active January 13, 2018 00:32
monad in practice
const PersonMonad = person => {
const ValidMon = failList => {
return {
map: ({ f, error }) => {
if (!f(person)) {
failList.push(error);
}
return ValidMon(failList);
},
flatMap: ({ f, error }) => {
class MyClass {
static [Symbol.hasInstance](lho) {
console.log('with-sugar: is', lho, 'an array?');
return Array.isArray(lho);
}
}
console.log([] instanceof MyClass); // true
console.log('my string' instanceof MyClass); // false
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class StreamFlatMap {
public static void main(String[] args) {
List<String> list = new ArrayList<>();
@thiagoh
thiagoh / tmux-cheatsheet.markdown
Created August 19, 2017 14:32 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@thiagoh
thiagoh / disk-utility
Last active August 23, 2017 14:01 — forked from dixson3/workspace.sh
Create and manage a case-sensitive disk-image on OSX. This is great when you have a need to work with case-sensitive repos on a mac.
#!/bin/bash
# where to store the sparse-image
WORKSPACE=~/Documents/workspace.dmg.sparseimage
create() {
if [ -f $WORKSPACE ]; then
echo "File ${WORKSPACE} already exists";
exit 1;
@thiagoh
thiagoh / ctail
Last active May 18, 2017 16:29
Colored tail -f
#!/bin/bash
macos="\x1B"
linux="\033"
marker=$linux
if echo $(uname -a) | grep -q -i "darwin"; then
marker=$macos
fi
@thiagoh
thiagoh / C Data Types - Handbook.md
Last active April 30, 2017 23:10
C Data Types - Handbook

C Data Types - Handbook

[C Data Types][17]

Table of Contents

C/C++ provides various data types that can be used in your programs.

In general, you'd commonly use:

@thiagoh
thiagoh / watchfiles.md
Last active June 8, 2023 15:56
watchfiles: Watch multiple files and execute bash commands as file changes occur

watchfiles

  • author: Thiago Andrade thiagoh@gmail.com
  • license: GPLv3
  • description:
  • watches the given paths for changes
  • and executes a given command when changes occur
  • usage:
  • watchfiles <paths...>
@thiagoh
thiagoh / instanceof.cpp
Last active March 25, 2017 07:56
c++ good stuff
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <typeinfo>
#include <type_traits>
namespace com::test {
class BaseClass {