Skip to content

Instantly share code, notes, and snippets.

View stefanovualto's full-sized avatar
:octocat:

stefanovualto stefanovualto

:octocat:
View GitHub Profile
@stefanovualto
stefanovualto / switchTrue.js
Created April 20, 2021 08:51
js pattern matching trick
// source: https://seanbarry.dev/posts/switch-true-pattern
switch (true) {
case !isDefined(user):
throw new Error("User must be defined.");
case !isString(user.firstName):
throw new Error("User's first name must be a string");
case !isValidEmail(user.email):
throw new Error("User's email address must be a valid email address");
case !isValidPhoneNumber(user.number):
@stefanovualto
stefanovualto / machine.js
Last active December 2, 2020 16:04
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@stefanovualto
stefanovualto / machine.js
Last active September 25, 2020 09:22
Generated by XState Viz: https://xstate.js.org/viz
const EventMachine = Machine({
id: "eventState",
initial: "INITIAL",
states: {
INITIAL: {
on: {
CreateLive: "PRE_LIVE",
CreateVOD: "PRE_VOD",
CreateRemix: "REMIX_GENERATING",
CreateArchiver: "ARCHIVER_PUBLIC",
@stefanovualto
stefanovualto / regexCheatsheet.js
Created January 25, 2019 09:38 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
#!/bin/bash
# Description: bump version only if the previous master version was the same (not manually modified)
# Requirements: The local package.json must have an upper property "url" setted with the git url of the project
git config --global user.email "[email protected]" && git config --global user.name "vuplay" && git config --global push.default simple
git fetch
git checkout HEAD~1
PREVIOUS_PACKAGE_VERSION=$(cat package.json \