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 / top_of_the_props.js
Created November 14, 2012 15:33
Fitocracy helpers
var Totp = (function ($, _) {
var body = $(document.body),
btn = $('<button type="button" class="pill-btn red-btn" id="top_of_the_props">Top Proppers</button>'),
counts = {},
pub = {},
names = [],
template = "",
url = 'https://www.fitocracy.com/notifications/?start=0&end=1000000',
key, count, list, renderer;
@aaronmccall
aaronmccall / calcWeight.js
Created January 28, 2013 23:27
javascript function for calculating best weight given target weight, minimum increment, preferred increment and number of minimum increments available
/*
* Function to calculate optimum weight to use based on preferred and minimum weight increments
* Args:
* startingWeight: the target weight
* minIncrement: the smallest increment that weight can increase by
* prefIncrement: this is our normal smallest increment (typically 2 * 2.5 with most weight sets)
* minMultiplier: how many of our minimum increment are available before we must return to our preferred
* increment.
*/
function calcWeight(startingWeight, minIncrement, prefIncrement, minMultiplier) {
@aaronmccall
aaronmccall / resolver.js
Last active December 16, 2015 16:19
Eliminates the need to do obj && obj.prop && obj.prop.subprop testing
function resolver(prop_string, obj) {
if (!obj) return;
if (prop_string.indexOf('.') === -1) return obj[prop_string];
var props = prop_string.split('.'),
p = props.length,
result = obj,
i = 0,
prop;
for (; i<p; i++) {
prop = props[i];
@aaronmccall
aaronmccall / LICENSE.txt
Last active December 18, 2015 01:09 — forked from 140bytes/LICENSE.txt
recursaprop: Eliminates the need to do data && data.prop && data.prop.subprop testing when accessing properties of objects. Given a dot-notated property (foo.bar.baz) of an object, returns the property or undefined if it or any step in the path does not exist.
DO WHAT THE HECK YOU WANT TO PUBLIC LICENSE
Version 1, December 2013
Copyright (C) 2013 Aaron McCall <https://github.com/aaronmccall>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE HECK YOU WANT TO PUBLIC LICENSE
@aaronmccall
aaronmccall / findit.sh
Created July 31, 2013 13:32
Recursive find in files with line numbers
# Recursive find in files with line numbers
find directory/ -name "*.html" -exec grep -ni "my search here" {} +
@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.
@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 / 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 / datepicker.html
Created September 22, 2014 17:24
init jquery ui widget on first click
<input class="addDatepicker" name="date">
@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