Skip to content

Instantly share code, notes, and snippets.

View mattbontrager's full-sized avatar

Matt Rose mattbontrager

View GitHub Profile
@mattbontrager
mattbontrager / index.html
Created February 18, 2013 18:34
A CodePen by Chris Coyier.
<div class="page-wrap">
<section class="main-content">
<h1>Main Content</h1>
<p><strong>I'm first in the source order.</strong></p>
<p>The key to victory is discipline, and that means a well made bed. You will practice until you can make your bed in your sleep. Fry, we have a crate to deliver. Hey, guess what you're accessories to.</p>
<p>I'll get my kit! That's not soon enough! Oh, all right, I am. But if anything happens to me, tell them I died robbing some old man.</p>
</section>
<nav class="main-nav">
@mattbontrager
mattbontrager / camelCase.js
Created December 14, 2015 21:46
convert hyphenated or underscored strings to camelCase
function camelCase(method) {
return method.replace(/[-_\s]+(.)?/g, function(match, c) {
return c ? c.toUpperCase() : "";
});
}
@mattbontrager
mattbontrager / force_mobile_safari_link_click_from_webapp.js
Created May 18, 2013 03:25
Force a link to open in mobile safari from WebApp
@mattbontrager
mattbontrager / preload-images.js
Created April 17, 2013 22:01
Preloading images with Ajax.
window.onload = function() {
setTimeout(function() {
// XHR to request a JS and a CSS
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://domain.tld/preload.js');
xhr.send('');
xhr = new XMLHttpRequest();
xhr.open('GET', 'http://domain.tld/preload.css');
xhr.send('');
// preload image
@mattbontrager
mattbontrager / fetch-and-track-all-remote-branches.sh
Created October 21, 2016 20:54
Fetch and track all git branches
for remote in `git branch -r`; do git branch --track ${remote#origin/} $remote; done
git fetch --all
git pull --all
# credit to Wookie88 and Shadowfax @ http://stackoverflow.com/questions/10312521/how-to-fetch-all-git-branches
# saving this for quick reference and easy insertion.
@mattbontrager
mattbontrager / example-ajax-handler-with-promises.js
Last active March 29, 2017 20:11
Custom Ajax handler (with jQuery Promises)
var App = (function() {
/**
* a development flag to easily silence console.logging
* @type {Boolean}
*/
var development = true,
self;
return {
init: function init() {
(function() {
/* == GLOBAL DECLARATIONS == */
TouchMouseEvent = {
DOWN: "touchmousedown",
UP: "touchmouseup",
MOVE: "touchmousemove"
}
/* == EVENT LISTENERS == */
@mattbontrager
mattbontrager / Detect & Handle Touch Events
Last active June 9, 2017 19:15
Detect presence of touch events and handle accordingly (keeping for later development).
var hasTouch = 'ontouchstart' in document.documentElement,
touchStart = hasTouch ? 'touchstart': 'mousedown',
touchMove = hasTouch ? 'touchmove': 'mousemove',
touchEnd = hasTouch ? 'touchend': 'mouseup';
@mattbontrager
mattbontrager / git-commit.md
Created February 17, 2017 21:37 — forked from batjaa/git-commit.md
Git Commit Messages

Git Commit Messages

  • Use the Present Tense ("Add feature" not "Added feature").
  • Use the Imperative Mood ("Move cursor to..." not "Moves cursor to...").
  • Limit the subject line to 50 characters
  • Wrap the body at 72 characters
  • Reference issues and pull requests
  • When only changing documentation, include [ci skip] in the commit description
  • Be creative with emojies
  • 🎉 :tada: Initial commit
@mattbontrager
mattbontrager / gist:5fec210b2672ddbadd95f92dafdda922
Last active August 22, 2017 17:35 — forked from christofluethi/gist:646ae60d797a46a706a5
Convert m4a to mp3 on OS X command line using ffmpeg
brew update
brew link yasm
brew link x264
brew link lame
brew link xvid
brew install ffmpeg
ffmpeg wiki:
https://trac.ffmpeg.org/wiki/Encode/MP3