This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet; | |
var mountFolder = function (connect, dir) { | |
return connect.static(require('path').resolve(dir)); | |
}; | |
// # Globbing | |
// for performance reasons we're only matching one level down: | |
// 'test/spec/{,*/}*.js' | |
// use this if you want to match all subfolders: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// snippet taken from http://catapulty.tumblr.com/post/8303749793/heroku-and-node-js-how-to-get-the-client-ip-address | |
function getClientIp(req) { | |
var ipAddress; | |
// The request may be forwarded from local web server. | |
var forwardedIpsStr = req.header('x-forwarded-for'); | |
if (forwardedIpsStr) { | |
// 'x-forwarded-for' header may return multiple IP addresses in | |
// the format: "client IP, proxy 1 IP, proxy 2 IP" so take the | |
// the first one | |
var forwardedIps = forwardedIpsStr.split(','); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'), | |
passport = require('passport'), | |
LocalStrategy = require('passport-local').Strategy, | |
connect = require('connect'), | |
http = require('http'), | |
path = require('path'), | |
util = require('util'), | |
fs = require('fs'), | |
redis = require('redis'), | |
cookie = require('cookie'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl https://www.npmjs.org/install.sh | sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var async = require('async'); | |
var ProgressBar = require('progress'); | |
var monk = require('monk'); | |
var ObjectId=require('mongodb').ObjectID; | |
var dest = monk('localhost:27017/storify_localhost'); | |
var backup = monk('localhost:27017/storify_backup'); | |
var userId = ObjectId(YOUR-OBJECT-ID); // monk should have auto casting but we need it for queries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function nFormatter(num) { | |
if (num >= 1000000000) { | |
return (num / 1000000000).toFixed(2).replace(/\.0$/, '') + 'G'; | |
} | |
if (num >= 1000000) { | |
return (num / 1000000).toFixed(2).replace(/\.0$/, '') + 'M'; | |
} | |
if (num >= 1000) { | |
return (num / 1000).toFixed(2).replace(/\.0$/, '') + 'K'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Show current time | |
$ date | |
# current timezone | |
$ more /etc/timezone | |
# change timezone | |
$ echo "Asia/Jakata" > /etc/timezone | |
$ dpkg-reconfigure -f noninteractive tzdata | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async | |
backbone | |
brfs | |
browjadify | |
browserify | |
bunyan | |
bytes | |
cf-api | |
cf-auth-middleware | |
cf-auth-provider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Definitions: | |
1. A .csr file is a certificate signing request which initiates your certificate request with a certificate provider and contains administrative information about your organization. | |
2. A .key file is the private key used to encrypt your site’s SSL-enabled requests. | |
3. .pem and .crt extensions are often used interchangeably and are both base64 ASCII encoded files. The technical difference is that .pem files contain both the certificate and key whereas a .crt file only contains the certificate. In reality this distinction is often ignored. | |
## Generate SSL Keys for Heroku: | |
$ openssl genrsa -des3 -out server.orig.key 2048 | |
$ openssl rsa -in server.orig.key -out server.key | |
$ openssl req -new -key server.key -out server.csr // Used for request of cert generation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
check host localhost with address 127.0.0.1 | |
start "/sbin/start myapp" | |
stop "/sbin/stop myapp" | |
if failed port 3000 protocol HTTP | |
request / | |
with timeout 5 seconds | |
then restart |
OlderNewer