Cross-browser function to trigger DOM events.
This file contains hidden or 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
| ;var _ = (function () { | |
| function lo() { } | |
| lo.prototype = { | |
| //XMLHttpRequest wrapper | |
| ajax: function() { | |
| var a = arguments, | |
| requestData, | |
| opts = { method: 'GET', data: null, url: '', async: true, done: null, fail: null, always: null }; | |
This file contains hidden or 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 mune(){ | |
| var a=Array.isArray(arguments[0]) ? arguments[0] : arguments; | |
| for(var i=0,l=a.length,l=l>31?31:l;i<l;i++){this[a[i]] = 1 << i} | |
| } |
This file contains hidden or 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
| var async = { | |
| waterfall: function (listOfRequests, callback) { | |
| var callbacks = 0; | |
| function handleCallback() { | |
| callbacks++; | |
| if (callbacks === listOfRequests.length) { | |
| callback(); | |
| } else { | |
| listOfRequests[callbacks](handleCallback); | |
| } |
This file contains hidden or 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
| //let's cache the event | |
| var priorEvt; | |
| function getMousePos(evt) { | |
| //set and store.. | |
| priorEvt = evt = evt || priorEvt; | |
| //get the bounding rectangle | |
| var rect = canvas.getBoundingClientRect(); | |
| //lastly, return the x and y coordinates | |
| if (evt) |
This file contains hidden or 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
| // List all files in a directory in Node.js recursively in a synchronous fashion | |
| var walkSync = function(dir, filelist) { | |
| var fs = fs || require('fs'), | |
| files = fs.readdirSync(dir); | |
| filelist = filelist || []; | |
| files.forEach(function(file) { | |
| if (fs.statSync(dir + file).isDirectory()) { | |
| filelist = walkSync(dir + file + '/', filelist); | |
| } | |
| else { |
This file contains hidden or 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
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import unittest | |
| def naive_fibonacci(n): | |
| '''Simplest recursive implementation''' | |
| if n == 0: | |
| return 0 |
This file contains hidden or 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
| var p1 = { | |
| x: 20, | |
| y: 20 | |
| }; | |
| var p2 = { | |
| x: 40, | |
| y: 40 | |
| }; |
This file contains hidden or 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
| keycode 8 = BackSpace BackSpace | |
| keycode 9 = Tab Tab | |
| keycode 12 = Clear | |
| keycode 13 = Enter | |
| keycode 16 = Shift_L | |
| keycode 17 = Control_L | |
| keycode 18 = Alt_L | |
| keycode 19 = Pause | |
| keycode 20 = Caps_Lock | |
| keycode 27 = Escape Escape |