Skip to content

Instantly share code, notes, and snippets.

View pedrochaves's full-sized avatar

Pedro Chaves pedrochaves

View GitHub Profile
@pedrochaves
pedrochaves / gist:9690776
Last active August 29, 2015 13:57
Esboço simples de scroll infinito
(function($) {
var // Distância entre o fundo da tela e a altura. Quanto maior o valor, mais rapido ele vai buscar
threshold = 200,
is_searching = false,
doc_height,
$d;
updateReferences();
// Só dispara o evento quando o usuário para o scroll. Depois de 150ms
@pedrochaves
pedrochaves / jQuery.stringify.js
Created March 1, 2012 16:54 — forked from chicagoworks/jQuery.stringify.js
jQuery.stringify() utility
/**
* converted stringify() to jQuery plugin.
* serializes a simple object to a JSON formatted string.
* Note: stringify() is different from jQuery.serialize() which URLEncodes form elements
* UPDATES:
* Added a fix to skip over Object.prototype members added by the prototype.js library
* USAGE:
* jQuery.ajax({
* data : {serialized_object : jQuery.stringify (JSON_Object)},
@pedrochaves
pedrochaves / gist:1709844
Created January 31, 2012 10:43
Small JavaScript function to create python-like string formatting (without the type of the variable)
var str_tpl = function (str, map) {
var prop;
str = str + '';
for (prop in map) {
if (map.hasOwnProperty(prop)) {
str = str.replace('%(' + prop + ')', map[prop]);
}
}