Skip to content

Instantly share code, notes, and snippets.

View GaryStanton's full-sized avatar
💭
Tinkering

Gary Stanton GaryStanton

💭
Tinkering
View GitHub Profile
@GaryStanton
GaryStanton / objectifyForm.js
Last active February 15, 2019 10:12 — forked from joseph-tran-tn/objectifyForm.js
Convert form data to JavaScript object with jQuery Ask Question
function objectifyForm(formArray) { //serializeArray data function
var returnArray = {};
for (var i = 0; i < formArray.length; i++){
returnArray[formArray[i]['name']] = ((formArray[i]['name'] in returnArray) ? returnArray[formArray[i]['name']] + ',' + formArray[i]['value'] : formArray[i]['value']);
}
return returnArray;
}
@GaryStanton
GaryStanton / phaser-3-utils.js
Created October 21, 2018 16:06
Phaser 3 utils
/*
Phaser 3 utility functions
Author: Gary Stanton
*/
/**
* Get GID from a tileset by property and value
* @param {Phaser.Tilemaps.Tileset} tileset - A Phaser Tileset object
* @param {string} name - The name of the property to inspect
<cffunction name="S3_PutObject" access="public" returntype="struct">
<cfargument name="Bucket" type="string" required="true" hint="The name of the bucket to which you would like to upload the file" />
<cfargument name="FilePath" type="string" required="true" hint="Full path of the file you would like to upload" />
<cfargument name="BucketPath" type="string" required="true" hint="Path within your bucket, to which you would like this file to be added" />
<cfargument name="AccessControl" type="string" default="Private" hint="Access level to grant to this file (Private / PublicRead)" />
<cfscript>
try {
// Check file exists
if (NOT fileExists(Arguments.FilePath)) {
@GaryStanton
GaryStanton / calculateArrivalDate.cfm
Last active February 2, 2016 17:06
Calculate an arrival date (e.g. for a package being shipped), taking into account a cut off time, business days and public holidays.
<!---
Calculate arrival date for a package, taking into account working days and public holidays
--->
<cffunction name="calculateArrivalDate" access="public" returnType="struct" output="false" hint="Returns information about the arrival of a shipment based on a shipping date and shipping length">
<cfargument name="OrderDate" type="date" default="#Now()#" hint="Date shipment is hoped to take place - i.e. the date an order is made" />
<cfargument name="cutOffTime" type="string" default="#CreateTime(15, 0, 0)#" hint="Cut off time for a shipment to occurr on the same day" />
<cfargument name="businessDays" type="string" default="2,3,4,5,6" hint="Days of the week (1 = Sunday) that may be considered a business day in this context" />
<cfargument name="arrivalDays" type="string" default="2,3,4,5,6" hint="Days of the week (1 = Sunday) that a package may be delivered in this context" />
<cfargument name="shippingLength" type="string" default="2" hint="Amount of time in days, expected fo
@GaryStanton
GaryStanton / closestNumberInList.cfm
Last active August 29, 2015 14:00
Returns the closest number in a list to the given value - CFML
<cffunction name="closestNumberInList" returntype="numeric" hint="Returns the closest number in a list to the given value">
<cfargument name="Value" type="numeric" required="true" hint="A number to convert to the nearest in our list">
<cfargument name="List" type="string" required="true" hint="A list of valid numbers we can return">
<cfscript>
var Local = {};
// Convert list to array
Local.ListArray = ListToArray(Arguments.List);