Skip to content

Instantly share code, notes, and snippets.

View mlafeldt's full-sized avatar

Mathias Lafeldt mlafeldt

View GitHub Profile
@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",
@mlafeldt
mlafeldt / notes.md
Last active December 31, 2015 03:39
Notes on SOA in Web Operations

Service-Oriented Architecture (SOA) [WEBOPS, pp. 67-69]

  • each system component is broken up into network-accessible services, which are integrated to make a functioning application
  • allows to create ever more flexible, powerful infra with less overhead and time
  • developers become free to compose new apps from network primitives, resulting in easy reuse, clear encapsulation, and simpler troubleshooting
  • core competency of Web 2.0 companies
  • SOA principles that apply to infra as code:
  • modular: small and simple services that do one thing (well)
  • cooperative: services exposed via network APIs encourage cooperation and become more useful, can hand off work to other services
  • composable: compose modularized services to automate infra as required
@mlafeldt
mlafeldt / plugin.list
Created December 11, 2013 16:03
Vagrant 1.4.0 w/ and w/o plugins
$ vagrant plugin list
vagrant-cachier (0.5.0)
vagrant-omnibus (1.1.2)
@mlafeldt
mlafeldt / gist:7772628
Created December 3, 2013 16:44
test-kitchen 1.0 + serverspec 0.13 fuckup
-----> Running serverspec test suite
/opt/chef/embedded/bin/ruby -I/tmp/busser/suites/serverspec -S /opt/chef/embedded/bin/rspec /tmp/busser/suites/serverspec/default_spec.rb --color --format documentation
1
skeleton::default
installs sample package (FAILED - 1)
does something (FAILED - 2)
Failures:
1) skeleton::default installs sample package
@mlafeldt
mlafeldt / gist:7631064
Created November 24, 2013 19:10
Ask VirtualBox for current SSH port of a Vagrant machine
machine_name=default
machine_id=$(cat ".vagrant/machines/$machine_name/virtualbox/id")
ssh_port=$(VBoxManage showvminfo "$machine_id" --machinereadable | grep ^Forwarding | head -n1 | cut -d, -f4)
echo $ssh_port
@mlafeldt
mlafeldt / env.rb
Created November 15, 2013 15:24
Aruba shims
require "cucumber"
require "aruba/cucumber"
# Add shims to PATH
SHIMS = "#{Dir.pwd}/tmp/aruba/shims"
ENV['PATH'] = "#{SHIMS}:#{ENV['PATH']}"
def generate_shims_for(commands)
FileUtils.mkdir_p(SHIMS)
commands.each do |cmd|
@mlafeldt
mlafeldt / pipefail.sh
Created November 8, 2013 10:25
pipefail example
[tmp]$ bash
[tmp]$ set -e
[tmp]$ (exit 10) | cat -
[tmp]$ echo $?
0
[tmp]$ set -o pipefail
[tmp]$ (exit 10) | cat -
[tmp]$ echo $?
10
@mlafeldt
mlafeldt / Vagrantfile
Created October 23, 2013 14:46
Vagrantfile which loads Chef attributes from a JSON file
# If you want to provide custom Chef attributes that should not end up in Git
# (e.g. secret tokens), copy `chef.json.example` to `chef.json` and edit the
# latter accordingly (in that case, the example file will be ignored).
# ...
# Configure Chef Solo provisioner
config.vm.provision :chef_solo do |chef|
# Tell Vagrant where the cookbooks are located
chef.cookbooks_path = "vendor/cookbooks"