Blog

September 28, 2011
Sql Server Rank() v/s Dense_rank()

Hello Friends, Some days before I was googling on sql server's system function and I got one site having sql server query puzzle. The site have very interesting puzzle. I got a puzzle during surfing and it is to find out second highest salary of each department and tie salary should also count. There are inbuilt functions in sql server to give rank as per result set. The Rank() function of sql server returns the position of value within a partition of a result set. Rank() function left ...

Read More
By Bharat Patel
Comments(2)
Tags: SqlServer
September 20, 2011
Read File line by line in ColdFusion by using Java Classes

HI,
I was having situation where I wanted to read a file and process each line.
I think cffile tag is not much to do it, so I use java classes.
Basically we need two kinds of classes.
1. InputSream
2. Buffer reader

Buffer reader is capable to read any input stream line by line.

Final code will look like:

<cfscript>
	FileName = expandPath('/temp.txt');
	objFileReader = createObject("java","java.io.FileReader");
	InputStreamReader = objFileReader.init(FileName);
	objBuffer = createObject("java","java.io.BufferedReader" );
	LineIO = objBuffer.init(InputStreamReader);
	</cfscript>
	
	<cfset eof = 0>
	<cfset cnt = 1>
	<cfloop condition="not eof">
	<cfset currline = LineIO.readline()>
	<cfif isdefined("currline") eq "no">
	<cfset eof = 1>
	<cfbreak>
	</cfif>
	<cfoutput>line #cnt#: #currline#<br/></cfoutput>
	<cfset cnt = cnt + 1>
	<cfflush>
	</cfloop>

Read More
By Vikas
Comments(2)
Tags: File, ColdFusion
September 20, 2011
Complex password strength checking through regular expression

Currently working on project for well non credit card company where they have online registration form. They really want user enter enter strong password for their account and criteria for password listed below..

  1. Password must length between 8 to 18.
  2. Password must contain atleast one alpha and on numeric.
  3. Password must have one special characters from @,#,$.
  4. Password can not have repeative alpha and numeric.

This is really complex but can be done with four different conditions easily (right?) but I decided to make things more complex and check all four condition with single regular expression. After spending time on this finally figure out regular expression can perform all four condition.

Read More
Comments(0)
Tags: Regular Expression, ColdFusion
September 6, 2011
Making Paypal standard checkbout more user friendly

Recently working with paypal standard checkout and it so easy to integrate with any application as it will redirect to paypal site and customer login and make all kind of payment stuff at paypal site only. But this task make really tuff for new customer who has limited knowledge of intenernet/paypal.

How this works? Well, paypal has very good documentation here. Basic flow is.

  1. Customer click on "Paypal" button which redirect to paypal site.
  2. Customer need to login or enter credit card information.
  3. Paypal ask for confirmation of payment.
  4. Thanks page for placing order with link to return original site.
Read More
Comments(0)
Tags: Paypal
September 4, 2011
Static method implementation in ColdFusion

I found some discussion about static method equivalence in ColdFusion.

In C# we can declare class as static and static class can only have all the static methods and static variables. And we can call static class methods without creating its instance.

In ColdFusion we must need to create an instance of cfc. Then & then we can call it’s method. To avoid creating instance each time, you can create object in Application init() function, and make it at application scope, so you can directly call the methods. But this is still a nasty approach, as we are still creating an object when Application initializes.

Then I remember that ColdFusion is not an Object Oriented Language. We make it look like OOP! It happens mostly when we use ColdBox or Model Glue or any other application framework, where most of the coding is in cfc only. Now a days people are using cfscript tag more as Lots of tags are now available in cfscript. And when we use cfscript tag we, feel like it's an OOP language! But remember ColdFusion is a scripting language as PHP and Classic asp. cfscript tag itself trying to remind us by its name!

Thanks...

Read More
By Vikas
Comments(0)
Tags: ColdFusion