Tuesday 24 November 2009

My 23rd Anniversary

I really can't believe that its been 23 years of me, when I lost my freedom, joking. I am very fortunate I got lovely wife today. Yesterday was my brothers 46th birthday. I feel like I am still 26-27 year old and its been just 2-3 years of my marriage.

I am going to buy some plants today for my wife as she wanted to have few plants for our living room and one for kitchen.

Sunday 22 November 2009

Hibernate option on vista

If you ever loose option to go hibernate on vista, here is what I found on some ones blog, sorry I forgot the blog address:

To enable hibernation in Vista bring up the Command Prompt by click on "Start Button" then in the "Start Search" field type CMD and press enter. (This should be as administrator and to do that right click on CMD and opt for run as administrator)

In the Command prompt type: POWERCFG -H ON

This will enable the hibernate option

Saturday 21 November 2009

Oracle 10g on Mac OSX - Snow-Leopard

I wanted to install Oracle on my Mac, and was thinking this would be straight forward like when I did on my Sony - VAIO Laptop, and turn out a little complicated task.
Found a good blog on how to install it on Mac OS X - Snow - Leopard.
http://blog.rayapps.com/2009/09/14/how-to-install-oracle-database-10g-on-mac-os-x-snow-leopard/

Still it was complaining about couldn't find MAKE under /usr/bin/. was up till 2 am last night.

The blog suggested to have Xcode, and now I am installing it, lets see what happens.

Thursday 5 November 2009

My New iMAC

Its been a week when I received my new iMAC (27 inch screen (its huge), 1 TB HDD, 3.06 GHz). I am over the moon, I loved this new experience, and took me 2 days to configure the machine to work in my way, I wasn't aware before this that I am very particular about how I work on any machine.

Apple are great in their innovation and they produce good and stylish machines with very high performance and technology.

Thanks to their team.

Only downside I have got with this is, I can't have MSSQL Data base on here, but the good thing is I can run windows in here to get this on there.

I am very happy and relaxed now.


:)

Java script trim function

I have used this trick in different places and sometimes when I need it again, I always forget, tahts why I am putting it here:

function AllTrim(str) // call this function if you want to remove spaces from both sides
{
str = LTrim(str);
str = RTrim(str);
return str;
}
function LTrim(str) // this function removes spaces from left
{
return str.replace(/^\s+/g,'');
}
function RTrim(str) // this function removes spaces from right
{
return str.replace(/\s+$/g,'');
}

Tuesday 13 October 2009

Converting a List to table

This function accepts a String which holds list of id's and returns a table and then you can use this table to join and filter main table data. You can pass the list with your choice of separator.

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go


Create function [dbo].[ListToTable]
( @list varchar(4000), @separator varchar(10) )

/* this function receives a @separator delimited list and outputs a table with
each item in the list as a row in a table so the following can be used
SELECT * from dbo.Customers
inner join listToTable( '123,456,789', ',' )
on CustomerID = listValue
*/

returns @listTable table( listValue Int null )
as
begin

if @list is null
insert into @listTable values( null )

-- @list is the list we wish to parse
-- @Separator is the separator charactor such as a comma
declare @separator_position int -- This is used to locate each separator character
declare @list_value varchar(1000) -- this holds each list value as it is returned

-- For my loop to work I need an extra separator at the end. I always look to the
-- left of the separator character for each list value
set @list = @list + @separator

-- Loop through the string searching for separator characters
while patindex('%' + @separator + '%' , @list) <> 0
begin

-- patindex matches the a pattern against a string
select @separator_position = patindex('%' + @separator + '%' , @list)
select @list_value = left(@list, @separator_position - 1)

insert into @listTable values( @list_value )

-- This replaces what we just processed with and empty string
select @list = stuff(@list, 1, @separator_position, '')
end

return

end

Finding file extension in SQL

Here is the SQL code to find the extension of a file:

declare @appurl varchar(50)
set @appurl= reverse('philip.singh.bedi.doc')

select reverse(LEFT(@appurl, CHARINDEX('.', @appurl) - 1)) ext,
reverse(RIGHT(@appurl, LEN(@appurl) - CHARINDEX('.', @appurl))) fname

Visit to Portishead

I went to Portishead, a small town near Bristol to see Jatin and work on one web service, Jatin is a terrific host and amazing friend, He has superb flat, and it was fun staying with him and working together like old times at Tag. I met with Ian Bale, he is a nice chap and talented professional, I think will learn a lot by working with him.
I stayed in Portishead for 4 days, Jatin has nice set up and working environment, his iMAC inspired me to have one and now I have ordered one and can't wait to try this one, I expect it to be with me in 1-2 weeks.

Lets see how it goes, I need to learn more about MAC, and this has latest powerful operating system - Snow.

