A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
# | |
# Working with branches | |
# | |
# Get the current branch name (not so useful in itself, but used in | |
# other aliases) | |
branch-name = "!git rev-parse --abbrev-ref HEAD" | |
# Push the current branch to the remote "origin", and set it to track | |
# the upstream branch | |
publish = "!git push -u origin $(git branch-name)" |
""" | |
Console module provide `copen` method for opening interactive python shell in | |
the runtime. | |
""" | |
import code | |
import readline | |
import rlcompleter | |
def copen(_globals, _locals): |
In general, the command ldd and the environment variable LD_LINKER_PATH
is your best friend when running new, untested binaries in Lambda. My process (which I want to get around to automating one day, maybe using Packer), goes like this:
ldd -v ./the-binary
. Note all of the shared libraries it requires. You’ll need to remember these.console.log(require('child_process').execSync('ldd -v ./the-binary'))
// runServer will start the HTTPServer, handling graceful | |
// shutdown on receives SIGTERM / SIGINT, returning nil. | |
// | |
// - returns error if the server can not start | |
// - returns error if the server panics in a way that isn't | |
// otherwise handled by gin | |
// - no errors otherwise | |
func runServer(addr string, r *gin.Engine) error { | |
s := &http.Server{ | |
Addr: addr, |
from urllib.request import urlopen | |
from io import BytesIO | |
from zipfile import ZipFile | |
from subprocess import Popen | |
from os import chmod | |
from os.path import isfile | |
import json | |
import time | |
import psutil |