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 | |
# -*- coding: utf-8 -*- | |
import os | |
import shlex | |
import subprocess | |
_env = None | |
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 echo(message, message_type=None): | |
colors = { | |
"OK": '\033[94m', | |
"SUCCESS": '\033[92m', | |
"WARNING": '\033[93m', | |
"FAIL": '\033[91m', | |
} | |
color = colors.get(message_type) | |
print "".join([color, message, '\033[0m']) if color else message |
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 commands | |
def ls(path): | |
return commands.getoutput('ls -m {}'.format(path)).replace('\n', '').split(', ') | |
ls('~') |
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
# -*- coding: utf-8 -*- | |
#!/usr/bin/env python | |
import codecs | |
import sys | |
from bs4 import BeautifulSoup | |
def main(argv): | |
file_path = argv[1] |
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 | |
import time | |
a = datetime.now() | |
# datetime.datetime(2015, 4, 16, 16, 15, 47, 92560) | |
b = int(time.mktime(a.timetuple())) | |
# 1429168547 | |
datetime.fromtimestamp(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
{{datetime_object|date:'n月j日 H:i'}} |
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 cached_property(func): | |
@property | |
def f(self): | |
name = "_{}_cache".format(func.__name__) | |
if not hasattr(self, name): | |
setattr(self, name, func(self)) | |
return getattr(self, name) | |
return f |
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
alias fd='find ./ -type f -print | xargs grep' |
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
select | |
id, | |
updated_at | |
from | |
foo_table | |
where | |
date(updated_at + interval 9 hour) between (current_date() - interval 3 day) and (current_date() - interval 1 day) | |
; |
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
git log --no-merges --date=short --pretty='format:%h %cd %an%d %s' master...HEAD | cat |