Skip to content

Instantly share code, notes, and snippets.

View ivanionut's full-sized avatar
🎯
Focusing

Ivan Ionut ivanionut

🎯
Focusing
View GitHub Profile
@JamoCA
JamoCA / isAjaxRequest.cfm
Last active August 29, 2015 14:01
This ColdFusion 8-11 UDF will query the server's request headers to determine if the request is an Ajax form post from jQuery. (jQuery adds a special header to all ajax requests.)
<!-- Compatible with ColdFusion 8-11.
4/28/2015 Rewritten to compensate for new undocumented CF10/11 behavior regarding getHTTPRequestData().
https://bugbase.adobe.com/index.cfm?event=bug&id=3042675
https://bugbase.adobe.com/index.cfm?event=bug&id=3581691
http://www.bennadel.com/blog/2824-gethttprequestdata-may-break-your-request-in-coldfusion-but-gethttprequestdata-false-may-not.htm
--->
<cffunction name="isAjaxRequestPost" output="false" returntype="boolean" access="public">
<cfset var response = StructNew()>
<cfset response.AjaxHeader = getPageContext().getRequest().getHeader("X-Requested-With") />
@coldfumonkeh
coldfumonkeh / README.md
Last active August 29, 2015 14:14
Server Detection Scriptlet.. (WTF is a scriptlet?)

ColdFusion Server Detection

This is a re-imagineering of a ColdFusion code block found here: https://github.com/webdevsourcerer/CF-Server-Detect

It is actually originally noted as a ColdFusion Scriptlet but we have NO frickin' idea what a ColdFusion Scriptlet is (because there is no such thing).

Credits

It's ALWAYS good etiquette to credit and thank those who gave time, skills and knowledge to advance the community and help to improve shitty code.

<cfscript>
// Query to retrieve some data from the database
variables.myData = queryExecute(
sql = "
SELECT *
FROM myTable
LIMIT 10
",
options = {datasource="#Application.myDSN#"}
);
@JamoCA
JamoCA / getMimeType.cfm
Last active September 15, 2015 16:40
Update to ColdFusion getMimeType UDF. Update struct creation & add/update mime types. Make filename optional. Passes "application/unknown" if type not found.
/* ORIGINAL: http://www.cflib.org/udf/getMimeType
Returns mime type and subtype for a file.
@param filename File name to examine. (optional)
@return Returns a string.
@author Kenneth Rainey (kip.rainey@incapital.com)
@version 1, April 21, 2004
@version 2, September 1, 2015 https://gist.github.com/JamoCA/5a2cece7e2a248f71ad9 */
function getMimeType() {
var fileExtension = "";
var mimeStruct = {"323" = "text/h323",
<!--- on initial request, run query --->
<cfset "session.#attributes.myactionfile#" = "" />
<cfsavecontent variable="datasorter_js">
<style type="text/css" title="currentStyle">
@import "css/datatables_table.css";
</style>
<script type="text/javascript" language="javascript" src="js/jquery.dataTables.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
@jonathancox
jonathancox / cf_encrypt
Created October 23, 2010 16:16
encrypt
<cfset algorithm = "AES">
<cfset encoding = "hex">
<cfset key = GenerateSecretKey(algorithm)>
<cfset str = "This is my secret string." >
<cfset enc = Encrypt(str, key, algorithm, encoding)>
<cfset dec = Decrypt(enc, key, algorithm, encoding)>
@ivanionut
ivanionut / gist:4071128
Created November 14, 2012 09:12 — forked from dskaggs/gist:3788338
Using caching to improve your ColdFusion application's performance

As you write more and larger ColdFusion applications, you will start looking for ways to improve the performance of your applications. There are many ways to do this but one of the easiest is to use ColdFusion's caching mechanisms to reduce the amount of work your application has to do over and over. Caching simply refers to the idea that you create a piece of content or data once and hold it in application memory for some period of time. During that time frame, any part of your application that needs that content or data uses the copy that was previously generated rather than regenerating it.

ColdFusion has several different caching mechanisms built in, but they generally fall into two main categories--programmatic caching and application server caching.

##Programmmatic Caching This type of caching is controlled by your application code. You decide which parts of your application would benefit from being cached and use CFML tags and attributes to determine what content is cached and how long your applicati

@mikesprague
mikesprague / gist:5706268
Last active December 25, 2015 11:47
JavaScript: getRootWebSitePath
function getRootWebSitePath() {
var _location = document.location.toString();
var applicationNameIndex = _location.indexOf('/', _location.indexOf('://') + 3);
var applicationName = _location.substring(0, applicationNameIndex) + '/';
var webFolderIndex = _location.indexOf('/', _
location.indexOf(applicationName) + applicationName.length);
var webFolderFullPath = _location.substring(0, webFolderIndex);
return webFolderFullPath;
}
@mikesprague
mikesprague / set-cookie.cfm
Last active December 25, 2015 11:49
set cookie without cfcookie example (cfscript)
@mikesprague
mikesprague / convert-query-to-struct-array.cfm
Last active December 25, 2015 11:49
CFML: convertQueryToStructArray
<cfscript>
function convertQueryToStructArray( q ) {
var result = [];
for ( var row in arguments.q ) {
result.append( row );
}
return result;
}