Skip to content

Instantly share code, notes, and snippets.

View zzzhc's full-sized avatar

Cheng Huang zzzhc

View GitHub Profile
@zzzhc
zzzhc / pi_digits.py
Created April 24, 2019 10:56 — forked from deeplook/pi_digits.py
Generate digits of Pi using a spigot algorithm.
"""
Run the algorithm below using CPython, Cython, PyPy and Numba and compare
their performance. (This is implementing a spigot algorithm by A. Sale,
D. Saada, S. Rabinowitz, mentioned on
http://mail.python.org/pipermail/edu-sig/2012-December/010721.html).
"""
def pi_digits(n):
"Generate n digits of Pi."
k, a, b, a1, b1 = 2, 4, 1, 12, 4
@zzzhc
zzzhc / encrypted-git-repo.md
Created October 30, 2018 05:21
Transparent Git Encryption

Transparent Git Encryption

This document has been modified from its [original format][m1], which was written by Ning Shang (geek@cerias.net). It has been updated and reformatted into a [Markdown][m2] document by [Woody Gilk][m3] and [republished][m4].

Description

When working with a remote git repository which is hosted on a third-party storage server, data confidentiality sometimes becomes

@zzzhc
zzzhc / SouGouDic.java
Created November 17, 2017 08:19 — forked from vivizhyy/SouGouDic.java
搜狗细胞词库解析
package scel;
import java.util.List;
import java.util.Map;
public class SouGouDic {
private Map<String, List<String>> pinyinToWords;
private String name;
private String type;
@zzzhc
zzzhc / .screenrc
Created June 14, 2017 03:54 — forked from joaopizani/.screenrc
A killer GNU Screen Config
# the following two lines give a two-line status, with the current window highlighted
hardstatus alwayslastline
hardstatus string '%{= kG}[%{G}%H%? %1`%?%{g}][%= %{= kw}%-w%{+b yk} %n*%t%?(%u)%? %{-}%+w %=%{g}][%{B}%m/%d %{W}%C%A%{g}]'
# huge scrollback buffer
defscrollback 5000
# no welcome message
startup_message off
@zzzhc
zzzhc / patent-search.md
Created January 23, 2017 07:21
国内专利查询网站
@zzzhc
zzzhc / latency.txt
Created January 3, 2017 10:44 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
  1. 开启ipv4转发
vi /etc/sysctl.conf
# 将net.ipv4.ip_forward=0更改为net.ipv4.ip_forward=1
sysctl -p
  1. 安装dnsmasq 和pdnsd解决dns污染

DNS的解析方案为 resolve.conf ==> dnsmasq ==> pdnsd

A backup of http://sites.google.com/site/redcodenl/creating-shazam-in-java-1 just in case
Why is this necessary? Read http://sites.google.com/site/redcodenl/patent-infringement
Please fork, tweet about, etc.
----
Creating Shazam in Java
A couple of days ago I encountered this article: How Shazam Works
This got me interested in how a program like Shazam works… And more importantly, how hard is it to program something similar in Java?
#!/bin/bash
##############################
# dnspodsh v0.3
# 基于dnspod api构架的bash ddns客户端
# 作者:zrong(zengrong.net)
# 详细介绍:http://zengrong.net/post/1524.htm
# 创建日期:2012-02-13
# 更新日期:2012-03-11
##############################
@zzzhc
zzzhc / air_ssd.md
Created April 29, 2013 08:59
save macbook air disk space by disable swap and sleepimage

disable swap

$ sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
$ sudo rm /private/var/vm/swapfile*

disable sleepimage