Skip to content

Instantly share code, notes, and snippets.

View say2joe's full-sized avatar
🏠
Codifying my code; possibly refactoring!

Joseph J. Johnson say2joe

🏠
Codifying my code; possibly refactoring!
View GitHub Profile
@say2joe
say2joe / enside.js
Last active January 5, 2020 03:51
Backbone Router (Controller) for iframe content. Includes bookmarking and routing support for navigating iframe content.
define(['rit','util/router','navIndicator'], function(RIT,Router) {
var $ = RIT.$, _ = RIT._, B = RIT.Backbone, Events = RIT.Events, self;
/**
* iEnside (/w enside.html) supports legacy Toyota connect and technology pages.
* Example uses include (URLs in browser's location / address bar, not iframe):
* http://local.rit.toyota.com/entune/enside.html#!/entune/learning-center/new-index.html
* http://local.rit.toyota.com/entune/enside.html#!phones (uses urls property object)
* http://local.rit.toyota.com/entune/enside.html (uses default route, "defRoute")
* @type {Router}
@say2joe
say2joe / switch.regexp.js
Created February 13, 2013 22:50
Use regular expressions in switch statements.
switch (true) {
case (/Chrome/).test(navigator.userAgent):
console.log("You're using Chrome.");
break;
case (/MSIE/).test(navigator.userAgent):
console.log("Unfortunately, you're using Internet Explorer");
break;
default:
console.log("You're using a different kinda browser.");
}
@say2joe
say2joe / ytIframe.js
Last active December 15, 2015 23:38
An iframe'd YouTube implementation wrapper.
/*! Reference: https://developers.google.com/youtube/iframe_api_reference/ */
/**
* Based on my original (admittedly) "rush" implementation. I
* will be refactoring this code in a module, based on use-cases driven by business
* reqs once they're more solidified. enableYouTubeAPI is
* invoked via a Backbone View's render method after page load (used on LPs).
*/
var MyNamespace = {
MySubModule: {
enableYouTubeAPI: function() {
@say2joe
say2joe / jsla.presentation.html
Last active December 16, 2015 16:40
JS.LA Presentation Template. Utilizes Google (Docs) Spreadsheet for presentation items.Use http://jsbin.com/gist/5464912 (JS Bin) for presentation visual. Used for my presentation on JavaScript Made Simple: Object Orientation.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta name="description" content="JS.LA - JavaScript Made Simple: Object Orientation" />
<title>JS.la Presents JavaScript Made Simple: Obect Orientation</title>
<style>
h4 pre {
border: 1px solid #ccc;
@say2joe
say2joe / object.debug.js
Last active December 23, 2015 23:09
Debug any JavaScript object's method invocations.
/**
* author: "Joe Johnson (say2joe@gmail.com)"
* Debug any JavaScript Object by inserting this code into your main JavaScript file.
* After initiating debugging on an object (ex. myObj.debug();), your console will
* log the name of a [named] function and its execution time. This helps when tracing
* the stack method calls with many objects and method calls.
* Note: this most likely only works for WebKit-based browsers supporting fn.name.
* Also, you may copy-paste this into console before running any event-based logic.
**/
@say2joe
say2joe / css-hacks-inputs.css
Last active December 24, 2015 02:59
CSS Hacks for Edge-Cases
/* Eliminate glow on input fields when focused */
input:focus { outline: none; }
@say2joe
say2joe / Gruntfile.js
Created October 10, 2013 19:47
Yeoman "webapp" Gruntfile customized for no dist build (only uses app directory) optimized for FED client delivery. Also, moves bower_components to scripts/vendor with no optimization, expecting both the minified (for page inclusion) and uncompressed js (for reference).
// Generated on 2013-09-24 using generator-webapp 0.4.1
'use strict';
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
// # Globbing
// for performance reasons we're only matching one level down:
@say2joe
say2joe / js-snippets.js
Created December 3, 2013 22:18
Small (few lines of code) snippets of JavaScript
// Return absolute path without domain or protocol:
path = location.href.replace(/(.+\w\/)(.+)/,"/$2");
// Node.js CheatSheet.
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@say2joe
say2joe / index.html
Created September 2, 2014 22:53
A Pen by Joe Johnson.
<form>
<input name="username" placeholder="username" />
<input name="password" type="password" placeholder="password" />
</form>