Skip to content

Instantly share code, notes, and snippets.

Avatar
🔥
Too blessed to be stressed

JP Erasmus jperasmus

🔥
Too blessed to be stressed
View GitHub Profile
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@jperasmus
jperasmus / flamelink-cloud-functions-cloud-firestore.js
Last active Feb 11, 2020
Example using Flamelink with Cloud Firestore in a Firebase Cloud Function
View flamelink-cloud-functions-cloud-firestore.js
@jperasmus
jperasmus / Git Housekeeping
Created Apr 15, 2019
A Git terminal command to remove all local branches that have already been merged into main remote branches.
View Git Housekeeping
git fetch -p && git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}' | xargs git branch -d
@jperasmus
jperasmus / font-stacks.css
Created Apr 5, 2019 — forked from don1138/font-stacks.css
CSS Modern Font Stacks
View font-stacks.css
/* 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;
View Add custom claim on ref entry
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 Jan 19, 2019
Basic example of how to use Flamelink within a Firebase Cloud Function
View Flamelink in Firebase Cloud Function
View Dynamic RTDB security rules for Flamelink
@jperasmus
jperasmus / headless-cms-archive.json
Created Jun 27, 2018
HEADLESSCMS.ORG DATA ARCHIVE
View headless-cms-archive.json
{"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 Sep 13, 2017
Basic "compose" example
View compose-example.js
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 Jun 27, 2019
"pipe" function that handles both sync and async functions
View pipe.js
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`))