Saturday, November 28, 2009

Adobe Wave

Adobe Wave is really cool and opens up so many new areas, and potential to push / alert your customers, do marketing, server alerts... whole new stuff. It's still in BETA now and you will need a publisher account to start working with it, the API is simple and can be integrated easily. Based on ADBOBE AIR, you would need to install it.

Adobe still provides PHP code example for API usage, hope they will start using their technology, COLDFUSION for coding examples and hosting their stuff.

Below is the link for Adobe wave

Creating PDF using wkhtmltopdf and Coldfusion

Coldfusion 8.0 does not support creating PDF from HTML pages which have Javascript that changes the look and feel, but in most of the cases you will have to create PDF for such documents only as JS is very common.

I looked on internet and found a really good free working solution, that works across MAC, LINUX and WINDOWS, wkhtmltopdf uses webkit rendering engine, and qt and works perfectly.


1. Download the required wkhtmltopdf for your operating system from
2. Use cfexecute command to call the program, you can either use and URL to a file path on your server and call it, below example uses a file on the server

windows - <cfexecute name="wkhtmltopdf.exe"
arguments="file:///d:/tmp/x.html d:\tmp\x.pdf"

Linux - <cfexecute name="wkhtmltopdf"
arguments="/tmp/x.html /tmp/x.pdf"

That is all what you need, it's a really good solution and works perfectly to create PDF, I hope Coldfusion introduces the use of JS in the next version of cfdocument tag. Ideally it should as CF on back uses iText Java free library which does everything.

Tuesday, September 15, 2009

Club Mahindra - Do not fall into their trap

I took Club Mahindra Membership 3 years back and we choose their White Season with studio apartment. I took their membership 3 years back for 1.81 lacks.

I have visited their Coorg, Goa and Asthamudi properties. There are a few things to watch for

1. After 3 years the same membership today is worth 1.5 lacks, so it's not a good investment, it's a loss.

2. Their customer service is very very poor, they will not tell you regarding the resorts facilities, they are rude and don't respond to your queries. If you ever send an email to they will close your case at will without response, I even had an incidence when my complain was closed without my knowledge and it said "as per Interaction with the customer", I was really surprised.

3. You will NOT be able to take a holiday at x-mas or new years time, MOST of their resorts have "purple season" then and you cannot travel in that season, no matter what membership you have.

4. Stuff at their resort, food, drinks, transport etc, is very expensive, food is okay, but for the money you pay not worth.

5. I wanted to cancel this membership after we went to Club Mahindra GOA, the resort manager called us as I complained directly to their director and promised on PHONE another free week of holdiday, but when I tried to take it, they didn't remember !!!!

I can only say with my experience, that it's not a good investment, rude customer service and expensive, so STAY AWAY from CLUB MAHINDRA.

Thursday, July 16, 2009

Ezone India Bangalore - Buying experience

