Skip to content

Instantly share code, notes, and snippets.

View bj7's full-sized avatar

Josh Bernitt bj7

View GitHub Profile
@bj7
bj7 / jsonDeepStringify.js
Last active March 25, 2017 16:38
Small recursive routine to deeply parse any object and convert all arrays into string lists. Helps when dealing with servers that limit http data parameters.
/**
* Recurse object and stringify any arrays. This helps when passing paremeters
* to a server since some servers may limit the number of distinct items in http requests.
* @param {Object} obj Object to parse
* @return {Object} Return the parsed object
*/
function jsonDeepStringify(obj) {
if (Object.prototype.toString.call(obj) == '[object Array]') {
obj = obj.join(',');
} else if (typeof (obj) == 'object') {
@bj7
bj7 / AlphaNumeric less than.js
Created July 28, 2016 12:09
This is an alphanumeric less than evaluator. It works on strings and numbers passed as arguments. When evaluating alphanumeric strings (string-1, string-2), it tests the string portion for equality, and if equal begins testing the numeric portion at the end.
/**
* Routine to compare numbers or strings and combinations thereof in terms
* of string1 < string2
*
* @param {Number|String} string1 First item to compare
* @param {Number|String} string2 Second item to compare
* @return {Boolean} True if string1 < string2, else false.
*/
var lessThan = function(string1, string2) {
// handle generic numbers
This is my atom editor sync gist
@bj7
bj7 / Custome Filter in Legacy Datatables.js
Created April 27, 2016 15:07
So apparently, Datatables applies custom filters globally, which will TOTALLY screw up your other tables. Recommended workaround is to test each table to ensure it’s the one to apply the filter to…What a joke. Easiest solution is to empty the array of custom filters and rebuild each time...
/**
* This function toggles the filter on campaigns with no clicks.
* @param {bool} toggle Boolean value of the toggled checkbox.
*/
$scope.toggleShowCampsNoClicks = function(toggle) {
// filter the table to show the appropriate entries
localStorage.setItem('thrivetracker_showCampsNoClicks', toggle);
$scope.showCampsNoClicks = toggle;
// custom filter extension for hiding columns with 0