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
@danmactough
danmactough / canvas-to-image.js
Created Jul 8, 2015
Not using this really clever bit
View canvas-to-image.js
function () {
actions.zoomForPrint();
window.requestAnimationFrame(function () {
const imgData = getImageFromCanvas();
// atob to base64_decode the data-URI
const imgSrc = atob(imgData.split(",")[1]);
// Use typed arrays to convert the binary data to a Blob
const buffer = new ArrayBuffer(imgSrc.length);
var view = new Uint8Array(buffer);
for (var i = 0; i < imgSrc.length; i++) {
View movebrew
#!/bin/bash
# Get Homebrew in the new location
git clone git@github.com:Homebrew/homebrew.git ~/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,CODEOFCONDUCT.md,CONTRIBUTING.md,LICENSE.txt,README.md,SUPPORTERS.md}
@danmactough
danmactough / output
Created May 12, 2015
What's using `process.nextTick`?
View output
node_modules/aws-sdk/lib/metadata_service.js
node_modules/aws-sdk/lib/request.js
node_modules/aws-sdk/node_modules/sax/examples/example.js
node_modules/aws-sdk/node_modules/xml2js/lib/xml2js.js
node_modules/feedparser/History.md
node_modules/feedparser/node_modules/readable-stream/lib/_stream_duplex.js
node_modules/feedparser/node_modules/readable-stream/lib/_stream_readable.js
node_modules/feedparser/node_modules/readable-stream/lib/_stream_writable.js
node_modules/feedparser/node_modules/sax/examples/example.js
node_modules/opmlparser/node_modules/readable-stream/lib/_stream_duplex.js
@danmactough
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 else.js
if {
something();
// } else {
// somethingElse();
}
View nodeschool-prep.md

NodeSchool - NationJS 2014

Welcome and thank you for signing up for NodeSchool at NationJS 2014. To make this NodeSchool the best NodeSchool, there are a few things that you can do before you arrive to be ready to excel at this NodeSchool!

Steps to get ready for NodeSchool

  1. Install Node.js - This can be done by choosing the pre-built installers here.
  2. After you've installed Node.js, install the NodeSchool workshops (see below).
  3. Come ready to learn with your favorite text editing program (We suggest Sublime Text, Atom or Brackets)
View ssh-purge-host
#!/bin/bash
LINE=$1
KNOWN_HOSTS=~/.ssh/known_hosts
usage() {
cat <<-EOM
Usage: ssh-purge-host <line no>
View multistar-gmai.md

How to enable multiple stars in Gmail

What?

Gmail has a setting to enable multiple types of stars. Not "give this email 2 stars and this other email 1 star," but "give this email a gold star and this other email a blue star." YMMV as to whether this is helpful.

How?

  1. Open up your Gmail settings. Under the "General" tab, find the "Stars" section and click on "4 stars".
@danmactough
danmactough / flushdns
Created Sep 9, 2014
Supposedly, this will flush your dns cache on Mac OS X Mountain Lion and greater
View flushdns
#!/bin/bash
if [[ $OSTYPE == darwin* ]]; then
sudo killall -HUP mDNSResponder
fi
View vm.js
var vm = require('vm');
var boss = 'Mr. Trump'
, condition = 'bald';
var script = [
'boss = name;',
'condition = type;',
'result = boss + " is " + condition;'
].join('\n');
You can’t perform that action at this time.