Skip to content

Instantly share code, notes, and snippets.

View ivanionut's full-sized avatar
🎯
Focusing

Ivan Ionut ivanionut

🎯
Focusing
View GitHub Profile
/* Simple spam protection for email addresses using jQuery.
* Well, the protection isn’t jQuery-based, but you get the idea.
* This snippet allows you to slightly ‘obfuscate’ email addresses to make it harder for spambots to harvest them, while still offering a readable address to your visitors.
* E.g.
* <a href="mailto:foo(at)example(dot)com">foo at example dot com</a>
* →
* <a href="mailto:foo@example.com">foo@example.com</a>
*/
$(function() {
<!--------------------------------------
Credit for the upload part (with some changes):
http://www.anujgakhar.com/2011/11/29/directly-uploading-a-file-to-amazon-s3-with-railo/
Performance improvements:
- store file initially in virtual disk first (ram://), do resize then write to s3
- define s3 path as railo mapping
- set region to correct region (defaults to us i believe)
---------------------------------------->
<!---
Does a URL exist? Checks that host exists and for
404 status code.
http://www.forta.com/blog/index.cfm?mode=day&day=2&month=1&year=2006
--->
<cffunction name="urlExists" output="no" returntype="boolean">
<!--- Accepts a URL --->
<cfargument name="u" type="string" required="yes">
<!--- Attempt to retrieve the URL --->
<!-- CODE
NAME
DESC
STATUS
MERGED
MAIN CATEGORY
SPACER
SUB CATEGORY
SPACER
SUB CATEGORY 3
<cffunction name="sanitizeEmailList" access="public" returnType="String" output="false">
<cfargument name="emailList" type="String" required="true" />
<cfset var local = {} />
<cfset local.email = '' />
<cfset local.RegEx = "[a-z0-9!##$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!##$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"/>
<cfloop list="#arguments.emailList#" index="local.i">
<cfset local.address = ReMatch(local.RegEx,local.i)/>
<cfif ArrayLen(local.address)>
<cfset local.email = ListAppend(local.email,local.address[1]) />
</cfif>
<!---
Function Name : numberToLetter()
Author : Ryan Spencer
Created : 22/05/2012
General Notes : convert a number into a letter similar to how excell columns work.
Function in :
number (int)
<cffunction name="MidLeft" returntype="string" output="no" hint="Returns numChars characters from the left side of startPos in the string">
<cfargument name="stringVal" type="string" required="yes" default="">
<cfargument name="startPos" type="numeric" required="yes" default="1">
<cfargument name="numChars" type="numeric" required="yes" default="0">
<!--- If startPos exceeds length of string argument then start picking characters from string end position --->
<cfif arguments.startPos gt len(arguments.stringVal)>
<cfset arguments.startPos = len(arguments.stringVal)>
</cfif>
<cfset var fromPos = arguments.startPos - arguments.numChars + 1>
<cfcomponent>
<cffunction name="csvToQuery">
<cfargument name="data" default="">
<cfargument name="cols" default="">
<cfargument name="delimiter" default=",">
<cfscript>
<cfcomponent name="PostMarkAPI" hint="Send email messages using Postmarkapp.com API">
<cffunction name="sendMail" output="false" access="remote" returntype="struct" returnformat="json" description="Assembles JSON packet and sends it to Postmarkapp">
<cfargument name="mailTo" required="true" type="string" displayname="Recipient" />
<cfargument name="mailFrom" required="true" type="string" displayname="Sender" default="xxx@xxx.com" />
<cfargument name="mailSubject" required="true" type="string" displayname="Subject" default="Testing Postmark" />
<cfargument name="apiKey" required="true" type="string" displayname="API key" default="xxx-xxx-xxx-xxx" />
<!--- optional --->
<cfargument name="mailReply" required="false" type="string" displayname="Reply-To (optional)" />
<cfargument name="mailCc" required="false" type="string" displayname="CC (optional)" />
<cfargument name="mailHTML" required="false" type="string" displayname="HTML body (optional)" />
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048