Skip to content

Instantly share code, notes, and snippets.

View mattkelley's full-sized avatar

Matt mattkelley

  • Austin, TX
  • 01:15 (UTC -05:00)
View GitHub Profile
@mattkelley
mattkelley / element_interface.js
Created August 27, 2015 19:21
element_interface.js
// Import lo-dash lang category
import lang from 'lodash/lang';
// Import lo-dash template string function
import stringTemplate from 'lodash/string/template';
// import assign from 'lodash/object/assign';
import forEach from 'lodash/collection/foreach';
// Loop through configs stored and return the matching config (value) element (key)
function reverseMapFind(id, map) {
@mattkelley
mattkelley / gist:83ff906ff86ce953abf2
Last active August 29, 2015 14:01
Trim long domains in a string
// truncate function from - http://stackoverflow.com/a/5723274
var truncate = function (fullStr, strLen, separator) {
if (fullStr.length <= strLen) return fullStr;
separator = separator || '...';
var sepLen = separator.length,
charsToShow = strLen - sepLen,
frontChars = Math.ceil(charsToShow/2),
backChars = Math.floor(charsToShow/2);
@mattkelley
mattkelley / gist:51b6384c6b7163e8c371
Last active August 29, 2015 14:03
Load external stylesheet jQuery
var externalFile = $.ajax({ type:'GET', url:'http://example.com/style.css', dataType:'text' });
externalFile.done(function() {
console.log('The external stylesheet has loaded with great success');
});
externalFile.fail(function() {
console.log('The external stylesheet failed to load');
});
@mattkelley
mattkelley / gist:0b75bbb69130e679165c
Last active August 29, 2015 14:03
Stop black screen on html5 video playback
function vidHack(event){
if (Mtime === 0) {
console.log('I happen once')
var timecode = event.timeStamp;
Mtime++;
} else {
videoM.classList.remove('zero');
videoM.muted= false;
console.log('I happen once after play');
videoM.removeEventListener("timeupdate", vidHack, false);
@mattkelley
mattkelley / invdExplore.js
Created July 11, 2014 17:35
app structuring with prototype
'use strict';
// Setup the explore tab
function InvdExplore(){
// get some elements
this.left = document.getElementById('invd-left');
this.right = document.getElementById('invd-right');
this.shield = document.getElementById('invd-shield');
this.shifter = document.getElementById('shifter'); // temp - demonstrating slow a tags
/**
* Pass Bootstrap $screen-size or pixel string to generate media queries
*
Small
$screen-xs-max
$screen-sm-min
$screen-sm-max
Medium
$screen-md-min
@mattkelley
mattkelley / index.html
Created August 18, 2014 18:55
vprint bizz card
<canvas id="card" width="500" height="300">Your browser does not support this Application.</canvas>
<form>
<input id="text-input" placeholder="Matt Kelley" />
<select id="textFont">
<option value="item1">Item 1</option>
<option value="item2">Item 2</option>
<option value="item3">Item 3</option>
<option value="item4">Item 4</option>
@mattkelley
mattkelley / test.php
Created September 9, 2014 21:13
transitentcaching
function me2_nav_get_cities() {
$cache_key = 'me2_navigation_cities';
/* Cache length in hours */
$cache_time = 1;
// For Debug
//delete_transient( $cache_key );
@mattkelley
mattkelley / scratch.js
Created September 10, 2014 14:03
some setup utility for IVP
function extend(out) {
out = out || {};
for (var i = 1; i < arguments.length; i++) {
if (!arguments[i])
continue;
for (var key in arguments[i]) {
if (arguments[i].hasOwnProperty(key))
{
"device": {
"text": "Samsung S4",
"manual": "http://www.fake.com/sgs4.pdf",
"legal": "Android is a trademark of Google, Inc. Use of this trademark is subject to Google Permissions. Gmail and the Gmail logo are trademarks of Google, Inc. Google and the Google logo are trademarks of Google, Inc. \"SAMSUNG\" is a trademark of SAMSUNG in the United States or other countries. Unauthorized use or duplication of these marks is strictly prohibited by law.",
"layout": {
"frame": {
"width": 280,
"height": 550
},