Skip to content

Instantly share code, notes, and snippets.

View GiancarloGomez's full-sized avatar
🛩️
Music, Aviation, Code ....

Giancarlo Gomez GiancarloGomez

🛩️
Music, Aviation, Code ....
View GitHub Profile
@GiancarloGomez
GiancarloGomez / uach.cfm
Created May 26, 2021 23:52
User Agent Client Hints - Request and Render
<cfscript>
headerList = "Sec-CH-UA-Arch,Sec-CH-UA-Full-Version,Sec-CH-UA-Mobile,Sec-CH-UA-Model,Sec-CH-UA-Platform-Version,Sec-CH-UA-Platform,Sec-CH-UA";
cfheader(name:"Accept-CH",value:headerList);
for ( key in headerList )
writeOutput(key & " : " & cgi[lcase(key)] & "<br />");
</cfscript>
@GiancarloGomez
GiancarloGomez / local-dates.html
Last active August 11, 2021 17:49
Date updates using moment and moment timezone
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<ul>
<!-- If date is from a specific timezone to your local -->
@GiancarloGomez
GiancarloGomez / local-dates.js
Last active December 1, 2020 18:57
Using moment.js and jQuery to render a local date inside an element that has a UTC value in a data-date attribute
// requires moment.js and jQuery
/**
* @value A datetime string value formatted as 01/01/01 12:00:00 AM
*/
function convertDateToLocal( value ){
return moment( value.replace(/\s(GMT|UTC)/,'') )
.add( moment().utcOffset(),'m' )
.format( 'MM/DD/YYYY hh:mm:ss A' );
}
@GiancarloGomez
GiancarloGomez / invalid_cfsqltype.regex
Last active September 28, 2021 13:53
Find Invalid CF SQL Types using this RegEx search in you IDE - set to case insensitive
cfsqltype(\s)?(=|:)(\s)?('|")(?!(cf_sql_bigint|cf_sql_bit|cf_sql_char|cf_sql_blob|cf_sql_clob|cf_sql_date|cf_sql_decimal|cf_sql_double|cf_sql_float|cf_sql_idstamp|cf_sql_integer|cf_sql_longnvarchar|cf_sql_longvarchar|cf_sql_money|cf_sql_money4|cf_sql_nchar|cf_sql_nclob|cf_sql_nvarchar|cf_sql_numeric|cf_sql_real|cf_sql_refcursor|cf_sql_smallint|cf_sql_sqlxml|cf_sql_time|cf_sql_timestamp|cf_sql_tinyint|cf_sql_varchar|bigint|bit|char|blob|clob|date|decimal|double|float|idstamp|integer|longnvarchar|longvarchar|money|money4|nchar|nclob|nvarchar|numeric|real|refcursor|smallint|sqlxml|time|timestamp|tinyint|varchar)('|"))
@GiancarloGomez
GiancarloGomez / coldfusion-ftpsclient.cfc
Last active August 30, 2019 18:48
ColdFusion-org.apache.commons.net.ftp.FTPSClient-Example
try{
ftpsClient = CreateObject("java","org.apache.commons.net.ftp.FTPSClient").init(JavaCast("boolean",true));
// set server address to connect to and begin
ftpsClient.connect("yourserver.com",990);
// set credentials
loggedIn = ftpsClient.login("username","password");
if (loggedIn){
//enter passive mode
ftpsClient.enterLocalPassiveMode();
// Set protection buffer size
@GiancarloGomez
GiancarloGomez / createODBCDateTimeError.cfc
Created March 5, 2019 15:40
ColdFusion 2018 ODBC Date Error
// this is for example purpose only. Not actual values used
today = "01/01/2019";
// use to work but generates an error now
createODBCDateTime(today & "23:59:59");
// throws 01/01/201923:59:59 is an invalid date or time string.
// required fix ( add the required space )
createODBCDateTime(today & " 23:59:59");
@GiancarloGomez
GiancarloGomez / delete-netflix-history.js
Created June 12, 2018 04:44
Netflix History Delete
let _year = new Date().getYear()-100;
let _regex = new RegExp(`/${_year}$`);
document.querySelectorAll('.retableRow').forEach(a => {
let _date = a.querySelector('.date');
if( !_regex.test(_date.innerText) )
a.querySelector('.deleteBtn').click()
})
<cfscript>
// Usage
appSecret = "You App Secret Here";
theUser = parseSignedRequest(form.signed_request,appSecret);
// if succesful you will see the entire struct
writeDump(theUser);
// the user id will be available as follows
writeOutput(theUser.user_id);
@GiancarloGomez
GiancarloGomez / SessionAgentCheck.cfm
Last active September 6, 2016 21:40
An example Struct using the ColdFusion MobileDetect CFC : https://github.com/GiancarloGomez/ColdFusion-MobileDetect/
<cfscript>
session.agentCheck = {
version : MobileDetect.getVersion(),
checkedOn : now(),
isMobile : MobileDetect.isMobile(),
isTablet : MobileDetect.isTablet(),
isIpad : MobileDetect.isIPad(),
isAndroid : MobileDetect.isAndroidOS(),
isIOS : MobileDetect.isIOS(),
// Example of how to define a Cordova app when using the AppendUserAgent option in the Config.xml
@GiancarloGomez
GiancarloGomez / cleanEmojiWithColdFusion.cfc
Last active September 11, 2016 14:29
Simple function that cleans emoji's from a string using Java's String replaceAll() function. Previous to this the solution used was => https://gist.github.com/GiancarloGomez/0e76348c89df8f3b72fddfe7843cbceb (http://www.giancarlogomez.com/2016/09/emoji-support-with-coldfusion-and-mysql.html)
public string function cleanEmojiWithColdFusion(required string value){
// Match Emoticons
var regexEmoticons = "[\x{1F600}-\x{1F64F}]";
// Match Miscellaneous Symbols and Pictographs
var regexSymbols = "[\x{1F300}-\x{1F5FF}]";
// Match Transport And Map Symbols
var regexTransport = "[\x{1F680}-\x{1F6FF}]";
// Return cleaned and trimmed string
return arguments.value
.replaceAll(regexEmoticons,"")