I had a very bad buying experience at Ezone India (, , Banagalore, Koramangala show room. On 29th June 2009, I purchased couple of articles, LG LCD TV and LG Fridge, together worth more than 1.15 lacks. I was told that TV will be delivered within 3 days and Fridge within 2 weeks. I paid for both full amount on 29th itself.

After the purchase there was no news or follow up from Ezone and after a week on 6th July 2009, I gave them a call and asked them regarding the TV delivery, I was told that it would be delivered the next day before 12:00 pm. The next day also there was also no news and I called Ezone at 12:00 pm and reminded them regarding my delivery, I was told that it would be delivered within an hour, they did come and delivered it after 2 hours or so. There was no follow up from Ezone to LG for installation and I had to call LG customer service to request for the same.

The worst was with the fridge, I did not hear anything from them for 12 days, then I went to the showroom personally on 11th July 2009, and met Mr. Santosh, who told me to give a call on coming Monday when he will tell me when the fridge will be delivered on Monday. On 13th July 2009, I gave them a call and spoke again to Santosh, who told me that there is some issue with LG logistics and if the fridge comes today evening they will deliver it tomorrow otherwise on 15th July 2009, Wednesday, which was also the committed date. In between all this he was trying to say that I had agreed till 15th so it will be delivered by that day. Then next day there was again no call whether they are going to deliver it or not, I called them in evening and requested them to deliver it by 1:00 pm on 15th as I have to go to office after that. Mr. Santosh promptly agreed.

On 15th July, I didn't get the fridge by 1:00 pm, so I called again and they told me that they cannot commit on a time, but it would be delivered, no one came till 7:30 pm so I called them again, this time Mr. Santosh told me that the driver has left and it would be delivered by 9:00 pm. We all waited till 9:00 and there was no call or delivery, after that I couldn't reach their customer service or office number.

Then next day, when I called around 12:00 pm, I was surprised when Mr. Santosh told me that fridge has already been delivered, he was very rude in his talk. At this point I decided to go to Ezone and cancel the order, luckily for Ezone, I got stuck at some work in office and in the mean time they came to home and delivered the fridge. They also told a lot of lies, like they called us and we didn't receive the phone, there was no one at home, Blah Blah, basically trying to blame us for their delay.

I don't have an experience by my friends told that PAI is good and the rates are very competitive.

This was my first and last purchase from Ezone, after this experience I would never buy anything from them again !!!!!!!!

Pros - 10:30 am - 8:30 pm toll free number customer service 1800 425 7722
Cons - Bad service, no delivery follow ups, no gifts along with purchase, no DEMO calls.

Thursday, June 4, 2009

How to display currency symbol using coldfusion 8, Cfgrid fomat HTML

Question - "how to display the currency $ in cfgrid while using cfgridcolumn, the format is HTML"

There are two solutions to the above question

1. Have the SQL format the data and return the column values with $ symbol added to it.

2. The below code I found on internet, but it is the only solution that I could found if you are using cfgrid and format is HTML, I am posting it so that it is available.

<--- Query --->
paymentQuery = queryNew("fname,lname,amount", "varchar,varchar,double");
querySetCell(paymentQuery, "fname", "John");
querySetCell(paymentQuery, "lname", "Smith");
querySetCell(paymentQuery, "amount", "103.846");
querySetCell(paymentQuery, "fname", "Mary");
querySetCell(paymentQuery, "lname", "James");
querySetCell(paymentQuery, "amount", "200");
querySetCell(paymentQuery, "fname", "Peter");
querySetCell(paymentQuery, "lname", "Stone");
querySetCell(paymentQuery, "amount", "3.25");
<--- Cfform and HTML grid --->

<cfgrid name = "paymentGrid" format="html">
<cfgridcolumn name = "fname" header = "First name">
<cfgridcolumn name = "lname" header = "Last name">
<cfgridcolumn name = "amount" header = "amount" dataalign="right">
<cfloop query="paymentQuery">
<cfgridrow data ="#paymentQuery.fname#, #paymentQuery.lname#, #lscurrencyformat(paymentQuery.amount,'local','English (US)')#">


Note -- the above will work with COLDFUSION 8, to work with CF MX 7 you need to change the
lscurrencyformat function(just remove the last two variables).

Wednesday, June 3, 2009

How to restart ColdFusion from Command prompt in LINUX

You can restart Coldfusion / Jboss / Mysql and other services using the following commant


/etc/init.d/coldfusion_8 restart or /etc/init.d/coldfusion restart


/etc/init.d/ jboss restart

and MySql

/etc/init.d/mysqld restart

Tuesday, June 2, 2009

Getting Twitter Followers using Coldfusion

Question :
How to get the number of followers on Twitter using Coldfusion ?

Well, just use cfhttp and some string functions to get the result, I have created a function for the same which can be used, the function accepts the twitter url.

<cffunction name="twitter" access="public" returntype="any" output="no">
<cfargument name="url" required="yes" type="string">
useragent="Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv: Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)">
<cfset stringTOCheck = '<span id="follower_count" class="stats_count numeric">'>
<cfset lenghtOfCheck = len(stringTOCheck)>
<cfset firstOccurance = Find('#stringTOCheck#','#cfhttp.FileContent#')>
<cfset secondOccurance = Find('</span>','#cfhttp.FileContent#','#firstOccurance#')>
<cfset startFrom = #firstOccurance#+#lenghtOfCheck#>
<cfset endFrom = #secondOccurance#-(#firstOccurance#+#lenghtOfCheck#)>
<cfset followers = MID('#cfhttp.FileContent#',#startFrom#,#endFrom#)>
<cfreturn followers>

Enjoy !

Monday, June 1, 2009

Adding new data to XML using Coldfusion

Recently asked a Question 

"Need to create an XML file in which data is appended to existing XML"

Answer is pretty simple, first create  XML using cfxml tag

<cfprocessingdirective suppresswhitespace="Yes">
<cfxml variable="xmlobject">
        <name>Brijesh Chauhan</name>
        <name>Radhika Chauhan</name>

Then insert New XML nodes using array insert, we will always insert the new data at first and second position(as in this case there are two children's).

ArrayInsertAt(, 1, XmlElemNew(xmlobject,"name"));
ArrayInsertAt(, 2, XmlElemNew(xmlobject,"email"));

Finally assign new data to the childrens

<cfset[1].XmlText = "Avyukth Chauhan"> 
<cfset[2].XmlText = ""> 
</cfprocessingdirective > 

Simple !!!!

Interview Questions - Coldfusion, SQL and Linked Lists

Sharing some of the Interview Questions

Linked Lists 

Q1. How will you that a circular linked list has Loop.
A1. This is a very common question, take two pointers say p and q, p = q-1, and then traverse the list, if at any point during traversing p=q, then that is the Loop.

Q2. Given a linked list with n nodes where n is larger number and Even. How will you divide the linked list into 2 equal parts in one traverse.
A2. Take 2 pointers p and q, what we know is that for last node -> next = null, we are looking at the following equation, say when p = n (end node) , then q = n/2, which gives us p=2q, which means that move pointer p twice pointer q, that is shift pointer p by 2 nodes and pointer q by 1 node, that way when p = n, q would be n/2 and we have achieved the result.
HINT - hint for the above question is "how to find the (n-1)th node in the linked list.


Q1. Given a database, with no choice of auto_increments, how will you select the next identity?
A2. The Answer varies to what database you are using.
a)MySql  - use the function "last_insert_id()" , your query should say "select last_insert_id() As NewID from table".
b) Sql Server - User @@Identity, your query would be "select @@Identity As NewID from table".
c)Oracle - use SEQUENCES, first you need to create a sequence "create sequence newId startwith 1 increment by 1" then use "newId.currentval" and "newId.nextval" to get the current and next values.

