Skip to content

Instantly share code, notes, and snippets.

View furixturi's full-sized avatar
😈

Xiaoli Shen furixturi

😈
View GitHub Profile
@furixturi
furixturi / gist:6790715
Created October 2, 2013 08:34
simulate slow connection in osx
# configure a pipe rule
sudo ipfw pipe 1 config bw 512Kbit/s delay 500ms
# add the pipe to connection in and out port 80
sudo ipfw add 1 pipe 1 src-port 80
sudo ipfw add 2 pipe 1 dst-port 80
# remove the rules and delete the pipe
sudo ipfw delete 1
sudo ipfw delete 2
@furixturi
furixturi / gist:6775430
Created October 1, 2013 08:29
Use reauestAnimationFrame
drawFrame: function(){
window.requestAnimationFrame(this.drawFrame, this.canvas);
this.render();
},
@furixturi
furixturi / gist:6775423
Created October 1, 2013 08:28
Check canvas support
checkCanvasSupport: function(){
if(!document.createElement('canvas').getContext) {
alert("This browser dosn't support the canvas element");
return false;
}else{
console.log("success!");
return true;
}
},
@furixturi
furixturi / gist:6775391
Last active December 24, 2015 09:09
neutralize request animation frame function
neutralizeAnimationFunc: function(){
if(!window.requestAnimationFrame){
window.requestAnimationFrame = (window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(callback){
return window.setTimeout(callback, 1000/60);
});
}
@furixturi
furixturi / gist:6775381
Last active December 24, 2015 09:09
HTML5 canvas mouse event
addMouseEvents: function (){
this.canvas.addEventListener('mousedown', function(event){
console.log("mouse down");
}, false);
this.canvas.addEventListener('mouseup', function(event){
console.log("mouse up");
}, false);
}