Skip to content

Instantly share code, notes, and snippets.

View A1rPun's full-sized avatar
🌊
Fractalicious

A1rPun A1rPun

🌊
Fractalicious
  • The Netherlands
View GitHub Profile
;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 };
@A1rPun
A1rPun / Enum
Last active August 29, 2015 14:05
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}
}
@A1rPun
A1rPun / Async
Last active August 29, 2015 14:05
var async = {
waterfall: function (listOfRequests, callback) {
var callbacks = 0;
function handleCallback() {
callbacks++;
if (callbacks === listOfRequests.length) {
callback();
} else {
listOfRequests[callbacks](handleCallback);
}
//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)
@kethinov
kethinov / walksync.js
Created September 22, 2013 09:04
List all files in a directory in Node.js recursively in a synchronous fashion
// 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 {
@dciccale
dciccale / README.md
Last active May 22, 2018 09:14
Cross-browser triggerEvent function done with 127 bytes of JavaScript

triggerEvent

Cross-browser function to trigger DOM events.

@tcurvelo
tcurvelo / fibonacci.py
Last active December 3, 2019 18:33
Fibonacci Experiments...
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
def naive_fibonacci(n):
'''Simplest recursive implementation'''
if n == 0:
return 0
@dciccale
dciccale / README.md
Last active December 9, 2015 17:49
requestAnimationFrame shim in 155 bytes (127 gzipped)

requestAnimationFrame shim

Cross-browser requestAnimationFrame in 155 bytes of JavaScript.

@conorbuck
conorbuck / angle-between-points.js
Created May 5, 2012 22:51
JavaScript: Find the angle between two points
var p1 = {
x: 20,
y: 20
};
var p2 = {
x: 40,
y: 40
};
@lbj96347
lbj96347 / jsKeyCode.txt
Created May 1, 2012 13:31
javascript Key Code
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