Skip to content

Instantly share code, notes, and snippets.

Avatar
🤦‍♂️
Coding

Zander Martineau mrmartineau

🤦‍♂️
Coding
View GitHub Profile
@mrmartineau
mrmartineau / getViewportSize.js
Created Apr 15, 2012 — forked from scottjehl/getViewportSize.js
Reliably get viewport dimensions in JS
View getViewportSize.js
/*!
An experiment in getting accurate visible viewport dimensions across devices
(c) 2012 Scott Jehl.
MIT/GPLv2 Licence
*/
function viewportSize(){
var test = document.createElement( "div" );
test.style.cssText = "position: fixed;top: 0;left: 0;bottom: 0;right: 0;";
@mrmartineau
mrmartineau / gist:2717799
Created May 17, 2012 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts
View gist:2717799

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
View gist:2940821
if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i)) {
$(document).ready(function () {
$('label[for]').click(function () {
var el = $(this).attr('for');
if ($('#' + el + '[type=radio], #' + el + '[type=checkbox]').attr('selected', !$('#' + el).attr('selected'))) {
return;
} else {
$('#' + el)[0].focus();
}
});
@mrmartineau
mrmartineau / rAF.js
Created Jul 24, 2012 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
View rAF.js
// 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) {
@mrmartineau
mrmartineau / app.min.js
Last active Dec 15, 2015
Sublime Closure Compile Build Script. Use a batchfile or shell script to determine which files should be concatinated and minified, then reference that in your Sublime build script
View app.min.js
/** //@ sourceMappingURL=app.min.js.map
*/
console.log('foo');console.log('bar');
@mrmartineau
mrmartineau / grunt-watch-livereload-subtask.js
Last active Dec 18, 2015
Grunt watch task for compiling scss, js and trigerring a livereload
View grunt-watch-livereload-subtask.js
livereload: {
options: { livereload: true },
files: [
// When these files are changed, livereload is triggered
// Make sure this directory is the same as the one your site points to
'resources/css/styles.css'
]
}
@mrmartineau
mrmartineau / inc-dec.json
Last active Dec 18, 2015
Out of date Sublime Text 2 settings
View inc-dec.json
[
{ "keys": ["alt+up"], "command": "inc_dec_value", "args": { "action": "inc_min" } },
{ "keys": ["alt+down"], "command": "inc_dec_value", "args": { "action": "dec_min" } },
{ "keys": ["super+up"], "command": "inc_dec_value", "args": { "action": "inc_max" } },
{ "keys": ["super+down"], "command": "inc_dec_value", "args": { "action": "dec_max" } },
{ "keys": ["super+alt+up"], "command": "inc_dec_value", "args": { "action": "inc_all" } },
{ "keys": ["super+alt+down"], "command": "inc_dec_value", "args": { "action": "dec_all" } }
]
@mrmartineau
mrmartineau / jquery-fallback.html
Created Jun 9, 2013
Provide two versions of jQuery, one for old browsers and one for new. See more details at http://martineau.tv/blog/2013/06/two-versions-of-jquery/
View jquery-fallback.html
<!--[if lte IE 8]>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="/js/libs/jquery.min.js"><\/script>')</script>
<![endif]-->
<!--[if gt IE 8]><!-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="/js/libs/jquery.2.min.js"><\/script>')</script>
<!--<![endif]-->
@mrmartineau
mrmartineau / jquery.data.code.block.js
Created Jul 13, 2013
Dave Rupert's data code block jQuery plugin
View jquery.data.code.block.js
/* jshint jquery:true */
/* Author: Dave Rupert
* License: WTFPL
----------------------*/
(function($){
'use strict';
$.fn.dataCodeBlock = function(){