Skip to content

Instantly share code, notes, and snippets.

@sirbrad
sirbrad / Working with HTML5 Video
Created December 7, 2011 11:46
Code for when working with HTML5 Video
// Below code relies on Modernizr to do element support checks.
// Check format browser supports
(function format(){
return {
ogg: !!Modernizr.video.ogg,
webm: !!Modernizr.video.webm,
mp4: !!Modernizr.video.h264
}
}());
@sirbrad
sirbrad / Populate Inputs
Created February 17, 2012 16:46
Quickly populating inputs for testing purposes
var inp = document.getElementsByTagName('input'), len = inp.length;
while (len--) {
inp[len].value = 'test';
}
@sirbrad
sirbrad / dabblet.css
Created March 17, 2012 14:54
A carousel pagination built with CSS
/**
* A carousel pagination built with CSS
*/
body {
background:grey;
}
.nav {
list-style:none;
@sirbrad
sirbrad / dabblet.css
Created April 18, 2012 09:31
Untitled
.face {
border:1px solid #ccc;
display:block;
height:1.3em;
text-align:center;
width:1.3em;
border-radius:.8em
}
@sirbrad
sirbrad / dabblet.css
Created April 18, 2012 16:16
The Magic
.prod-listing {
list-style:none;
margin:0;
padding:0;
}
.prod__item {
border:1px solid #000;
float:left;
text-align:center;
@sirbrad
sirbrad / gist:2488644
Created April 25, 2012 10:02
Dynamically loading an external script with call back
var loadScript = function(url, callback) {
var d = document,
s = d.getElementsByTagName('script')[0],
done = false,
script = d.createElement("script");
script.type = "text/javascript",
script.src = url;
script.onload = script.onreadystatechange = function() {
if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
@sirbrad
sirbrad / gist:2490603
Created April 25, 2012 15:23
Finding specific elements
/*IE8+*/
function findElem(elem, va, arg, str){
var el = document.getElementsByTagName(elem),
len = el.length;
while (len--) {
// document.body["getAttribute"].call(elementToUseInstead, arg1, arg2, arg3)
@sirbrad
sirbrad / gist:2497921
Created April 26, 2012 09:10
For cloning a repo into a new repo
$ cd /directory
$ git clone /path/to/repo
$ mv /repo/with/contents/* .
$ rmdir /cloned/repo
@sirbrad
sirbrad / Content Choreography
Created April 30, 2012 09:32
Resemble the order of elements.
// Ref: http://www.jordanm.co.uk/post/21863299677/building-with-content-choreography
.container {
display:box;
display:-moz-box;
display:-webkit-box;
box-orient:vertical;
-moz-box-orient:vertical;
-webkit-box-orient:vertical;
}
@sirbrad
sirbrad / dabblet.css
Created June 25, 2012 15:10
Mobile first button abstraction
/**
* Mobile first button abstraction
*/
.btn {
display: block;
text-align: center;
text-decoration: none;
padding: 1em 0;
box-sizing: border-box;