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
| import sys | |
| import __builtin__ | |
| real_import = __builtin__.__import__ | |
| def debug_import(name, locals=None, globals=None, fromlist=None, level=-1): | |
| glob = globals or sys._getframe(1).f_globals | |
| importer_name = glob and glob.get('__name__') or 'unknown' | |
| print '%s imports %s' % (importer_name, name) | |
| return real_import(name, locals, globals, fromlist, level) |
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
| l = [1, 2, 3, 4, 5, 6] | |
| (a, b), c = l[:2], l[2:] | |
| print a #1 | |
| print b #2 | |
| print c #[3, 4, 5, 6] |
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
| import os, re | |
| pattern = ''.join([os.path.sep, os.path.altsep or '']) | |
| split = re.compile(r'[\0%s]' % re.escape(pattern)) | |
| def secure_filename(path): | |
| return split.sub('', path) |
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
| no_targets__: | |
| list: | |
| @grep '^[^#[:space:]].*:' Makefile | grep -Ev 'no_targets__:|list:' |
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
| .PHONY: tests | |
| all: venv install | |
| bootstrap: | |
| echo "Installing Pip" | |
| sudo apt-get install python-pip | |
| echo "Installing virtualenv" | |
| sudo pip install virtualenv |
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
| //Array enumerator in Go. Can also be used with map type. | |
| import "fmt" | |
| var items = []int{1, 2, 3, 4, 5, 6} | |
| func main(){ | |
| for i, v := range items { | |
| fmt.Println(i, v) | |
| } |
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
| ZSHRC='~/.zshrc' | |
| read -p "Enter golang version to download and install: " gover | |
| read -p "32-bit ? [yn] " type | |
| case $type in | |
| [Yy]* ) arch='386' | |
| ;; | |
| [Nn]* ) arch='amd64' | |
| ;; | |
| * ) echo "Invalid architecture" |
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
| print cmp("a", u"a") | |
| #0 | |
| print cmp((1,), 'a') | |
| #1 | |
| print cmp((1,), u'a') | |
| #-1 | |
| print sorted(["a", (1, 3, 2), None, u'a']) |
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 Foo(object): | |
| def __init__(self): | |
| self._username = 'Kiran' | |
| def _get_username(self): | |
| return self._username | |
| def _set_username(self, value): | |
| self._username = value |