Skip to content

Instantly share code, notes, and snippets.

View kmosher's full-sized avatar

Keith Mosher kmosher

View GitHub Profile
@kmosher
kmosher / ngx-detect-heartbleed.patch
Last active August 29, 2015 13:58
Add heartbleed attack logging to nginx
diff --git a/nginx-1.5.8/src/event/ngx_event_openssl.c b/nginx-1.5.8/src/event/ngx_event_openssl.c
index ee66713..1ea58e1 100644
--- a/nginx-1.5.8/src/event/ngx_event_openssl.c
+++ b/nginx-1.5.8/src/event/ngx_event_openssl.c
@@ -18,6 +18,9 @@ typedef struct {
static int ngx_ssl_verify_callback(int ok, X509_STORE_CTX *x509_store);
static void ngx_ssl_info_callback(const ngx_ssl_conn_t *ssl_conn, int where,
int ret);
+static void ngx_ssl_msg_callback(
+ int write_p, int version, int content_type,
@kmosher
kmosher / random_gmail_emoji.py
Created July 31, 2014 15:52
Random Gmail Emojis
#!/usr/bin/python
"""
Return a random unicode character likely to render as a valid emoji in gmail
Ranges are taken from
http://www.unicode.org/~scherer/emoji4unicode/20090804/utc.html
"""
import random
@kmosher
kmosher / gmail-label-rotate
Last active October 8, 2016 01:50
Gmail Bulk Deletion and Pruning
// A script for bulk deleting emails in the background and preventing future buildup
// Allows you to continue to use your gmail inbox while it runs.
//
// Instructions for use
// --------------------
// 1. Put this in a new project on script.google.com
// 2. Edit the LABELS or even the search construction to fit your needs
// 3. Set a trigger to run main() every 5 minutes. Why 5 minutes? That's the longest a script is allowed to run,
// so your script will also get killed every 5 minutes if it's busy trying to delete a lot of mail
@kmosher
kmosher / style.css
Last active April 8, 2016 05:22
Positioning relative to perfect center with flexbox
body {
width: 100%;
height: 100%;
margin: 0;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
align-content: center;
}
#!/bin/zsh
set -e
setopt extendedglob
o_font=(--font /Library/Fonts/Impact.ttf)
o_pointsize=(--pointsize 42)
o_remote=(--remote "people.yelpcorp.com:public_html/dockercats/")
o_identity=(--identity "dockercats")
o_irc=(--irc)
o_tumblr=()
# Makes an image (namely this one: http://ksdenvironmental.co.uk/wp-content/uploads/2014/12/icon_shed.jpg) flash red and blue
# Creates a slack-friendly gif
#!/bin/bash
convert "$1" -fuzz '14%' -transparent white \
-gravity Center -crop 140x120-0-1 +repage \
-grayscale rec709luma \
\( +clone +level-colors red, \) \( -grayscale rec709luma +clone +level-colors blue, \) \
-delete 0 \
-morph 2 -set delay 15 \
@kmosher
kmosher / pg_dumpall2git.py
Last active June 27, 2016 23:22
Turn a pg_dumpall file into a directory structure.
#!/usr/bin/env python
"""
Turns the output of pg_dumpall into a directory structure. The
format is intended to be suitable for committing to git.
The original pg_dumpall file can be reconstructed easily from the
TABLE_OF_CONTENTS file like so:
cd DUMP_DIR; cat $( <TABLE_OF_CONTENTS )
@kmosher
kmosher / keybase.md
Created July 7, 2016 23:25
keybase.md

Keybase proof

I hereby claim:

  • I am kmosher on github.
  • I am kmosher (https://keybase.io/kmosher) on keybase.
  • I have a public key whose fingerprint is FC98 08AE E9C9 F406 607D E40C 5152 BA66 67FD D423

To claim this, I am signing this object:

@kmosher
kmosher / wallpaper-tryiptych
Created October 6, 2016 23:20
Turn any image into a set of wallpapers to span multiple monitors
#!/bin/bash
display_height=1920
display_width=1200
display_count=3
bg=black
resolution="$(($display_count * $display_width))x$display_height"
convert "$1" -resize $resolution \
@kmosher
kmosher / fix-etrade-csv.py
Last active April 16, 2019 05:07
Turns csv exports from etrade into sched D ready imports for TaxAct. This is of course provided with NO WARRANTY or guarantee that it is fit for any purpose. Use at your own risk
#!/usr/bin/env python
import csv
import sys
from pprint import pprint
with open(sys.argv[1]) as infile:
with open(sys.argv[2], 'wb') as outfile:
reader = csv.DictReader(infile)
writer = csv.DictWriter(outfile, ['Description', 'Date Acquired', 'Sales Proceeds', 'Date Sold', 'Cost', 'Adjustment Code', 'Adjustment Amount', 'Reporting Category'])