Date: 2020-07-09
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
# `python-base` sets up all our shared environment variables | |
FROM python:3.8.1-slim as python-base | |
# python | |
ENV PYTHONUNBUFFERED=1 \ | |
# prevents python creating .pyc files | |
PYTHONDONTWRITEBYTECODE=1 \ | |
\ | |
# pip | |
PIP_NO_CACHE_DIR=off \ |
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
# Response to: | |
# http://blog.honeybadger.io/how-openstruct-and-hashes-can-kill-performance/ | |
# | |
# It's not faire to use `Hash.new.merge(data)` if you can `Hash[data]`. | |
# `Hash[data]` is way faster! Lets compare! | |
# | |
# Read more: http://ruby-doc.org/core-2.2.0/Hash.html#method-c-5B-5D | |
# | |
# [UPDATE] | |
# |
FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.
- By Edmond Lau
- Highly Recommended 👍
- http://www.theeffectiveengineer.com/
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
from functools import reduce | |
def pipeline(steps, initial=None): | |
def apply(result, step): | |
yield from step(result) | |
yield from reduce(apply, steps, initial) | |
if __name__ == '__main__': | |
# BEFORE |
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
from functools import wraps | |
def defaults(method='__init__', **default_args): | |
"""Class decorator. Overrides method default arguments.""" | |
def decorate(cls): | |
func = getattr(cls, method) | |
@wraps(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
# Python Libraries | |
import re | |
# Django Packages | |
from django import template | |
register = template.Library() | |
_re_camel_humps = re.compile('([a-z])([A-Z0-9])') | |
""" |
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/sh | |
sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-common vim-gui-common | |
sudo apt-get install liblua5.1-dev luajit libluajit-5.1 python-dev ruby-dev libperl-dev mercurial libncurses5-dev libgnome2-dev libgnomeui-dev libgtk2.0-dev libatk1.0-dev libbonoboui2-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev | |
sudo mkdir /usr/include/lua5.1/include | |
sudo ln -s /usr/include/luajit-2.0 /usr/include/lua5.1/include | |
cd ~ | |
hg clone https://code.google.com/p/vim/ |
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
git branch -m old_branch new_branch # Rename branch locally | |
git push origin :old_branch # Delete the old branch | |
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote |
Hi there!
The docker cheat sheet has moved to a Github project under https://github.com/wsargent/docker-cheat-sheet.
Please click on the link above to go to the cheat sheet.
NewerOlder