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
<?php
function removeEmoji($text) {
$clean_text = "";
// Match Emoticons
$regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u';
$clean_text = preg_replace($regexEmoticons, '', $text);
// Match Miscellaneous Symbols and Pictographs
@GiancarloGomez
GiancarloGomez / cleanEmoji.cfc
Last active September 11, 2016 14:30
Simple function that sends a string to the clean_emoji.php using a cfhttp call and returns a string with all emoji removed. https://gist.github.com/GiancarloGomez/e62928a665ef796464137bafc6cb20ec (http://www.giancarlogomez.com/2016/09/emoji-support-with-coldfusion-and-mysql.html)
string function cleanEmoji(required string value){
var gotourl = "/clean_emoji.php";
var php = new http(url:gotourl,method:"post");
php.addParam(type:"formfield",name:"value",value:arguments.value);
// Return trimmed response
return trim(php.send().getPrefix().fileContent);
}
@GiancarloGomez
GiancarloGomez / my_emoji_safe.cnf
Last active September 7, 2016 05:19
Setting required to support utf8mb4 in mySQL server. This example was pulled from the following post => https://mathiasbynens.be/notes/mysql-utf8mb4 (http://www.giancarlogomez.com/2016/09/emoji-support-with-coldfusion-and-mysql.html)
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
@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,"")
@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
<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 / 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()
})
@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 / 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 / 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)('|"))