Skip to content

Instantly share code, notes, and snippets.

function getPasswordStrength(pass) { /* 100% = r4R#$3fR5$h&K6n@yU^ */
var v = pass + '';
var regSymbols = new RegExp(/`|~|!|@|#|\$|%|\^|&|\*|\(|\)|_|-|\+|=|{|}|\[|]|\\|\||:|;|"|'|<|>|,|\.|\?|\//g),
regConsecutiveSymbols = new RegExp(/(`|~|!|@|#|\$|%|\^|&|\*|\(|\)|_|-|\+|=|{|}|\[|]|\\|\||:|;|"|'|<|>|,|\.|\?|\/){2,}/g);
var z = {
size: v.length
, numbers: v.match(/[0-9]/g)
, caseLower: v.match(/[a-z]/g)
, caseUpper: v.match(/[A-Z]/g)
@JDMcKinstry
JDMcKinstry / JStoIntArray.js
Created February 26, 2016 15:34
Converts a String into an Array of Numbers
if (Object['defineProperty'] && !String.prototype.hasOwnProperty('toIntArry')) Object.defineProperty(String.prototype, "toIntArry", {
// b = split character/phrase
// c = boolean wether to keep periods or not
value: function(b, d) {
b || (b = "");
var a = this.split(b), c;
for (c in a) a[c] = parseFloat(a[c].replace(d ? /[^0-9|.]/g : /[^0-9]/g, "").replace(/^0+/g, ""));
return a.filter(function(a) { return a === a })
}
});
@JDMcKinstry
JDMcKinstry / JSisValidTag.js
Created February 25, 2016 20:55
Easy way to test if created element is a valid Tag for current browser
Object.defineProperty && !Element.prototype.hasOwnProperty("isValidTag") ? Object.defineProperty(Element.prototype, "isValidTag", {
value: function(b) {
if (this.tagName) {
var c = "acronym applet basefont bgsound big blink center dir font frame frameset hgroup isindex listing marquee multicol nextid nobr noembed noframes plaintext spacer strike tt xmp".split(" "),
a = this.tagName;
return a.match(/[^a-zA-Z0-9]/) ? !1 : -1 !== b && -1 !== c.indexOf(a.toLowerCase()) ? b || !1 : "[object HTMLUnknownElement]" !== Object.prototype.toString.call(document.createElement(a))
}
return !1
}
}) :
@JDMcKinstry
JDMcKinstry / JStoInt.js
Created February 25, 2016 20:54
Convert string to Int || Float
if (Object['defineProperty'] && !String.prototype.hasOwnProperty('toInt')) Object.defineProperty(String.prototype, 'toInt', { value: function() { return parseFloat(this.replace(/[^0-9|.]/g, '').replace(/^0+/g, '')); } });
// Get any string into an INT or FLOAT, if it has a period
"jafs98y934hrqrjn34.wf.4e3whtw0g78sbenh bsghers.".toInt() // 9893434
"a1b2@&%92.234dfg.64%^564j.thyj5.67!~56.3453 v3".toInt() // 1292.234
"55.66.77".toInt(); // 55.66
"$4.55".toInt(); // 4.55
@JDMcKinstry
JDMcKinstry / jsRandString.js
Created February 25, 2016 20:48
JS Easy way to create Random String
if (Object['defineProperty'] && !String.hasOwnProperty('rand')) Object.defineProperty(String,"rand",{value:function(){function f(a){for(var c=(Math.random()*eval("1e"+~~(50*Math.random()+50))).toString(36).split(""),b=3;b<c.length;b++)b==~~(Math.random()*b)+1&&c[b].match(/[a-z]/)&&(c[b]=c[b].toUpperCase());c=c.join("");c=c.substr(~~(Math.random()*~~(c.length/3)),~~(Math.random()*(c.length-~~(c.length/3*2)+1))+~~(c.length/3*2));if(24>a)return a?c.substr(c,a):c;c=c.substr(c,a);if(c.length==a)return c;for(;c.length<a;)c+=f();return c.substr(0,a)}var d=arguments,a,e;if(!d.length)return f();for(var b=0;b<d.length;b++)"string"==typeof d[b]&&d[b].length&&!a&&(a=d[b]),"number"==typeof d[b]&&d[b]&&!e&&(e=d[b]);if(!a&&!e)return f();if(!a)return f(e);if(!e){a=window.btoa(escape(encodeURIComponent(a))).replace(/[^\w]/g,"");a=a.split("");for(b=a.length-1;0<b;b--){var d=Math.floor(Math.random()*(b+1)),g=a[b];a[b]=a[d];a[d]=g}return a.join("")}a=window.btoa(escape(encodeURIComponent(a))).replace(/[^\w]/g,"");b=f(e-a.length)
@JDMcKinstry
JDMcKinstry / denCode.js
Created February 25, 2016 20:43
Easy way to get base64 encode and decode of a string
if (Object['defineProperty'] && !String.prototype.hasOwnProperty('deCode')) Object.defineProperty(String.prototype, 'deCode', { value: function() { return decodeURIComponent(unescape(window.atob(this))); } });
if (Object['defineProperty'] && !String.prototype.hasOwnProperty('enCode')) Object.defineProperty(String.prototype, 'enCode', { value: function() { return window.btoa(escape(encodeURIComponent(this))); } });
var a = 'GitHub'.enCode(); // a = "R2l0SHVi"
var b = a.deCode(); // b = "GitHub"
@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
/* Example Plug-in Setup */
(function($) {
if (!$.myExample) { // check your plugin namespace does not already exist
$.extend({ // this will allow you to add your plugin to the jQuery lib
myExample: function(elm, command, args) {
// keep in mind, right here you might want to do a class or data check to determine which direction this call is going
// for example, upon init the plugin on an element you may add the plugin name as a class,
// this way, when it's recalled, you can see it alrady has that class and might be calling a command,
// thus make an if statemnt to push the process through
return elm.each(function(index){
@JDMcKinstry
JDMcKinstry / main.css
Last active December 18, 2015 07:29 — forked from bmegod/gist:5731771
/* ==========================================================================
Globals
========================================================================== */
@font-face {
font-family: 'GaramondPro';
src: url('fonts/AGaramondPro-Regular.otf');
font-weight: normal;
font-style: normal;
}
@JDMcKinstry
JDMcKinstry / index.html
Last active December 18, 2015 07:29 — forked from bmegod/gist:5731763
<!DOCTYPE html>
<html class="no-js">
<head>
<!-- Include meta data first, although this is slowly becoming less read by modern browsers -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="cache-control" content="no-cache" />
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">