Skip to content

Instantly share code, notes, and snippets.

View mlafeldt's full-sized avatar

Mathias Lafeldt mlafeldt

View GitHub Profile
@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 / 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 / main.go
Created September 4, 2014 19:21
Go YAML
package main
import (
"fmt"
"log"
"gopkg.in/yaml.v1"
)
var data = `
@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 / 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 (tyler@opscode.com)
@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"
$ docker images quay.io/mlafeldt/chef-runner
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
quay.io/mlafeldt/chef-runner rpm b524faf0fe69 42 hours ago 830.3 MB
quay.io/mlafeldt/chef-runner deb d26c1d8dc51c 42 hours ago 622.9 MB
$ docker push quay.io/mlafeldt/chef-runner
The push refers to a repository [quay.io/mlafeldt/chef-runner] (len: 2)
Sending image list
Pushing repository quay.io/mlafeldt/chef-runner (2 tags)
Image 511136ea3c5a already pushed, skipping
@mlafeldt
mlafeldt / subprocess_check_output.py
Created February 22, 2011 23:47
[Python] subprocess.check_output() for Python < 2.7
#!/usr/bin/env python
import sys
from subprocess import *
#
# subprocess.check_output() is new in Python 2.7
#
def _check_output(*popenargs, **kwargs):
r"""Run command with arguments and return its output as a byte string.
@mlafeldt
mlafeldt / gitweb-apache2.conf
Created February 23, 2011 21:00
working config for gitweb v1.7.4.1
#
# /etc/apache2/conf.d/gitweb
#
Alias /gitweb /var/www/gitweb
<Directory /var/www/gitweb>
Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride All
order allow,deny
Allow from all
@mlafeldt
mlafeldt / hello.c
Created July 1, 2011 12:39
One-line header enabling executable single-file C scripts (via @reddit)
//&>/dev/null;x="${0%.*}";[ ! "$x" -ot "$0" ]||(rm -f "$x";cc -o "$x" "$0")&&"$x" $*;exit
// Usage: bash ./hello.c
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("Hello world!\n");
return 0;