brew install nginx
vi /usr/local/etc/nginx/
function pad(len, num) { | |
return (new Array(len + 1).join('0') + num).slice(-len); | |
} | |
pad(2, 1); // 01 | |
pad(2, 11); // 11 | |
pad(10, 12345); // 0000012345 | |
pad(10, 12345678); // 0012345678 | |
pad(10, 1234567890); // 1234567890 |
<style> | |
.ribbon { | |
overflow: hidden; | |
white-space: nowrap; | |
position: absolute; | |
right: 0; | |
top: 0; | |
width: 100px; | |
height: 100px; | |
} |
// a.js | |
var A = function () { | |
}; | |
A.prototype.a = function (a) { | |
return a; | |
}; |
####### NGINX | |
nginx config for running redmine under /redmine | |
(assuming working nginx config) | |
+++ add | |
upstream redmine-puma { | |
server unix:/<<redminepath>>/tmp/sockets/redmine.sock fail_timeout=0; | |
} |
function timer(func, start, interval, end) { | |
start = start || 0; | |
if (arguments.length <= 2) { | |
setTimeout(func, start); | |
} else { | |
var repeat = function() { | |
var i = setInterval(func, interval); | |
end && setTimeout(function() { | |
clearInterval(i); | |
}, end); |
/** | |
* var u = url('http://wenzhixin.net.cn:12345/test?name=wenzhixin#about'); | |
* console.log(u.protocol); // http: | |
* console.log(u.hostname); // wenzhixin.net.cn | |
* console.log(u.port); // 12345 | |
* console.log(u.pathname); // /test | |
* console.log(u.search); // ?name=wenzhixin | |
* console.log(u.hash); // #about | |
*/ | |
function url(href) { |
function parse(search) { | |
var query = {}, | |
params = search.substring(1).split('&'); | |
for (var i = 0, l = params.length; i < l; i++) { | |
var p = params[i].split('='); | |
query[p[0]] = p[1] || ''; | |
} | |
return query; | |
} |
function getSize(value) { | |
var b1 = Math.pow(2, 10), //KB | |
b2 = Math.pow(2, 20), //MB | |
b3 = Math.pow(2, 30), //GB | |
b4 = Math.pow(2, 40), //TB | |
value = value.toLowerCase(), | |
size = parseFloat(value); | |
if (!size) { | |
return 0; |