Skip to content

Instantly share code, notes, and snippets.

View srhopkins's full-sized avatar

Steven Hopkins srhopkins

View GitHub Profile
import requests
token = ''
def github_request(uri, method='get', **kwargs):
'''GitHub API wrapper for auth and baseline vars'''
if not uri.startswith('http'):
@srhopkins
srhopkins / .gitconfig
Last active August 17, 2021 17:35
.gitconfig
# curl -s https://gist.githubusercontent.com/srhopkins/9a9f85d08a6420b1287368aeac1d2520/raw/.gitconfig
[user]
email = [user_email]
name = [user_full_name]
[core]
excludesFile = ~/.gitignore_global
[pull]
rebase = true
[fetch]
# alias jupyter='curl -s https://gist.githubusercontent.com/srhopkins/f6eddd7761fefee9a49bfa6cfba73642/raw/3adebd63093637ba0bfd56a0c466ab04ebdc2da2/jupyter.yaml | docker compose -f - up'
version: "3.2"
services:
jupyter:
image: jupyter/datascience-notebook
volumes:
- ${HOME}/.ssh:/home/jovyan/.ssh
- ${HOME}/.aws:/home/jovyan/.aws
- ${HOME}/.kube/config:/home/jovyan/.kube/config
@srhopkins
srhopkins / .tmux.conf
Last active September 18, 2020 18:29
Finally updated my tmux to fix everything that broke in v2.9
# curl -L https://gist.github.com/srhopkins/f1cbe2932750fb383884919f9e53f23c/raw/
# Setting the prefix from C-b to C-a
# START:prefix
set -g prefix C-a
# END:prefix
# Free the original Ctrl-b prefix keybinding
# START:unbind
unbind C-b
# END:unbind
@srhopkins
srhopkins / get_k8s_token
Created February 6, 2018 19:48
Get kubernetes token for api one-liner access
~ kubectl get secrets --namespace=int # check secrets for namespace
NAME TYPE DATA AGE
default-token-skzsj kubernetes.io/service-account-token 3 6d
example-app-int kubernetes.io/tls 2 6d
~ export TOKEN=`kubectl get secret default-token-skzsj --namespace=int -o jsonpath={.data.token} | base64 -D` # `-D` for mac `-d` for linux
~ docker run --rm lachlanevenson/k8s-kubectl:v1.9.2 --namespace=int --server=https://api.example.com --token=${TOKEN} --insecure-skip-tls-verify=true get pods
NAME READY STATUS RESTARTS AGE
example-app-5866987b76-n2phz 1/1 Running 0 5d
example-app-5866987b76-tqtw2 1/1 Running 0 5d

Keybase proof

I hereby claim:

  • I am srhopkins on github.
  • I am srhopkins (https://keybase.io/srhopkins) on keybase.
  • I have a public key ASCUPKAbmZp5I9bf6KNDLPZmuGstq95hgEnVW9J8V0grdAo

To claim this, I am signing this object:

@srhopkins
srhopkins / govim.sh
Created December 3, 2016 14:44
govim - relative path aware
#!/bin/bash
# This allows use of govim container with relative paths
# e.g.
# vim ../this.file
# vim ~/.bashrc
function govim(){
RDIR=`pwd | awk -F/ '{print "/"$2}'`
docker run -it --rm -v ${RDIR}:${RDIR} -w `pwd` srhopkins/govim vim "$@"
}
@srhopkins
srhopkins / euler_18.py
Last active March 13, 2016 06:36
Euler - Maximum path sum I - Problem 18
def dig_numbers(table, row=0, index=0):
checks = []
for n in (index, index+1):
try:
checks.append(table[row][n] + dig_numbers(table, row=row+1, index=n))
except:
checks.append(0)
return max(checks)
@srhopkins
srhopkins / create_repo.sh
Created May 27, 2015 21:53
Create git repo with github api
#!/usr/bin/env bash
USER=${1}
REPO=${2}
curl -u "${USER}" https://api.github.com/user/repos -d '{"name":"'${REPO}'"}'
@srhopkins
srhopkins / wireshark_remote.sh
Last active August 29, 2015 14:22
Remote wireshark
# /etc/sudoers on target may require "Defaults:username !requiretty" e.g. RHEL/CentOS <= 5
#set -x
[ -n "${2}" ] && TCPDUMP_FILTER="${2}" || TCPDUMP_FILTER="not port 22"
ssh ${1} sudo /usr/sbin/tcpdump -U -s0 -w - "${TCPDUMP_FILTER}" \
| wireshark -k -i -