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
/** | |
* Recursively flatten the data | |
* [{path:string},{path:string}] => {path,path2} | |
* @param menus | |
*/ | |
export const getFlatMenuKeys = (menuData: MenuDataItem[] = []): string[] => { | |
let keys: string[] = []; | |
menuData.forEach(item => { | |
if (!item) { | |
return; |
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
/* | |
* 要求:0 1 背包问题 | |
* 参考:https://segmentfault.com/a/1190000012829866 | |
*/ | |
function knapsack(weights, values, W) { | |
/* | |
* 根据公式计算填写表格 f(i, j) | |
* i=0 && j<wi f(i, j)=0 | |
* i=0 && j>=wi f(i, j)=v0 |
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
/* | |
* 要求:实现一个div滑动的动画,由快至慢5s结束 | |
* 参考:https://developers.google.com/web/fundamentals/design-and-ux/animations/css-vs-javascript?hl=zh-tw | |
*/ | |
function Box() { | |
let startTime = 0 | |
const ACCEL = 30 | |
const TIME = 5 | |
let initSpeed = ACCEL * TIME |
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
for i in range(3): | |
try: | |
posts = get_userposts(user) | |
break | |
except: | |
print 'Failed user ' + user + ', retrying' | |
time.sleep(4) |
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
#!/usr/bin/env node | |
const download = require('download-git-repo') | |
const program = require('commander') | |
const exists = require('fs').existsSync | |
const path = require('path') | |
const ora = require('ora') | |
const home = require('user-home') | |
const tildify = require('tildify') | |
const chalk = require('chalk') |
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 supportAsyncFunctions() { | |
try { | |
new Function('(async function () {})()'); | |
return true; | |
} catch (ex) { | |
return false; | |
} | |
} | |
module.exports = supportAsyncFunctions() ? require('./lib/client.js') : require('./es5/client.js'); |