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.onscroll = function onScroll() { | |
var htmlEl = document.documentElement, | |
alturaJanela = htmlEl.clientHeight, | |
alturaTotal = Math.max(document.body.scrollHeight, htmlEl.scrollHeight, document.body.offsetHeight, htmlEl.offsetHeight, htmlEl.clientHeight); | |
// Aplique a lógica que quiser, usei: se o scroll | |
if(alturaTotal - 2 * alturaJanela < window.scrollY) { | |
carregarDados(); | |
} | |
window.onscroll = null; |
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
/** Get the maximum call stack and the error it generates */ | |
(function () { | |
var results = {}; | |
(function f (a) { | |
try { | |
f(a+1); | |
} catch (e) { | |
results[a] = e; | |
} | |
}(0)); |
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
// Example usage: | |
var example1 = {foo: {bar: 1}}, | |
example2 = {foo: {bar: 1, qux: 1}}, | |
example3 = {foo: {BAZ: 1}}, | |
template1 = {foo: {bar: 1}} | |
template2 = {foo: {bar: {qux: 1}}}}, | |
// returns true: all keys from the template exist in the object | |
hasChainOfKeys(example1, template1); |
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
/** | |
* Validates e-mail addresses | |
* Supports internacionalized e-mails | |
*/ | |
function isValidEmail(input) { | |
// Split the e-mail into local part and domain part: | |
var parts = input.split('@'); | |
// It needs to have those two parts: | |
if (parts.length !== 2) return false; |
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 reservedWords = "arguments caller length name prototype __proto__".split(" ") | |
module.exports = createNamedParameters | |
function createNamedParameters(argv, fn) { | |
var length = fn.length | |
var composed = Array(length) | |
if (argv.length !== length) throw new Error("Argument lengths don't match") | |
function composing() { |
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
// note: require ES6 | |
$('#frame').html('<canvas id="pinkSlime" resize></canvas><div id="werd" class="glitch" data-text=""></div>') | |
{let script=$('script[canvas="pinkSlime"]')[0]; | |
script.innerHTML=script.innerHTML | |
// disable checking | |
.replace('Boolean(window.chrome)', 'true') | |
// replace IE specific javascript with the standards one | |
// http://stackoverflow.com/a/21512167 | |
.replace(/event\.event\.(\w)/g, (a,b) => `event.event.client${b.toUpperCase()}`); | |
} |
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
<!doctype html> | |
<!-- Use cdn.rawgit.com or htmlpreview.github.io to test --> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width"> | |
<meta property="og:title" content="Harder, Better, Faster, Stronger"/> | |
<meta property="og:url" content="http://davealger.c.mom/stronger/"/> | |
<meta property="og:image" content="http://davealger.com/stronger/punk_small.jpg"/> | |
<meta property="og:site_name" content="davealger.com"/> |
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
// Requires: jQuery, Zepto or a library with similar api | |
let React = {createElement: (e, args, ...children) => $(`<${e}>`, args).append( | |
children.map(e => typeof e==='string' ? $('<span>',{text:e}) : e) | |
)}; | |
// Usage: | |
$('.container').append( | |
<div> | |
<h1>Credens Justitiam</h1> | |
<p>Solti ola i <br /> |
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
/** | |
* This script takes a directory of images, looks for GPS | |
* coordinates in each file, and then writes the filename and | |
* decimal degrees to CSV. If you're pulling images off of your | |
* iPhone, using Image Capture is a quick way to move them onto | |
* your computer and get started. | |
* | |
* Make sure you have imagemagick installed: | |
* $ brew install imagemagick | |
* Download these files and install dependencies: |
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
// Usage: | |
// Start a XDCC download then use | |
// /eval [folowed with the code below] | |
(function down(i) { | |
let f = client.dcc.files, | |
s = f[f.length - 1].state, | |
_ = s.socketDisconnected; | |
s.socketDisconnected = () => { | |
_.call(s); | |
if (i === 1229) return; // LAST PACK NUMBER |
OlderNewer