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 MyConstructor = (function(){ | |
function Constructor(options){ | |
this.name = "foo"; | |
} | |
//methods | |
Constructor.prototype = { | |
getName: function(){ |
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 ajaxLoad(element, url, parameters){ | |
if(typeof element=="string") element=document.querySelector(element); | |
var Ajax=(function(){ | |
try{return new XMLHttpRequest()} | |
catch(e){try{return new ActiveXObject("Msxml2.XMLHTTP")} | |
catch(e){try {return new ActiveXObject("Microsoft.XMLHTTP")} | |
catch(e){ return null; }}} | |
})(); | |
if(Ajax){ |
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 DomReady = new function(){ | |
var listeners = []; | |
var done = 0; | |
function onDomReady(e){ | |
if(e.type=='readystatechange' && (document.readyState!='interactive' && document.readyState!='complete')) return; | |
if(!done++) | |
for(var i=0;i<listeners.length;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
/** | |
* An alternative to setInterval and requestAnimationFrame that will call insanely fast for testing purposes. | |
* This will alternate between syncronous/blocking and assyncrounous non-blocking execution. | |
* Be very careful using this, this can freeze your browser. | |
* | |
* Your callback should return true in order to keep the loop running, return false to stop. | |
*/ | |
function insaneLoop(callback, maxBlockingExecutionTime, assyncInterval){ | |
maxBlockingExecutionTime = maxBlockingExecutionTime | 50; |
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
#include <stdlib.h> | |
#include <stdio.h> | |
#include <time.h> | |
#define PEDRA 1 | |
#define PAPEL 2 | |
#define TESOURA 3 | |
int pontosJogador; | |
int pontosComputador; |
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
#include <stdlib.h> | |
#include <stdio.h> | |
#include <time.h> | |
#define CARA 1 | |
#define COROA 2 | |
int pontosJogador; | |
int pontosComputador; |
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 compileTemplate = function(html) { | |
var re = /{{([^}]*(?:}[^}]+)*}*)}}/g, | |
reExp = /(^( )?(if|for|else|switch|case|break|{|}))(.*)?/g, | |
code = 'var r=[];\n', cursor = 0, match; | |
var add = function(line, js) { | |
js? (code += line.match(reExp) ? line + '\n' : 'r.push(' + line + ');\n') : | |
(code += line != '' ? 'r.push("' + line.replace(/"/g, '\\"') + '");\n' : ''); | |
return add; | |
} |
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
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ | |
/* AES implementation in JavaScript (c) Chris Veness 2005-2014 / MIT Licence */ | |
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ | |
/* jshint node:true *//* global define */ | |
'use strict'; | |
/** | |
* AES (Rijndael cipher) encryption routines, |
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
/** | |
* Access a deep value inside an object | |
* Works by passing a path like "foo.bar", also works with nested arrays like "foo[0][1].baz" | |
* @author Victor B. https://gist.github.com/victornpb/4c7882c1b9d36292308e | |
* Unit tests: http://jsfiddle.net/Victornpb/0u1qygrh/ | |
* @param {any} object Any object | |
* @param {string} path Property path to access e.g.: "foo.bar[0].baz.1.a.b" | |
* @param {any} [defaultValue=undefined] Optional value to return when property doesn't exist or is undefined | |
* @return {any} | |
*/ |
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
if (!String.prototype.format) { | |
/** | |
* formats a string replacing tokens with an argument list, array, objects, and nested objects. | |
* @args Can be a list of arguments, array or object | |
* | |
* Usage: | |
* "hello {0} world {0}!".format("foo", "bar"); //"hello foo world bar" | |
* "hello {0} world {0}!".format(["foo", "bar"]); //"hello foo world bar" | |
* "hello {name} world {test}!".format({name: "foo", test: "bar"}); //"hello foo world bar" | |
* "hello {obj.name} world {obj.test[0]}!".format({obj:{name: "foo", test: ["bar"]}}); //"hello foo world bar" |