This file contains hidden or 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 fib(n) { return n < 2 ? n : fib(n-1) + fib(n-2) } | |
// 使用循环计算 | |
function fib_1(n) { | |
var arr = [1, 1] | |
var curLen | |
while(arr.length < n) { | |
curLen = arr.length | |
arr[curLen] = arr[curLen - 1] + arr[curLen - 2] |
This file contains hidden or 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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>GistRun</title> | |
<!--<link rel="stylesheet" href="styles.css">--> | |
</head> | |
<body> | |
<h1>Hello world!</h1> | |
This file contains hidden or 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 getOrdinal(n) { | |
var s=["th","st","nd","rd"], | |
v=n%100; | |
return n+(s[(v-20)%10]||s[v]||s[0]); | |
} | |
function ordinal_suffix_of(i) { | |
var j = i % 10, | |
k = i % 100; | |
if (j == 1 && k != 11) { |
This file contains hidden or 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 flatten(arr, result) { | |
result = result || [] | |
arr.forEach(function(item) { | |
if (Array.isArray(item)) { | |
flatten(item, result) | |
} else { | |
result.push(item) | |
} | |
}) |
This file contains hidden or 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 clone(value) { | |
var result | |
if (Array.isArray(value)) { | |
result = [] | |
value.forEach(function (item) { | |
result[result.length] = item | |
}) | |
} else if (typeof value === 'object') { | |
result = {} | |
Object.keys(value).forEach(function (key) { |
This file contains hidden or 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 (root, factory) { | |
root.CrossTab = factory() | |
}(window, function factory() { | |
var store = { | |
get: function (key) { | |
var strValue = localStorage.getItem(key) | |
var value | |
try { | |
value = JSON.parse(strValue) | |
} catch (err) { |
This file contains hidden or 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 toColStr(n) { | |
str = '' | |
while (n > 0) { | |
var mod = (n-1) % 26 | |
n = Math.floor( (n-1)/26 ) | |
str = String.fromCharCode( mod + 65 ) + str | |
} | |
return str | |
} |
This file contains hidden or 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
var str = '' | |
var FP_CODE = 0x263f | |
var FS_CODE = 0X2648 | |
for (var i = 0; i < 9; i++) { str += String.fromCharCode( FP_CODE + i ) } // --> "☿♀♁♂♃♄♅♆♇" | |
for (i = 0; i < 12; i++) { str += String.fromCharCode( FS_CODE + i ) } // --> "☿♀♁♂♃♄♅♆♇♈♉♊♋♌♍♎♏♐♑♒♓" |
This file contains hidden or 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
let psdSize = 750; //设计稿宽度 | |
let RemRatio = 16; //REM 换算比值 | |
let baseFontSize = psdSize / RemRatio; // 基准字体大小,单位px | |
var templateFunction = function (data) { | |
var common = '.icon {display: inline-block;}'; | |
var perSprite = data.sprites.map(function (sprite) { | |
return '.imgN {background-image: url(I); width: Wpx; height: Hpx; background-position: Xpx Ypx; }' | |
.replace(/px/g, 'rem') | |
.replace('I', sprite.image) |
This file contains hidden or 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
border-width: 0 0 1px | |
border-bottom-style: solid | |
border-bottom-color: #c8c7cc | |
/* :root.retina */ | |
border-image-source: url("data:image/svg+xml;charset=utf-8,<svg height='1' width='1' xmlns='http://www.w3.org/2000/svg'><rect height='.5' width='1' y='.5' fill='%23c8c7cc'/></svg>") | |
border-image-slice: 0 0 1 |