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 / expose_rancher_docker_tcp.sh
Last active May 8, 2024 20:42
A small container to expose the rancher desktop docker socket on the localhost TCP port
docker run -d --restart=always \
-p 0.0.0.0:2375:2375 \
-v /var/run/docker.sock:/var/run/docker.sock \
alpine/socat \
tcp-listen:2375,fork,reuseaddr unix-connect:/var/run/docker.sock
@mtbdeano
mtbdeano / Dockerfile.es-2.4.6.alpine
Last active May 8, 2022 20:23
Minimal elasticsearch 2.4.5 dockerfile for arm64
FROM openjdk:8-jre-alpine
RUN apk update && apk add --nocache curl
ENV ELASTIC_CONTAINER true
RUN mkdir /usr/share/elasticsearch
WORKDIR /usr/share/elasticsearch
RUN curl -L -O https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.4.6/elasticsearch-2.4.6.tar.gz
@mtbdeano
mtbdeano / konami.js
Last active May 27, 2021 14:02
a simple plain JS konami code listener
// https://en.wikipedia.org/wiki/Konami_Code
// up, up, down, down, left, right, left, right, b, a, esc (in the real world was "start")
let konami_code = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 27];
let pressed = [];
document.addEventListener("keydown", event => {
// 229 is the key code android devices send when their software keyboards are guesing key presses
// https://bugs.chromium.org/p/chromium/issues/detail?id=118639
if (event.isComposing || event.keyCode === 229) {
return;
@mtbdeano
mtbdeano / migrate_midroll_to_airwave.py
Created May 7, 2021 00:53
Migrate omny / midroll to airwave / megaphone
'''
Data export from midroll's omny system for episodes and ad positions in a CSV (utf-8 encoded)
(Megaphone Developer API)[https://developers.megaphone.fm/]
'''
import csv
import requests
from collections import defaultdict
import time
NETWORK = "from megaphone"

Keybase proof

I hereby claim:

  • I am mtbdeano on github.
  • I am deano (https://keybase.io/deano) on keybase.
  • I have a public key ASCJFCp-6D3jbA5KOPM0_Ff2m2r2Ct-xxex5_DJ1yDyKuwo

To claim this, I am signing this object:

@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
@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 / 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 / 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 / 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