Skip to content

Instantly share code, notes, and snippets.

View lhsfcboy's full-sized avatar
🌴
On vacation

Mike Hongshuai Luo lhsfcboy

🌴
On vacation
  • Feicheng,China
View GitHub Profile
@lhsfcboy
lhsfcboy / download_bilibili.sh
Last active August 4, 2017 06:05
Download Bilibili with filename stored in txt and youtube-dl
#!/bin/bash
# very ugly code, good boy dont copy this, hope
# 其实可以写成Chrome插件?
# 读入bilibili的播放列表的URL, 分拆出每一集的地址和标题
# 貌似youtube-dl没法读出合适的下载名称
i=1
declare -a filenamearray
@lhsfcboy
lhsfcboy / clean_git_history
Last active August 21, 2017 04:21
Clean up git history
# without submodule
-- Remove the history from
rm -rf .git
-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"
-- push to the github remote repos ensuring you overwrite history
@lhsfcboy
lhsfcboy / hash_function.gs
Last active August 25, 2017 17:43
Google Script of Hash
function SHA256_BIN(input){
var binstr = '';
var digest = Utilities.computeDigest(Utilities.DigestAlgorithm.SHA_256, input);
for (i = 0; i < digest.length; i++) {
var val = (digest[i]+256) % 256;
var hexstring= ('0'+val.toString(16)).slice(-2);
var bytestring = Number('0x' + hexstring).toString(2);
padded_bytestring=String("00000000" + bytestring).slice(-8); // returns 00123
binstr += padded_bytestring;
}
@lhsfcboy
lhsfcboy / check_duplication_item.gs
Created August 25, 2017 17:52
Google Script check duplication item
function onOpen() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{name : "Check Duplicates",functionName : "checkDuplicates"}];
sheet.addMenu("Scripts", entries);
};
function checkDuplicates() {
var sheet = SpreadsheetApp.getActiveSheet();
//var dataRange = sheet.getDataRange();
var dataRange = sheet.getRange("A:A"); // Set Any Range
@lhsfcboy
lhsfcboy / itchat_hellowechat.py
Last active September 15, 2017 05:07
quick demo of itchat
import itchat
itchat.auto_login(enableCmdQR = 2,hotReload = True)
itchat.send('Hello, filehelper', toUserName='filehelper')
@lhsfcboy
lhsfcboy / regular_expression.txt
Last active November 6, 2017 04:36
notepad_plus_plus中的正则表达式
Target:
1、第1章 第1节 集合(1)2、第1章 第1节 集合(2)3、第1章 第1节 集合
Purpose:
Search for "1、" and replace with newline plus that
Solution:
Search: (\d{1,3}\、)
Replace: \n\1
-----------------------------------------------------------------------
Target:
第14章 第2节 第二类曲线积分与第二类曲面积分
@lhsfcboy
lhsfcboy / python_timestamp.py
Last active December 24, 2017 12:10
Get timestamp from python
import time;
ts = time.time()
print(ts)
# 1514116641.1691682
# 小数点后七位,也就是100ns
import datetime;
ts = datetime.datetime.now().timestamp()
print(ts)
# 1514116641.171174
@lhsfcboy
lhsfcboy / lookahead_iterable.py
Last active January 16, 2018 12:14
for循环中判断当前元素是否是最后一个元素
def lookahead(iterable):
"""Pass through all values from the given iterable, augmented by the
information if there are more values to come after the current one
(True), or if it is the last value (False).
"""
# Get an iterator and pull the first value.
it = iter(iterable)
last = next(it)
# Run the iterator to exhaustion (starting from the second value).
for val in it:
@lhsfcboy
lhsfcboy / enum.py
Created January 16, 2018 13:03
python中的枚举类型, 有待整理
from enum import Enum, unique
@unique
class Side(Enum):
Buy = 0
Sell = 1
class OrderType(Enum):
Market = 0
Limit = 1
@lhsfcboy
lhsfcboy / log_to_slack.sh
Created January 29, 2018 07:29
读取log文件并过滤, 之后发布到slack频道里
tail -n0 -F logs/lastest.log | grep --line-buffered INFO| xargs -I @ curl -s \
https://hooks.slack.com/AAAAAAAA/BBBBBBB/CCCCCC \
-X POST \
-H 'Content-type: application/json' \
--data '{"username":"curl", "text":"@"}'