Skip to content

Instantly share code, notes, and snippets.

View shuson's full-sized avatar
🎯
Focusing

Nevermoi shuson

🎯
Focusing
View GitHub Profile
@shuson
shuson / generateUUID
Created December 5, 2014 07:08
To generate a simple UUID using javascript
function generateUUID(){
var d = new Date().getTime();
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = (d + Math.random()*16)%16 | 0;
d = Math.floor(d/16);
return (c=='x' ? r : (r&0x7|0x8)).toString(16);
});
return uuid;
};
@shuson
shuson / stopwords
Created December 26, 2014 10:26
StopWords list based on Rainbow statistical text
a
able
about
above
according
accordingly
across
actually
after
afterwards
@shuson
shuson / sample.js
Last active September 19, 2023 08:50
get base64 raw data of image from responseBody using jquery ajax
$.ajax({
type: "GET",
url: "imageURL",
beforeSend: function (xhr) {
xhr.overrideMimeType('text/plain; charset=x-user-defined');
},
success: function (result, textStatus, jqXHR) {
if(result.length < 1){
alert("The thumbnail doesn't exist");
$("#thumbnail").attr("src", "data:image/png;base64,");
@shuson
shuson / getSSLCertInfo.js
Created April 15, 2015 10:09
get ssl certificate information by nodejs
var https = require('https');
https.get('https://www.douban.com/', function(res) {
console.log("cert info: ", res.socket.getPeerCertificate());
}).on('error', function(e) {
console.error(e);
});
//that's it, but no Official API shows socket has ''getPeerCertificate'' function
@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.

@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 / 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 / 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 / _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._ = _;
}
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