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