Skip to content

Instantly share code, notes, and snippets.

View dstroot's full-sized avatar
:octocat:
Slingin' Code

Dan Stroot dstroot

:octocat:
Slingin' Code
View GitHub Profile
@dstroot
dstroot / setup_nginx.sh
Last active August 29, 2015 13:56
Setup NGINX on Ubuntu
#!/bin/bash
###############################################
# To use:
# wget https://raw.github.com/gist/4411254
# chmod 777 setup_nginx.sh
# ./setup_nginx.sh
###############################################
echo "*****************************************"
echo " Step 1: Install nngix"
echo "*****************************************"
@dstroot
dstroot / nginx_config_1.txt
Last active August 29, 2015 13:56
Configuration for nginx in front of node
# Example 1
# -------------------------------------------------
# nginx config file for nodejs
#
# you can put nginx in front of node for two good reasons:
# 1) To take some of the load off nodejs for serving
# anything static.
# 2) To run multiple nodjs sites on one server
# domain1:80 -|->nginx-|-> nodejs:3000
# domain2:80 -| |-> nodejs:4000
// This is for SEO: We *only* want to serve from
// either www.domain.com or just domain.com but *not* both.
// So we need to choose and then do a 301 redirect to get
// traffic where we want it.
//
// NOTE: Don't hardcode the http:// or https:// in the redirect
// URI; this makes life suck when switching between dev and prod
// environments - use req.protocol instead as we do below.
//
// Also note that in order to use req.protocol reliably behind a
@dstroot
dstroot / gist:48adce48ab2857ae9c0a
Created June 22, 2014 19:26
conservatory Error (403): Forbidden
❯ jitsu deploy
info: Welcome to Nodejitsu dstroot
info: jitsu v0.13.16, node v0.10.28
info: It worked if it ends with Nodejitsu ok
info: Executing command deploy
info: Analyzing application dependencies in node app.js
warn: Local package version appears to be old
warn: The package.json version will be incremented automatically
warn: About to write /Users/Dan/Code/skeleton/package.json
data:
@dstroot
dstroot / .jscsrc
Last active August 29, 2015 14:03
issue with gulp-jscs
{
"disallowTrailingComma": true,
"requireSpaceAfterLineComment": true,
"requireSpacesInConditionalExpression": true
}

Mac OS X 10.10 Yosemite

Custom recipe to get OS X 10.10 Yosemite running from scratch, setup applications and developer environment. I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your own needs.

Install Software

// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@dstroot
dstroot / ec2_install_node.sh
Created March 25, 2012 01:13
An EC2 setup script to install Node.js
#!/bin/bash
echo "*****************************************"
echo " get superuser and install all updates "
echo "*****************************************"
sudo su
yum –y update
echo "*****************************************"
echo " Installing Development Tools"
echo "*****************************************"
yum install gcc gcc-c++ make -y
From Hack Sparrow:
---------------------------
Some time ago, I wrote a post on keeping Node.js apps running even after logging out from the shell. It was cool and all, but soon you will soon realize that Forever alone is not enough. Because, on system reboots, Forever itself is killed. Who will restart your app now?
There are many options for handling this kind of scenario, but today we will implement a solution using cron. Let's find out how we can make Forever and our Node.js app reboot-proof.
The app you want Forever to start on system restart is probably a web app, so let's try this thing on an Express.js web app.
Install Express, if you haven't already:
$ npm install -g express
@dstroot
dstroot / reboot.sh
Created May 23, 2012 20:58
script to start forever after reboot
#!/bin/sh
if [ $(ps aux | grep $USER | grep node | grep -v grep | wc -l | tr -s "\n") -eq 0 ]
then
export NODE_ENV=production
export PATH=/usr/local/bin:$PATH
forever start ~/vizilinkz/server.js > /dev/null
# redirects port 80 to port 8080
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080
fi