Really looking forward to working on this.

:)

Monday 28 September 2009

Snippets in CFEclipse

Found this on Ray's site where Bob wrote it in his comments to one article, thanks Bob (article)

Snippets in CFEclipse

Set directory in Eclipse: Window > Preferences > CFEclipse > alter File Paths To Snippets Directory

To create a snippet in Eclipse, open Snip Tree View (Window > Show View > Snip Tree View). Click the + icon to add a new snippet. 'Insert' inserts the current snippet into your CF document.

Each snippet comprises one XML file, for example here's a basic CFQUERY for a SELECT:

<code>
<?xml version="1.0" encoding="utf-8"?>
<snippet>
<name>select</name>
<help>select</help>
<starttext><!--[CDATA[
SELECT
FROM
WHERE
</cfquery>]]--></starttext>
<endtext><!--[CDATA[]]--></endtext>
</snippet>
</code>

If you're working in a team environment, you could point everyone's snippet file path to the same network directory in order to share snippets.

PS: remove <code> </code> before pasting in Eclipse

Saturday 26 September 2009

Model-Glue - one of ColdFusion frameworks

I am out of job, I came to know this on 22nd of July 09, I was expecting this would happen from few weeks as Markus (CEO of Emojo) was kept mentioning it in our project meetings that co is facing hard challenges in this recession time for getting money from clients which was over due. Even on one day we worked over night to finish one promise which co made to one client and we worked approx. 28 hrs. staying over night. But that didn't help to change the fate of the co.

I am using this time to learn few new things and brush-up some things which I wasn't using from a while, one of the new things I wanted to learn from a while was MODEL-GLUE framework and now it is coupled with ColdSpring which was another thing I wanted to learn. During this journey I have come across few good articles/ tutorials, which I would like to mention here and share with others.

1) Tutorial from Dan Wilson, which is very helpful if you want to learn Model-Glue, I would like to thank Dan about this tutorial. Here is the link to his series:

Dan's Model-Glue Tutorial

2) A series from Raymond Camden about learning Model-Glue, Ray is very talented and knowledgeable person and on top of that he is very kind and helpful and always willing to help other developers by sharing his knowledge and experience. This series is quite old (written in early 2006) but still it helped me to get on with Model-Glue. I will try to write the changes which I had to make in line with latest version of Model-Glue.

Here are the links to his series, I find it very difficult to get a list of his series and decided to put them here.

Building your first Model-Glue application - part 1

Building your first Model-Glue application - Part 2

Building your first Model-Glue application - Part 3

Building your first Model-Glue application - Part 4

Building your first Model-Glue application - Part 5

Building your first Model-Glue application - Part 6

Building your first Model-Glue application - Part 7

Building your first Model-Glue application - Part 8

Building your first Model-Glue application - Part 9

Building your first Model-Glue application - Part 10

Final notes from Ray

I wrote this one before finishing the complete series, I am a huge fan of Ray and big thanks to him for helping the comunity.

Thursday 24 September 2009

SEO Tips and links

I was reading through some good articles about SEO (Search Engine optimization) tips, and come across really good articles and article about how to write Robots.txt file to allow or disallow content or directories of your web site, you want or dont want to be searched/ indexed.

1) Top 10 ways to link popularity - its really a good article on what one should do to improve popularity of his site.

http://www.free-seo-news.com/ways-to-link-popularity.htm

2) Improving your search-engine status - Its a tutorial in 4 parts on how to improve your sites rating score.

http://www.softsteel.co.uk/tutorials/search/searchIndex.html

Part 1: http://www.softsteel.co.uk/tutorials/search/part1.html etc

3) How to improve your Page Ranking: This is an article which helps to improve page ranking and tells seven things to take care of:

http://www.squidoo.com/OptimizationforGoogleRating

4) Tutorial to Improve and Achieve Higher Search Engine Placement and Positions: Its a good tutorial to learn about search engine rankings

http://www.tsworldofdesign.com/search_engine/higher_placement.htm

also one interesting one: http://www.kensavage.com/archives/the-basic-principles-of-seo/

5) Here are few links to help you learning how to write robots.txt

http://www.free-seo-news.com/all-about-robots-txt.htm

http://sandeepdharak.blogspot.com/2009/09/how-write-robotstxt-file-seo-google.html

enjoy above articles

Saturday 19 September 2009

SQL Express DSN creation problem

I had problem creating DSN through ColdFusion administrator for a database in MSSQL 2005 express addition and problem was my tcp port was not enabled for this service and the post/ blog which helped me was this one:

http://www.fusioncube.net/index.php/coldfusion-sql-server-express

Thanks to Steve Brownlee who posted this blog in 2006

Tuesday 21 April 2009

How to generate randam string of 8 characters

|start cfscript|

