Skip to content

Instantly share code, notes, and snippets.

Tom Wu tom76kimo

Block or report user

Report or block tom76kimo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tom76kimo
tom76kimo / queueAsynFuction.js
Last active Aug 29, 2015
[Javascript] Queue Asynchronous Function using Promise
View queueAsynFuction.js
var Promise = require('es6-promise').Promise;
var funcs = [];
funcs[0] = function (cb) {
setTimeout(function () {
console.log(1);
cb();
}, 2000);
};
View webpack.js
var webpack = require("webpack");
module.exports = {
entry: {
app: "./app.js",
vendor: ["jquery", "underscore", ...],
},
output: {
filename: "bundle.js"
},
View simulate-function.js
function simulate(element, eventName) {
var event; // The custom event that will be created
if (document.createEvent) {
event = document.createEvent("HTMLEvents");
event.initEvent(eventName, true, true);
} else {
event = document.createEventObject();
event.eventType = eventName;
}
View decorator_design_pattern.ts
interface Component {
operation(): void;
}
class ConcreteComponent implements Component {
public operation() {
console.log('origin opration');
}
}
View decorator_transparent.ts
// Do this
Component c, c1;
c = new ConcreteComponent();
c1 = new ConcreteDecorator(c);
// Do not
ConcreteComponent c;
c = new ConcreteComponent();
ConcreteDecorator c1;
View decorator_semi-transparent.ts
interface Component {
operation(): void;
}
class ConcreteComponent implements Component {
public operation() {
}
}
View divineShieldDecorator.ts
interface Minion {
behit(damage: number): void;
getBlood(): number;
}
class SilverHandRecruit implements Minion {
private blood: number = 10;
behit(damage: number) {
this.blood -= damage;
}
View proxy_pattern_example.ts
interface Extent {
width: number;
height: number;
}
abstract class Graphic {
protected fileName: string;
abstract getExtent(): Extent;
abstract draw(): void;
}
View proxy_pattern_implementation.cpp
class ImagePtr {
public:
ImagePtr(const char* imageFile);
virtual ~ImagePtr();
virtual Image* operator->();
virtual Image& operator*();
private:
Image* Loadlmage();
private:
View js_fundamental.md
  • Explain event delegation
  • Explain how this works in JavaScript
  • What is a closure, and how/why would you use one?
  • Explain the difference between synchronous and asynchronous functions
  • Explain Function.prototype.bind.
  • Explain Ajax in as much detail as possible.
  • Explain "hoisting".
  • Describe event bubbling.
  • Describe event capturing.
  • What are the differences between variables created using let, var or const?
You can’t perform that action at this time.