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
/**
* JavaScript code for Steelhouse coding exercise.
* Any CSS is provided in the upper CSS directory.
*/
'use strict';
/**
Write a function that takes a single argument, lines, which is a list of
strings. Each element of lines is a line of prose from some passage. You will
return a list of strings that is read "downward", as opposed to left-to-right.
@say2joe
say2joe / viewReporting.js
Last active October 27, 2016 18:35
Angular View (vm integrated with legacy app code /wo ng routing)
(function($){
'use strict';
var $appRoot, auth, APIs, app = {},
tmpl = com.marketshare.optimizer.template,
reportCategoryKeys = 'nav-report-categories',
ns = 'com.marketshare.optimizer.view.viewReporting';
function updateNavigation(event) {
var $itemsHolder,
@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");
@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 / 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 / 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 / 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 / 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 / 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 / jQuery.fn.formData.js
Created November 30, 2012 00:13
jQuery extension for form GET requests requiring comma-separated values.
/**
* Extend jQuery with additional functionality to be used throughout app.
*/
$.fn.extend({
/** formData:
* Most form submissions will require special formatting different from
* a normal get request (a=val1,val2&b=val3 vs. a=val1&a=val2&b=val3).
* Sample use: $.getJSON(url,$("myFormElement").formData(),callback);.
* @return {String} Serialized form data appropriate for GET requests.
* @author Joe Johnson