Skip to content

Instantly share code, notes, and snippets.

View jperasmus's full-sized avatar
🔥
Too blessed to be stressed

JP Erasmus jperasmus

🔥
Too blessed to be stressed
View GitHub Profile
@jperasmus
jperasmus / machine.js
Created January 26, 2022 08:03
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@jperasmus
jperasmus / flamelink-cloud-functions-cloud-firestore.js
Last active February 11, 2020 10:26
Example using Flamelink with Cloud Firestore in a Firebase Cloud Function
@jperasmus
jperasmus / Git Housekeeping
Created April 15, 2019 10:36
A Git terminal command to remove all local branches that have already been merged into main remote branches.
git fetch -p && git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}' | xargs git branch -d
@jperasmus
jperasmus / font-stacks.css
Created April 5, 2019 07:37 — forked from don1138/font-stacks.css
CSS Modern Font Stacks
/* Modern Font Stacks */
/* System */
font-family: system, -apple-system, ".SFNSText-Regular", "San Francisco", "Roboto", "Segoe UI", "Helvetica Neue", "Lucida Grande", sans-serif;
/* Times New Roman-based serif */
font-family: Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif;
/* A modern Georgia-based serif */
font-family: Constantia, "Lucida Bright", Lucidabright, "Lucida Serif", Lucida, "DejaVu Serif," "Bitstream Vera Serif", "Liberation Serif", Georgia, serif;
const functions = require('firebase-functions');
const admin = require('firebase-admin');
exports.addCustomClaim = functions.database.ref('/flamelink/environments/production/content/userAccount/en-US/{entryId}')
.onCreate((snapshot, context) => {
const entry = snapshot.val();
const entryId = context.params.entryId;
const uid = entry.uid;
// user creating the new entry
@jperasmus
jperasmus / Flamelink in Firebase Cloud Function
Last active January 19, 2019 14:15
Basic example of how to use Flamelink within a Firebase Cloud Function
@jperasmus
jperasmus / headless-cms-archive.json
Created June 27, 2018 10:04
HEADLESSCMS.ORG DATA ARCHIVE
{"timestamp":1530093891101,"data":{"appernetic":[{"timestamp":1530093891101,"followers":3504}],"bowtie":[{"timestamp":1530093891101,"followers":4}],"builtio":[{"timestamp":1530093891101,"followers":1387}],"butter-cms":[{"timestamp":1530093891101,"followers":278}],"cannerio-cms":[{"timestamp":1530093891101,"followers":55}],"cloudcannon":[{"timestamp":1530093891101,"followers":1110}],"cloud-cms":[{"timestamp":1530093891101,"followers":252}],"cockpit":[{"timestamp":1530093891101,"followers":676,"stars":3074,"forks":303,"issues":171}],"coisas":[{"timestamp":1530093891101,"stars":244,"forks":17,"issues":0}],"contenta":[{"timestamp":1530093891101,"followers":738,"stars":183,"forks":56,"issues":32}],"contentful":[{"timestamp":1530093891101,"followers":33865}],"cosmic-js":[{"timestamp":1530093891101,"followers":4122}],"daptin":[{"timestamp":1530093891101,"stars":173,"forks":7,"issues":13}],"datocms":[{"timestamp":1530093891101,"followers":389}],"directus":[{"timestamp":1530093891101,"followers":16484,"stars":3176,"fo
@jperasmus
jperasmus / compose-example.js
Created September 13, 2017 06:50
Basic "compose" example
const double = x => x * 2;
const square = x => x * x;
const plus3 = x => x + 3;
const composedFunction = compose(double, square, plus3);
const result = composedFunction(2);
// result = 50
// 2 (plus3) => 5 (square) => 25 (double) => 50
@jperasmus
jperasmus / pipe.js
Last active June 27, 2019 09:52
"pipe" function that handles both sync and async functions
const pipe = (…functions) => input => functions.reduce((chain, func) => chain.then(func), Promise.resolve(input));
// Functions fn1, fn2, fn3 can be standard synchronous functions or return a Promise
pipe(fn1, fn2, fn3)(input).then(result => console.log(`Do with the ${result} as you please`))