Skip to content

Instantly share code, notes, and snippets.

View mlafeldt's full-sized avatar

Mathias Lafeldt mlafeldt

View GitHub Profile
@mlafeldt
mlafeldt / recipe.rb
Created January 9, 2015 10:47
Package Go tools with fpm-cookery (automatically uses godep dependencies if present)
class ChefRunner < FPM::Cookery::Recipe
GOPACKAGE = "github.com/mlafeldt/chef-runner"
name "chef-runner"
version "0.8.0"
revision 1
source "https://#{GOPACKAGE}/archive/v#{version}.tar.gz"
sha256 "a7de23f989f8353ecf838b551a8ceff09b83c8aeff2553b2c31d57615f8fcc53"
description "The fastest way to run Chef cookbooks"
@mlafeldt
mlafeldt / spec-runner.sh
Created November 7, 2014 13:41
Helper script to run individual Puppet RSpec tests, best used with https://github.com/Jimdo/vim-spec-runner
#!/bin/sh
# Helper script to run (almost) any individual Puppet RSpec test.
# Usage: ./scripts/spec-runner <specfile[:line]> ...
set -e
PUPPET_ROOT=$(cd -P -- $(dirname -- "$0")/.. && pwd)
if test "$PUPPET_ROOT" != "$(pwd -P)"; then
echo >&2 "error: spec-runner must be executed in $PUPPET_ROOT"
@mlafeldt
mlafeldt / install.sh
Last active August 29, 2015 14:07
Omnibus installer
#!/bin/sh
# WARNING: REQUIRES /bin/sh
#
# - must run on /bin/sh on solaris 9
# - must run on /bin/sh on AIX 6.x
# - if you think you are a bash wizard, you probably do not understand
# this programming language. do not touch.
# - if you are under 40, get peer review from your elders.
#
# Author:: Tyler Cloke ([email protected])
@mlafeldt
mlafeldt / Rakefile
Created September 22, 2014 20:12
My Jekyll Rake tasks
# Rake tasks for Jekyll
# Inspired by https://github.com/imathis/octopress/blob/master/Rakefile
require 'rake/clean'
require 'redcloth'
require 'stringex'
POSTS_DIR = '_posts'
BUILD_DIR = '_site'
DEPLOY_DIR = '_deploy'
@mlafeldt
mlafeldt / puppet-installer.sh
Created September 15, 2014 17:29
Helper script to install a specific version of Puppet
#!/bin/sh
# Helper script to install a specific version of Puppet
# Usage: puppet-installer.sh <distro name> <Puppet version>
set -e
DISTRO=$1
VERSION=$2
CURRENT=$(apt-cache policy puppet | awk '/Installed:/ {print $2}' 2>/dev/null)
@mlafeldt
mlafeldt / main.go
Created September 4, 2014 19:21
Go YAML
package main
import (
"fmt"
"log"
"gopkg.in/yaml.v1"
)
var data = `
@mlafeldt
mlafeldt / image_processor.py
Created April 10, 2014 12:21
Batch processing script from Architecting on AWS training
import boto
import json
import time
import sys
import getopt
import argparse
import os
import logging
import StringIO
import uuid
@mlafeldt
mlafeldt / Usage.md
Last active November 24, 2015 21:25
Vagrant + fpm-cookery

Boot up the Vagrant virtual machine:

$ vagrant up

Build a specific recipe with fpm-cookery:

$ RECIPE=<recipe-name> vagrant provision

The final packages will be located here:

@mlafeldt
mlafeldt / gist:8772223
Last active August 29, 2015 13:55
RuboCop offences for Practicing Ruby Rails app
Inspecting 166 files
CCCCCCCCCCCCCCWWCCCCCCCCCCCCCCCCWCCCCCCCCWCCCCCCCCCW.C..C.CCCCC.C..CCC.C.CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCWC.WCC..CC.WWCCCCWCCCWCCCCCCCCCWCCCCCCCWWCCC
Offences:
app/controllers/admin/announcements_controller.rb:1:1: C: Missing top-level class documentation comment.
class Admin::AnnouncementsController < ApplicationController
^^^^^
app/controllers/admin/announcements_controller.rb:18:29: C: Missing space after #.
redirect_to root_path #announcement_path(@announcement)
@mlafeldt
mlafeldt / gist:8332701
Created January 9, 2014 11:23
Packer AWS policy actions
{
"Statement": [{
"Effect": "Allow",
"Action" : [
"ec2:AttachVolume",
"ec2:CreateVolume",
"ec2:DeleteVolume",
"ec2:DescribeVolumes",
"ec2:DetachVolume",