Skip to content

Instantly share code, notes, and snippets.

View lean8086's full-sized avatar

Leandro Linares lean8086

View GitHub Profile
@lean8086
lean8086 / extension.js
Created August 7, 2012 14:30
Get the file extension of a string
function getFileExtension(string) {
"use strict";
return string.split(".").pop();
}
@lean8086
lean8086 / rAF.js
Created August 18, 2012 20:13 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
// requestAnimationFrame polyfill by Erik Möller
// Fixes from Paul Irish and Tino Zijdel
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
(function (w) {
"use strict";
var lastTime = 0,
vendors = ["ms", "moz", "webkit", "o"],
len = vendors.length,
@lean8086
lean8086 / animation-shorthand.css
Created September 9, 2012 02:34
Formal grammar for CSS Animation shorthand
/**
* Property + initial value
*/
-webkit-animation: name:none duration:0s timing-function:ease delay:0s iteration-count:1 direction:normal fill-mode:none;
@lean8086
lean8086 / ucfirst.js
Created October 2, 2012 19:43
Uppercase to the first letter of a string
function ucfirst (string) {
return string[0].toUpperCase() + string.substr(1);
}
@lean8086
lean8086 / em.css
Created November 7, 2012 03:05
Getting "1em" in pixels in JavaScript
#em {
width: 1em;
visibility: hidden;
pointer-events: none;
position: absolute;
}
@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;
}
@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 / konami.js
Last active December 11, 2015 20:58
/**
* Konami Code
* @example
* konami(function () {
* alert("easter egg!");
* });
*/
function konami(success) {
var keys = '',
/* 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);