Skip to content

Instantly share code, notes, and snippets.

View thecfguy's full-sized avatar

Pritesh thecfguy

View GitHub Profile
@thecfguy
thecfguy / jqueryajax.html
Created August 18, 2013 06:00
Correct way pass additional variable to callback function to make sure correct value passed on
<html>
<head>
<script src="/js/jquery-1.4.2.min.js?131211022029" type="text/javascript"></script>
<script>
function loadMe(){
for(var i=1;i<=3;i++){
$.ajax({
url:"scribble2.cfm?id=" + i,
success:showMessage(i)
});
@thecfguy
thecfguy / stackoverflowchart.cfm
Created August 18, 2013 06:30
Generate chart based on question asked by tag
<cfparam name="URL.tagname" default="ColdFusion,Java,Python">
<cfparam name="URL.startYear" default="#year(now())#">
<cfparam name="URL.endYear" default="#year(now())#">
<cfoutput>
<form method="get" action="">
<table width='100%'>
<tr>
<td>
Tag : <input type="text" name="tagname" value="#URL.tagname#"/> <br/>
No more than 5 tags
@thecfguy
thecfguy / transfercomment.cfm
Last active December 21, 2015 05:58
Transfer comments from Mura to Disqus exporter
<cfquery name="q" datasource="livemura">
SELECT
tc.title,
CONCAT('http://www.thecfguy.com/blog/',tc.`urltitle`,'/') AS urltitle,
tc.`Body`,
tc.`ContentID`,
tc.`created`,
tcc.`commentid`,
tcc.`name`,
tcc.`email`,
<cfparam name="url.param1" default="URL Parameter 1">
<cfparam name="url.param2" default="URL Parameter 2">
<cfscript>
function callme(){
var url = "http://www.thecfguy.com";
writedump([url,local.url]);
}
callme();
writedump(url);
abort;
@thecfguy
thecfguy / peoplesearch.cfm
Created October 2, 2013 10:12
Get people search for linkedin
<cfhttp url="https://api.linkedin.com/v1/people-search:(people:(id,first-name,last-name))">
<cfhttpparam type="header" name="content-type" value="application/x-www-form-urlencoded">
<cfhttpparam type="url" name="oauth2_access_token" value="[access-token]">
<cfhttpparam type="url" name="first-name" value="pritesh">
<cfhttpparam type="url" name="last-name" value="patel">
<cfhttpparam type="url" name="format" value="json">
<cfhttpparam type="url" name="count" value="2">
</cfhttp>
<cfset response = deserializeJSON(cfhttp.filecontent)>
@thecfguy
thecfguy / pd4fonts.properties
Created October 16, 2013 07:22
RAILO font properties file to add additional font.
#this is an autogenerated file. please remove manually any references to copyrighted fonts
#Fri Apr 17 20:00:52 CEST 2009
Arial=arial.ttf
Arial\ Bold=arialbd.ttf
Arial\ Bold\ Italic=arialbi.ttf
Arial\ Italic=ariali.ttf
Courier\ New=cour.ttf
Courier\ New\ Bold=courbd.ttf
Courier\ New\ Bold\ Italic=courbi.ttf
Courier\ New\ Italic=couri.ttf
@thecfguy
thecfguy / generatepdf.cfm
Created October 16, 2013 07:23
Generate PDF using CFDOCUMENT with custom fonts
<cfdocument format="PDF" fontembed="true" filename="#expandpath('./test.pdf')#" overwrite="true"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test</title>
<style type="text/css">
@font-face
{font-family:"Calibri"; }
@font-face
{font-family:"Impact"; }
@font-face
<cfscript>
writeOutput("Before lock at #now()#");
lock name="threadlock" timeout="3" type="exclusive"
{
writeOutput("<br/>started at #now()#");
thread action="sleep" duration="10000";
writeOutput("<br/>ended at #now()#");
}
writeOutput("<br/>After lock at #now()#");
</cfscript>
@thecfguy
thecfguy / zapreport.xsl
Created November 23, 2013 06:34
Render ZAP export in human readable format. Just add <?xml-stylesheet type="text/xsl" href="zapreport.xsl"?> next to top most <?xml ...> tag and open xml file any new generation browser.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<style>
body{
font-family: verdana,arial,sans-serif;
<cfparam name="url.x" default="1;delete from x">
<cfset esapi = CreateObject("java", "org.owasp.esapi.ESAPI").encoder()>
<cfset codec = createObject("java","org.owasp.esapi.codecs.MySQLCodec").init(0)>
<cfset url.x = esapi.encodeForSQL(codec, url.x)>
<cfquery name="q" datasource="amex">
select * from [users]
where id like #url.x#
</cfquery>
<cfdump var="#q#" />