以下所有的API都有两种方式可调用 http://api?key=value&key2=value2 以及 http://api/key/value/key2/value
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
`` | |
http://home.ustc.edu.cn/~danewang/c/ctypes.html | |
`` | |
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
Java泛型的参数只可以代表类,不能代表个别对象。 | |
--- | |
由于Java泛型的类型参数之实际类型在编译时会被消除,所以无法在运行时得知其类型参数的类型。 | |
> In Java, generics are only checked at compile time for type correctness. The generic type information is then removed via a process called type erasure, to maintain compatibility with old JVM implementations, making it unavailable at runtime. | |
Java编译程序在编译泛型时会自动加入类型转换的编码 |
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
#High performance video for mobile | |
`<video>`的详细信息: | |
https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/video | |
`<video>` 与 `</video>` 之间的内容会在浏览器无法显示视频时显示出来 | |
例如 | |
``` | |
<video autoplay controls src="video/bunny.webm"> | |
<p>Sorry! Your browser doesn't support the video element.</p> | |
</video> |
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
/** | |
* A simple co | |
* @param {Function} fn Generator Function | |
* @return {Function} callback | |
*/ | |
function co(fn) { | |
return function(done) { | |
done = done || function() {}; | |
var gen = fn(); |
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
``` | |
import { Component, Input, OnDestroy, OnInit } from '@angular/core'; | |
let nextId = 1; | |
@Component({ | |
selector: 'heavy-loader', | |
template: '<span>heavy loader #{{id}} on duty!</span>' | |
}) | |
export class HeavyLoaderComponent implements OnDestroy, OnInit { | |
id = nextId++; | |
@Input() logs: string[]; |
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
// 1000->1020->1040->1050(100) | |
let read_line = (() => { | |
let arr = ['1000 1050', '1000 1020 50', '1000 1030 70', '1020 1030 15', '1020 1040 30', '1030 1050 40', '1040 1050 20']; | |
let i = 0; | |
return _ => { | |
return arr[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
export class MinStack { | |
stack: number[] = []; | |
num: number = 0; | |
private _min: number; | |
get min(): number { | |
if (this.num > 0) { | |
return this._min; | |
} | |
} |
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
// Returns a function, that, as long as it continues to be invoked, will not | |
// be triggered. The function will be called after it stops being called for | |
// N milliseconds. If `immediate` is passed, trigger the function on the | |
// leading edge, instead of the trailing. | |
function debounce(func, wait, immediate) { | |
var timeout; | |
return function() { | |
var context = this, args = arguments; | |
var later = function() { | |
timeout = null; |
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
/** | |
* 实现一个nodejs的Master-Worker的小程序,要求: | |
* 1. Master维护与cpu核数相同的Worker的数量; | |
* 2. Master接收到Worker的disconnect消息时,重启新的Worker进程; | |
* 3. Worker监听1024端口并输出“Hello World”; | |
* 4. 在Worker遇到uncaughtException时,通知Master进程并等待3s后退出 | |
*/ | |
var os = require('os'), | |
cluster = require('cluster'), |
OlderNewer