Skip to content

Instantly share code, notes, and snippets.

DanHerbert /
Last active Nov 23, 2021
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

READ THIS Very Important Update

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

sphvn / traverse.js
Last active Nov 17, 2021
Recursively traverse object javascript, recurse json js, loop and get key/value pair for JSON
View traverse.js
var traverse = function(o, fn) {
for (var i in o) {
if (o[i] !== null && typeof(o[i])=="object") {
traverse(o[i], fn);
// usage
dmnsgn / listAllEventListeners.js
Created Apr 5, 2017
List all event listeners in a document
View listAllEventListeners.js
const listeners = (function listAllEventListeners() {
let elements = [];
const allElements = document.querySelectorAll('*');
const types = [];
for (let ev in window) {
if (/^on/.test(ev)) types[types.length] = ev;
for (let i = 0; i < allElements.length; i++) {
const currentElement = allElements[i];
kevinelliott /
Last active Oct 27, 2021
Mac OS X 10.10 Yosemite Setup

Mac OS X 10.10 Yosemite

Custom recipe to get OS X 10.10 Yosemite running from scratch, setup applications and developer environment. I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your own needs.

Install Software

andrewlkho /
Last active Oct 8, 2021
Implementing HTTPS on NFSN ( hosting using Let's Encrypt

These instructions are for implementing HTTPS on a NFSN-hosted static site using a certificate from Let's Encrypt. The certificate is generated manually on a separate computer.

Start off by installing the letsencrypt client. This requires sudo privileges and will install a bunch of packages:

% curl -O
% chmod +x ./certbot-auto
% ./certbot-auto

Generate the certificate. This will require you to publish some challenge responses on NFSN. I find it easiest to use tmux with letsencrypt running in one window and an SSH session to NFSN in another:

ourmaninamsterdam / simple-pagination.html
Created Jan 24, 2013
Simple JS pagination script that can be easily modified to accept a JSON array. Known bug where pages 11-20 are skipped when paging through.
View simple-pagination.html
<!DOCTYPE html>
<html lang="en-GB">
<title>Simple JavaScript pagination</title>
<meta charset="UTF-8">
position: relative;
odan /
Last active Dec 8, 2020
Basic CRUD operations with PDO and MySQL