RPassword = "";
// Get the random characters for password

RandomCharacters=1;

for (RandomCharacters;RandomCharacters < 8; RandomCharacters++ )
{
//character code from A To Z
ranPassword = RandRange(0097,0122);
RPassword = ListAppend(RPassword, CHR(ranPassword));
}

//Get the random numbers from 1 to 9 for password

RPassword = ListAppend(RPassword,RandRange(1,9));

//Get rid of commas

RPassword = Replace(RPassword,',','', 'all');

|end cfscript|

How to make call using Ajax/ JQuery

First thing you got to include Jquery library
Second thing:
create some functions inside jqueries ready function like this:
$(document).ready(
function()
{
// if you want to take any action on load
});
Third:
There are few ways to do this call and here are 3 ways of them:

1) This is a get call
$("#DivToDisplayResult).load('pageToBeCalled.cfm',{
Param1: param1value,
Param2: param2value,
Param2: param2value,
Param2: param2value,
……..
},
// following function is required, which is being called after we get the result back
function(responseText, textStatus, XMLHttpRequest){
//alert(responseText);
}
2) $.getJSON('pageToBeCalled.cfm',{UserProfileCode: userProfCode}, function(j){
// here you can put the action and you would get result in “j” variable
// like
$("#divName").html(j);
});
3) Post
$.post(
pageToBeCalled.cfm,
{
Param1: param1value,
Param2: param2value,
Param2: param2value, },
function(j) {
//here you can take action by reading “j” variable
}
);

MS SQL: Backup database Stored Procedure

Here is a stored procedure to create a full backup of the database.
Run the code on the master database.
To backup a db run:
sp_backupdatabase 'databasename'
To verify the backup we need to use use CHECKSUM.

USE "master"
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE "dbo"."sp_backupdatabase" (
@DBName nvarchar(50)
)
WITH ENCRYPTION
AS
BEGIN
SET NOCOUNT ON;
DECLARE @sqlCommand NVARCHAR(1000)
DECLARE @dateTime NVARCHAR(20)
SELECT @dateTime = REPLACE(CONVERT(VARCHAR, GETDATE(),111),'/','') + REPLACE(CONVERT(VARCHAR, GETDATE(),108),':','')
SET @sqlCommand = 'BACKUP DATABASE ' + @DBName + ' TO DISK = ''D:\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\' + @DBName + '_backup_' + @dateTime + '.BAK'' WITH CHECKSUM'
EXECUTE sp_executesql @sqlCommand
END

Thursday 9 April 2009

The Italy earthquake

I really feel sorry for people of L'Aquila and other towns in central Italy and Italy for what they have been experiencing after this. Prey god be merciful, but its the way now people behaving, and what wrongful deeds they are doing cost to other innocent people to suffer.

May god help the families of the sufferers to come out from this shock and great loss bravely.

My New Kitchen

Its all fitted now and looks amazing, will post some pics of it soon, looking forward to long weekend (Easter one, tomorrow), when painter will come to paint and lay tiles on wall opposite to sink and Hob.

It was worth spending money with KBBC, Kitchen fitting company.

Saturday 14 March 2009

Working on Saturday

I have to come on Saturday to work, so next release can be done in time for Internet World.
:(

Friday 13 March 2009

My New Car - RAV4

I bought a new car/SUV yesterday, its one year old, Toyota RAV4 XT5 Automatic and have amazing feature, I was very thrilled when I drove it to home and went on a ride with my dream girl Ritu, she loved it too.
:)
My kids who are in uni want to enjoy this ASAP, I guess, LOL.

Out of one feature, it senses the key itself and bearer don't need to press the button, just he has to open the driver side door.

Wednesday 11 March 2009

ColdFusion > JVm memmory status

<cfset runtime = CreateObject("java","java.lang.Runtime").getRuntime() >
<cfset freeMemory = runtime.freeMemory() / 1024 / 1024 >
<cfset totalMemory = runtime.totalMemory() / 1024 / 1024 >
<cfset maxMemory = runtime.maxMemory() / 1024 / 1024 >
<cfoutput >
Free Allocated Memory: #Round(freeMemory)#mb

Total Memory Allocated: #Round(totalMemory)#mb

Max Memory Available to JVM: #Round(maxMemory)#mb

</cfoutput>

Tuesday 10 March 2009

CF 8 - New Identity COL feature

I like the new feature of getting Identity column value from cfquery in CF*, saved me couple of line of code to get the value from SCOPE_IDENTITY() (MS SQL system variable), you just got to put result name in cfquery tag and then you can get it as resultname.IdentityCol, there is one restriction, you should have just one insert statement in that cfquery, when I had one local query lookup which was saving its result in local @VAR then this IdentityCol thing didn't work.

let me know if you are not clear about what I am saying, LOL