Skip to content

Instantly share code, notes, and snippets.

View mtbdeano's full-sized avatar

Dean McRobie (he/him) mtbdeano

View GitHub Profile
@mtbdeano
mtbdeano / ipython.conf
Created January 28, 2015 14:39
ubuntu 14.04 IPython upstart script
description "IPython server, after installing ipython and dependencies into /home/ubuntu/.ipython, setup a system daemon to run"
pre-start script
export HOME=/home/ubuntu
end script
script
exec sudo /usr/local/bin/ipython notebook --ipython-dir=/home/ubuntu/.ipython --profile=notebook --pylab=inline --no-browser
end script
@mtbdeano
mtbdeano / split_horizonator.py
Created June 29, 2015 21:10
Simple python script to keep Amazon Route 53 public/private split horizon DNS domains in sync
import boto.route53
import boto.ec2
import pprint as pp
def match_domain(domain, region="us-east-1"):
''' iterate through the public EIPs and make sure that if there is a `domain.com` entry for that EIP, it's private IP is also mapped in the private `domain.com`
'''
r53 = boto.route53.connect_to_region(region)
ec2 = boto.ec2.connect_to_region(region)
@mtbdeano
mtbdeano / Preferences.sublime-settings
Last active August 29, 2015 14:25
Dean's Python Sublime Settings
{
"bold_folder_labels": true,
"caret_style": "wide",
"color_scheme": "Packages/User/SublimeLinter/Solarized (Dark) (SL).tmTheme",
"ensure_newline_at_eof_on_save": true,
"folder_exclude_patterns":
[
".svn",
".git",
".hg",
@mtbdeano
mtbdeano / ApplySyntax.sublime-settings
Last active August 29, 2015 14:27
Sublime Text - Apply Syntax - Rules for flask Jinja2 templates and Elastic Beanstalk Extensions
{
// If you want exceptions reraised so you can see them in the console, change this to true.
"reraise_exceptions": false,
// If you want to have a syntax applied when new files are created, set new_file_syntax to the name of the syntax to use.
// The format is exactly the same as "syntax" in the rules below. For example, if you want to have a new file use
// JavaScript syntax, set new_file_syntax to 'JavaScript'.
"new_file_syntax": false,
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@mtbdeano
mtbdeano / migrate.py
Created December 9, 2015 01:01
Gist to force users from old Google apps domain to new domain (after domain rename)
from __future__ import print_function
import httplib2
import os
import json
from apiclient import discovery
import oauth2client
from oauth2client import client
from oauth2client import tools
@mtbdeano
mtbdeano / ecr-to-image-pull-secrets.py
Created June 7, 2016 22:10
simple script to translate an `aws ecr get-login` into a Kubernetes `create secret` for `ImagePullSecrets`
#!/usr/bin/env python
import argparse
import subprocess
import sys
# expects the output of `aws ecr get-login --region <whatevs>` piped into it, translates command line into `kubectl`
if len(sys.argv) != 2:
exit('usage: aws ecr get-login | {} <keyname>'.format(sys.argv[0]))
secret_name = sys.argv[1]
@mtbdeano
mtbdeano / activity_grabber.py
Last active June 23, 2016 13:52
simple_salesforce Account ActivityHistory extractor
ACTIVITY_QUERY = """
SELECT Id,
(SELECT Id, ActivityDate, WhatId, WhoId, Description
FROM ActivityHistories)
FROM Account
"""
ACTIVITY_FIELDS = ["Id", "AccountId", "ActivityDate", "WhatId", "WhoId", "Description"]
result = sf.query(ACTIVITY_QUERY)
@mtbdeano
mtbdeano / handy_docker_commands.rst
Last active October 21, 2016 19:20
Handy Docker Swarm 1.12 commands!

Get a list of all services on your swarm and their associated published ports:

docker service inspect \
    --format="{{range .Spec.EndpointSpec.Ports}} {{$.Spec.Name}} on port {{.PublishedPort}} {{else}} {{$.Spec.Name}} exposes nothing {{end}}" \
    `docker service ls|awk '{print $2;}'|tail -n +2`
@mtbdeano
mtbdeano / move_node_modules.sh
Last active March 16, 2021 18:08
Speed up WSL2 node/gatsby development
#!/bin/bash
# get just the current folder stub/name
export PROJECT=${PWD##*/}
# set WHERE_TO if you have a preference, defaults to ~/node_cache/$PROJECT/node_modules
export WHERE_TO=${WHERE_TO:-$HOME/node_cache/$PROJECT}
echo "Moving $PROJECT node_modules to $WHERE_TO"
if [[ -L ./node_modules ]]; then