Skip to content

Instantly share code, notes, and snippets.

View StoneCypher's full-sized avatar

John Haugeland StoneCypher

View GitHub Profile
@StoneCypher
StoneCypher / ts.js
Last active August 25, 2018 05:05
comment time; make generic the name of the range label
function timeString(userMilliseconds) {
var // the actual data ranges. now trivial to extend
ranges = [
{ range: 86400, singular: 'day', plural: 'days' },
{ range: 3600, singular: 'hour', plural: 'hours' },
{ range: 60, singular: 'minute', plural: 'minutes' },
{ range: 1, singular: 'second', plural: 'seconds' }
],
@StoneCypher
StoneCypher / show-between.directive.js
Last active August 29, 2015 14:02 — forked from callumacrae/show-between.directive.js
Patch for simplification requested on IRC. Regards lines 23,24, vs 23-31 in the original.
'use strict';
/* global angular */
var app = angular.module('playground', []);
app.directive('showBetweenHours', function () {
return {
restrict: 'AC',
link: function (scope, element, attrs) {
@StoneCypher
StoneCypher / Learning JS.md
Created March 18, 2018 18:48 — forked from Ehawk82/LearningJS.md
(Jason's) experience in learning JS

Scope & Timeline. Troubleshooting takes time and it's painful when the problem is because of where something is written in respect to other things. "Return functions". I wish i learned to do this earlier. Instead of writing "document.get[thing]" over and over again sucks. So creating a return function in my global object is a great timesaver... something like UI.bySelect("#tag") and UI.byTag("body"). I believe this is also a good way to learn how to use parameters Parameters. Specifically about the scope of where a variable is named. I found that there are times where i'll use "x", "y" for a generic variable to pass as a parameter. This means the previous function will try to pass their variable in those spots. This is something to pay attention to when using more than two parameters Using setTimeout() to delay a className change. This is something that i spent a lot of time and code on to do things, only to find out that a simple timeout can delay a change momentarity. This is important when l