Skip to content

Instantly share code, notes, and snippets.

View lean8086's full-sized avatar

Leandro Linares lean8086

View GitHub Profile
@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 / 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 / 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/';
.reblogr {
position: absolute;
right: 5px;
top: 5px;
}
.reblogr a {
background-color: rgba(0, 0, 0, 0.5);
float: left;
margin-left: 3px;
/* Hexagon kitty - By @LeaVerou
Disappointingly inflexible, but still interesting methinks.
*/
.hexagon {
display: inline-block;
position: relative;
width: 200px;
height: 200px;
transform: scale(1.25,.707) rotate(-45deg);
@lean8086
lean8086 / konami.js
Last active December 11, 2015 20:58
/**
* Konami Code
* @example
* konami(function () {
* alert("easter egg!");
* });
*/
function konami(success) {
var keys = '',
@lean8086
lean8086 / delete-script.js
Created December 5, 2012 03:57
How to self-delete a script
// Create the "script" element
var script = document.createElement('script');
// Append
document.getElementsByTagName('head')[0].appendChild(script);
// Delete
script.parentNode.removeChild(script);
@lean8086
lean8086 / text-size-adjust.css
Created December 3, 2012 23:15
Prevents text size adjust after orientation change, without disabling user zoom
html {
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
@lean8086
lean8086 / tap-highlight.css
Created December 3, 2012 22:54
Hide the translucent highlight when elements with hyperlinks are tapped
a {
/* iOS: Actions without the gray overlay */
-webkit-tap-highlight-color: rgba(0,0,0,0);
/* iOS: Remove the actions panel */
-webkit-touch-callout: none;
}