Skip to content

Instantly share code, notes, and snippets.

View lean8086's full-sized avatar

Leandro Linares lean8086

View GitHub Profile
/* 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);
.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 / 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 / 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 / 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 / navigation-menu.js
Last active August 29, 2015 13:57
Improve the #navigation-menu behavior
(function (doc) {
var input = doc.getElementById('ml-header-user');
// Only works when a user menu exists (for logged users)
if (!input) return;
// Listen for every click on <html>
// The support for IE8+ was dropped because of lack of support of :checked pseudo-selector
doc.documentElement.addEventListener('click', function (ev) {
// Avoid to close if I click on the trigger. In that case, it will use CSS
if (input.checked && ev.target !== input && ev.target !== input.previousElementSibling) input.checked = false;
});
#include "MIDIUSB.h"
const byte TOTAL_BUTTONS = 16;
// All the Arduino pins used for buttons, in order.
const byte BUTTONS_PIN[TOTAL_BUTTONS] = {2,3,4,5,6,7,8,9,10,11,12,A0,A1,A2,A3,A4};
// Every pitch corresponding to every Arduino pin. Each note has an associated numeric pitch (frequency scale).
// See https://github.com/arduino/tutorials/blob/master/ArduinoZeroMidi/PitchToNote.h
const byte BUTTONS_PITCH[TOTAL_BUTTONS] = {36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};
// Current state of the pressed buttons.
byte currentRead[TOTAL_BUTTONS];