Skip to content

Instantly share code, notes, and snippets.

View remyoudemans's full-sized avatar

Rémy Oudemans remyoudemans

  • Cardiff
View GitHub Profile
@remyoudemans
remyoudemans / closures.js
Last active October 10, 2022 17:53
Closures for private state
const makeCounter = () => {
let count = 0;
return {
get() {
return count;
},
increment() {
count += 1;
},
@remyoudemans
remyoudemans / asyncTimeCheck.ts
Created August 11, 2022 11:03
async time check util to find out what's slowing down a node function. I should probably use the node debugger instead.
const asyncTime = async (
cb: (timecheck: (msg: string) => void) => Promise<any>,
) => {
let prevTime: number;
let nowTime: number;
let prevStepName: string;
const timecheck = (stepName: string) => {
if (!prevStepName) {
console.log('\x1b[36m%s\x1b[0m', `first step: ${stepName}`);
@remyoudemans
remyoudemans / machine.js
Last active April 27, 2021 16:32
Generated by XState Viz: https://xstate.js.org/viz
const singleData = context => {
return context.dataLength < 2;
};
const multipleData = context => {
return context.dataLength > 1;
};
const isEnough = context => !!context.enough;
import { useCallback } from 'react'
import { ActionCreator, bindActionCreators } from 'redux'
import { useDispatch } from 'react-redux'
export const useBindActionCreator = <DispatchAction>() => {
const dispatch = useDispatch<(action: DispatchAction) => void>()
return <A, C extends ActionCreator<A>>(actionCreator: C) =>
useCallback(
bindActionCreators(actionCreator, dispatch),
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
green='\033[0;32m'
NC='\033[0m' # No Color
branches=()
eval "$(git for-each-ref --shell --format='branches+=(%(refname))' refs/heads/)"
@remyoudemans
remyoudemans / lodash-fp-documentation.md
Last active August 7, 2020 14:46
Generated docs for Lodash/fp (with ramda aliases). Help make them better at https://github.com/jfmengels/lodash-fp-docs