Skip to content

Instantly share code, notes, and snippets.

@thmsmlr
thmsmlr / deploy.sh
Created August 17, 2016 17:17
GitHub Pages deploy script
#!/bin/sh
set -e
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$CURRENT_BRANCH" != "jekyll" ]; then
echo "ERROR! You can only deploy from jekyll branch"
exit 1
fi
CLEAN_REPO=$(git status --porcelain)
@thmsmlr
thmsmlr / cached_property.py
Created June 18, 2015 16:56
Cached Property
def cached_property(func):
property_name = '_' + func.__name__
@functools.wraps(func)
def wrapped(self, *args, **kwargs):
private_property = getattr(self, property_name, None)
if kwargs.get('force', False) or private_property == None:
val = func(self, *args, **kwargs)
setattr(self, property_name, val)
return val
else: