Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴
On vacation

Mike Hongshuai Luo lhsfcboy

🌴
On vacation
View GitHub Profile
View How to run Tmux in GIT Bash on Windows.txt
I did a little research and have found that GIT Bash uses MINGW compilation of GNU tools.
It uses only selected ones.
You can install the whole distribution of the tools from https://www.msys2.org/
and run a command to install Tmux. And then copy some files to installation folder of Git.
This is what you do:
Install before-mentioned msys2 package and run bash shell
Install tmux using the following command: pacman -S tmux
Go to msys2 directory, in my case it is C:\msys64\usr\bin
View create_md_files_from_html.py
#! python
from bs4 import BeautifulSoup
import requests
target_urls = {
"01":"http://zhuanlan.zhihu.com/p/28277072",
"02":"http://zhuanlan.zhihu.com/p/28325166",
"03":"http://zhuanlan.zhihu.com/p/28434767",
"04":"http://zhuanlan.zhihu.com/p/28490221",
@lhsfcboy
lhsfcboy / log_to_slack.sh
Created Jan 29, 2018
读取log文件并过滤, 之后发布到slack频道里
View log_to_slack.sh
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":"@"}'
@lhsfcboy
lhsfcboy / enum.py
Created Jan 16, 2018
python中的枚举类型, 有待整理
View enum.py
from enum import Enum, unique
@unique
class Side(Enum):
Buy = 0
Sell = 1
class OrderType(Enum):
Market = 0
Limit = 1
@lhsfcboy
lhsfcboy / lookahead_iterable.py
Last active Jan 16, 2018
for循环中判断当前元素是否是最后一个元素
View lookahead_iterable.py
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 / python_timestamp.py
Last active Dec 24, 2017
Get timestamp from python
View python_timestamp.py
import time;
ts = time.time()
print(ts)
# 1514116641.1691682
# 小数点后七位,也就是100ns
import datetime;
ts = datetime.datetime.now().timestamp()
print(ts)
# 1514116641.171174
@lhsfcboy
lhsfcboy / itchat_hellowechat.py
Last active Sep 15, 2017
quick demo of itchat
View itchat_hellowechat.py
import itchat
itchat.auto_login(enableCmdQR = 2,hotReload = True)
itchat.send('Hello, filehelper', toUserName='filehelper')
@lhsfcboy
lhsfcboy / check_duplication_item.gs
Created Aug 25, 2017
Google Script check duplication item
View check_duplication_item.gs
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 / hash_function.gs
Last active Aug 25, 2017
Google Script of Hash
View hash_function.gs
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 / clean_git_history
Last active Aug 21, 2017
Clean up git history
View clean_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