Skip to content

Instantly share code, notes, and snippets.

@ryanray
ryanray / deploy.rb
Created November 21, 2013 05:32 — forked from alkema/deploy.rb
set :application, "appname"
set :deploy_to, "/var/www"
set :scm, :git
set :repository, "git@github.com:user/app.git"
default_run_options[:pty] = true
set :user, "www-data"
set :domain, "foo.tld"
set :normalize_asset_timestamps, false
@ryanray
ryanray / deploy.rb
Created November 21, 2013 11:15
I couldn't find a quick example of how to deploy a node.js app using Capistrano 3. This gist assumes you are using Capistrano 3, Upstart, Forever, ssh/forward agent, and an unprivileged user named 'deploy'. Hopefully this simple setup will help to get you started.
# config/deploy.rb
# probably a lot of ways to improve this...
set :application, 'my_app'
set :repo_url, 'git@github.com:USERNAME/my_app.git'
# should set up a deploy user
set :user, 'deploy'
set :deploy_to, '/var/www/my_app'
set :scm, :git
@ryanray
ryanray / aws-api-gateway-form-to-json.ftl
Created October 4, 2015 01:24
API Gateway application/www-form-urlencoded to application/json based on https://forums.aws.amazon.com/thread.jspa?messageID=673012&tstart=0#673012
## convert HTML POST data or HTTP GET query string to JSON
## get the raw post data from the AWS built-in variable and give it a nicer name
#if ($context.httpMethod == "POST")
#set($rawAPIData = $input.path('$'))
#elseif ($context.httpMethod == "GET")
#set($rawAPIData = $input.params().querystring)
#set($rawAPIData = $rawAPIData.toString())
#set($rawAPIDataLength = $rawAPIData.length() - 1)
#set($rawAPIData = $rawAPIData.substring(1, $rawAPIDataLength))
@ryanray
ryanray / lodash-4-migrate
Created May 31, 2016 17:35
Simple script that finds all files with lodash 3.x method calls within a given directory so you can upgrade them to lodash 4.x
# Use to find methods that were renamed in lodash 4. https://github.com/lodash/lodash/wiki/Deprecations
# Ex: `./lodash-4-migrate.sh src/` to find files that contain any of the lodash 3.x names in the src/ directory.
# supporting the _.chain() methods such as .min() can produce false positives such as Math.min(). See line ~151.
usage() {
echo "wrong number of arguments"
echo "Usage: $0 directory_to_search"
}
if [ "$#" -lt 1 ]
then