Skip to content

Instantly share code, notes, and snippets.

@kjoconnor
kjoconnor / md5sums.sh
Created March 20, 2012 23:07
Create md5sums file for Debian packages
# Assuming you're in the 'debian' directory and the directories (var, usr, etc.) are contained within
find -type f | egrep -v '^\./DEBIAN' | xargs --replace=hh -n1 md5sum "hh" | sed 's/\ \.\///' > DEBIAN/md5sums
@kjoconnor
kjoconnor / gist:2484425
Created April 24, 2012 22:50
Install puppet-server on Amazon Linux
1. Paste into /etc/yum.repos.d/puppetlabs.repo
[puppetlabs]
name=Puppet Labs - $basearch
baseurl=http://yum.puppetlabs.com/el/6Server/products/$basearch
failovermethod=priority
priority=0
enabled=0
2. rpm --import http://yum.puppetlabs.com/RPM-GPG-KEY-puppetlabs
@kjoconnor
kjoconnor / delete_snapshots.py
Created November 6, 2013 21:33
boto script to delete snapshots matching a filter and older than X days
import sys
from boto.ec2 import connect_to_region
from datetime import datetime, timedelta
try:
days = int(sys.argv[1])
except IndexError:
days = 7
@kjoconnor
kjoconnor / monitor_queue.py
Created July 20, 2012 11:10
Monitor your SQS queues with boto
from boto.ec2.cloudwatch import CloudWatchConnection
from boto.sqs.connection import SQSConnection
import boto
import sys
from datetime import datetime, timedelta
import locale
from time import sleep
if(len(sys.argv) > 1):
queue_name = sys.argv[1]
@kjoconnor
kjoconnor / clean_gmail_emails.py
Created January 23, 2020 15:09
I used this script to delete a bunch of cron emails that had built up in my inbox. You should be able to change the search params to cover anything you might want to get rid of. Note this will _permanently delete_, not just move to trash.
import pickle
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
# If modifying these scopes, delete the file token.pickle.
SCOPES = ['https://mail.google.com/']
@kjoconnor
kjoconnor / find_in_sg.py
Created October 22, 2013 08:50
Remove an IP from all EC2 security groups
from boto.ec2 import connect_to_region
ec2 = connect_to_region('us-west-1')
target = '127.0.0.1/32'
remove = False
sgs = ec2.get_all_security_groups()
for sg in sgs:
for rule in sg.rules:
@kjoconnor
kjoconnor / gist:1007303
Created June 3, 2011 22:37
Logstash Agent init script
#! /bin/sh
#
# Logstash Start/Stop logstash
#
# chkconfig: 345 99 99
# description: Logstash
# processname: logstash
logstash_bin="java -Djava.net.preferIPv4Stack=true -jar /opt/logstash/logstash-1.0.11pre-monolithic.jar"
logstash_log="/opt/logstash/logstash-agent.log"

Keybase proof

I hereby claim:

  • I am kjoconnor on github.
  • I am gooeyblob (https://keybase.io/gooeyblob) on keybase.
  • I have a public key ASBnf2dJdzlAv0fp95hoai_HHUAXITBOc1f0LX0Jtv3RuQo

To claim this, I am signing this object:

@kjoconnor
kjoconnor / get_icon.py
Created June 20, 2013 08:56
Grab icons from RSS feed URLs via the awesome getfavicon.appspot.com service
import logging
import requests
import tldextract
from collections import deque
from urllib import quote_plus
from urlparse import urlparse, urlunparse
DEFAULT_ICON = "http://mozorg.cdn.mozilla.net/media/img/"\
@kjoconnor
kjoconnor / ec2_info.py
Created April 1, 2013 23:43
Grains for salt on EC2
import json
import logging
import requests
try:
from boto.ec2 import connect_to_region as _connect_to_region
has_boto = True
except ImportError:
has_boto = False