This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This function creates a new anchor element and uses location | |
// properties (inherent) to get the desired URL data. Some String | |
// operations are used (to normalize results across browsers). | |
function parseURL(url) { | |
var a = document.createElement('a'); | |
a.href = url; | |
return { | |
source: url, | |
protocol: a.protocol.replace(':',''), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (event.stopPropagation) { | |
event.stopPropagation(); | |
} else { | |
event.cancelBubble = true; | |
} | |
evnet.target = evnet.target || event.srcElement; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[user] | |
name = leohxj | |
email = leohxj@gmail.com | |
[alias] | |
st = status | |
l = log --pretty=oneline -n 20 --graph --abbrev-commit | |
ll = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -- | |
b = branch | |
ci = commit | |
ca = commit -a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream nodejs__upstream { | |
server 127.0.0.1:3000; | |
keepalive 64; | |
} | |
server { | |
listen 80; | |
server_name 192.168.1.60; | |
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typeof {foo: 'bar'}; | |
// "object" | |
typeof ['foo', 'bar']; | |
// "object" | |
typeof "foobar"; | |
// "string" | |
typeof /foo|bar/; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function y(){ | |
var args = Array.prototype.slice.call(arguments); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 直白一点的方法, 循环拼接字符串 | |
function formatNumber(number, split) { | |
var string = String(number); | |
var split = split || 3; | |
var newStr= new Array(string.length+ parseInt(string.length/split)); | |
newStr[newStr.length-1]=string[string.length-1]; | |
var currentIndex=string.length-1; | |
for(var i = newStr.length-1;i >= 0;i--) | |
{ | |
if((newStr.length-i)%(split+1)==0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// iterative | |
function string_reverse_1(str) { | |
var new_str = ""; | |
for (var i = str.length - 1; i >= 0; i--) { | |
new_str += str.charAt(i); | |
} | |
return new_str; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 你可以使用余数运算(%),将一个数字按1求余,看看余数是不是0。 | |
function isInteger(x) { | |
return x % 1 === 0; | |
} | |
// 通过Math.round() | |
function isInteger(x) { | |
return Math.round(x) === x; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 | |
function indexOfSmallest(a) { | |
var lowest = 0; | |
for (var i = 1; i < a.length; i++) { | |
if (a[i] < a[lowest]) lowest = i; | |
} | |
return lowest; | |
} | |
// 2 |
OlderNewer