Skip to content

Instantly share code, notes, and snippets.

View betandr's full-sized avatar
🦄
Vague, but exciting...

Beth Anderson betandr

🦄
Vague, but exciting...
View GitHub Profile
@betandr
betandr / singleton.py
Last active July 16, 2018 16:47
Python Singleton
class _Singleton(object):
def id(self):
return id(self)
def __init__(self):
print("creating singleton")
_singleton = _Singleton()
@betandr
betandr / dijkstra.py
Last active November 15, 2021 20:43
Dijkstra's Shortest Path Algorithm in Python
from decimal import Decimal
class Node:
def __init__(self, label):
self.label = label
class Edge:
def __init__(self, to_node, length):
self.to_node = to_node
self.length = length
@betandr
betandr / quick_sort.py
Created July 3, 2018 14:57
Quick sort Python implementation using the Lomuto partition scheme
def _partition(array, lo, hi):
pivot = array[hi]
i = lo - 1
for j in range(lo, hi):
if array[j] < pivot:
i += 1
temp = array[i]
array[i] = array[j]
array[j] = temp
@betandr
betandr / k8s_ingress.md
Created June 1, 2018 10:13
Kubernetes Ingress
@betandr
betandr / minikube_osx.md
Last active May 23, 2018 10:31
Minikube on OSX

Installing Minikube

brew install kubectl

kubectl version --client

brew cask install minikube

brew install docker-machine-driver-xhyve (xhyve is now deprecated in favor of hyperkit)

(run the chown and chmod)

@betandr
betandr / onion_balance.md
Last active April 28, 2018 13:24
Creating an Onion Balance Tor service on Debian/GCP

Set up a Tor Onion Balance Server on Debian

Install and Start Onion Balance

sudo apt-get update
sudo apt-get install onionbalance

Configure Onion Balance

@betandr
betandr / .zshrc
Created April 27, 2018 16:00
Powerlevel9k Virtualenv
# ...
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status virtualenv root_indicator background_jobs history time)
POWERLEVEL9K_VIRTUALENV_FOREGROUND='black'
POWERLEVEL9K_VIRTUALENV_BACKGROUND='31'
POWERLEVEL9K_PYTHON_ICON='🐍 '
# ...
@betandr
betandr / tor.md
Last active December 27, 2020 16:18
Creating a Tor Server on GCP

Set up a Tor Server on Debian

Install and Configure Apache

sudo apt-get update
sudo apt-get install -y apache2

sudo vi /etc/apache2/ports.conf:

#!/bin/bash
URL="$1"
echo "Testing $URL"
while [ 1 ]; do
RESPONSE=`curl $URL -o /dev/null -s -w %{time_total},%{http_code}`
TIME=`cut -d',' -f1 <<< $RESPONSE`
CODE=`cut -d',' -f2 <<< $RESPONSE`
DATE=`date`
@betandr
betandr / virtual_env.sh
Created October 30, 2017 16:25
Using Virtualenv
mkdir ~/virtualenv
virtualenv -p python2.7 ~/virtualenv/APPNAME/
source ~/virtualenv/APPNAME/activate
pip install blah
pip freeze > requirements.txt
pip install -r requirements.txt # (instead of pip install ...)
python blah.py
deactivate