Skip to content

Instantly share code, notes, and snippets.

View molant's full-sized avatar

Antón Molleda molant

View GitHub Profile
@molant
molant / gist:9772070
Created March 25, 2014 21:45
AngularJS watchers in page
(function () {
var root = $(document.getElementsByTagName('body'));
var watchers = [];
var f = function (element) {
if (element.data().hasOwnProperty('$scope')) {
angular.forEach(element.data().$scope.$$watchers, function (watcher) {
watchers.push(watcher);
});
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@molant
molant / uievents-raf.js
Last active December 14, 2015 18:09
How to process UI events with RAF
var deltaX = 0,
queued = false;
function myAction(){
//your awesome code here uses deltaX
deltaX = 0; //we reset the deltaX so it can be incremented next time onEvent is executed
queued = false;
}
function onEvent(evt){
@molant
molant / gameloop-videoediting.js
Created March 10, 2013 04:08
Game Loop example for video editing project
function tick(){
//we clean if we've changed the size of the quadrant
if(needsClean){
cleanCanvas();
}
//if we have to change the quadrant's frame because we are the active one (or the opposite)
if(newFrame){
drawFrame(); //we draw just the frame in a separate canvas so it doesn't need to be calculated all the time, and it is still faster than copying from an image
}
@molant
molant / bugrepro.js
Created April 29, 2013 16:00
Problem with cookie handling and some websites
"use strict";
var request = require('request'),
request = request.defaults({
// jar: false,
headers: {
'Accept': 'text/html, application/xhtml+xml, */*',
'Accept-Language': 'en-US,en;q=0.5',
'User-Agent': 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)'}}),
websites = ['http://cnet.com',