This file contains 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
'use strict' | |
var trait = {} | |
trait.whatever = function (context) { | |
context.prototype.exec = function () { | |
console.log(this.i) | |
} | |
} |
This file contains 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
window.requestAnimationFrame = function(){ | |
return ( | |
window.requestAnimationFrame || | |
window.webkitRequestAnimationFrame || | |
window.mozRequestAnimationFrame || | |
window.oRequestAnimationFrame || | |
window.msRequestAnimationFrame || | |
function(/* function */ callback){ | |
window.setTimeout(callback, (fadeInDuration + fadeOutDuration)); | |
} |
This file contains 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 isCyclic (obj) { | |
var seenObjects = []; | |
function detect (obj) { | |
if (obj && typeof obj === 'object') { | |
if (seenObjects.indexOf(obj) !== -1) { | |
return true; | |
} | |
seenObjects.push(obj); | |
for (var key in obj) { |
This file contains 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 con | |
var keepAlive = function () { | |
console.log('Trying MySQL connection') | |
con = mysql.createConnection({host: 'localhost', user: 'root', password: '', database: 'default'}) | |
con.connect(function (err) { | |
if (err) return console.log('MySQL connection failed', err.stack) | |
console.log('Connected to MySQL') |
This file contains 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 getLine() { | |
var s = new Error().stack, | |
r = /at\s.*:([\d]*):/g | |
r.exec(s) | |
return r.exec(s)[1] | |
} |
This file contains 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
DELIMITER | | |
CREATE TRIGGER cancel_delete BEFORE DELETE ON table | |
FOR EACH ROW | |
BEGIN | |
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'DELETE canceled'; | |
END | | |
DELIMITER ; |
This file contains 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
using System.Security.Cryptography; | |
string hash(string str) | |
{ | |
try | |
{ | |
SHA1 sha1 = SHA1.Create(); | |
byte[] hashData = sha1.ComputeHash(Encoding.UTF8.GetBytes(str)); | |
return BitConverter.ToString(hashData).Replace("-", "").ToLower(); | |
} |
This file contains 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 clone(obj) { | |
return Object.create({o: obj}).o | |
} |
This file contains 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 rand(min,max) { | |
return Math.floor(Math.random()*(max-min+1)+min); | |
} |
This file contains 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 randomiza(n) { | |
return Math.round(Math.random()*n); | |
} | |
function mod(dividendo,divisor) { | |
return Math.round(dividendo - (Math.floor(dividendo/divisor)*divisor)); | |
} | |
function gerarCPF(comPontos) { | |
var n = 9; |
OlderNewer