This file contains hidden or 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
from functools import partial | |
# Algorithm needs to avoid newlines being appended to output | |
pr = partial(print, end="") | |
for n in range(1, 101): | |
if n%3 == 0: | |
pr("Fizz") | |
if n%5 == 0: | |
pr("Buzz") |
This file contains hidden or 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
""" | |
Minimal setuptools setup.py example | |
Useful links: | |
https://pythonhosted.org/setuptools/setuptools.html#command-reference | |
https://pythonhosted.org/setuptools/setuptools.html#basic-use | |
https://pythonhosted.org/setuptools/setuptools.html#new-and-changed-setup-keywords | |
https://pypi.python.org/pypi?%3Aaction=list_classifiers | |
""" |
This file contains hidden or 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
git log --name-only --decorate=short --sparse --format=oneline | grep "/" | grep -v " " > /tmp/files-changed.txt | |
cat /tmp/files-changed.txt | sort | uniq -c > /tmp/changes-by-file.txt | |
cat /tmp/changes-by-file.txt | sort -r |
This file contains hidden or 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
""" | |
# template.py | |
Extremely simple Python Templating Engine | |
This is a no-frills templating engine written in Python. I chose to | |
write this when I decided that I wanted something that was extremely | |
simple templating system and even str.format seemed like overkill. | |
You can use either a string as a template, or a file. NOTE, however, |
This file contains hidden or 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
$ sudo docker images | awk '{ print $3 }' | grep -v IMAGE | xargs -L 1 sudo docker rmi |
This file contains hidden or 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
# The following command will cycle through all containers and attempt to remove it. | |
# NOTE: This will fail on running containers (you will get an error message, but it | |
# will just move on to the next one) | |
$ sudo docker ps -a | grep -v CONTAINER | awk '{ print $1 }' | xargs -L 1 sudo docker rm |
This file contains hidden or 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
# Because migrating to python 2.7.9 requires me to update my code (or ask my clients to add cafiles to their trust store | |
# [which some people don't know how to do]), I found a way to explicitly allow insecure connections (ie. without hostname | |
# verification) using urllib2.urlopen() | |
# | |
# This gist basically involves creating an ssl.SSLContext() with some options which disable hostname verification | |
# This allows you to, for instance, add a parameter to a function which disables hostname verification. | |
import ssl | |
import urllib2 | |
import logging |
This file contains hidden or 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
sudo du -h / | cut --delimiter $'\t' -f 1,2 | grep G$'\t' |