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 / ca.md
Created February 2, 2022 01:19 — forked from soarez/ca.md
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

Alright, thank you.
So, I’ve got about apparently I’ve got about five to six minutes to say the most useful things I can think of.
I’m gonna do my best.
It was suggested that I distill things down to 3 items.
I think I’ll go with four.
And I’ll try, I think, I think these are pretty important ones.
Some of it may kinda sound like, well you’ve heard them before.
But, you know, worth reemphasizing.
I think the first is, you need to work, if you, depending on how well you want to do,
gmail.com
yahoo.com
hotmail.com
aol.com
msn.com
live.co.uk
live.com.au
facebook.com
live.com
yahoo.ca
@tianshanghong
tianshanghong / free_email_provider_domains.txt
Created May 1, 2020 18:35 — forked from tbrianjones/free_email_provider_domains.txt
A list of free email provider domains. Some of these are probably not around anymore. I've combined a dozen lists from around the web. Current "major providers" should all be in here as of the date this is created.
1033edge.com
11mail.com
123.com
123box.net
123india.com
123mail.cl
123qwe.co.uk
126.com
150ml.com
15meg4free.com
@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
@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 / 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 / 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 / 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 / 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")