Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am os on github.
  • I am oktaysancak (https://keybase.io/oktaysancak) on keybase.
  • I have a public key ASD7eNDaRBf9h2XcfMaaOZF96Fl1jCM2gCoPoCZakLMmAwo

To claim this, I am signing this object:

dash
robo-3t
autoconf
aws-elasticbeanstalk
awscli
cask
colordiff
cookiecutter
elixir
emacs
erlang
fontconfig
@os
os / gitch.sh
Created September 2, 2015 04:51
Git checkout by partial branch name
branch_name=$1
git checkout $(git branch | grep $branch_name)
@os
os / assert.py
Last active August 29, 2015 14:04
def validate(condition, message=None, exception=None):
"""
Raises an error if the given condition is not validated.
"""
if condition:
return
if exception:
if isinstance(exception, Exception):
raise exception
# virtualenv
alias addenv='mkvirtualenv'
alias delenv='deactivate; rmvirtualenv'
# pip
alias pipin='pip install'
alias pipout='pip uninstall'
# patching
alias createpatch='svn diff >'
class CycloneAdapterMixin(object):
"""A mixin to support Cyclone cookie system and authentication"""
def set_secure_cookie(self, name, value, expires_days=30, **kwargs):
"""Signs and timestamps a cookie so it cannot be forged.
You must specify the 'cookie_secret' setting in your Application
to use this method. It should be a long, random sequence of bytes
to be used as the HMAC secret for the signature.
# import aliases
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# virtualenvwrapper
export WORKON_HOME=~/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
export PIP_VIRTUALENV_BASE=$WORKON_HOME
export PIP_RESPECT_VIRTUALENV=true
{
"auto_complete_delay": 250,
"close_windows_when_empty": false,
"color_scheme": "Packages/Color Scheme - Default/Twilight.tmTheme",
"dictionary": "Packages/Language - English/en_GB.dic",
"find_selected_text": true,
"folder_exclude_patterns":
[
".svn",
".git",
def flatten(d, parent_key=''):
"""
Flattens a given dictionary into a list of tuples.
"""
if isinstance(d, dict):
for key, value in d.items():
key = '.'.join(map(str, [parent_key, key])) if parent_key else key
for sub_key, sub_value in flatten(value, parent_key=key):
yield (sub_key, sub_value)