Skip to content

Instantly share code, notes, and snippets.

danmactough /
Last active Mar 24, 2021
Apple cli tweaks
# Disable gesture navigation only in Chrome
defaults write AppleEnableSwipeNavigateWithScrolls -bool FALSE
# Make Finder display "hidden" files and folders
# like ~/.ssh
defaults write AppleShowAllFiles TRUE
# Apache in Mountain Lion
View feeds.json
[{"title":"Techmeme","xmlUrl":""},{"title":"Sam Ruby","xmlUrl":""},{"title":"Lethal Librarian","xmlUrl":""},{"title":"","xmlUrl":""},{"title":"Amyloo","xmlUrl":""},{"title":"bits & bytes & pixels & sprites","xmlUrl":""},{"title":"Bad Gods","xmlUrl":""},{"title":"Geek's Guide to the Galaxy","xmlUrl":""},{"title":"Writing (3)","xmlUrl":""},{"title":"Ficlets Blog","xmlUrl":""},{"title":"Achewood","xmlUrl":""},{"title":"Achewood","xmlUrl":""},{"title":"Auralgasms News","xmlUrl":""},{"title":"100 Word Stories","xmlUrl":"http://100wordstories.
View tsconfig.json
"compilerOptions": {
/* Visit to read more about this file */
"module": "none" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
"allowJs": true /* Allow javascript files to be compiled. */,
"checkJs": true /* Report errors in .js files. */,
"noEmit": true /* Do not emit outputs. */,
"noImplicitAny": false /* Raise error on expressions and declarations with an implied 'any' type. */,
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
"skipLibCheck": true /* Skip type checking of declaration files. */,
View fetch-callbackified
const fetch = require('node-fetch');
function request (options, cb) {
.then(res => {
return res.body()
.then(body => {
cb(null, res, body);
}, cb);
danmactough /
Last active Apr 14, 2020
Move your entire music library from one directory to another
set -euo pipefail
set -x
IFS=$(echo -en "\n\b")
# OLD_DIRECTORY=/Users/your_username/Music
# NEW_DIRECTORY=/Volumes/your_external_drive/Music
danmactough /
Created Feb 2, 2020 — forked from dergachev/
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF


To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

danmactough / resolve.js
Created Apr 21, 2015
In any koa app, find the app root directory from any location.
View resolve.js
var path = require('path');
var appRoot = path.resolve(path.dirname(require.resolve('koa')), '..', '..', '..');
View async_handle_request.js
const Layer = require('express/lib/router/layer');
Layer.prototype.handle_request = async function handle(req, res, next) {
var fn = this.handle;
if (fn.length > 3) {
// not a standard request handler
return next();
try {
View movebrew
# Get Homebrew in the new location
git clone ~/Homebrew
# Move all your installed packages to the new location
mv /usr/local/Cellar ~/Homebrew/Cellar
mv /usr/local/Library ~/Homebrew/Library
# Remove "root" directory files left behind
rm -rf /usr/local/.git /usr/local/{.gitignore,.yardopts,,,LICENSE.txt,,}

Notes on using Cognito with Serverless

  • event.requestContext.identity.cognitoIdentityId should be the user id
  • Cognito User Pools are for handling user registration, authentication, and account recovery
  • Cognito Identity Pools (or Cognito Federated Identities) are a way to authorize users to directly use the various AWS services in your account, such as S3, DynamoDB, and, most relevant for APIs, API Gateway

CloudFormation in serverless.yml