Skip to content

Instantly share code, notes, and snippets.

View Martlark's full-sized avatar

Andrew Rowe Martlark

View GitHub Profile
@Martlark
Martlark / request_arg.py
Last active March 8, 2021 00:09
Flask Decorator to auto convert request arg to a method parameter
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 April 3, 2020 22:17
Install Google Chrome and Chrome driver to Linux 18.04
#!/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 January 27, 2020 02:48
Reverse proxy conf for a Docker application using an Apache proxy with letsencrypt
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 July 7, 2019 01:14
Python SortedList class derived from List
# 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 October 29, 2023 14:54
Simple script to get logs from the pods of a deployment
#!/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 September 3, 2015 02:55 — 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.
/*
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