Skip to content

Instantly share code, notes, and snippets.

@griiid
griiid / time_cost.py
Created November 22, 2022 03:09 — forked from yipo/time_cost.py
Calculate the time cost
#!/usr/bin/env python
import time
from contextlib import contextmanager
from datetime import timedelta
@contextmanager
def time_cost():
begin = time.time()
@griiid
griiid / gist:944fa4d4ef7d58cdd06937898f59769c
Last active February 5, 2022 16:33
噗浪自訂主題
/* Design and Copyright by 千秋,請追蹤噗浪以獲得佈景主題的更新資訊:Plurk@akira02
佈景主題官方網站: https://github.com/akira02/Zero-Memo
Zero-Memo模糊背景產生器·改beta:https://chiaki.uk/Zero-Memo/
*/
/* 根元素 */
body {
/* △未模糊背景圖片 */
/*# BACKGROUND timeline #*/
# Yes:
if x == 4: print x, y; x, y = y, x
# No:
if x == 4 : print x , y ; x , y = y , x
# Yes:
spam(ham[1], {eggs: 2})
# No:
spam( ham[ 1 ], { eggs: 2 } )
"""This is the example module.
This module does stuff.
"""
from __future__ import barry_as_FLUFL
__all__ = ['a', 'b', 'c']
__version__ = '0.1'
__author__ = 'Cardinal Biggles'
from subprocess import Popen, PIPE
# Yes: 更容易把運算元和運算子連結起來
income = (gross_wages
+ taxable_interest
+ (dividends - qualified_dividends)
- ira_deduction
- student_loan_interest)
# No: 運算子離運算元很遠
income = (gross_wages +
taxable_interest +
(dividends - qualified_dividends) -
ira_deduction -
student_loan_interest)
# No: operators sit far away from their operands
income = (gross_wages +
taxable_interest +
(dividends - qualified_dividends) -
ira_deduction -
student_loan_interest)
with open('/path/to/some/file/you/want/to/read') as file_1, \
open('/path/to/some/file/being/written', 'w') as file_2:
file_2.write(file_1.read())