Skip to content

Instantly share code, notes, and snippets.

View scoates's full-sized avatar

Sean Coates scoates

View GitHub Profile
@scoates
scoates / salt_roots_sshd-mfa_init.sls
Created March 13, 2015 19:15
SSH + MFA (with Google Authenticator) on Debian Wheezy
include:
# for backports
- apt
openssh6.6:
pkg.installed:
# backports; this number *will* change
- pkgs:
- openssh-server: 1:6.6p1-4~bpo70+1
- openssh-client: 1:6.6p1-4~bpo70+1

WHAT?

<?php

function machine_forget(&$data) {
    $data = null;
}

$answer = 42;
@scoates
scoates / 0_reuse_code.js
Created July 24, 2014 15:45
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@scoates
scoates / keybase.md
Last active March 16, 2020 17:56
Keybase

Keybase proof

I hereby claim:

  • I am scoates on github.
  • I am scoates (https://keybase.io/scoates) on keybase.
  • I have a public key whose fingerprint is 8A45 6450 4355 2F7B FB92 5422 E905 36DD 957A 42BE

To claim this, I am signing this object:

@scoates
scoates / twitter_user_to_image
Last active December 19, 2015 09:49
Get a twitter profile image from a username. We route around bad APIs. Twitter wears the scumbag hat, these days.
#!/bin/bash
# Usage: $0 username
# e.g.:
# $ ./twitter_user_to_image coates
# https://si0.twimg.com/profile_images/1597362183/me.jpg
curl -sL http://twitter.com/$1 | grep profile_images | head -n1 | perl -p -e's/.*?http/http/;s/".*//;s/_bigger//'
@scoates
scoates / check_elb_healthy_hosts.py
Created June 27, 2013 17:22
Nagios plugin to monitor AWS/EC2 Elastic Load Balancers for healthy hosts
#!/usr/bin/env python
"""
A nagios plugin for ensuring that load balancers have at least a certain
number of healthy nodes.
Usage:
Nagios Command:
define command {
command_name check_elb_healthy_hosts
alert('ownerened?')
alert('ownenated?')
@scoates
scoates / timeline
Last active December 10, 2015 09:29
Times each line of stdin
#!/usr/bin/env python
import time
from sys import stdin, stdout, argv, exit
try:
if argv[1] == 'help' or argv[1] == '--help' or argv[1] == '-h':
print "%s: times each line of stdin.\n Optional parameter is a float of a threshold. (defaults to 2.0)" % argv[0]
exit(255);
else:
@scoates
scoates / gist:3355357
Created August 15, 2012 03:11
MongoDB: findandmodify seems to use the wrong query on the update command
> db.runCommand({ findAndModify: 'assets', query: {$or: [ { "_id" : "4ff70c97c87a97bc7f000002" }, { "_id" : ObjectId("4ff70c97c87a97bc7f000002") } ]}, update: {$set: {private: true}}, new: true, upsert: false })
{
"lastErrorObject" : {
"updatedExisting" : true,
"n" : 1,
"connectionId" : 1317,
"err" : null,
"ok" : 1
},
"value" : {