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 copy | |
X = spark.createDataFrame([[1,2], [3,4]], ['a', 'b']) | |
_schema = copy.deepcopy(X.schema) | |
_X = X.rdd.zipWithIndex().toDF(_schema) |
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/local/bin/bash | |
############################### FOLDER ICONS ################################### | |
folder="$(pwd)" | |
# Construct the path for the folder icon | |
FOLDER_ICON_PATH="$folder/.icon" | |
if [ -f $FOLDER_ICON_PATH ]; then |
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 hypothesis.strategies as st | |
from hypothesis import given | |
def quick_pow(a: int, b: int) -> int: | |
base, ans = a, 1 | |
while b: | |
if b & 1: | |
ans *= base | |
base *= base |
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 threading | |
import time | |
import signal | |
# Python会等待非 daemon 线程运行结束,如果进程收到 SIGINT 信号,会提醒一次,第二次结束线程了 | |
# Python不会等待 daemon 线程运行结束,收到 SIGINT 信号,就结束 Python 进程,线程也就不存在了 | |
# 使用信号 handler 来优雅退出 | |
event = threading.Event() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
### Keybase proof | |
I hereby claim: | |
* I am kadaliao on github. | |
* I am kadaliao (https://keybase.io/kadaliao) on keybase. | |
* I have a public key ASBIcqEdc6oBkcHJyH0NbyARfgSacweeqa3Lvw8PMj49fQo | |
To claim this, I am signing this 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
# coding: utf-8 | |
# use module pycryptodome | |
from Crypto import Random | |
from Crypto.Cipher import PKCS1_OAEP | |
from Crypto.Hash import MD5, SHA, SHA1, SHA256, SHA384, SHA512 | |
from Crypto.PublicKey import RSA | |
from Crypto.Signature import PKCS1_v1_5 | |
from Crypto.Util import 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
def split_list(li, chunks=1): | |
for i in range(0, len(li), chunks): | |
yield li[i:i+chunks] |
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 get_logger(log_path): | |
logger = logging.getLogger(__name__) | |
logger.setLevel(logging.DEBUG) | |
st_handler = logging.StreamHandler(sys.stderr) | |
st_handler.setLevel(logging.DEBUG) | |
st_handler.setFormatter(logging.Formatter( | |
'%(asctime)s %(levelname)s: %(message)s ' | |
'[in %(pathname)s:%(lineno)d]')) | |
file_handler = RotatingFileHandler(log_path, |
NewerOlder