Skip to content

Instantly share code, notes, and snippets.

Yifei Kong yifeikong

View GitHub Profile
View client.py
#!/usr/bin/env python
# coding: utf-8
import requests
def main():
r = requests.post('http://localhost:8080/api', json={'foo': 'bar'})
print(r.text)
if __name__ == "__main__":
View qrcode.py
import time
import logging
import zbar
from PIL import Image, ImageEnhance, ImageFilter
def timing(f):
def wrap(*args):
time1 = time.time()
ret = f(*args)
time2 = time.time()
View get_moments.sh
#!/bin/bash
IP=$1
# 刷新朋友圈
ssh root@$IP 'kill `pgrep com.tencent.mm`'
ssh root@$IP am start -n com.tencent.mm/.plugin.sns.ui.SnsTimeLineUI
# 调用WeChatMomentStat获取all_sns.json
# 暂时手动触发
View android-x-compile-init-mac.sh
#!/bin/bash
brew install android-ndk
export NDK_VERSION='r13'
export NDK=/usr/local/Cellar/android-ndk
export GCC_VERSION='4.9'
export ANDROID_VERSION='21' # android 5.0
export ARCH='arm'
export PATH=$PATH:$NDK/$NDK_VERSION/toolchains/$ARCH-linux-androideabi-$GCC_VERSION/prebuilt/darwin-x86_64/bin
View get_bucket.lua
if not redis.pcall('exists', KEYS[1]) then
return 1
end
local bucket_name = KEYS[1]
local current_time = ARGV[1]
-- bucket {rate, timespan, last_check, tokens}
local rate = redis.pcall('hget', bucket_name, 'rate')
local timespan = redis.pcall('hget', bucket_name, 'timespan')
View tmux_session.sh
#!/usr/bin/env bash
# Save and restore the state of tmux sessions and windows.
# TODO: persist and restore the state & position of panes.
set -e
dump() {
local d=$'\t'
tmux list-windows -a -F "#S${d}#W${d}#{pane_current_path}"
}
@yifeikong
yifeikong / remove_emoji.py
Created Feb 22, 2018
remove emoji in python
View remove_emoji.py
#!/usr/bin/env python
# coding: utf-8
import re
text = u'This dog \U0001f602'
print(text) # with emoji
def remove_emoji(data):
if not data:
View test_spaces.py
<title>There are more than one spaces " "</title>
<h1>h1: There are more than one spaces " "</h1>
<p>p: There are more than one spaces " "</p>
<pre>pre: There are more than one spaces " "</pre>
View ascii2unicode.py
#!/usr/bin/env python
#coding: utf-8
import sys
import json
ascii_json = sys.stdin.read().decode('utf-8')
json_obj = json.loads(ascii_json)
print(json.dumps(json_obj, ensure_ascii=False, indent=4, encoding='utf-8'))
You can’t perform that action at this time.