Skip to content

Instantly share code, notes, and snippets.

@mm53bar
mm53bar / README.md
Last active December 15, 2015 07:49

Simpler bash recipes

Goal

Build install scripts that are stand-alone bash

Secondary goal

Support "dry runs", where the guard statements can be executed without actually running the installation statements

@mm53bar
mm53bar / gitrev
Last active December 14, 2015 07:49
cd $DEPLOY
git rev-parse HEAD
@mm53bar
mm53bar / .env
Last active December 14, 2015 02:49
Simple bash based deployment script
# deploy to:
SERVER=server.com
APP=app_name
DEPLOY=/srv/$APP
ENVIRONMENT=production
# clone source from:
REPO=ssh://[email protected]/username/repo.git
BRANCH=master
Problem: how to reference templates from recipe file?
How about....
* export all attributes as env variables (in install.sh just before the place where the role scripts get injected?)
* add helper method to recipes/sunzi.sh called sunzi::template
* call sunzi::template from recipes and pass in url of template file
* sunzi::template will wget the file to ~/sunzi/files/ unless the file already exists (allows override with local template file)
* sunzi::template will then run the template file through envsubst to substitute the env variables (http://www.oreillynet.com/linux/cmd/cmd.csp?path=e/envsubst)
@mm53bar
mm53bar / 01-intro.markdown
Created February 16, 2013 18:05
Turn your markdown-written user stories into a PDF requirements doc

Introduction

Stakeholders

@mm53bar
mm53bar / static_roadreports
Last active February 11, 2019 15:48
A simple nginx virtual server config. Should redirect all requests to / except for those that actually have a match (i.e. html/images/css/js).
server {
listen 80;
server_name amaroadreports.ca www.amaroadreports.ca;
root /srv/road_reports_static;
location / {
try_files $uri/index.html $uri.html $uri @missing;
}
location @missing {
@mm53bar
mm53bar / Gemfile
Created January 30, 2013 15:37
Be sure to install the datadog agent on your server before applying this code to your app. Instructions are at https://app.datadoghq.com/account/settings#agent or use my Sunzi recipe at https://github.com/Shift81/sunzi-recipes/blob/master/ubuntu/precise/datadog.sh
gem 'dogstatsd-ruby'
@mm53bar
mm53bar / README.md
Last active December 11, 2015 05:28 — forked from mynameisrufus/db_backup.sh
Stop using Ruby to back up the postgres database in your Rails app. Use bash instead!

Backing up Postgres with Bash

Stop using Ruby to back up the postgres database in your Rails app. Use bash instead!

##Install:

cd /usr/local/bin
git clone https://gist.github.com/4552332.git db_backup

chmod +x db_backup/db_backup.sh

@mm53bar
mm53bar / README.md
Created November 29, 2012 18:46
Using Cloudfront CDN with a rails app

Using Cloudfront CDN with a Rails app

Stop serving assets from your own nginx instance. Instead, let Cloudfront CDN do it for you.

Steps:

  1. Read http://ryantownsend.co.uk/post/13126016608/cloudfront-cdn-on-rails
  2. Set up your nginx virtual host according to the snippet I've included in nginx_vhost.conf
  3. Set up your rails app to use an asset host as described in the article. I've included my config in production.rb
@mm53bar
mm53bar / gist:2500646
Created April 26, 2012 16:11
Testing the Scoutapp.com webhook method for submitting messages to Hubot
curl -X POST -d 'payload={"id": 999999, "time": "2012-03-05T15:36:51Z", "server_name": "Blade", "server_hostname": "blade", "lifecycle": "start", "title": "Last minute met or exceeded 3.00 , increasing to 3.50 at 01:06AM", "plugin_name": "Load Average", "metric_name": "last_minute", "metric_value": 3.5, "severity": "warning", "url": "https://scoutapp.com/a/999999"}' http://HOSTNAME/hubot/scoutapp/ROOM_NUMBER