Skip to content

Instantly share code, notes, and snippets.

View thecfguy's full-sized avatar

Pritesh thecfguy

View GitHub Profile
@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`,
@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 / 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 / jqueryajax.html
Created August 18, 2013 05:54
Wrong way to call ajax within loop and using index in success method.
<html>
<head>
<script src="/js/jquery-1.4.2.min.js" type="text/javascript"></script>
<script>
function loadMe(){
for(var i=1;i<=3;i++){
$.ajax({
url:"scribble2.cfm?",
success:function(res){
showMessage(res,i); // Call another function with additional parameter
@thecfguy
thecfguy / jqueryajax.html
Created August 18, 2013 05:51
Method2: Call jquery.ajax and display response in variable div
<html>
<head>
<script src="/js/jquery-1.4.2.min.js" type="text/javascript"></script>
<script>
function loadMe(){
$.ajax({
url:"scribble2.cfm?",
success:function(res){
showMessage(res,"div1");
}
@thecfguy
thecfguy / submitajax1.html
Created August 18, 2013 05:45
Method 1: Load html content with jQuery.ajax
<html>
<head>
<script src="/js/jquery-1.4.2.min.js" type="text/javascript"></script>
<script>
function loadMe(){
$.ajax({
url:"scribble2.cfm?",
success:function(res){
$("#div1").html(res);
}
@thecfguy
thecfguy / submitform.cfm
Last active September 13, 2018 21:05
Create coldfusion window and submit form to display response in cfwindow.
<cfajaximport tags="cfwindow">
<script type="text/javascript" src="/CFIDE/scripts/ajax/ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/ajax/ext/ext-all.js"></script>
<script>
function submitMe(){
var frm = window.document.frmTest;
ColdFusion.Window.create("Windowresponse","Response Window","",{x:100,y:100,height:200,width:400,modal:true,closable:true,draggable:true,resizable:true,center:true,initshow:true});
objWin = ColdFusion.Window.getWindowObject("Windowresponse");
var objupdate = objWin.getUpdater();
objupdate.update({url:frm.action,params:Ext.lib.Ajax.serializeForm("frmTest"), method:"POST",scripts:true});
@thecfguy
thecfguy / listscheduletask.cfm
Created August 18, 2013 05:18
List out all scheduled task in ColdFusion
<cfscript>
alltask=ArrayNew(1);
taskService=createobject('java','coldfusion.server.ServiceFactory').getCronService();
alltask=taskservice.listall();
</cfscript>
INSERT INTO `muracms`.`tcontentcomments`
(commentId,contentId,comments,NAME,email,url,entered,isApproved,siteId)
SELECT
MC.id AS commentId,
MUT.contentId AS contentId,
MC.content AS comments,
MC.creator_name AS NAME,
MC.creator_email AS email,
MC.creator_url AS url,
MC.created_on AS entered,
insert into table2
select * from table1
insert into table2 (no,name,city)
select no,name,city from table1