Skip to content

Instantly share code, notes, and snippets.

View jelder's full-sized avatar

Jacob Elder jelder

View GitHub Profile
@mikesouza
mikesouza / lifecycle-plugin.js
Created February 20, 2019 11:11 — forked from bwinant/lifecycle-plugin.js
Serverless Plugin Lifecycle Events
'use strict';
// This plugin will bind to all available lifecycle events and print them out as they are invoked
class LifecyclePrinter {
constructor(serverless, options) {
this.serverless = serverless;
this.options = options;
this.provider = this.serverless.getProvider('aws');
@jelder
jelder / README.md
Last active December 27, 2015 19:29
Bookmarklet to toggle between Pow and Production

Pow Toggle Bookmarklet

Ever come across something funky in production and want to see it in your development environment? Use Pow? This is for you. Make a new bookmark for this location:

javascript:(function()%7Bif%20(%2Fhttp%3A.*%5C.dev%2F.test(window.location.origin))%20%7Burl%20%3D%20window.location.href.replace(%2F%5Ehttp%3A%2F%2C%20'https%3A').replace(%2F.dev%2F%2C'.com')%3Bwindow.open(url)%3B%7D%20else%20%7Burl%20%3D%20window.location.href.replace(%2F%5Ehttps%3A%2F%2C%20'http%3A').replace(%2F.com%2F%2C'.dev')%3B%3Bwindow.open(url)%3B%7D%7D)()

If you want to edit this, first copy and paste the JavaScript below into a bookmarklet creator. I used http://mrcoles.com/bookmarklet/ but others might be nice, too.

Zero downtime deploys with unicorn + nginx + runit + rvm + chef

Below are the actual files we use in one of our latest production applications at Agora Games to achieve zero downtime deploys with unicorn. You've probably already read the GitHub blog post on Unicorn and would like to try zero downtime deploys for your application. I hope these files and notes help. I am happy to update these files or these notes if there are comments/questions. YMMV (of course).

Other application notes:

  • Our application uses MongoDB, so we don't have database migrations to worry about as with MySQL or postgresql. That does not mean that we won't have to worry about issues with the database with indexes being built in MongoDB or what have you.
  • We use capistrano for deployment.

Salient points for each file:

@jelder
jelder / template.sh
Created July 26, 2012 17:25
Template for robust shell scripting
#!/bin/bash
set -o nounset
set -o errtrace
set -o errexit
set -o pipefail
progname=$(basename $0)
default_name="Marley"
@jelder
jelder / install_ruby.sh
Created May 25, 2012 02:22
Get the specificed version of Ruby onto a Linux host by any means necessary, and cache it in S3.
#!/bin/bash
# Get the specificed version of Ruby onto a Linux host by any means necessary. Invoke like this:
#
# curl https://raw.github.com/gist/2785410/install_ruby.sh | bash -s -- -r '1.9.3-p125' -b mybucket
#
# Jacob Elder <jacob@boundless.com>
usage() {
echo "Usage: $(basename $0) -r 1.9.3-p125 -b mybucket"
exit 1
@jelder
jelder / gist:2154989
Created March 22, 2012 01:19
New Machine Checklist
#!/usr/bin/ruby
class Node
attr_accessor :val, :left, :right
def initialize( val = nil )
@val = val
@left, @right = nil, nil
end
@peplin
peplin / recipe.rb
Created July 10, 2010 01:30
S3 File Resource for Chef
# Source accepts the protocol s3:// with the host as the bucket
# access_key_id and secret_access_key are just that
s3_file "/var/bulk/the_file.tar.gz" do
source "s3://your.bucket/the_file.tar.gz"
access_key_id your_key
secret_access_key your_secret
owner "root"
group "root"
mode 0644
end