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 / .gitignore
Last active August 29, 2017 22:30
my gitignore, which is essentially a live document as there are always cool new things to find and add.
#text editors
*.esproj
*.sublime-workspace
*.tmlanguage.cache
*.tmLanguage.cache
*.tmPreferences.cache
*.stTheme.cache
# project files should be checked into the repository, unless a significant
# number of contributors will not be using SublimeText which
(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 / 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 / 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 / WebApp-Document-Head.html
Last active May 5, 2023 16:48
Typically required meta tags, icons, startup images, stylesheets, etc. for Mobile Web Apps.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<!-- this viewport meta tag configures the mobile device viewport behavior -->
<meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<!-- this meta tag enables the web site to become a mobile web app (iDevices). See also: navigator.standalone -->
<meta name="mobile-web-app-capable" content="yes" />
@mattbontrager
mattbontrager / checkObjectLength-helper.js
Last active October 6, 2017 20:24
Check the length of a JavaScript Object as though it were an Array.
function checkObjectLength(obj) {
var key = 0;
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
key++;
}
}
return key;
}
@mattbontrager
mattbontrager / Geocode Handler
Created September 13, 2013 22:34
This method takes an address (string), geocodes it through google maps api, processes the results, and packages it up nicely in an object literal.
GeoKode: {
init: function geoKodeInit(addressString) {
!!App.development && console.log('in geoKodeInit');
var self = this, submissionString = addressString.replace(/ /g, '+'),
geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': submissionString}, function attemptingToGeoCode(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
console.log('geocode results: ', results);
$.each(results, function(i, result) {
@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() : "";
});
}