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
class Middleware{ | |
constructor () { | |
this._middlewares_ = [] | |
} | |
use (...middlewares) { | |
this._middlewares_ = this._middlewares_.concat(middlewares) | |
return this | |
} |
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
document.onclick= function(event) { | |
if (event===undefined) event= window.event; // IE hack | |
var target= 'target' in event? event.target : event.srcElement; // another IE hack | |
var root= document.compatMode==='CSS1Compat'? document.documentElement : document.body; | |
var mxy= [event.clientX+root.scrollLeft, event.clientY+root.scrollTop]; | |
var path= getPathTo(target); | |
var txy= getPageXY(target); | |
var message = 'You clicked the element '+path+' at offset '+(mxy[0]-txy[0])+', '+(mxy[1]-txy[1]); |
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
interface FileReaderEventTarget extends EventTarget { | |
result:string | |
} | |
interface FileReaderEvent extends Event { | |
target: FileReaderEventTarget; | |
getMessage():string; | |
} |
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
'use strict' | |
/* | |
描述: | |
Flexbox Grid(http://flexboxgrid.com/) 这个 css 库的 ts 生成器. 用于 React 使用 felxboxgrid. | |
比 react-flexbox-grid 简单粗暴, 不需要 webpack 就能用, 不需要编译一堆东西. 并且由于生成的是静态代码, 效率还要更高, 无论编译时还是运行时. | |
使用: | |
node generate.js > target.tsx |
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
'use strict' | |
export type Result<T, E> = Succ<T> | Fail<E> | |
export class Succ<T> { | |
readonly cont: T | |
readonly ok: true = true | |
constructor(cont: T) { this.cont = cont } | |
} |
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
'use strict' | |
import * as Konva from 'konva' | |
type Events = | |
'mouseover' | 'mouseout' | 'mouseenter' | | |
'mouseleave' | 'mousemove' | 'mousedown' | | |
'mouseup' | 'wheel' | 'click' | 'dblclick' | | |
'dragstart' | 'dragmove' | 'dragend' | | |
'touchstart' | 'touchmove' | 'touchend' | |
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 patch() { | |
const input = $('#tw-source-text-ta') | |
const target = $('#tw-target-text') | |
input.onchange = () => { | |
console.log(input.value, '=>', target.innerText) | |
input.value = '' | |
} | |
})() |
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
Windows Registry Editor Version 5.00 | |
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] | |
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,3a,00,46,00,01,00,3a,00,00,00,00,00 |
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
#include <map> | |
#include <functional> | |
typedef unsigned long ListenerID; | |
template <class EventData> | |
using Listener = std::function<void(EventData)>; | |
template <class EventData> | |
using ListenersMap = std::map<ListenerID, Listener<EventData>>; |
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
// 一些方便用的函数库 | |
#ifndef GAME_ENGINE_UTILS_HPP | |
#define GAME_ENGINE_UTILS_HPP | |
#include <iostream> | |
#include <vector> | |
#include <functional> | |
#include <map> |