Skip to content

Instantly share code, notes, and snippets.

@JDMcKinstry
JDMcKinstry / apiCCB.php
Last active July 22, 2019 18:39
Simple PHP class for interacting with the Church Community Builder (CCB) API.
<?
/***
* class apiCCB
*
* @author Jeremiah D. McKinstry <jdmckinstry@gmail.com>
* @date Wednesday, August 14, 2013
* @version 1.0.0
* @see https://cdn6.ccbchurch.com/2/documents/pwt_implement.pdf
*
* @copyright This class is free: you can redistribute it and/or modify
/** make_flat(Array)
* Simple method for flattening a multidimensional array
* @example make_flat([[1,2,[3]],4]) == [1, 2, 3, 4]
**/
function make_flat(arr) {
// simply make use of `reduce` method to to reduce each element to a single val
return arr.reduce(function(a, b) {
// if val is array, rerun thru, else, move on
return a.concat( Array.isArray(b) ? make_flat(b) : b );
},
;(function() {
/**
* AssociativeArray( { key: value } )
* AssociativeArray( key, value )
* AssociativeArray( [keys], [value] )
**/
function AssociativeArray() {
var args = Array.prototype.slice.call(arguments),
arr = [];
switch (true) {
/** isEmpty(varried)
* Simple method for testing if item is "empty"
**/
;(function() {
/**
* !a Basic empty check. Takes care of 90% of items passed through.
* 0 >= a Catchs '0' strings and empty Arrays
*
* /\{\}/.test(JSON.stringify(a).replace(/"[^"]*":(0|"0*"|false|null|\{\}|\[(null(,)?)*\]),?/g, '').replace(/"[^"]*":\{\},?/g, '')) // to determine Blank Object
* /|\[(null(,)*)*\]/.test(JSON.stringify(a).replace(/(0|"0*"|false|null|\{\}|\[(null(,)?)*\]),?/g, '')) // to determine Blank Array
;(function() {
function createOpenLink(href, oType) {
var objStyle = {
'padding': '1em',
'text-align': 'center'
},
strStyle = $.map(objStyle, function(v, k) { return k + ': ' + v; }).join('; ') + ';',
attrs = { 'href': href, 'style': strStyle, 'target': '_blank', 'text': 'Open ' + oType },
lnkOpen = $('<a />', attrs);
return lnkOpen;
;(function() {
if (/(\/$)|\/(hot|trending)/.test(location.href)) {
var art = $('article:first').clone(),
/* REPLACEMENTS MADE BELOW */
title = "YOU'RE AWESOME!", // replace between "" with what you want it to say
picLink = 'http://some.picture.com/pic.png', // replace this with a link to a pic you want on hots
profileLink = 'http://9gag.com/u/your_username'; // replace this with link to your profile
/* REPLACEMENTS MADE ABOVE */
img = $('<img />', { 'alt': "Your pic link is incorrect.", 'src': picLink }).addClass('badge-item-img');
art.find('.badge-item-title a').text(title);
@JDMcKinstry
JDMcKinstry / arrStateAreaSizes.js
Created September 6, 2016 14:43
Array of States Sizes in Mi and Km. Index is rank size with Alaska being 1 & RI at 50. DC set to 0, as it's not a state, and helps complete the array 0-50.
[
{
"District of Columbia": {
"sqmi":6825,
"sqkm":17675
}
},
{
"Alaska": {
"sqmi":663267,
@JDMcKinstry
JDMcKinstry / jQuery.outerHTML.js
Last active July 2, 2016 22:39
Simply adds outerHTML method to jQuery
;(function($) {
$.extend({
outerHTML: function() {
var $ele = arguments[0],
args = Array.prototype.slice.call(arguments, 1)
if ($ele && !($ele instanceof jQuery) && (typeof $ele == 'string' || $ele instanceof HTMLCollection || $ele instanceof Array)) $ele = $($ele);
if ($ele && $ele.length) {
if ($ele.length == 1) return $ele[0].outerHTML;
else return $.map($("div"), function(ele,i) { return ele.outerHTML; });
}
@JDMcKinstry
JDMcKinstry / instagram.desktop.links.js
Created June 22, 2016 21:59
Makes it easy to open Instagram images and videos in separate links when using IG on Desktop
var cjsSelector = '';
;(function() {
var iDoIt = 1;
function doIt() {
/* ↓↓↓ DO WORK IN HERE ↓↓↓ */
jQuery(cjsSelector).remove();
/* ↑↑↑ DO WORK IN HERE ↑↑↑ */
iDoIt = iDoIt < 10 ? iDoIt + 1 : 1;
setTimeout(doIt, iDoIt * 1000);
}