In computing, memoization or memoisation
is an optimization technique used primarily
to speed up computer programs by storing
the results of expensive function calls and
returning the cached result when the same
inputs occur again.
— wikipedia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { promises } from "fs"; | |
import crypto from "crypto"; | |
import path from "path"; | |
import { print, parse } from "graphql"; | |
const plugin = { | |
name: "relay", | |
setup: build => { | |
build.onLoad({ filter: /\.tsx$/, namespace: "" }, async args => { | |
let contents = await promises.readFile(args.path, "utf8"); |
you should review every pull request of your team
- each pull request will make understand what everyone in your team is working on
- it will ensure you keep consistency of file location, and code patterns
- it will catch bugs/regression early on
- it will teach the best way to solve the problem
you should ensure consistency of the code base
you should pair programming with all devs of your team
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const webpack = require('webpack') | |
const path = require('path') | |
const nodeExternals = require('webpack-node-externals') | |
const StartServerPlugin = require('start-server-webpack-plugin') | |
module.exports = { | |
entry: [ | |
'webpack/hot/poll?1000', | |
'./local/server' | |
], | |
watch: true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const listeners = [] | |
const state = {} | |
let noop = x => x | |
function subscribe (fn) { | |
listeners.push(fn) | |
} | |
function unsubscribe (fn) { | |
listeners.splice(listeners.indexOf(fn), 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mapAsync<T, U>(array: T[], callbackfn: (value: T, index: number, array: T[]) => Promise<U>): Promise<U[]> { | |
return Promise.all(array.map(callbackfn)); | |
} | |
async function filterAsync<T>(array: T[], callbackfn: (value: T, index: number, array: T[]) => Promise<boolean>): Promise<T[]> { | |
const filterMap = await mapAsync(array, callbackfn); | |
return array.filter((value, index) => filterMap[index]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const _ = require('lodash'); | |
const exec = require('child_process').exec; | |
const path = require('path'); | |
// Concatenate root directory path with our backup folder. | |
const backupDirPath = path.join(__dirname, 'database-backup'); | |
const dbOptions = { | |
user: '<databaseUsername>', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION notify_rows_changes() | |
RETURNS trigger AS $$ | |
DECLARE | |
record JSON; | |
BEGIN | |
record := row_to_json(CASE TG_OP | |
WHEN 'INSERT' THEN NEW | |
WHEN 'UPDATE' THEN NEW | |
ELSE OLD | |
END); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import firebase from 'firebase/app'; | |
import 'firebase/messaging'; | |
import { useEffect, useRef } from 'react'; | |
import config from '../config'; | |
import firebaseConfig from './firebaseConfig'; | |
import { PushTokenAddMutation } from './__generated__/PushTokenAddMutation.graphql'; | |
import { PushTokenAdd, USER_PUSHENDPOINT_TYPE } from './PushTokenAddMutation'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Restore yarn workspaces | |
id: yarn-cache | |
uses: actions/cache@master | |
with: | |
path: | | |
node_modules | |
*/*/node_modules | |
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} | |
- name: Install dependencies | |
if: steps.yarn-cache.outputs.cache-hit != 'true' |
NewerOlder