Skip to content

Instantly share code, notes, and snippets.

View letsgetrandy's full-sized avatar

Randy letsgetrandy

View GitHub Profile
@letsgetrandy
letsgetrandy / setup-ui-testing.sh
Last active December 17, 2015 23:19
Setup script for UI testing tools (Mac, Linux)
#!/bin/bash
#
# Install UI tools
# - node
# - jshint
# - csslint
# - phantomjs
# - casperjs
# - specter
ARCDIR = /usr/local/share/arcanist
BINPATH = /usr/bin/arc
PHPPATH = /usr/bin/php
help:
@echo "no target specified."
@echo "try:"
@echo " make [ install | update | config_linters ]"
@echo ""
@letsgetrandy
letsgetrandy / uisetup
Created August 12, 2013 02:45
Install several handy tools for UI development and testing.
#!/bin/bash
#
# uisetup
#
# This script will install the basic tools and utilities used
# on the UI team, and then it will kick off another script to
# install the shared development stack used by all developers
# create ~/bin if not already exists
@letsgetrandy
letsgetrandy / fmtWholeNum.js
Last active January 19, 2017 19:49
Format whole numbers with commas at every 3rd digit.
function fmtWholeNum (num) {
var n = parseFloat(num.toString().replace(/[^\d\.]+/, '')),
s = Math.floor(n).toString();
return s.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")
}
@letsgetrandy
letsgetrandy / all.js
Created June 23, 2014 20:18
A few semantic functions for Javascript...
/**
* Returns TRUE if all arguments passed in can be evaluated as true.
* Otherwise, returns FALSE.
*/
function all() {
var i, l = arguments.length;
for (i = 0; i < l; i++) {
if (!arguments[i]) {
return false;
}
@letsgetrandy
letsgetrandy / brototype.js
Last active February 1, 2019 17:52
Bro, do you even?
if (Object.defineProperty) {
Object.defineProperty(Object.prototype, 'doYouEven', {
value: function(key) {
var props = (key || '').split('.'),
item = this;
for (var i=0; i<props.length; i++) {
item = item[props[i]];
if (typeof item === 'undefined') return false;
}
return true;
@letsgetrandy
letsgetrandy / rangemap.js
Last active August 29, 2015 14:07
Provide values for ranges
var Rangemap = function(points, values) {
this.points = points || [];
this.values = values || [];
};
Rangemap.prototype = {
"equalInRange": true,
"compare": function(a, b) {
if (a === b) {
return this.equalInRange;
function Color(r, g, b) {
if (Array.isArray(r)) {
colors = r;
} else if (!g && !b) {
colors = this.asRGB(r);
} else {
colors = [r, g, b];
}
this.r = colors[0];
this.g = colors[1];
// language exceptions
var exceptions = {
"are": "were",
"eat": "ate",
"go": "went",
"have": "had",
"inherit": "inherited",
"is": "was",
"run": "ran",
"sit": "sat",
function yo(fn) {
if (fn instanceof Function) {
this.listeners.push(fn);
} else {
_.each(this.listeners, function (listener) {
listener(fn);
})
}
}