Skip to content

Instantly share code, notes, and snippets.

@SimonLlewellyn
SimonLlewellyn / greyscaleimg.css
Created May 2, 2017 00:30
Hover image remove greyscale - classy af
.imgclass img{
filter: grayscale(100%);
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
filter: grayscale(100%);
}
.imgclass img:hover{
filter: grayscale(0%);
-webkit-filter: grayscale(0%);
-moz-filter: grayscale(0%);
@SimonLlewellyn
SimonLlewellyn / crypt.cfc
Created May 2, 2017 00:27
Coldfusion Encrypt/Decrypt
<cfset application.pkey = "whateveryouwant">
<cffunction name="epwd" output="no" access="remote">
<cfargument name="pwd" required="yes">
<cfset done = Encrypt(arguments.pwd,application.pkey,'AES/CBC/PKCS5Padding','HEX')>
<cfreturn done />
</cffunction>
<cffunction name="dpwd" output="no">
<cfargument name="pwd" required="yes">
<cfset done = Decrypt(arguments.pwd,application.pkey,'AES/CBC/PKCS5Padding','HEX')>
@SimonLlewellyn
SimonLlewellyn / bool.cfc
Created May 2, 2017 00:25
Convert Bool
<cffunction name="convertBool" output="no">
<cfargument name="str" required="yes">
<cfif arguments.str eq "true"><cfreturn 1/></cfif>
<cfif arguments.str eq "yes"><cfreturn 1/></cfif>
<cfif arguments.str eq "on"><cfreturn 1/></cfif>
<cfif arguments.str eq "1"><cfreturn 1/></cfif>
<cfif arguments.str eq "false"><cfreturn 0/></cfif>
<cfif arguments.str eq "no"><cfreturn 0/></cfif>
<cfif arguments.str eq "off"><cfreturn 0/></cfif>
@SimonLlewellyn
SimonLlewellyn / share.js
Created May 2, 2017 00:21
Share to Facebook, Twitter, G+
function shareTwitter(title,url){
//url = encodeURI(url);
var t = title;
var lnk = "https://twitter.com/intent/tweet?text="+t+"&url="+url+"&via=NZBandGear";
window.open(lnk, 'mywin','left=50,top=50,width=600,height=350,toolbar=0');
return false;
}
//===========================================================================
function shareFacebook(url){
var lnk = "http://www.facebook.com/sharer.php?u="+url;
@SimonLlewellyn
SimonLlewellyn / wwwRedir.cfm
Created May 1, 2017 23:58
Redirect www from Application.cfc
//in Application.cfc
<cfset currentPath = "#cgi.request_url#">
<cfif find("www.",currentPath)>
<cfheader statuscode="301" statustext="Moved permanently">
<cfheader name="Location" value="http://domain.com">
<cfabort>
</cfif>
@SimonLlewellyn
SimonLlewellyn / daysRemaining.cfm
Created May 1, 2017 23:42
daysRemaining(date1,date2)
<cfscript>
function daysRemaining(date1,date2) {
var numDays = 0;
while (date1 LT date2) {
date1 = dateAdd("w",1,date1);
numDays = numDays + 1;
}
return numDays;
}
</cfscript>
@SimonLlewellyn
SimonLlewellyn / timeago.cfm
Last active May 1, 2017 23:40
CF Function - return how long ago a date/time was: timeAgoFormat(date).short
<cfscript>
function timeAgoFormat(date){
var interval = "";
var offset = 0;
var result = 0;
var res = structNew();
if (isDate(arguments.date)){
var formattedDate = dateFormat(arguments.date, "ddd dd mmm yy");
//& " at " & timeFormat(arguments.date, "HH:MM");