Skip to content

Instantly share code, notes, and snippets.

View shuson's full-sized avatar
🎯
Focusing

Nevermoi shuson

🎯
Focusing
View GitHub Profile
@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 }

@shuson
shuson / Puppet&Chef.md
Last active August 29, 2015 14:21
New stuff on 14th May 2015

Puppet, from Puppet Labs

It is a configuration management tool that helps system administrators automate the provisioning, configuration, and management of a server infrastructure.

Chef

It is a systems and cloud infrastructure automation framework that makes it easy to deploy servers and applications to any physical, virtual, or cloud location, no matter the size of the infrastructure. Each organization is comprised of one (or more) workstations, a single server, and every node that will be configured and maintained by the chef-client. Cookbooks (and recipes) are used to tell the chef-client how each node in your organization should be configured. The chef-client (which is installed on every node) does the actual configuration.