Skip to content

Instantly share code, notes, and snippets.


Elliott Foster elliotttf

View GitHub Profile
elliotttf /
Last active Aug 12, 2021
Bench Memoization


Memoization is a technique for storing computed values in-memory. Essentially, it's a fancy name for in-memory cache.

Why Memoize?

Memoization is useful when you have potentially expensive or highly repetitive computations that need to be executed. Rather than re-running the computation on each iteration, your routine computes once and fetches already computed values from memory.

View example.js
'use strict';
const { createBackgroundTransaction, endTransaction } = require('newrelic');
const fs = require('fs');
createBackgroundTransaction('fileProcessing', () => {
return new Promise((resolve, reject) => fs.readFile('/tmp/input.txt', (err, file) => {
if (err) {
return reject(err);

Keybase proof

I hereby claim:

  • I am elliotttf on github.
  • I am elliotttf ( on keybase.
  • I have a public key whose fingerprint is 44E1 73E2 CF8C F08C 87D6 7685 BCCE 227F C0D4 9E70

To claim this, I am signing this object:

elliotttf /
Last active Mar 3, 2016
socket stuff

To use

node master&
node test&
# wait ~7 seconds
pkill -SIGINT -x test-server
elliotttf / master.js
Last active Feb 23, 2016
adios example
View master.js
'use strict';
* @file master.js
* Master process code for adios-example.
const cluster = require('cluster');
const os = require('os');
const path = require('path');
# Bot factoid.
# facts - List all the stored definitions.
# <subject> is <definition> - Define a word or subject.
# forget <subject> - Remove a definition.
u = require 'underscore'
util = require 'util'
module.exports = (robot) ->
elliotttf /
Last active Aug 29, 2015
Example source for "theme it once" blog post.
name = Theme it Once Example
description = Example of sharing markup with a front-end and back-end template engine in Drupal.
core = 7.x
View out.txt
elliotttf@4kmba:~$ php /tmp/test.php
Notice: Undefined index: baz in /private/tmp/test.php on line 15
Notice: Undefined index: baz in /private/tmp/test.php on line 16
View node-load-from-path.php
$node = menu_get_object();
if (empty($node)) {
$node = node_load(arg(1));
elliotttf / images.js
Created May 26, 2013
Helper function to pull data from flickr for 4k node.js training.
View images.js
var request = require('superagent');
var Stream = require('stream');
* Get Images function
module.exports = function nodes (url, fn) {
var data = '';
// Set up a stream to pipe data to.