Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# ag is the_silver_searcher (https://github.com/ggreer/the_silver_searcher)
ag TODO | while read line; do
file=$(echo ${line} | awk -F ':' '{print $1}');
lineno=$(echo ${line} | awk -F ':' '{print $2}');
git blame --line-porcelain "./${file}" -L ${lineno},${lineno} | grep author-mail | cut -d ' ' -f 2;
done | sort | uniq -c

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@toddlers
toddlers / sma9.rb
Last active August 29, 2015 14:22 — forked from thomasklemm/sma9.rb
# Require the json library to parse json into Ruby objects
require 'json'
require 'simple_statistics'
# The input
json = '[
{
"Low": 8.63,
"Volume": 14211900,
"Date": "2012-10-26",

ChefDK, Test Kitchen Driven NTP Cookbook

This gist uses TK+Berkshelf to drive creating a vagrant virts and converging a simple recipe to install and configure NTPd. This is a simple cookbook that has one recipe, one template (for ntp.conf) and one attribute file. It works on Ubuntu 12.04 and CentOS 6.4 (and derviatives) and the attribute file is used to support both distros.

This should work on Mac (where I developed it) and any chef-supported Linux that you can get Vagrant onto (Ubuntu/CentOS).

Because I use ChefDK and Test Kitchen, I can largely ignore setting up Vagrant and Berkshelf and can get right to work on writing recipe code.

NOTE: Modern (7/6/2014) Recipe Generation

##Install AWS CLI Tools##

  1. Install AWS CLI Tools. You can also use the EC2 API Tool if you are more comfortable with them. But this write-up uses the EC2 CLI.
  2. Create a user via Amazon IAM or download the security accessID and securitykey you will need it to query Amazon CLI.
  3. using Terminal cd into .aws directory cd ~/.aws edit or create new file named config paste the following contents inside.
    `[default]`
    `aws_access_key_id = ACCESS_ID`
    `aws_secret_access_key = SECRET_ID`
    `output = json OR bson OR text`
    `region = PREFERRED_AWS_REGION`

Save the file as "config"

sudo su -
# stuff we need to build from source
apt-get install libpcre3-dev build-essential libssl-dev
# get the nginx source
cd /opt/
wget http://nginx.org/download/nginx-0.8.54.tar.gz
tar -zxvf nginx*
# we'll put the source for nginx modules in here
@toddlers
toddlers / merge.md
Last active August 29, 2015 14:24 — forked from pablitoc/merge.md

If someone forks a gist and you'd like to merge their changes. Do this:

  1. clone your repo, I use the name of the gist

     git clone git://gist.github.com/1163142.git gist-1163142
    
  2. add a remote for the forked gist, I'm using the name of my fellow developer

     git remote add aaron git://gist.github.com/1164196.git
    

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@toddlers
toddlers / Opsworks.md
Created October 9, 2015 19:10 — forked from zdk/Opsworks.md
OpsWork Tips
  • Run specific coookbook in running instance.
sudo -i
cd /opt/aws/opsworks/current/
opsworks-agent-cli get_json > attributes.json
bin/chef-solo -c conf/solo.rb -j attributes.json -o recipe[whatever],recipe[whatever_else::specific_recipe]
  • Test Opswork built-in cookbook on Vagrant

EC2 上で OptWorks 用のカスタムレシピを作成する

# cd /opt/aws/opsworks/current
# bundle exec knife cookbook create xxx -o /tmp/cookbook -c conf/solo.rb

EC2 上で OptWorks 用のカスタムレシピ実行

# bundle exec chef-solo -c conf/solo.rb -o xxx