Ctrl + K, Ctrl + b = Toggle sidebar
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
| [color] | |
| ui = auto | |
| [user] | |
| name = Phil Tysoe | |
| email = phil@***.com | |
| [push] | |
| default = simple | |
| [alias] | |
| lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative | |
| st = status |
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
| #!/usr/bin/env python | |
| import sys | |
| """ | |
| Given a file of the following format: | |
| MyClass | |
| - My test case | |
| - Another test case | |
| - And another test case |
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
| class LanguageMiddleware(object): | |
| """ | |
| Detect the user's browser language settings and activate the language. | |
| If the default language is not supported, try secondary options. If none of the | |
| user's languages are supported, then do nothing. | |
| """ | |
| def is_supported_language(self, language_code): | |
| supported_languages = dict(settings.LANGUAGES).keys() | |
| return language_code in supported_languages |
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
| def bytes_to(bytes, to, bsize=1024): | |
| a = {'k': 1, 'm': 2, 'g': 3, 't': 4, 'p': 5, 'e': 6} | |
| r = float(bytes) | |
| for i in range(a[to]): | |
| r /= bsize | |
| return r | |
| class ShardedCache(object): | |
| """ |
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
| #!/bin/bash | |
| # Install Oracle Java 7 on Ubuntu in a script i.e. no confirmation | |
| sudo add-apt-repository ppa:webupd8team/java -y | |
| sudo echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections | |
| sudo echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections | |
| sudo apt-get install oracle-java7-installer | |
| sudo update-java-alternatives -s java-7-oracle | |
| java -version |
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
| def assertRaisesWithMessages(self, exception, messages, _callable, *args, **kwargs): | |
| try: | |
| _callable(*args, **kwargs) | |
| except exception as e: | |
| self.assertEqual(e.messages, messages) |
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
| #!/usr/bin/env python | |
| """ | |
| To enable save as /yourproject/.git/hooks/prepare-commit-msg | |
| and make executable: chmod +rx prepare-commit-msg | |
| """ | |
| import sys | |
| from subprocess import check_output | |
| def get_ticket_number(): |
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
| #!/bin/bash | |
| PARENT_BRANCH=master | |
| CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD` | |
| DIVERGED_FROM_PARENT=`git merge-base HEAD $PARENT_BRANCH` | |
| # git difftool --tool-help to see supported software | |
| git difftool --no-prompt $CURRENT_BRANCH $DIVERGED_FROM_PARENT |
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 contextlib import contextmanager | |
| """ | |
| Usage: | |
| with env_var('MY_VAR', 'foo'): | |
| # is set here | |
| # does not exist here | |
| """ |