Skip to content

Instantly share code, notes, and snippets.

@noahehall
noahehall / ultimate-ut-cheat-sheet.md
Created May 12, 2016 13:59 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


#!/bin/sh
DEBUG=""
DATE=$(date +%Y-%m-%d)
HOSTNAME=`/bin/hostname`
AMINAME="$DATE-$HOSTNAME-AMI"
AMIDESC="$HOSTNAME backup to AMI on $DATE"
EC2_INSTANCE_ID="`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id || die \"wget instance-id has failed: $?\"`"
test -n "$EC2_INSTANCE_ID" || die 'cannot obtain instance-id'
#!/bin/bash
SERVICENAME="NAME-OF-NODE"
INSTANCEID=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)
AWS=/usr/bin/aws
REGION=$(wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | awk -F '"' '{print $4}')
DOMAIN=$(/usr/bin/aws ec2 describe-instances --region $REGION --instance-id $INSTANCEID --query 'Reservations[*].Instances[*].Tags[*]' --output=t
ext | grep Name | awk -F ":" '{print $1}' | awk '{print $2}')
SNSARN=arn:aws:sns:${REGION}:948962939411:BPPM_Connector
METRICNAME=$1
PERIOD=$2
# Get a (filtered) list of AWS instances, comma separated:
#
# Here's the reference to the 'describe-instances' command in aws-cli,
# check out the filters section.
# http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html
$ aws ec2 describe-instances --filters "Name=availability-zone,Values=us*" | \
jq -r '.Reservations[] | .Instances[] | "\(.InstanceId)"' | \
tr '\n' ','
.random-color {
border-top-color: "LightCoral";
border-right-color: #a44b58;
border-bottom-color: rgb(108, 188, 134);
border-left-color: rgb(24%, 88%, 5%);
outline-top-color: hsl(88, 69%, 69%);
outline-right-color: rgba(220, 71, 132, 0.69);
outline-bottom-color: rgba(79%, 47%, 14%, 0.37);
outline-left-color: hsla(111, 31%, 38%, 0.86);
}
@noahehall
noahehall / AtomVerticalTabs.md
Last active July 28, 2016 05:05 — forked from jasesmith/AtomVerticalTabs.md
Vertical file tab list in Atom

Vertical File Tabs in Atom

Add the styles to the .atom/styles.less stylesheet in Atom.

Atom Vertical File Tabs

@noahehall
noahehall / node-on-ec2-port-80.md
Created June 12, 2016 03:52 — forked from kentbrew/node-on-ec2-port-80.md
How I Got Node.js Talking on EC2's Port 80

The Problem

Standard practices say no non-root process gets to talk to the Internet on a port less than 1024. How, then, could I get Node talking on port 80 on EC2? (I wanted it to go as fast as possible and use the smallest possible share of my teeny tiny little micro-instance's resources, so proxying through nginx or Apache seemed suboptimal.)

The temptingly easy but ultimately wrong solution:

Alter the port the script talks to from 8000 to 80:

}).listen(80);
@noahehall
noahehall / .gitignore
Created June 17, 2016 20:46 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@noahehall
noahehall / better-nodejs-require-paths.md
Created June 20, 2016 12:44 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions