Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View thedaviddias's full-sized avatar
🌍

David Dias thedaviddias

🌍
View GitHub Profile
@thedaviddias
thedaviddias / CSS: Image Replacement
Created September 28, 2012 22:17
CSS: Image Replacement
.ir {
border: 0;
font: 0/0 a;
text-shadow: none;
color: transparent;
background-color: transparent
}
@thedaviddias
thedaviddias / gist:3820132
Created October 2, 2012 15:27
Iphone: hide url bar
<script>
window.onload = function() {
setTimeout(function(){window.scrollTo(0, 1);}, 100);
}
</script>
@thedaviddias
thedaviddias / gist:3820197
Created October 2, 2012 15:32
Iphone: detect iphone
<script>
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)))
{location.href='http://m.website.com';}
</script>
@thedaviddias
thedaviddias / gist:3820265
Created October 2, 2012 15:42
Iphone: orientation
<script>
if (!isNaN(window.orientation)) {
var orientation = (window.orientation == 0 || window.orientation == 180) ? "portrait" : "landscape";
$("body").addClass(orientation);
} else {
// Choose layout depending on viewport width
var orientation = ($(window).width() < 980) ? "portrait" : "landscape";
$("body").addClass(orientation);
}
@thedaviddias
thedaviddias / rAF.js
Created October 3, 2012 06:41 — forked from paulirish/rAF.js
Polyfill: requestAnimationFrame
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller
// fixes from Paul Irish and Tino Zijdel
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
@thedaviddias
thedaviddias / gist:3826280
Created October 3, 2012 10:31
CSS3: stitch effect (tiret)
.stitched {
height:100px;
width:500px;
padding: 5px 10px 5px 10px;
margin: 15px;
background: #e2e2e2;
border: 2px dashed rgba(255,255,255,0.4);
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
border-radius: 6px;
@thedaviddias
thedaviddias / gist:3898494
Created October 16, 2012 10:15
JAVASCRIPT: Make it safe to use console.log always
// usage: log('inside coolFunc', this, arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
log.history = log.history || []; // store logs to an array for reference
log.history.push(arguments);
arguments.callee = arguments.callee.caller;
if(this.console) console.log( Array.prototype.slice.call(arguments) );
};
// make it safe to use console.log always
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});
@thedaviddias
thedaviddias / gist:3905236
Created October 17, 2012 12:17
SASS: mixin for retina-ready images
div.logo {
background: url("logo.png") no-repeat;
@include image-2x("logo2x.png", 100px, 25px);
}
@mixin image-2x($image, $width, $height) {
@media (min--moz-device-pixel-ratio: 1.3),
(-o-min-device-pixel-ratio: 2.6/2),
(-webkit-min-device-pixel-ratio: 1.3),
@thedaviddias
thedaviddias / get_barcode_from_image.js
Created October 21, 2012 14:36 — forked from tobitailor/get_barcode_from_image.js
Barcode recognition with JavaScript - Demo: http://bit.ly/djvUoy
/*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*/
(function(){
var UPC_SET = {
"3211": '0',
"2221": '1',
"2122": '2',
@thedaviddias
thedaviddias / normalize.css
Created November 5, 2012 09:48 — forked from THEtheChad/normalize.css
Minified Normalize CSS Reset
/*! normalize.css 2012-02-07T12:37 UTC - http://github.com/necolas/normalize.css */article,aside,details,figcaption,figure,footer,header,hgroup,nav,section,summary{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}[hidden]{display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}html,button,input,select,textarea{font-family:sans-serif}body{margin:0}a:focus{outline:thin dotted}a:hover,a:active{outline:0}h1{font-size:2em;margin:.67em 0}h2{font-size:1.5em;margin:.83em 0}h3{font-size:1.17em;margin:1em 0}h4{font-size:1em;margin:1.33em 0}h5{font-size:.83em;margin:1.67em 0}h6{font-size:.75em;margin:2.33em 0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}blockquote{margin:1em 40px}dfn{font-style:italic}mark{background:#ff0;color:#000}p,pre{margin:1em 0}pre,code,kbd,samp{font-family:monospace,serif;_font-family:'courier new',monospace;font-size:1em}pre{white-space:pre;white-space:pre-wrap;word-wrap:break-word