Skip to content

Instantly share code, notes, and snippets.

View LiamChapman's full-sized avatar

Liam Chapman LiamChapman

View GitHub Profile
@LiamChapman
LiamChapman / html5_tags_support.js
Created February 21, 2014 22:34
129 bytes to enable HTML5 on old browsers (copied from: https://coderwall.com/p/qkkx9g)
;("header footer section aside nav article figure figcaption hgroup time").replace(/\w+/g,function(a){document.createElement(a)})
@LiamChapman
LiamChapman / css_each_animate.js
Created May 7, 2014 08:34
Little JS / jQuery function for adding classes with a delay for animations.
function cssEachAnimate(items, animation_name, delay) {
items.each(function (i) {
var item = $(this);
setTimeout(function () {
item.addClass(animation_name)
}, delay * i);
});
}
@LiamChapman
LiamChapman / inside_iframe.js
Created June 4, 2014 12:51
A little snippet to check if in an iFrame. Handy for apps on Facebook.
var inIframe = window.location !== window.parent.location;
@LiamChapman
LiamChapman / isTouch.js
Created June 5, 2014 13:37
Var to detect if device is touch enabled. Handy for conditional mobile and tablet code.
var isTouch = 'ontouchstart' in document.documentElement;
@LiamChapman
LiamChapman / console.js
Created June 6, 2014 14:10
Simple bit of code for setting a console so there are no errors. There are many ways to do this, but this is a quick approach.
if (typeof console == "undefined") {
window.console = {
log: function () {}
};
}
@LiamChapman
LiamChapman / canvas_support.js
Created June 11, 2014 13:34
canvas support
function isCanvasSupported (){
var elem = document.createElement('canvas');
return !!(elem.getContext && elem.getContext('2d'));
}
@LiamChapman
LiamChapman / restrict
Created June 11, 2014 13:42
restrict site with password login via apache .htaccess etc..
SetEnvIf HOST "mydomain.dev" local_env
AuthType Basic
AuthName "My Website"
AuthUserFile /document_root/path/for/project/.htpasswd
Require valid-user
Deny from all
Allow from env=local_env
Satisfy any
@LiamChapman
LiamChapman / ms-bkg-size.css
Created June 11, 2014 14:45
A little bit of css to fix background-size issues in ie8
-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, src='imageandpath.png', sizingMethod=scale)";
background-image: none;
@LiamChapman
LiamChapman / susy_grid_bkg_less.css
Created June 16, 2014 21:12
Less Mixin for showing column grid found in Susy SASS. You can change the rgba values.. Currently defaults to a light blue and 12 columns at 4em and 1em gutter
.susy-grid-bkg (@r: 100, @g: 100, @b: 225, @a: 0.25) {
background-image: -webkit-gradient(linear, 0% 50%, 100% 50%, color-stop(0%, rgba(0, 0, 0, 0)), color-stop(0%, rgba(@r, @g, @b, @a)), color-stop(6.77966%, rgba(@r, @g, @b, @a)), color-stop(6.77966%, rgba(0, 0, 0, 0)), color-stop(8.47458%, rgba(0, 0, 0, 0)), color-stop(8.47458%, rgba(@r, @g, @b, @a)), color-stop(15.25424%, rgba(@r, @g, @b, @a)), color-stop(15.25424%, rgba(0, 0, 0, 0)), color-stop(16.94915%, rgba(0, 0, 0, 0)), color-stop(16.94915%, rgba(@r, @g, @b, @a)), color-stop(23.72881%, rgba(@r, @g, @b, @a)), color-stop(23.72881%, rgba(0, 0, 0, 0)), color-stop(25.42373%, rgba(0, 0, 0, 0)), color-stop(25.42373%, rgba(@r, @g, @b, @a)), color-stop(32.20339%, rgba(@r, @g, @b, @a)), color-stop(32.20339%, rgba(0, 0, 0, 0)), color-stop(33.89831%, rgba(0, 0, 0, 0)), color-stop(33.89831%, rgba(@r, @g, @b, @a)), color-stop(40.67797%, rgba(@r, @g, @b, @a)), color-stop(40.67797%, rgba(0, 0, 0, 0)), color-stop(42.37288%, rgba(0, 0, 0, 0)), color-stop(42.37288%, rg
@LiamChapman
LiamChapman / laravel_remove_public_url
Created June 19, 2014 14:24
Laravel's .htaccess to remove "public" from URL - put in the root. Good for when on something like heroku
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>