Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import yaml
import pprint
def main(args):
if len(args) >= 2:
for i in args[1:]:
s = open(i).read()
pprint.pprint(yaml.load(s))
else:
#!/usr/bin/env python
import json
import os
import re
from glob import glob
SUDOERS_D = '/etc/sudoers.d'
SUDOERS_FILE = '/etc/sudoers'
__doc__ = "Prints all sudoers entries (users/groups) found in /etc/sudoers.d & /etc/sudoers, and their assigned rules to stdout"
@robbyt
robbyt / java_ver.rb
Last active August 4, 2017 19:55
Custom fact for finding the version of java installed
Facter.add(:java) do
confine :kernel => "Linux"
regexp = /\d+\.(\d+)\./
setcode do
java = {}
java['path'] = Facter::Core::Execution.which('java')
if java['path'] != nil
p = java['path']
@robbyt
robbyt / 01-update-ecs-agent.config
Last active January 6, 2016 04:56
Update the ECS agent from ElasticBeanstalk
{
"commands": {
"01ecsupdate": {"command": ".os-config/scripts/ecs-agent-update.sh"},
"99completed": {"command": "logger -t update-ecs-agent completed"}
}
}
#!/bin/bash
ECS_INIT_VER=`curl -sS http://localhost:51678/v1/metadata | jq -r .Version`
echo $ECS_INIT_VER | grep '1.6.0'
if [ $? -eq 0 ]
then
echo "Found outdated version of ECS agent"
NEEDS_UPDATE=1
@robbyt
robbyt / 80_chars.py
Created February 18, 2015 03:53
Simple script to rewrite and wrap text files at 80 chars. Great for `.txt` files and `.md` files.
#!/usr/bin/env python
import sys
import textwrap
WIDTH = 79
def main(argv):
if len(argv) != 2:
# encoding: UTF-8
# Chiliproject to Redmine converter
# =================================
#
# This script takes an existing Chiliproject database and
# converts it to be compatible with Redmine (>= v2.3). The
# database is converted in such a way that it can be run multiple
# times against a production Chiliproject install without
# interfering with it's operation. This is done by duplicating
@robbyt
robbyt / raring-heart.txt
Created April 11, 2014 21:18
Heartbleed fix - rebuild openssl for Ubuntu Raring 13.04
#!/bin/bash
mkdir sslfix
cd sslfix
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/openssl_1.0.1e-3ubuntu1.2.dsc
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/openssl_1.0.1e.orig.tar.gz
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/openssl_1.0.1e-3ubuntu1.2.debian.tar.gz
sudo apt-get build-dep openssl
dpkg-source -x openssl_1.0.1e-3ubuntu1.2.dsc
; --COPYRIGHT--,BSD_EX
; Copyright (c) 2012, Texas Instruments Incorporated
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions
; are met:
;
; * Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
@robbyt
robbyt / ruby-wtf
Last active August 29, 2015 13:57
Ruby reminds me of PHP sometimes.
irb(main):001:0> require 'facter'
=> true
irb(main):002:0> network = Facter.value('network_bond0') or Facter.value('network_eth0')
=> "100.10.3.0"
irb(main):003:0> network
=> nil
irb(main):004:0> network = Facter.value('network_bond0') || Facter.value('network_eth0')
=> "100.10.3.0"
irb(main):005:0> network
=> "100.10.3.0"