Skip to content

Instantly share code, notes, and snippets.

View kadaliao's full-sized avatar
:octocat:

Kada Liao kadaliao

:octocat:
  • Beijing
View GitHub Profile
@kadaliao
kadaliao / fm.bash
Created June 28, 2017 10:47
批量转换视频格式
#!/bin/bash
file_name="text.gif"
for name in *
do
file_name=${name%.*}
echo "ffmpeg -i $name mp4/$file_name.mp4"
ffmpeg -i $name mp4/$file_name.mp4
done
@kadaliao
kadaliao / selenium-phantomjs
Last active October 12, 2018 09:46
selenium运行phantomjs
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--headless')
driver = webdriver.Chrome(options=options)
driver.get('http://baidu.com')
print(driver.current_url)
@kadaliao
kadaliao / get_logger.py
Created October 24, 2018 02:45
返回一个输出到控制台和文件的 logger
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,
@kadaliao
kadaliao / split_list.py
Created October 24, 2018 04:09
等份切割列表
def split_list(li, chunks=1):
for i in range(0, len(li), chunks):
yield li[i:i+chunks]
@kadaliao
kadaliao / rsa_util.py
Last active November 27, 2020 09:20
a rsa helper that can handle large size message, no length error.
# 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
@kadaliao
kadaliao / install-docker.sh
Created June 26, 2020 06:55
CentOS一键安装 Docker 脚本
#!/bin/bash
# 移除掉旧的版本
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
### 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:
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.
@kadaliao
kadaliao / external_sort.py
Last active September 2, 2021 10:03
大文件桶排序
"""
演示外部排序-桶排序
拆分大文件到固定尺寸的桶中,桶内进行排序之后,再合并成排序好的大文件。
"""
import os
import shutil
import random
from math import ceil