Skip to content

Instantly share code, notes, and snippets.

View ThomasBurleson's full-sized avatar

Thomas Burleson ThomasBurleson

View GitHub Profile
@ThomasBurleson
ThomasBurleson / DelayedMessages.js
Created February 17, 2014 17:29
Example of using promise chains to delay and log messages. Uses Q Promises with setTimeout to create promise-based API delay() function.
/**
* Chain 2 Delay calls together in a non-nesting fashion
*/
function myDelayedMessages()
{
/**
* Delay function using Q promises and setTimeout() internally
*/
var delay = function( duration )
{
@ThomasBurleson
ThomasBurleson / verboseForLoop.js
Last active August 29, 2015 13:57
Demonstration of reducing a messy, verbose `for loop` using functional approach for terse, concise solution.
/**
* Traditional solution: For-loop usage
*/
function buildEpisodes(markers)
{
var result = [],i, newEpisode;
if (markers && markers.length > 0) {
for (i = 0; i < markers.length; i++) {
newEpisode = makeEpisode(markers[i]);
@ThomasBurleson
ThomasBurleson / UnderstandingClosures.js
Created April 11, 2014 02:49
JavaScript - Qualification Test (Senior) > Closures
function init(list)
{
var result = [ ];
for (var i=0; i<list.length; i++)
{
var item = 'item' + list[i];
result.push( function() {
console.log( item + ' ' + list[i]);
'use strict';
var _ = require('underscore');
module.exports = function () {
var proto,
injections = [];
// define constructor function
@ThomasBurleson
ThomasBurleson / StoryService.js
Created April 24, 2014 22:57
Using URLLookups with <xxx>Services to centralize all RESTful dataservice urls.
/**
* URLS before prefixing with ENDPOINT
*
* var URLS = { *
* STORY : {
* FIND_ALL : "/clients/{1}/stories.json"
* , LOAD_STORY : "/clients/{1}/stories/{2}.json"
* }
* USER : {
* LOAD_ALL : "clients/{0}/users.json"
@ThomasBurleson
ThomasBurleson / PromisePathways.js
Last active August 29, 2015 14:01
Example use of module pattern and angular.module() usage to easily group classes by context... without using AMD.
(function( angular, supplant ) {
"use strict";
angular.module( "Pathways", [ ] )
/**
* Loader for topology data models
*/
.service( "nodeLoader", function NodeLoader( $http )
{
function unkMH(req, res) {
var allowHeaders;
if (req.method.toLowerCase() === 'options') {
allowHeaders = ['Accept', 'Accept-Version', 'Content-Type', 'Api-Version', 'Authorization'];
if (res.methods.indexOf('OPTIONS') === -1) {
res.methods.push('OPTIONS');
}
res.header('Access-Control-Allow-Credentials', true);
res.header('Access-Control-Allow-Headers', allowHeaders.join(', '));

##Introducing ngAria

A new feature released in Angular 1.3.0 is the accessibility module: ngAria. As someone involved in with the development of this community-driven module, I thought it might be helpful to introduce ngAria. I'll also explain what the module can’t do and what issues you must consider when building accessible, single-page web applications with AngularJS.

The goal of ngAria is to improve Angular's default accessibility by enabling common ARIA attributes for directives. Using ngAria is as simple as requiring the ngAria module in your application. ngAria hooks silently hooks into standard AngularJS directives and quietly injects accessibility support into your application at runtime.

The list of supported directive attributes is currently limited; but we are identifying other ways the module can improve accessibility by default. To explain the current state

@ThomasBurleson
ThomasBurleson / docSearcher.js
Last active August 29, 2015 14:10
Enhanced version of `docSearcher` webWorker discussed in Pete Darwin's blog [AngularJS Docs Performance](http://www.bacondarwin.co.uk/angularjs-docs-performance/)
angular.module('search', [])
.service('docsSearch', ['$q','$rootScope','$timeout','NG_PAGES',BackgroundSearchService]);
/**
* Document search service that uses Web Workers to index
* and search in the background.
*/
function BackgroundSearchService($q, $rootScope, $timeout, NG_PAGES) {
console.log('Using WebWorker Search Index');
@ThomasBurleson
ThomasBurleson / sideNavDemo.html
Created March 1, 2015 13:56
Demonstration of how the SideNav component requires the Angular Material app to be defined/used.
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Material Test</title>
<link rel="stylesheet" href="https://rawgit.com/angular/bower-material/master/angular-material.css"/>
</head>
<body layout="column" ng-app="starterApp">
<md-toolbar layout="row">