Skip to content

Instantly share code, notes, and snippets.

Roberto Aguilar rca

  • NYC
View GitHub Profile
@rca
rca / PythonOnMac.md
Created Jan 27, 2020
Setting up Pyhon on a Mac
View PythonOnMac.md

Installing Python3 on a Mac

Getting a sane Python3 runtime on a Mac can be tedious. The most painless way I have found thus far installing a Python3 package from python.org and, from there, installing two additional packages into the system directory: pip and pipx.

Install Python

Install Python with a package from python.org. This post uses 3.6.8: https://www.python.org/downloads/release/python-368/

At this point, close the current shell and launch a new shell. This will ensure you have Python 3.6 in your PATH; you should see something similar to:

@rca
rca / README.md
Last active Sep 26, 2019
An explanation of `git rebase --onto`
View README.md

git rebase onto fu

Looking at the following git history, there are a few commits that were accidentally made on top of env/dev-auth that should be on a feature branch named experiments/sso-login-app (1. in the command below):

[0][~/Projects/openslate/thing(env/dev-auth:feb0ee9)]
$ git log
commit feb0ee98c8b77e929b9cc23442c5664c9d4986c9 (HEAD -> env/dev-auth)  # this is `0.` in the command below
Author: Roberto Aguilar <roberto@openslate.com>
Date:   Thu Sep 26 00:25:15 2019 -0400
@rca
rca / vault-env
Created Aug 29, 2019
Converts key/value pairs returned by a vault command into environment variables
View vault-env
#!/usr/bin/env python3.6
"""
Converts key/value pairs returned by a vault command into environment variables
"""
import json
import sys
KEY_MAP = {
'access_key': 'AWS_ACCESS_KEY_ID',
'secret_key': 'AWS_SECRET_ACCESS_KEY',
@rca
rca / flush_dns
Created Feb 5, 2019
Flushes local DNS cache on MacOS X
View flush_dns
#!/bin/bash
set -e
sudo killall -HUP mDNSResponder
@rca
rca / rancher-exec
Created Jan 25, 2019
Execute a command within a container running in Rancher k8s
View rancher-exec
#!/bin/bash
set -e
set -x
SCRIPT_NAME=$(basename $0)
if [ -z "$4" ]; then
echo "${SCRIPT_NAME} <env> <namespace> <pod name> <command> [args]" 1>&2
exit 1
fi;
View gist:07cb74c350d6be278249db6136faa7f7
class Foo:
def __init__(self, x=[]):
self.x = x
f = Foo()
f.x.append(1)
@rca
rca / docker-service-ports
Created Mar 21, 2018
Script to list service ports and get next available port
View docker-service-ports
#!/usr/bin/env python3.6
import argparse
import logging
import re
import shlex
import sh
PORT_RE = re.compile(r':(?P<port>\d+)->')
@rca
rca / docker-networks
Last active Jul 13, 2018
Lists all docker networks sorted by their subnet address
View docker-networks
#!/usr/bin/env xonsh
import json
import re
import sys
from tabulate import tabulate
# https://arcpy.wordpress.com/2012/05/11/sorting-alphanumeric-strings-in-python/
# https://stackoverflow.com/questions/2669059/how-to-sort-alpha-numeric-set-in-python
def sorted_alnum(l, key=None):
@rca
rca / git_whitespace
Created Feb 13, 2018
get rid of whitespace in your uncommitted work
View git_whitespace
#!/usr/bin/env python2.7
"""
Ensure new lines added to git do not have whitespace
"""
import os
import sys
import time
import traceback
from optparse import OptionParser
View r-rreboto.com.asc
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFofh2EBEADOk6j+F3WhGVcjsIIwgSEglsNBjVDYs9q8t+zEYrumOInS/VD4
7zshkVkJTo6TwplLOIxj/b2EbeG/9Qsf2zGF63fdfk4l/gTcELfTdnKc9lH2JdBm
1dm/XdLL09ITn3u36TL19xUjV2qiSBL6iXWmn5Zqg28LzVjWiMkjSuLNsPOfxiYG
lQXFnSD8zX3mL9ceFmyOFBt8DwzttyYui2dQ4xw67GpMnxEmsTOtNP6hEasBAjzA
r9fRjpP6wer6isDqVcgCkUzZY670p3oA3mMCy5qbi4eHCNn1h8caQdhoMElNVPYA
dnSx/Ut9TGQnFWtCpl9O4wMieMg2AtNsKXbTDpHVO7VN+Asj0bQb0+ysN0Y/PUP6
+FFi6u7OAyUslmkxS+UGxasm8prKSRBY9oF/00vgeCC/mAuWY2crjJhjNeO5n0Tb
BJOkh9ouEMmd5VARGQaH3FmCcyEAsQBRJW5ingg2FYDrFx2NsdSLvFN9mfYjkDSQ
You can’t perform that action at this time.