Skip to content

Instantly share code, notes, and snippets.


Zander Martineau mrmartineau

Block or report user

Report or block mrmartineau

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
zephraph /
Last active May 15, 2019
A shell script to clean up all node_modules in projects that haven't been touched in a couple weeks.
node_modules=$(find $SEARCH_PATH -name "node_modules" -type d -prune)
Aidurber /
Last active May 1, 2019
A handy script to clean up a mac thanks to - Gant Laborde's article:
# Cleanup old node_modules
echo "Cleaning node_modules in projects older than 30 days"
find . -name "node_modules" -type d -mtime +30 | xargs rm -rf
echo "Done cleaning node_modules"
# Clean up homebrew
echo "Clean homebrew"
brew update && brew upgrade && brew cleanup
echo "Done cleaning homebrew"
MoOx /
Last active Apr 5, 2019
Matrix of existing React ui kit (more than 200 download/week, more than 200 stars)



  • ✏️ method changes this.
  • 🔒 method does not change this.


  • concat(...items: Array<T[] | T>): T[] 🔒 ES3
Atinux / async-foreach.js
Last active Dec 11, 2019
JavaScript: async/await with forEach()
View async-foreach.js
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
metasean /
Created Jun 30, 2017
How to share a webpack config between next.js and Storybook
zcaceres /
Last active Dec 10, 2019
error handling patterns in Express

Handling Errors

Express.js makes it a breeze to handle errors in your routes.

Express lets you centralizes your error-handling through middleware.

Let's look at patterns for how to get the most out of your error-handling.

First, our error-handling middleware looks like this:

bendc / randomInterval.js
Created Mar 9, 2017
rAF-based random interval
View randomInterval.js
const randomInterval = (() => {
const random = (min, max) => Math.random() * (max - min) + min;
return (callback, min, max) => {
const time = {
total: random(min, max)
const tick = now => {
if ( <= now - time.start) {
time.start = now;
ellm /
Last active Jan 17, 2019
Webpack Notes and Snippets

Webpack 3.0

Code spliting in webpack to help decrease loaded dependencies on load.

  • UI that gets displayed as a callback from an event can benefit.
  • We can async. load a ES6 import() and code after it is returned using a promise.
// At top of file, assign an `import()` that is returned from a function.
const getBloodhound = () => import('bloodhound-js');

// Add an event that will trigger loading the module.
ggauravr /
Last active May 3, 2018 — forked from ljharb/
Array iteration methods summarized

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.


JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it much simpler to think about both the old list and the new one, what they contain, and

You can’t perform that action at this time.