Skip to content

Instantly share code, notes, and snippets.

Dan MacTough danmactough

Block or report user

Report or block danmactough

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
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:

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 {

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

danmactough /
Created May 21, 2017 — forked from leucos/
Bootstrap your DO infrastructure unsing Ansible without dynamic inventory (version for Ansible v2.0+ and DO API v2.0)
# What is that
# ============
# This script will help you setting up your digital ocean
# infrastructure with Ansible v2.0+ and DO API v2
# Usually, when working with DO, one is supposed to use
# inventory file, and spin up instances in a playbook.
View write.js
var fs = require("fs");
var path = require("path");
var outfile = path.resolve(__dirname, "appPrefs.json");
var lockfile = outfile + ".lock";
var data = "some data or other";
// obtain an exclusive read/write file handle on the semaphore file, "wx+", function (err, fd) {
if (err) {

Tweet help

  • Great @NodeDC meetup @socialtables ty @NodeSource @Hired_HQ for sponsoring
  • ty @socialtables @NodeSource @Hired_HQ for sponsoring @NodeDC


Use these links! Sign up for Hired if you haven't already!

View memory.js
var heapdump = require('heapdump');
var FeedParser = require('..');
var fs = require('fs');
var feed = __dirname + '/feeds/intertwingly.atom';
var ct = 10000;
var premem = process.memoryUsage().heapUsed;
if (process.env.HEAPDUMP) heapdump.writeSnapshot();
console.log("Pre: %s", premem);
View 20nginx-https-redirect.config
command: perl -0777 -pe 's#(listen 8080;\n)#$1\n if (\$request_uri = "/health") {\n set \$redirectFlag N;\n }\n\n if (\$http_x_forwarded_proto != "https") {\n set \$redirectFlag "\${redirectFlag}Y";\n }\n\n if (\$redirectFlag = "Y") {\n return 301 https://\$host\$request_uri;\n }#igms' -i /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf
You can’t perform that action at this time.