Skip to content

Instantly share code, notes, and snippets.

// A memoize function to store function results of heavy functions
// http://jsfiddle.net/arian/UQsEA/1/
(function(slice){
Function.prototype.memoize = function(hashFn, bind){
var cache = {}, self = bind ? this.bind(bind) : this, hashFn = hashFn || JSON.stringify;
return function(){
return ((key = hashFn(slice.call(arguments))) in cache)
@arian
arian / Table.js
Created January 10, 2011 15:44
Another Table implementation which could be used for Class
var Table = function(args){
this.keys = [];
this.values = [];
this.length = 0;
if (args) for (var i = 0, l = args.length; i < l; i += 2){
this.set(args[i], args[i + 1] || null);
}
@arian
arian / jshint.html
Created February 23, 2011 16:29
JSHint MooTools More
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
body {font: 0.8em sans-serif;}
strong {font-weight: bold}
h3 {font-size: 1.2em}
.fail {background: lightcoral}
* dc90ba7 - Welcome to 1.3.1.1. (2011-02-25 19:59:21 +0100) <Tim Wienk>
* 0292a3a - Update to mootools-core 1.3.1 for the Specs (2011-02-25 19:55:20 +0100) <Arian>
* e96492b - Clarified the :keys psuedo event test (2011-02-25 18:45:07 +0100) <Arian>
* 4761528 - Add specs for Element.validated and Form.Validator fields with warnings (2011-02-25 17:31:26 +0100) <Arian>
* a83eed8 - InputValidator should be public (2011-02-25 15:25:10 +0100) <Arian>
* 78e298b - Element.get('validator', options); doesn't work since MooTools 1.3 (2011-02-25 15:23:29 +0100) <Arian>
* ec1c624 - Form.Validator fixes: stopOnFailure and Element.validate (2011-02-24 08:49:16 -0800) <Aaron Newton>
* 358378c - Fixes #498 - Form.Validator OnElementPass event has parameter 'undefined' (2011-02-24 00:37:25 +0100) <Jacob Thornton>
* 075e026 - Whitespace Police! (2011-02-23 18:57:56 +0100) <Arian>
* 687d3fc - JSHint fixes (2011-02-23 17:12:09 +0100) <Arian>
* 2caa225 - Welcome to 1.3.1 (2011-02-25 02:36:41 +0100) <Christoph Pojer>
* af48c8d - Some small JSHint fixes (2011-02-24 12:32:31 +0100) <Arian>
* 749af0f - Fixing some old broken links to /Native/* (2011-02-24 01:33:17 +0100) <Arian>
* ddf73cd - Fix broken MDC links in the Docs to DOM related pages (2011-02-24 01:23:51 +0100) <Arian>
* 215c2fa - Updating Slick to 1.1.5 (2011-02-23 18:30:16 +0100) <Christoph Pojer>
* 37e200e - Don't use the native IE9 msMatchesSelector because it is awfully buggy in IE9 RC and I don't trust them enough to fix it until the final. If they do we can add support for it again in 1.3.2. (2011-02-23 14:50:14 +0100) <Christoph Pojer>
* cee4e50 - Reusing the same function reference for resetting XHR events, should fix a leak in IE6. Also check for progressSupport when resetting loadstart and progress, throws in IE (2011-02-23 14:40:50 +0100) <Christoph Pojer>
* 4c8640d - Updating Slick to 1.1.4 (2011-02-23 04:38:18 +0100) <Christoph Pojer>
* 81ff9f7 - Specs update (2011-02-23 04:08:
@arian
arian / .gitconfig
Last active September 25, 2015 03:27
.gitconfig
[core]
pager = less -+$LESS -RS
[alias]
st = status
ci = commit
co = checkout
br = branch
lg = log -p
pr = pull --rebase
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>MooTools Continues Fx</title>
<script src="mootools-core.js"></script>
<script>
@arian
arian / Function.overload.js
Created April 17, 2011 14:09
Overload functions or methods by the types of the arguments
Function.overload = function(fns, thisArg){
var dflt = (typeOf(fns[fns.length - 1]) == 'function') ? fns.pop() : null;
return function(){
var args = Array.from(arguments),
self = thisArg || this;
overload: for (var i = 0, l = fns.length; i < l; i++){
var types = fns[i].slice(0, -1), length = types.length,
fn = fns[i][length];
@arian
arian / moo.js
Created May 1, 2011 11:01
MooTools.define / MooTools.export
(function(){
var global = typeof exports == 'undefined' ? window : exports,
old = {};
var provide = MooTools.provide = function(key, value){
old[key] = global[key];
global[key] = value;
return value;
};
@arian
arian / Camel.matlab
Created May 19, 2011 11:06
Camel and Bananas Puzzle
%% puzzle description
%
% There is a desert, one camel and 3000 bananas.
%
% The camel has to transport as many bananas 1 km (1000 m).
% However each meter, the camel eats one banana.
% Also the camel can only carry 1000 bananas at the same time
%
% What is the maximum number of bananas the camel can bring to the other side?
%