Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Rowe Martlark

View GitHub Profile
@Martlark
Martlark / request_arg.py
Last active Mar 8, 2021
Flask Decorator to auto convert request arg to a method parameter
View request_arg.py
def request_arg(arg_name, arg_type=str, arg_default=None):
"""
decorator to auto convert arg or form fields to
named method parameters with the correct type
conversion
@route('/something/<greeting>/')
@request_arg('repeat', int, 1)
def route_something(greeting='', repeat):
@Martlark
Martlark / chrome_install.sh
Created Apr 3, 2020
Install Google Chrome and Chrome driver to Linux 18.04
View chrome_install.sh
#!/usr/bin/env bash
# install the latest version of Chrome and the Chrome Driver
apt-get update && apt-get install -y libnss3-dev
version=$(curl http://chromedriver.storage.googleapis.com/LATEST_RELEASE)
wget -N http://chromedriver.storage.googleapis.com/${version}/chromedriver_linux64.zip
unzip chromedriver_linux64.zip -d /usr/local/bin
chmod +x /usr/local/bin/chromedriver
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
dpkg -i google-chrome-stable_current_amd64.deb; apt-get -fy install
@Martlark
Martlark / example.conf
Last active Jan 27, 2020
Reverse proxy conf for a Docker application using an Apache proxy with letsencrypt
View example.conf
Define HOST example
Define HOST_URL www.${HOST}.com
Define DOCKER_PORT 8083
<VirtualHost *:80>
ServerName ${HOST_URL}
ServerAlias ${HOST}.com
Redirect permanent / https://${HOST_URL}/
</VirtualHost>
@Martlark
Martlark / SortedList.py
Created Jul 7, 2019
Python SortedList class derived from List
View SortedList.py
# sorted list
class SortedList(list):
def __init__(self, initial_list_values):
super().__init__(sorted(initial_list_values))
def append(self, new_value) -> None:
for pos, value in enumerate(self):
if new_value <= value:
@Martlark
Martlark / log_deployment.sh
Last active Sep 13, 2022
Simple script to get logs from the pods of a deployment
View log_deployment.sh
#!/usr/bin/env bash
DEPLOYMENT=$1
for p in $(kubectl get pods | grep ^${DEPLOYMENT}- | cut -f 1 -d ' '); do
echo ---------------------------
echo $p
echo ---------------------------
kubectl logs $p
done
@Martlark
Martlark / static_server.js
Last active Sep 3, 2015 — forked from ryanflorence/static_server.js
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument. With file change detection. Requirements: npm install websocket. To use. place in head of your html files <meta detection-change="true"> so that it will auto refresh if any served files change.
View static_server.js
/*
node js static web server with file change detection
based upon
https://gist.github.com/ryanflorence/701407
by Andrew Rowe 2015.
requirements.
=============
npm install websocket