Skip to content

Instantly share code, notes, and snippets.

View Foredoomed's full-sized avatar

Foredoomed Foredoomed

  • Shanghai,China
View GitHub Profile
@Foredoomed
Foredoomed / System Design.md
Created June 15, 2020 09:14 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@Foredoomed
Foredoomed / gcsettings.sh
Last active May 31, 2019 08:54 — forked from svanoort/gcsettings.sh
Blessed GC settings for big servers
#参考:https://github.com/vipshop/vjtools/blob/master/vjstar/src/main/script/jvm-options/jvm-options.sh
# http://calvin1978.blogcn.com/articles/jvmoption-7.html
# Base settings and GC logging
-server
-XX:+AlwaysPreTouch # First should be default, but we make it explicit, second pre-zeroes memory mapped pages on JVM startup -- improves runtime performance
# -Xloggc:gc-%t.log # CUSTOMIZE LOCATION HERE - $path/gc-%t.log -- the %t in the gc log file path is so we get a new file with each JVM restart
-XX:NumberOfGCLogFiles=5 -XX:+UseGCLogFileRotation -XX:GCLogFileSize=20m # Limits the number of files, logs to folder
-XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintHeapAtGC -XX:+PrintGCCause

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

// XXX should be standard (and named clone, after Java?)
Object.prototype.copy = function () {
let o = {}
for (let i in this)
o[i] = this[i]
return o
}
// Containment testing for arrays and strings that should be coherent with their iterator.
Array.prototype.contains = String.prototype.contains = function (e) {
http://docs.jboss.org/jbossas/7/plugins/maven/7.4.Final/examples/deployment-example.html
@Foredoomed
Foredoomed / 复习
Last active December 14, 2015 02:08
public class LockTest {
private static final String fileName = "C:/work/LockExample.txt";
private static final String EXIT_FLAG = "BYE";
private static final int NO_OF_LINES = 10;
private static final Lock fileLock = new ReentrantLock();
private static final Condition condition = fileLock.newCondition();
private static final ExecutorService executorPool = Executors.newFixedThreadPool(2);
public static void main(String[] args) {
美国著名图书频道Book Pool集结最权威的62位作者评选出了最近10年计算机专业图书:
1.Design Patterns: Elements of Reusable Object-Oriented Software
By Erich Gamma, et al
2.The Mythical Man-Month: Anniversary Edition
By Frederick P. Brooks Jr.
3.TCP/IP Illustrated, Volume 1: The Protocols
By W. Richard Stevens
方滨兴 230103196007175511
@Foredoomed
Foredoomed / iehtml
Created December 4, 2012 05:41
IE in html
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->