Skip to content

Instantly share code, notes, and snippets.

View 20nginx-https-redirect.config
container_commands:
10redirect:
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
@danmactough
danmactough / Cargo.toml
Created Dec 28, 2015
Dining Philosophers
View Cargo.toml
[package]
name = "dining_philosophers"
version = "0.1.0"
authors = ["Dan MacTough <danmactough@gmail.com>"]
[dependencies]
@danmactough
danmactough / add-collaborator.sh
Created Oct 12, 2015
I needed to add a read-only collaborator to many repositories, and doing it via the website was really tedious
View add-collaborator.sh
#!/bin/bash
GITHUB_TOKEN=$(git config --global github.token) # I've defined an API token in my git config -- ymmv
GITHUB_USER="" # the collaborator
REPO_OWNER="" # the owner of the repos
REPOS="" # space-delimited list of repositories
PERMISSION="pull" # may be one of "admin", "push" (i.e., read/write -- default), or "pull" (i.e., read-only)
for REPO in ${REPOS} ; do
curl -X PUT -i -d '{ "permission": "'${PERMISSION}'" }' \
-H 'Accept: application/vnd.github.ironman-preview+json' \
-H "Authorization: token ${GITHUB_TOKEN}" \
@danmactough
danmactough / second-boot.sh
Created Jul 31, 2015
Setting up a gpu (nvidia) ec2 instance with ubuntu and electron for headless webgl rendering
View second-boot.sh
#!/bin/bash -xe
# Unload nouveau
sudo rmmod nouveau
# Load nvidia
sudo modprobe nvidia
# Configure X
sudo nvidia-xconfig --use-display-device=None --virtual=1280x1024 --output-xconfig=/etc/X11/xorg.conf --busid=PCI:0:3:0 --enable-all-gpus
@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)