Skip to content

Instantly share code, notes, and snippets.

View codyzu's full-sized avatar

Cody Zuschlag codyzu

View GitHub Profile
// Create a private instance of lodash
// since we will modify the memoize cache config
const {memoize} = require('lodash').runInContext();
// Set the memoize cache to use WeakMap
memoize.Cache = WeakMap;
const getUserFromDatabase = memoize(async ctx => {
const {
req: {
headers: {Authorization: userCred},
},
} = ctx;
const user = await db.getUserByCredential(userCred);
return user;
});
await sendMessageToUser(ctx);
await replyOk(ctx);
async function getUserFromDatabase(ctx) {
const {
req: {
headers: {Authorization: userCred},
},
} = ctx;
const user = await db.getUserByCredential(userCred);
return {
...ctx,
user,
const R = require('ramda');
const ctx = {
// ...
};
R.pipeWith(R.then, [getUserFromDatabase, sendMessageToUser, replyOk])(ctx);
R.pipeWith(R.then, [getUserFromDatabase, replyOk, sendMessageToUser])(ctx);
@codyzu
codyzu / darter-pro-tips-and-tricks.md
Last active May 25, 2022 14:01
Linux Tips and Tricks

PopOS (System76 Darter Pro)

Broken emojis in chrome

sudo apt remove fonts-noto-color-emoji
sudo apt install fonts-noto-color-emoji

reference

@codyzu
codyzu / hp-pavillion-gaming-17-cd0002nf-tips-and-tricks.md
Last active March 23, 2020 08:47
Tips and tricks for HP Pavillion Gaming 17 cd0002nf
const functions = require("firebase-functions");
const admin = require("firebase-admin");
const {nanoid} = require('nanoid');
admin.initializeApp();
exports.withLock = functions.pubsub
.schedule("0 * * * *")
.onRun((context) => {
const { eventId, timestamp } = context;
@codyzu
codyzu / index.js
Created November 30, 2020 20:34
Exam 1 Express Server
const express = require('express')
const app = express()
app.get('/', function (req, res) {
res.send('Hello World!')
})
// 👉👉 ADD YOUR ROUTE HERE! 👈👈