Skip to content

Instantly share code, notes, and snippets.

@theashcraig
theashcraig / parseFields.js
Last active November 20, 2018 04:19
Javascript String extend that parses a string with object data
/*
A javascript string extend that makes it easy to parse through
text to replace placeholder fields with live data
*/
if (String.prototype.parseFields == null) String.prototype.parseFields = function (str, obj) {
Object.keys(obj).forEach(function (key) {
str = str.split(key).join(obj[key]);
});
return str;
@theashcraig
theashcraig / rejected-poller.php
Last active October 30, 2018 20:39
Find rejected ACH transactions returned from the bank by polling the Bluepay reporting API
<?php
/*
Polls the Bluepay reporting API to discover transactions that have been rejected
due to insufficient funds or other common reasons.
Grabs the output and organizes into an associative 'rejected' array that is easy
to parse. From here, you can easily find and update the failed transaction
to a 'collection' status.
*/
@theashcraig
theashcraig / getJobResults.php
Last active August 1, 2018 19:43
Example of how to create an associative array from Bluepay's batch upload delineated results output
<?php
/*
************************
************************
quick and dirty example of
how check for a completed job
using the Bluepay Batch Upload
Reporting API and how to convert
the CSV results data to an
associative array - including all
@theashcraig
theashcraig / validate-password.js
Last active January 29, 2017 01:40
Quick and dirty jQuery snippet to validate password for length, numbers and capital letters.
/*
Quick and dirty jquery snippet to validate password for length, numbers and capital letters.
example: this will check password for 8-16 chars, at least one number and at least two capital letters
password = _verifyPassword(password, 8, 16, 1, 2);
*/
function _verifyPassword(str, lengthMin, lengthMax, intCount, capitalCount) {
@theashcraig
theashcraig / phone-number-formatter-validator.php
Created January 28, 2017 08:58
PHP snippet that validates and formats 10 digit US phone numbers from user input.
/*
1. strips formatting from inputted phone numbers
2. validates it has 10 digits
3. creates US formatted phone number (XXX) XXX-XXXX
4. returns empty string if invalid.
Turns this: 555-123-1233 0r 5551231233 into this: (555) 123-1233
var $formattedPhone = phoneNumberPretty($userInputtedPhone);
@theashcraig
theashcraig / phone-number-formatter-validator.js
Last active January 28, 2017 09:10
jQuery snippet that validates and formats 10 digit US phone numbers from user input.
/*
1. strips formatting from inputted phone numbers
2. validates it has 10 digits
3. creates US formatted phone number (XXX) XXX-XXXX
4. returns empty string if invalid.
Turns this: 555-123-1233 0r 5551231233 into this: (555) 123-1233
var formattedPhone = phoneNumberPretty(userInputtedPhone);