Skip to content

Instantly share code, notes, and snippets.

View aaronmccall's full-sized avatar

Aaron McCall aaronmccall

  • METER Group, Inc. USA
  • Kennewick, WA
View GitHub Profile
@aaronmccall
aaronmccall / timestamped_console.js
Created September 2, 2019 00:28
Add seconds.milliseconds at the end of every console call
const now = () => new Date().toISOString().replace(/^.*:([\d.]+)Z$/, '$1')
if (
process.env.NODE_ENV === 'development'
|| (localStorage.debug === 'true' && !console.__ts__)
) {
['log', 'debug', 'info', 'warn', 'error'].forEach(method => {
const original = console[method]
console[method] = (...args) => original.call(console, ...args, `| ${now()}`)
})
@aaronmccall
aaronmccall / People.coffee
Created January 4, 2017 22:21
How to replace coffee-react in your project
# Finally, ensure that all of your JSX in your components is in raw JS
import React from 'react'
export class People extends React.Component
onPersonClick: (personId) => @context.router.push("/people/#{personId}")
render: ->
{ data } = @props
`(
<div>
<h1>People</h1>
@aaronmccall
aaronmccall / Readme.md
Last active June 4, 2016 03:07
Example of oboe.js + pagination in &-collection

This was implemented for a real world application that was pulling in a large amount of data from multiple databases (SQL and MongoDB).

In order to improved TTFP (time to first page of results) and thus user-perceived performance, the API was converted to stream the results objects as it completed them.

Oboe.js allowed us to take advantage of that streaming API by parsing the incoming JSON stream on the browser-side.

@aaronmccall
aaronmccall / Readme.md
Last active June 4, 2016 02:44
An expirement

This was an experiment to come up with an efficient cache key generator for lat/lng origin/destination pairs.

It seemed to work pretty well, generating nearly a million keys in 66ms.

@aaronmccall
aaronmccall / debug.js
Last active August 29, 2015 14:13
some useful &.js debugging utils
var each = require('amp-each');
var isFunction = require('amp-is-function');
function debugMethods(prototype, handler) {
each(prototype, function (prop, name) {
if (isFunction(handler)) return handler(prop, name);
if (isFunction(prop)) {
prototype[name] = addLogger(prop, name);
}
});
@aaronmccall
aaronmccall / readme.md
Last active August 29, 2015 14:07
Script to see what top-level packages are outdated and then update them

Install

  1. Save the script below as update-outdated in your path.
  2. run chmod +x /path/to/update-outdated
  3. run update-outdated from the root of your project
  4. if you'd like to auto-update and save updated versions to your package.json, run again like so update-outdated -f
@aaronmccall
aaronmccall / datepicker.html
Created September 22, 2014 17:24
init jquery ui widget on first click
<input class="addDatepicker" name="date">
@aaronmccall
aaronmccall / repo_status.sh
Last active August 29, 2015 13:57
bash script to show git changed/new status of repos in a directory
#!/bin/bash
reset=$(tput sgr0)
green=$(tput setaf 2)
cyan=$(tput setaf 6)
magenta=$(tput setaf 5)
bold=$(tput bold)
for arg in $( ls | egrep '^dsm-' ); do
(
cd "$arg"
if [ -e "./package.json" ]; then
@aaronmccall
aaronmccall / update_package.sh
Last active August 29, 2015 13:57
bash script to npm i --save-exact an npm package/module in every repo in a directory
#!/bin/bash
if [ $# -lt 2 ]; then
echo "Usage: update_package <directory> <package> [optional: <version>]"
exit 1
fi
if [ "$3" ]; then
version=$3
else
@aaronmccall
aaronmccall / findWhere.js
Created March 24, 2014 23:19
Simple implementation of findWhere
// returns first matching list member
function findWhere(list, props) {
var idx = 0;
var len = list.length;
var match = false;
var item, item_k, item_v, prop_k, prop_val;
for (; idx<len; idx++) {
item = list[idx];
for (prop_k in props) {
// If props doesn't own the property, skip it.