Thursday, March 26, 2009

Using CFTHREAD to loop through a query

My first experience with Cfthread tag, I had to loop through a query with loads of records. To make the looping faster, I used 10 cfthreads, below is how to do it.

<cfquery name="get_data" datasource="whatever">
select xyz from table

First create 10 threads

<cfloop index="intGet" from="0" to="9" step="1">
<cfthread action="run" name="objGet#intGet#">

do some calculations to get the startrow and endrow for each thread to loop through

<cfset startRow = int((#intGet# * #get_users.Recordcount# / 10) + 1)>
<cfset endRow = int(((#intGet# + 1) * #get_users.Recordcount# / 10))>

Loop through the query

<cfloop query="get_data" startrow="#startRow#" endrow="#endRow#">
-------- Your calculations / stuff goes here -------------


Lastly JOIN the threads

<cfloop index="intGet" from="0" to="9" step="1">
<cfthread action="join" name="objGet#intGet#" />

you would be able to save a lot of time, also you can use "thread" scopes to assign values and then do the calculations.

Tuesday, March 24, 2009

Coldfusion Query to List

Well, I was looking for a simple function which could give me the query results in form of a list, I only had one Column Selected

<cfquery name="get_data" datasource="testDsn">
select date from table1

what is was looking for was just I can do <cfset list = QueryToList(> and I found that there is already a coldfusion function "valueList" to do the same. So to get the list from above you can simply do

<cfset list = valueList(>

really helpful.

Tuesday, February 24, 2009

Extract Coldfusion Cfchart as jpg or png image

While working on a reporting project recently, there was requirement of extracting the charts developed using CFCHART tag to a .jpg file. Coldfusion 8 has the ability where you can generate the graph as Binary data and then save it in .jpg or .png format.

Here is what needs to be done

1. use the "name" variable in cfchart and type as jpg or png.
<cfchart type="jpg" name="whatever">
--- Chart stuff here ---

2. Then do the following, write the entire content to the file 

<cfset savedFile = getTempFile(getTempDirectory(),"Download") & ".jpg">
<cfset fileWrite(savedFile, whatever)>

3. Force the header for download

<cfheader name="Content-Disposition" value="attachment;filename=download.jpg">
<cfcontent type="image/jpeg" file="#savedFile#">

Thats ALL :-)

Friday, January 23, 2009

Creating Analystics Tool using coldfusion

Analytics tool using Coldfusion, ideally you can add your website to Google Analytics and monitor it, but if you are a provider which gives custom tools to the customer, then you might need to have a reporting section which includes the Analysis of KEYWORDS and location where visitors came from.

When someone searches using a keyword on some search ENGINE, then you can get the keyword from CGI variable HTTP_REFERER. Well there is no standard that is followed while passing the keyword, Google, MSN, Live, Alexa  passes it as "q=" in the http_referer, Yahoo passes it as "p=" and AOL passes it as "query=", some engines pass it along the like if you search for something on, then you will have http_referrer as

The second CGI variable that you will need is REMOTE_ADDR which will give you the IP of the location from where the visitor came from.

So our first step will be to get the KEYWORD and the Search Engine name from the Http_Referer, this can be done using REGULAR expressions and using REFind and MID string functions. Basically depending on your search engine, you find the occurrence of "q=", "p=" or "query=" and then URLDECODE the string to get the keyword.

So now you have the IP, KEYWORD and The Search Engine name. The next thing is you need to get the location from where the IP came from, I did some google work and came across the post from, the post is self explanatory and even has all the required files for you to get the location based on the IP address, and it is pretty accurate. You can download all the required files and just use the code as it is, also everything given on his post is free for download.

The next is you need is to map everything on GOOGLE maps, again you can find a custom tag for it on, this is pretty simple to use and has lots of examples to choose the configurations you need.

That gives you everything you need, Location, IP, search engine, keyword and a MAP.

I will be adding more enhancements to it and if you need the code to get the KEYWORDS and search engine, then just send me an email and I will send it across to you, although it is pretty simple.


Tuesday, January 6, 2009

ActivEdit WYSIWYG editor -- "Must Be Contained in Form" Error

ActivEdit is now an open source WYSIWYG editor. I had used this editor long time back while working on Coldfusion 4.5.

ActivEdit was Closed source sometime back, recently it's source code is made available(also ActivMail, a JAVA based CFX tag is also open source now). I like this editor as it is pretty simple and works, but is not as advanced with features as FCKEditor or TinyMCE.

The Latest version of ActivEdit, if your DOM structure is not proper(As below) then you will get an error "ActivEdit Must be contained in a form" and also you will NOT BE able to save any changes you make.

For AcitvEdit to work properly, you should have the following structure


The above issue will occur with Firefox 3, Safari and Google Chrome.

Monday, January 5, 2009

Design Patterns -- Coldfusion

Sometime back while working on a project we came up with a system for reporting, at that time I got to learn and use some of the design patterns. I am describing them below

1. Facade(Structural Pattern) -- While creating a system, we come across an issue that the subsytem grows and it becomes complex with large number of smaller objects. As a solution of this, what needs to be done is, Introduce a single component that provides a simple API to the set of components within the subsystems. Applying this pattern we actually reduce coupling of the subsystems and the subsytem are managed as different pieces by their own components.

2. Front Controller(J2EE Presentation Tier) -- The second problem that we came across was to have every request follow the same logic(security, layout etc), well the solution is simple, just have all the request go through a common single file which decides how to process the request. So now we have centralized controller and this moves the logic from individual pages to the controller.

3. Data Access Object (J2EE Integration Tier) -- This helps you separate your data access from any business Logic. Basically DAO will have 4 methods a) Inserting Data b) updating data c) deleting data d) selecting data. Now you have to make minimal changes if you database changes from MySQL to Oracle or XML or anything else.

4. Factory (Creational Pattern) -- Just like factories in real life which creates things, the factory pattern job is to create other objects. So you can say it is an INTERFACE for creating an object. Then after creating an object, have the subclasses decide which class to call.

5. Dependency Injection -- In conventional method, if an object needs to gain access of a particular service, then either it holds a reference to the location of the service or has access to some service locator. In contrast, in DI, when an object is created a reference to an implementation of that type of service will automatically be injected. Why DI? - because it allows you to create alternative implementation of a given service type.

Then we also used security in the system by having all the files beginning with _(underscore) and adding small piece of code in Application.cfc file which did not allow to access files that begin with underscore. One of the other things used in the project was ERROR COLLECTION classes and a page which showed the errors.

References for above article a) b) c)