Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Slingin' Code

Dan Stroot dstroot

:octocat:
Slingin' Code
View GitHub Profile
@dstroot
dstroot / nginx_config_1.txt
Last active Aug 29, 2015
Configuration for nginx in front of node
View nginx_config_1.txt
# 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
@dstroot
dstroot / setup_nginx.sh
Last active Aug 29, 2015
Setup NGINX on Ubuntu
View setup_nginx.sh
#!/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 "*****************************************"
View www-redirect.js
// 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 Jun 22, 2014
conservatory Error (403): Forbidden
View gist:48adce48ab2857ae9c0a
❯ 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 Aug 29, 2015
issue with gulp-jscs
View .jscsrc
{
"disallowTrailingComma": true,
"requireSpaceAfterLineComment": true,
"requireSpacesInConditionalExpression": true
}
View osx-10.10-setup.md

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

View exportjson.js
// 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 Mar 25, 2012
An EC2 setup script to install Node.js
View ec2_install_node.sh
#!/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
View Start Forever.js on System Restarts
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
script to start forever after reboot
View reboot.sh
#!/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