Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mattLummus
mattLummus / spaRoutingProgEnhacement.txt
Last active August 29, 2015 14:21
SPA Routing w/ Progressive Enhancement
A structural issue I've been thinking about a lot lately is routing in single page apps.
S.P.A.'s are great. They can increase speed (== UX++) and reduce the load on your server.
However, routing can be tricky and they can become a barrier to progressive enhancement.
1. How to set up your server side routing
Server can accept either hash uri's (/#/foo/bar) or hashless uri's (/foo/bar)
These should have the same result with the exception of the client not reloading the page when the hash is present
2. On an initial page load, serve pre-rendered html on the initial request.
@mattLummus
mattLummus / caps.js
Last active August 29, 2015 14:21
JS capitalize shim
function caps(str) {
return str.replace(str[0], str[0].toUpperCase());
}
@mattLummus
mattLummus / AddThis toolbox
Created May 29, 2014 18:58
Social-Media Share Buttons for Squmblr project (NSS Cohort 4)
.addthis_toolbox.addthis_default_style.addthis_32x32_style
%a.addthis_button_facebook
%a.addthis_button_twitter
%a.addthis_button_tumblr
%a.addthis_button_pinterest_share
%a.addthis_button_compact
%script{src: "//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-538759146c05abe0", type: "text/javascript"}
@mattLummus
mattLummus / Ruby Koans Scoring Project Answer
Last active August 29, 2015 13:58
Ruby Koans Scoring Project Answer
def score(dice)
score = 0
#checks for empty array
if dice == []
return score
else
#avoids double counting
tempdice = dice.uniq
dice.sort!
@mattLummus
mattLummus / prio Backup Data
Last active August 29, 2015 13:57
CSS styles for priorisize interface (js) and example data for d3-force collapsible
//d3
var graph = {'name':'Project', 'children':[
{'name':'analytics', 'children':[
{'name':'cluster', 'children':[
{'name':'AgglomerativeCluster', 'size':3938},
{'name':'CommunityStructure', 'size':3812},
{'name':'HierarchicalCluster', 'size':6714},
{'name':'MergeEdge', 'size':743}
]},
{'name':'graph', 'children':[
@mattLummus
mattLummus / Team.populate
Last active August 29, 2015 13:57
DB population for teams in Find My Fans project
//admin.js (browser)
Team.requestInfo(sport, fn){
//calls ESPN for [team objects] by sport
fn(record)
}
//teams.js (routes)
Team.pullData(data, sport, leagueName, leagueShortName){
var object = {};