This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
from queue import Queue | |
class AsyncThread(threading.Thread): | |
""" | |
Based off of ssynchronous downloading script pull from stackoverflow | |
http://stackoverflow.com/questions/18883964/asynchronous-file-downloads-in-python | |
""" | |
def __init__(self, queue, func): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def chunks(l, n): | |
""" Yield successive n-sized chunks from l. | |
http://stackoverflow.com/a/312464/1572077 | |
""" | |
for i in xrange(0, len(l), n): | |
yield l[i:i+n] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_attribute_class(model, attribute): | |
""" | |
If the attribute is found, it returns an array of places the attribute is defined. | |
The array is ordered by priority, the first element being the one that is called. | |
If not found, returns an empty array. | |
""" | |
return [m for m in model.mro() if attribute in m.__dict__] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To determine which node a container is on: | |
kubectl get pods -o wide | |
# To view current resource usuage and limits of a cluser | |
kubectl describe nodes <cluster name> | |
# To view what is happening on a container | |
kubectl attach <container-name> | |
# To start an interactive shell on a container |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kccontexts() { | |
# Works with kubectl v1.4.0 and the config file generated by gcloud containers clusters get-credentials | |
# If you pass in an arg, then we will filter the contexts for that string | |
# The following block creates a list of the contexts and filters if an argument | |
# is passed in. | |
if [[ $1 ]] | |
then | |
options=(`kubectl config get-contexts -o name | sort | grep $1`) | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Requirements: | |
# - gcloud/gsutil is installed on the box | |
# - gcloud is logged in as a user with write access to Google Cloud Storage | |
# - The file has execution rights so that it can be run in cron | |
# - The Google Cloud Storage bucket already exits | |
# Exit on any error | |
set -e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function containerCommand() { | |
# Given a string, search for the matching running docker containers. | |
# If more than one argument is passed, attempt to run remaning arguments | |
# on that docker container. | |
container=`docker ps --format '{{.ID}} {{.Names}}'1`; | |
shift; | |
if [[ ! -z "$@" ]] | |
then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find the difference between the arc lengths of the inner and outer radius you want and divide by the kerf width, that'll give you the number of cuts, then space them evenly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DO $func$ | |
BEGIN | |
EXECUTE ( | |
SELECT | |
'TRUNCATE TABLE ' || string_agg(oid::regclass::text, ', ') || ' CASCADE' | |
FROM | |
pg_class | |
WHERE | |
relkind = 'r' | |
AND relnamespace = 'schema_name'::regnamespace); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python3 -m cProfile -s cumulative script.py > profile.txt |
OlderNewer