Skip to content

Instantly share code, notes, and snippets.

View chriseckhardt's full-sized avatar

Christopher Eckhardt chriseckhardt

View GitHub Profile
#!/usr/bin/ruby -W
def get_local_timezone_str
if File.exist?("/etc/timezone")
tz = File.read("/etc/timezone").chomp
elsif File.symlink?("/etc/localtime")
tz = File.readlink("/etc/localtime").sub(%r{.*/usr/share/zoneinfo}, '').lines.first.chomp
else
raise "Olson time zone could not be determined"
end
module AuthHelper
def http_login
user = 'username'
pw = 'password'
request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(user,pw)
end
end
module AuthRequestHelper
#
@chriseckhardt
chriseckhardt / swap-cop.sh
Created January 13, 2015 01:02
Simple script that displays processes' vm swap usage
#!/bin/bash
# Get current swap usage for all running processes
# Erik Ljungstrom 27/05/2011
# Modified by Mikko Rantalainen 2012-08-09
# Pipe the output to "sort -nk3" to get sorted output
# Modified by Marc Methot 2014-09-18
# removed the need for sudo
SUM=0
OVERALL=0
@chriseckhardt
chriseckhardt / content.md
Last active August 29, 2015 14:11 — forked from eam/content.md
{
"Version": "2014-08-27",
"Statement": [
{
"Sid": "BarnDoor",
"Effect": "Allow",
"Action": [
"ec2:*"
],
"Resource": [
# Puppet definition:
exec {"Clone a copy of ${scm_uri}":
command => "git clone ${scm_uri} ${source_checkout_dir}",
path => ['/usr/local/bin'],
cwd => $::nexus::nexus_root,
user => $::nexus::nexus_user,
creates => $source_checkout_dir,
require => Package['git'],
unless => "/usr/bin/test -e ${source_checkout_dir}/.git",
}
#!/usr/bin/env bash
# Compress MySQL tables on disk.
# Author: Andrew Berry, [email protected]
#
# Compress all tables in a MySQL InnoDB database using compression from the
# Barracuda table format. Tables have to already be in the Barracuda file
# format to actually compress tables, otherwise the table setting is ignored.
#
# innodb_file_per_table = 1 MUST be set in my.cnf for compression to work.
describe LeadService do
LeadService.configure(:test) do
before { settings.set(:instance, self) }
end
# Required for Rack::Test
#
def app
LeadService
@chriseckhardt
chriseckhardt / statsd_init_spec.rb
Last active January 4, 2016 07:39
This seems to bomb out with "Failure/Error: @content = catalogue.resource('file', '/etc/statsd/config.js').send(:parameters)[:content] ArgumentError: wrong number of arguments (0 for 1)"
# ...
it { should contain_file('/etc/statsd/config.js')
.with(
:ensure => 'file',
:require => 'Package[nodejs-statsd]',
)
}
describe '/etc/statsd/config.js' do
before :each do
@chriseckhardt
chriseckhardt / gist:8365058
Last active January 2, 2016 21:39
PUPPET Y U NO OVERRIDE?!
class profile::sensu::client {
class {'sensu':
use_embedded_ruby => true,
safe_mode => false,
client => true,
server => false,
api => false,
dashboard => false,
log_level => hiera('sensu::client::log_level', 'info'),