Skip to content

Instantly share code, notes, and snippets.

View winsonwq's full-sized avatar
🎯
Focusing

Wang Qiu winsonwq

🎯
Focusing
  • 可好玩乐
  • Chengdu China
View GitHub Profile
@winsonwq
winsonwq / aami.config.js
Last active December 21, 2015 02:59
Viff config file for AAMI prodtest & prod
'use strict'
module.exports = {
seleniumHost: 'http://localhost:4444/wd/hub',
browsers: ['firefox'],
envHosts: {
prodtest: 'http://prodtest.aami.com.au',
prod: 'http://www.aami.com.au'
},
paths: [
@winsonwq
winsonwq / array_callback.rb
Created May 27, 2013 03:08
add hook when array size changed
a = []
class << a
Array.instance_methods(false).each do |meth|
old = instance_method(meth)
define_method(meth) do |*args, &block|
old_size = size
old.bind(self).call(*args, &block)
size_changed(size) if old_size != size
end if meth != :size
@winsonwq
winsonwq / Cakefile
Created December 11, 2012 09:53
Cakefile
{exec} = require 'child_process'
run = (command, callback) ->
exec command, (err, stdout, stderr) ->
console.warn stderr if stderr
callback?() unless err
build = (callback) ->
run 'coffee -co lib src', callback
@winsonwq
winsonwq / git-note
Created May 26, 2012 02:27
Git note
Wikipedia explanation: http://zh.wikipedia.org/wiki/Git#.E5.91.BD.E5.90.8D.E6.9D.A5.E6.BA.90
@winsonwq
winsonwq / stop(Immediate)Propagation.js
Created April 20, 2012 16:36
stop(Immediate)Propagation
var outer2 = document.getElementById('outer2');
var inner2 = document.getElementById('inner2');
var stopChecked = document.getElementById('stopChecked');
outer2.addEventListener('click', function(evt) {
alert('outer click 1.');
}, false);
inner2.addEventListener('click', function(evt) {
alert('inner click 1.');
@winsonwq
winsonwq / once.js
Created April 20, 2012 16:34
once implementation
function once(elem, eventType, handler){
elem.addEventListener(eventType, function(evt){
handler.call(elem, evt);
elem.removeEventListener(eventType, arguments.callee/*, false */);
}, false)
}
once(document.getElementById('onceButton'), 'click', function(evt){
alert('just show once!');
});
@winsonwq
winsonwq / bubbleAndCapture.js
Created April 20, 2012 16:29
bubble and capture
var outer = document.getElementById('outer');
var inner = document.getElementById('inner');
outer.addEventListener('click', function(evt){
console.log(evt.target);
alert(0);
}, false);
inner.addEventListener('click', function(evt){
console.log(evt.currentTarget);
@winsonwq
winsonwq / renderView.js
Created March 4, 2012 16:54
pseudocode of renderView
require(['./lib/Mr.Async', './lib/Recoder/main'], function(Mr, interpreter){
function getListData(url, callback){
$.get(url, callback, 'json');
}
function getSideBarData(url, data, callback){
$.get(url, data, callback, 'json');
}
@winsonwq
winsonwq / uploadImages.js
Created March 4, 2012 16:32
upload images one by one
require(['./lib/Mr.Async', './lib/Recoder/main'], function(Mr, interpreter){
function asyncUpload(image){
var dfd = Mr.Deferred();
ajaxPost(image, function(ret){
if(ret.status == 200){
dfd.resolve();
}
});
return dfd;
@winsonwq
winsonwq / JSInheritance.js
Created February 13, 2012 16:12
JavaScript Inheritance (not 100% perfect)
/*
why is it not 100% perfect?
- because if you wanna override the parent's method to get the private variable and use
my way to extend, you can not get the right value. in this code, a example can be found
to demonstrate the right way to use extend method, in this example, is you change the 'title'
variable like this way 'var title' not 'this.title', finally you just get the undefined value
after invoking the getTitle on Child class instance.
- any question, contact me through http://sheldonw.sinaapp.com
*/