Skip to content

Instantly share code, notes, and snippets.

View lean8086's full-sized avatar

Leandro Linares lean8086

View GitHub Profile
.reblogr {
position: absolute;
right: 5px;
top: 5px;
}
.reblogr a {
background-color: rgba(0, 0, 0, 0.5);
float: left;
margin-left: 3px;
@lean8086
lean8086 / tumblr_loader.js
Last active December 14, 2015 11:09
Progressive image loader + infinite scroll
(function (win) {
'use strict';
var doc = win.document,
scrollTop,
pagination = doc.getElementsByClassName('pagination')[0],
loadingPosts = false,
xhr = new win.XMLHttpRequest(),
page = 1,
nextHref = win.location.href + (win.location.pathname === '/' ? '' : '/') + 'page/';
@lean8086
lean8086 / jQuery-variable-bindings.js
Created March 5, 2013 21:18
Bind multiple *variable events* on jQuery/Zepto
var enter = (mobile ? 'touchstart' : 'mouseenter'),
leave = (mobile ? 'touchend' : 'mouseleave'),
events = {};
events[enter] = function () { ... }
events[leave] = function () { ... }
$('selector').on(events);
@lean8086
lean8086 / obstrusive_while.js
Created March 5, 2013 21:13
Walk through a collection killing each walked position
var elements = [el1, el2, elN];
while (elements.length) {
elements.shift(); // This is the element
}
@lean8086
lean8086 / php_image_proxy.php
Created July 16, 2013 21:19
Image proxy made for Weat in 2010.
<?php
// Requires "file", "size" and "default" parameters
if (!isset($_REQUEST["file"]) || !isset($_REQUEST["size"]) || !isset($_REQUEST["default"])) {
die("Expected to find \"file\", \"size\" and \"default\" parameters.");
}
// URL of file
$url = $_REQUEST["file"];
@lean8086
lean8086 / rAF2.js
Created August 25, 2012 03:58
Updated requestAnimationFrame pollyfill
var lastTime = 0,
currTime,
timeToCall,
id;
window.requestAnimationFrame = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.msRequestAnimationFrame ||
window.oRequestAnimationFrame ||
@lean8086
lean8086 / friendlyDate.php
Created May 22, 2012 19:34
Get a friendly date from unformated date
function friendlyDate($s) {
$minutes = (time() - strtotime($s)) / 60;
if ($minutes < 1) return "Seconds ago";
if ($minutes < 2) return "1 minute ago";
if ($minutes < 60) return floor($minutes)." minutes ago";
$hours = $minutes / 60;