View cleanDEA.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Validate and clean a DEA Registration ID | |
* @param string $enteredValue user supplied DEA ID | |
* @param string $lastname OPTIONAL extended validation requires first letter of users last name to match corresponding character in ID | |
* | |
* @return string|bool returns sanitized alphanumeric DEA Registration ID or FALSE | |
*/ | |
function cleanDEA(string $enteredValue, string $lastname = '') { | |
//if a " Supervisee Identifier" was supplied, just ignore it |
View csv2json.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Read a CSV File an convert to JSON object | |
* Assumes first row is header data with column titles | |
* For Google Sheets, publish the sheet in csv format and use the provided URL | |
*/ | |
function csv2json($url) { | |
$csv = file_get_contents($url); | |
$rows = array_map("str_getcsv", explode("\n", $csv)); | |
$result = array(); |
View bulma_quick_notification.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* display a quick notification box that slides up from the bottom for a few seconds | |
*/ | |
function quickNotice(message,cssClass,timeOnScreen) | |
{ | |
cssClass = (cssClass) ? cssClass : 'is-success'; | |
timeOnScreen = (timeOnScreen) ? timeOnScreen : 3000; | |
var html = '<div id="quickNotice" style="position: absolute; z-index: 100; width: 100%" class="notification has-text-centered has-text-weight-semibold '+cssClass+'">'; | |
html+= message; |
View register-esc.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var escEvents = new Array(); | |
// If something needs to listen for the "ESC" key to be pressed, pass that functionality here | |
// eventName STRING a name for this event, like "myPopupDialog" | |
// eventFunction FUNCTION what to do when the user hits the escape key | |
function setEscEvent(eventName, eventFunction){ | |
escEvents.push({ eventName: eventName, eventFunction: eventFunction }); | |
} | |
// When an item doesn't need to listen for the "ESC" key anymore, remove it |
View set_app_path.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* set the server directory that this application is stored in. | |
* if applicaiton is in the root directory, set to "/" | |
*/ | |
$_app_server_path = rtrim(str_replace('\\', '/', dirname(__FILE__)),"/")."/"; // eg: "/home/ubuntu/workspace/my-website/" | |
$web_app_path = str_replace(rtrim($_SERVER['DOCUMENT_ROOT'],"/"),'',$_app_server_path); // eg: "/my-website/" or just "/" if in root |
View responsive-images.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// make all user uploaded images responsive | |
$(".user_uploaded_content_wrapper img").each(function(){ | |
var oldWidth = ($(this).width() > 0) ? $(this).width()+"px" : '100%'; | |
$(this).css({width:'100%', height:'auto', maxWidth:oldWidth}); | |
}); |
View required-fields-validation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var invalid_fields = 0; //global var can be accessed without calling function | |
function validate() | |
{ | |
invalid_fields = 0; // reset counter | |
$("[required]").each(function(){ | |
var val = $(this).val(); | |
if(val == "" || val == null || val.match('/select/i')) | |
{ |
View time_ago.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function time_ago($pastTime) | |
{ | |
$datetime1=new DateTime("now"); | |
$datetime2=date_create($pastTime); | |
$diff=date_diff($datetime1, $datetime2); | |
$timemsg=''; | |
if($diff->y > 0){ | |
$timemsg = $diff->y .' year'. ($diff->y > 1?"'s":''); | |
} |
View 0_reuse_code.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
NewerOlder