Skip to content

Instantly share code, notes, and snippets.

View tianshanghong's full-sized avatar
🚀
We feed on negative entropy.

wwang tianshanghong

🚀
We feed on negative entropy.
View GitHub Profile
@tianshanghong
tianshanghong / flask-mail-qq.py
Created June 12, 2018 01:49 — forked from binderclip/flask-mail-qq.py
用 Flask-Mail 通过 QQ 邮箱发送邮件
from flask import Flask
from flask_mail import Mail, Message
app = Flask(__name__)
app.config.update(
#EMAIL SETTINGS
MAIL_SERVER='smtp.qq.com',
MAIL_PORT=465,
MAIL_USE_SSL=True,
@tianshanghong
tianshanghong / file-size-in-bytes.py
Created June 13, 2018 03:11 — forked from robert-claypool/file-size-in-bytes.py
File size calculation in Python
import os
print os.path.getsize("c:\\temp\\my.file") # returns the size in bytes
#!/usr/bin/env python
"""
Quick script to beemind entering at least some meals into MyFitnessPal for the day.
Setup instructions:
- install myfitnesspal, requests and keyring (if you don't have them)
- call keyring.set_password("myfitnesspal", <your_username>, <your_password>)
- call keyring.set_password("beeminder", <your_username>, <your_api_key>)
@tianshanghong
tianshanghong / gist:e4be93a4f53771b804815c3786149d98
Created April 3, 2019 19:56 — forked from digitaljhelms/gist:4287848
Git/GitHub branching standards & conventions

Branching

Quick Legend

Description, Instructions, Notes
Instance Branch
@tianshanghong
tianshanghong / profile2csv.py
Created May 5, 2019 20:11 — forked from maliubiao/profile2csv.py
profile2csv.py file -> profile.csv, cProfile->pstats->csv.
import sys
import marshal
def main():
if len(sys.argv) < 2:
print "usage: profile2csv file -> profile.csv"
f = open(sys.argv[1], "r")
k = marshal.loads(f.read())
f.close()
f = open("profile.csv", "w")
@tianshanghong
tianshanghong / Blocking.py
Created June 12, 2019 17:25 — forked from winstonma/Blocking.py
APScheduler Blocking Demo
"""
Demonstrates how to use the blocking scheduler to schedule a job that executes on 3 second
intervals.
"""
from datetime import datetime
import os
import threading
from apscheduler.schedulers.blocking import BlockingScheduler
@tianshanghong
tianshanghong / fullnode.md
Created June 26, 2019 22:03 — forked from romanz/fullnode.md
Bitcoin Full Node on AWS Free Tier

Bitcoin Full Node on AWS Free Tier

Provisioning

  • Launch one T2 micro instance, using Ubuntu 14.04 LTS AMI.
  • Open SSH and Bitcoin Protocol TCP ports: 22, 8333.
  • Attach 40GB EBS (General-Purpose SSD) volume for blockchain storage to /dev/sdf.

The pricing should be ~3$ for the first year (assuming 30GB upload per month). See here for more details.

@tianshanghong
tianshanghong / pinyin_seg.py
Created September 6, 2019 05:08 — forked from wong2/pinyin_seg.py
以前写的一个简单拼音分词程序。"tianqibucuo" -> "tian qi bu cuo"
#-*-coding:utf-8-*-
def seg(pinyin):
sm = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'w', 'x', 'y', 'z', 'sh', 'zh', 'ch']
ymd = {'a': {'i':None, 'o':None, 'n': {'g': None}},
'e': {'i':None, 'r':None, 'n': {'g': None}},
'i': {'e':None, 'a':{'n':{'g':None}, 'o':None}, 'u':None, 'o':{'n':{'g':None}}, 'n':{'g':None}},
'o': {'u':None, 'n':{'g':None}},
'u': {'a':{'i':None, 'n':{'g':None}}, 'e':None, 'i':None, 'o':None}
}
@tianshanghong
tianshanghong / add_contact_pinyin.py
Created September 28, 2019 18:12 — forked from zhenalexfan/add_contact_pinyin.py
Batch add phonetic names to your Chinese contacts
import csv
from pypinyin import pinyin, lazy_pinyin, Style
def cn_char(text):
return all('\u4e00' <= char <= '\u9fff' for char in text)
if __name__ == '__main__':
data =[]
with open('contacts.csv', encoding='utf-8') as f:
@tianshanghong
tianshanghong / Count lines in Git repo
Created April 10, 2020 00:20 — forked from mandiwise/Count lines in Git repo
A command to calculate lines of code in all tracked files in a Git repo
// Reference: http://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository
$ git ls-files | xargs wc -l