Skip to content

Instantly share code, notes, and snippets.

View customcommander's full-sized avatar
🇺🇦
I stand with Ukraine

Julien Gonzalez customcommander

🇺🇦
I stand with Ukraine
  • London, UK
View GitHub Profile
@customcommander
customcommander / transitions-observable.md
Created January 5, 2023 10:31
Observing state transitions with XState & RxJS

Observing state transitions with XState & RxJS

Objective

Create an observable that emits each time a specific transition is taken.

Problem

This "flip" machine keeps tossing the coin each time it lands on head. The machine reaches its final state when the side is tail:

@customcommander
customcommander / testdoublejs.md
Last active October 6, 2021 17:51
Testdouble.js Cheatsheet & Cookbook

Testdouble.js Cheatsheet & Cookbook

Why use testdouble.js?

Suppose we need to test that a function calls another function:

function call(fn) {
  fn();
}
@customcommander
customcommander / RIS-Specification.md
Last active August 25, 2021 18:06
A detailed look at the 2011 RIS Specification

RIS Specification

This is to the best of my knowledge the RIS specification as it was defined in 2011 by the original author. See https://en.wikipedia.org/wiki/RIS_(file_format)#cite_note-:1-5.

(Re)producing the dataset

Requirements

In order to run the scripts used to produce the dataset the following programs must be available on your system path:

@customcommander
customcommander / browserify-your-nodejs-lib-with-closure-compiler.md
Last active February 11, 2021 01:18
How to use the Google Closure Compiler to browserify your Node.js library

Canonical post for my Stack Overflow Q&A

How to use the Google Closure Compiler to browserify your Node.js library

I have this simple Node.js library:

mylib/
|- inc.js
|- index.js
@customcommander
customcommander / jsdoc-cheat-sheet.md
Last active June 26, 2023 05:20
JSDoc Cheat Sheet

Git Mining

Some scripts I use to mine data out of my Git repositories. Sharing in case it is useful to others.

Last commit for each year/month

git log --format="%cd %h" --date=short | sort -t- -k1,1n -k2,2n -u
@customcommander
customcommander / spread-vs-assign.md
Last active December 18, 2023 11:13
On using assignment over spread to achieve performance

Spread vs assign

Abstract

In this article I compare the performance of the spread operator ... and the performance of the assignement operator = in the context of data transformation.

I show that using the spread operator isn't a trivial choice to make and I suggest that immutability and mutation don't have to be mutually exclusive. I also show how one-liner functions can be enriched with the comma operator ,.

What are we measuring?

@customcommander
customcommander / browser_logs-chrome.js
Created May 25, 2017 09:13
Capture console.log() output from a web page with Selenium WebDriver 2.53 and Chrome
require('chromedriver');
const path = require('path');
const wd = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
var builder = new wd.Builder();
var options = new chrome.Options();
var prefs = new wd.logging.Preferences();
var driver;
@customcommander
customcommander / permute.js
Last active April 15, 2019 16:28
Return all permutations of a string
/**
* Return all permutations of given string.
*
* @example
* permute('abc');
* //=> ['abc', 'acb', 'bac', 'bca', 'cab', 'cba']
* @param str {String}
* @return {Array}
*/
function permute(str) {