Skip to content

Instantly share code, notes, and snippets.

View d33pfri3d's full-sized avatar
🏠
Working from home

Shaun D d33pfri3d

🏠
Working from home
View GitHub Profile
@d33pfri3d
d33pfri3d / jquery.ba-tinypubsub.js
Created March 8, 2012 22:09 — forked from cowboy/HEY-YOU.md
jQuery : Tiny Pub Sub
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function($) {
var o = $({});
$.subscribe = function() {
o.on.apply(o, arguments);
@d33pfri3d
d33pfri3d / gist:2003803
Created March 8, 2012 22:15 — forked from paulirish/gist:366184
HTML5 : Geolocation with Fallback
// geo-location shim
// currentely only serves lat/long
// depends on jQuery
;(function(geolocation){
if (geolocation) return;
var cache;
@d33pfri3d
d33pfri3d / phonegapCamera.js
Created March 8, 2012 22:17 — forked from matsumotius/phonegapCamera.js
Phonegap : Camera
function getPicture(){
navigator.camera.getPicture(function(data){
// success handler
alert('success');
}, function(){
// error handler
alert('error');
}, {
// options
quality: 50
@d33pfri3d
d33pfri3d / dabblet.css
Created March 8, 2012 22:53
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height:100%;
@d33pfri3d
d33pfri3d / gist:2005383
Created March 9, 2012 06:51
jQuery : Ajax Deferred
$.X = function(){
var deferred = new $.Deferred();
// DO AJAX
/*
$.ajax({
// Do Ajax Call
url: '',
//Success
@d33pfri3d
d33pfri3d / gist:2013170
Created March 10, 2012 20:56
HTML : BeginTemplate
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
@d33pfri3d
d33pfri3d / gist:2138353
Created March 20, 2012 17:23
JQUERY : Animation Deferred
$.when(this.animate({"width": 50}), 2000).done(function(){
// DO SOMETHING
});
@d33pfri3d
d33pfri3d / Micro $
Created April 27, 2012 10:24
Micro $ Selector
var $ = function (d) {
var $ = document.querySelectorAll.bind(document);
Element.prototype.on = Element.prototype.addEventListener;
NodeList.prototype.on = function (event, fn) {
[].forEach.call(this, function (el) {
el.on(event, fn, false);
});
};
@d33pfri3d
d33pfri3d / Alt DD
Created June 8, 2012 11:49
Drag and Drop
var root = document.documentElement;
root.addEventListener('dragover', cancel, false);
root.addEventListener('dragend', cancel, false);
root.addEventListener('drop', drop, false);
function cancel(event){
event.preventDefault();
}
@d33pfri3d
d33pfri3d / History API
Created June 8, 2012 13:14
JQUERY: History API
$('a[href^="/"]').click(function(e){
var target = e.currentTarget;
if (!e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey){
e.preventDefault();
url = target.pathname;
navigate(url, {triggered: true});
}
});
function navigate(url, data){