Skip to content

Instantly share code, notes, and snippets.

View homestar9's full-sized avatar
🎯
Focusing

Dave L homestar9

🎯
Focusing
  • Angry Sam Productions, Inc.
  • Irvine, CA
View GitHub Profile
/**
* Parses API Document $extend notations recursively
*
* @param APIDoc The struct representation of the API Document
* @param [XPath] The XPath to zoom the parsed document to during recursion
**/
public function parseDocumentInheritance( required any DocItem ){
if( isArray( DocItem ) ) {
for( var i = 1; i <= arrayLen( DocItem ); i++){
/**
* Extends schema definitions based on the passed array of schema objects
* Note: Ignores CFML objects (non-structs) because sometimes the parser gets passed in here for some reason
*
* @objects
*/
function extendObject( array objects ) {
var output = {
"type": "object"
};
@homestar9
homestar9 / stripTags.cfm
Last active May 25, 2022 19:00
Strip HTML tags but allow some tags
<cfscript>
/**
* stripTags
* removes all html tags from a string (e.g. <p></p>)
* Inspired by: https://stackoverflow.com/questions/38811076/how-can-i-keep-sup-sub-html-tags-in-my-coldfusion-string-but-get-rid-of-al
*
* @input: the string to process
* @reIgnore: a regex of tags to ignore (e.g. </?su[bp])
*/
function stripTags( required string input, string reIgnore="" ) {
@homestar9
homestar9 / geolocation.js
Last active January 26, 2022 18:51
Geolocation Javascript
// default center position
var pos = {lat: 37.751918, lng: -122.450249};
if (navigator.geolocation) {
var options = {
//enableHighAccuracy: false,
timeout: 30000, // 30 seconds
maximumAge: 600000 // 10 minutes
};
@homestar9
homestar9 / DSNStore.cfc
Created January 24, 2022 18:00
DSN Store for Cachebox which uses the DSN set in Application.cfc. This was derived from the default JDBC Store.
/**
* Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
* www.ortussolutions.com
* ---
*
* I am a cool cool DSN Store for CacheBox. I use the DSN set up in Application.cfc.
* Derived from the JDBCStore which comes with Coldbox/Cachebox
* You may create the table first with the following columns
*
* id - varchar(100) PK
@homestar9
homestar9 / hashify.cfm
Created March 27, 2019 00:28
Hashify (UDF)
<cfscript>
/*
Hashify
http://brianflove.com/2015/02/24/hash-any-coldfusion-type/
*/
private string function hashify(required any value) {
//return an empty string for null
if (IsNull(arguments.value)) {
@homestar9
homestar9 / componentUtilities.cfm
Last active March 27, 2019 00:27
Component Utilities (UDF)
<cfscript>
/*
COMPONENT UTILITIES
This component houses frequently used functions for things like
exporting a DTO from a component.
hashing component properties, etc.
*/
/*
GET COMPONENT PROPERTY HASH
@homestar9
homestar9 / entity.cfc
Last active March 27, 2019 00:28
Base Entity Class
component
hint="I am the base class for all entities"
{
property name="dateCreated" type="any" getter="true" setter="false"; // think of this like date first persisted
property name="dateModified" type="any" getter="true" setter="false"; // think of this like date last persisted
property name="createdBy" type="numeric" getter="true" setter="false"; // first persisted by
property name="modifiedBy" type="numeric" getter="true" setter="false"; // last persisted by
/*