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 pkg_resources import working_set | |
| for x in working_set: | |
| print("%s: %s" % (x.key, x.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
| >>> import sys | |
| >>> sys.executable | |
| '/usr/local/python/2.7.5/bin/python' |
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 | |
| python2 = sys.version_info[0]==2 | |
| python3 = sys.version_info[0]==3 |
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 datetime import datetime | |
| >>> now = datetime.now() | |
| >>> now.strftime('%Y-%m-%d %H:%M:%S') #hard | |
| '2013-10-06 07:59:20' | |
| >>> str(now) | |
| '2013-10-06 07:59:20.532184' | |
| >>> str(now).split('.')[0] #easy | |
| '2013-10-06 07:59:20 |
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 Color(object): | |
| __slots__ = ('r', 'g', 'b') | |
| def __init__(self, r, g, b): | |
| self.r = r | |
| self.g = g | |
| self.b = b |
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 Hello(object): | |
| def __init__(self, name): | |
| self.name = name | |
| obj = Hello("Haruhi") | |
| print(obj.__dict__) #=> {'name': 'Haruhi'} |
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
| var obj = {"name": "Alice", "Bob"}; | |
| alert(obj); | |
| >> object | |
| alert(JSON.stringify(obj)); | |
| >> {"name": "Alice", "Bob"} |
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
| function browserLanguage() { | |
| try { | |
| return (navigator.browserLanguage || navigator.language || navigator.userLanguage).substr(0,2) | |
| } | |
| catch(e) { | |
| return undefined; | |
| } | |
| } |
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
| chrome.i18n.getMessage("@@extension_id"); |
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
| document.write("hoge\n"); | |
| setTimeout(function(){ document.write("fuga\n") }, 1000); | |
| document.write("piyo\n"); |