Skip to content

Instantly share code, notes, and snippets.

View shuson's full-sized avatar
🎯
Focusing

Nevermoi shuson

🎯
Focusing
View GitHub Profile
@shuson
shuson / how_about_e.md
Created March 3, 2018 08:31
自然底数e是怎么回事
  1. 假设你在银行存了1元钱(下图蓝圆),很不幸同时又发生了严重的通货膨胀,银行存款利率达到了逆天的100%!
  2. 银行发善心,每半年付利息,你可以把利息提前存入,利息生利息(红圆),1年存款余额=2.25元
  3. 假设银行人品爆发,一年365天,愿意天天付利息,这样利滚利的余额≈2.71456748202元
  4. 假设银行丧心病狂的每秒付利息,你也丧心病狂的每秒都再存入,1年共31536000秒,利滚利的余额≈2.7182817813元

1元存1年,在年利率100%下,无论怎么利滚利,其余额总有一个无法突破的天花板,这个天花板就是e

summary: 每个理想的存款,其余额都是e的倍数。

@shuson
shuson / git_log_beautify.md
Created March 1, 2018 10:40
make your git log prettier

just put the following to your ~/.gitconfig

[alias] lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all lg = log --abbrev-commit --decorate --oneline --graph

@shuson
shuson / terminial_mac_config
Created March 1, 2018 10:30
give your mac terminal some colors
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
alias ls='ls -GFh'
alias la='ls -aGFhl'
@shuson
shuson / CLIPSJNI_MacOS_Guide.md
Last active February 17, 2018 07:20
Load CLIPJNI.jnilib for Mac OS in Eclipse IDE

A basic rule is "JNI libraries are named with the library name used in the System.loadLibrary() method of your Java code, prefixed by lib and suffixed with .jnilib." refs

Use System.out.println(System.getProperty("java.library.path"));, print your java.library.path, and put the CLIPSJNI.jnilib to one of the dirs, for example "/Users/xxx/Library/Java/Extensions/" and rename it as libCLIPSJNI.jnilib

Now you can use System.loadLibrary("CLIPSJNI") to get it.

def sol(A):
n = len(A)
for i in range(n):
j = n-1
while j > i:
if A[i] == A[j]:
return j - i
j -= 1
return 0
@shuson
shuson / _umd.js
Created August 25, 2016 09:31
underscore umd code
if (typeof exports !== 'undefined') {
if (typeof module !== 'undefined' && module.exports) {
exports = module.exports = _;
}
exports._ = _;
} else {
this._ = _;
}
@shuson
shuson / artical.md
Created December 30, 2015 10:15
Brief of phrase "REWRITE", "ACCESS" and "CONTENT" in Nginx

When a request comes to location \test, it will be processed by different phrases in sequence. There are 3 main phrases highlighted here out of totally 11 phrases. 1, rewrite 2, access 3, content

Every directive has its own phrase handler to be executed. For example set directive is executed in rewrite phrase, but echo is only executed in content phrase.

For rewrite and access phrases, directives from multiple modules can be executed, but in phrase content only one module is allowed to execute. For example,echo and echo_by_lua are conflicted if used together.

@shuson
shuson / matrixTransposer.py
Created November 24, 2015 06:06
Matrix Transpose From list
"""
given list[1,2,3,4,5,6,7,8,9,10], and delimter as 5,
output is as [1,6,2,7,3,8,4,9,5,10]
"""
def matricTranspos(ls, delimter):
length = len(ls)
parts = length/delimter
matrics = [ls[i*delimter:(i+1)*delimter] for i in range(parts)]
transposed = [[row[i] for row in matrics] for i in range(delimter)]
return reduce(lambda c, x: c + x, transposed, [])
@shuson
shuson / Weighted_random_distribution.md
Last active August 29, 2015 14:21
Even Random Distribution vs Weighted Random Distribution

Origin artical

This is just for personal memorial use.

Given a map X = { A: 2, B: 4, C: 1, D: 3 }