Skip to content

Instantly share code, notes, and snippets.

View jstangroome's full-sized avatar

Jason Stangroome jstangroome

View GitHub Profile
@jstangroome
jstangroome / packages.log
Created March 14, 2016 05:52
Default packages on ami-6c14310f (ubuntu-trusty-14.04-amd64-server-20160114.5)
$ dpkg --get-selections
accountsservice install
acpid install
adduser install
apparmor install
apport install
apport-symptoms install
apt install
apt-transport-https install
apt-utils install
@jstangroome
jstangroome / get-raw-blob.sh
Created September 27, 2015 00:15
See the original format of a git committed file, bypassing text conversion, etc
git cat-file -p $commit_id
git cat-file -p $tree_id
git cat-file -p $sub_tree_id
#git cat-file -p $sub_sub_tree_id
git cat-file blob $blob_id >rawblob
@jstangroome
jstangroome / init.pp
Last active September 12, 2015 05:37
file { '/opt/somedir':
source => 'puppet:///modules/mymodule/somedir',
recurse => true,
}
exec { 'runsomething':
command => '/opt/somedir/something.sh',
require => File['/opt/somedir'],
}
sub vcl_deliver {
set resp.http.Public-Key-Pins = {"pin-sha256="JcGyEMpuXl20IZG7NP8AFuLozlUZEoiENiuoelCVVaM="; pin-sha256="nh/TNmYDfa77LDPF0AfqxYcq0zLIgsIQSyGqj1MwzD4="; pin-sha256="cm5Kw3idmwUbZOGh20sAPAQq31Oyiaot7BJPH3iTN78="; max-age=5184000;"};
}
sub vcl_deliver {
set resp.http.Strict-Transport-Security = "max-age=31536000";
}
sub vcl_recv {
if ( req.http.X-Forwarded-Proto !~ "(?i)https") {
return (synth(750, ""));
}
}
sub vcl_synth {
if (resp.status == 750) {
set resp.status = 301;
set resp.http.Location = "https://blog.stangroome.com" + req.url;
@jstangroome
jstangroome / sendmail
Last active July 13, 2016 07:47
Mock /usr/sbin/sendmail implementation to see Cron failure detail
#!/bin/bash
# for when a Cron job fails on Ubuntu with "(No MTA installed, discarding output)"
# captures the job output to syslog instead
exec 1> >(/usr/bin/logger --id --tag sendmail-to-syslog --priority mail.notice) 2>&1
echo $ sendmail "$@"
exec cat
@jstangroome
jstangroome / diff-docker-images.sh
Last active August 29, 2015 14:16
Compare the list of files changed in two docker images with file sizes
sudo docker run --rm imagebase /usr/bin/find / -printf '%s\t%p\n' | sort -k2 >/tmp/imagebase
sudo docker run --rm imagenext /usr/bin/find / -printf '%s\t%p\n' | sort -k2 >/tmp/imagenext
# list removed files by size
diff -u /tmp/imagebase /tmp/imagenext | grep '^-' | cut -c 2- | sort -n
# list added files by size
diff -u /tmp/imagebase /tmp/imagenext | grep '^+' | cut -c 2- | sort -n
# list removals and adds by size
@jstangroome
jstangroome / install-pathod.sh
Last active August 29, 2015 14:10
Install pathod on Ubuntu Trusty
#!/bin/bash -xe
sudo apt-get install python-pip python-dev libffi-dev libssl-dev
sudo pip install six cryptography pathod
[ಠ_ಠ]
[AttributeUsage(System.AttributeTargets.All, AllowMultiple = true, Inherited = true)]
public class ಠ_ಠAttribute : Attribute
{
public ILog Log { get; set; }
public ಠ_ಠAttribute()
{
Log.Info("This code is bad and you should feel bad");
}