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 ([email protected]). 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

@zzzhc
zzzhc / gist:f30383dc3462026a5631
Created November 23, 2015 10:49 — forked from rc1/gist:69b2c49d0efaebeafd08
Building node.js for Raspberry Pi 2 (with Armv7 and Neon support)
export CC='gcc -O3 -march=armv7-a -mtune=cortex-a8 -mfpu=neon'
export CXX='g++ -O3 -march=armv7-a -mtune=cortex-a8 -mfpu=neon'
./configure --without-snapshot
make -j4
sudo make install
#
# https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
# based on the RSnake original http://ha.ckers.org/xss.html
# Retrieved on 2013-11-20
# Much of this wildly obsolete
#
# XSS Locator 2
'';!--"<XSS>=&{()}
@zzzhc
zzzhc / graphite.md
Last active August 29, 2015 14:10 — forked from relaxdiego/graphite.md

Follow these steps to install graphite on OS X Mavericks.

Prerequisites

  • Homebrew
  • Python 2.7
  • Git

Install dependencies

Install Cairo and friends