Saturday, August 02, 2008
Updates about me
Monday, July 28, 2008
वक्त!
करता फ़िर रहा जो इकठ्ठा कहाँ ले जाऊँगा
सब यहीं पर था, यहीं पर है, यहीं रह जायेगा,
शायद ही किसी को मेरा नाम याद रह पायेगा!
मगर फ़िर भी इच्छा यही है की इस को, उस को, और न जाने किस किस को अपना कह सकूं मैं,
इसी इकठ्ठा करने की एक अजीब सी कशिश में, क्यूँ न ख़ुद को खुश रख सकूँ मैं!
पैसे का क्या वोह तो आज अगर मेरी जेब में तो कल किसी और की जेब में जायेगा,
अरे मन इतना समझ ले की यह जो वक्त बीत रहा है ये न फ़िर वापस आयेगा!!
दो पंक्तियाँ
जानना है मुझको की बता ए वक्त तुझमे छुपा क्या है?
क्यों यूँ तिल तिल कर के खोलता है परत दर परत,
क्यों यूँ हमेशा आस देता है तू पल पल, की होगी सुबह जल्दी से
बस इस बदलने की आस में यूँ बिताता हूँ में अब हर एक पल
शायद आज से अच्छा ही होगा जो आने वाला है कल!
समय के इस फेर में मैं भूल सा गया हूँ की आज की भी कितनी महत्ता है
जरा सी देख की मुश्किल यह दिल कुछ ऐसे बहकता है
संभाले नही संभलता, आंसू आ ही जाते हैं बस आँखें साथ नहीं देतीं
कब का छूट गया होता साथ इस जिंदगी का जो उम्मीद मेरा दामन थाम नही लेती!
अब जब थामा है हाथ तो बीच मझधार में मुझे छोड़ ना देना
मेरा जो कल अच्छा होने का सपना है वो तोड़ ना देना
Saturday, July 12, 2008
Hyperlink Column in ASP.NET
Public Class HyperlinkBoundField
Inherits BoundField
Public NavigateUrlFormatString As String
Public NoLinkValue As String
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal field As BoundField, ByVal noLinkValue As String, ByVal urlFormat As String)
Me.DataField = field.DataField
Me.HeaderText = field.HeaderText
Me.HeaderImageUrl = field.HeaderImageUrl
Me.SortExpression = field.SortExpression
Me.NoLinkValue = noLinkValue
Me.NavigateUrlFormatString = urlFormat
End Sub
Protected Overrides Function FormatDataValue(ByVal dataValue As Object, ByVal encode As Boolean) As String
Dim value As String = MyBase.FormatDataValue(dataValue, encode)
If String.IsNullOrEmpty(value) OrElse value = NoLinkValue Then
Return value
Else
Return String.Format(NavigateUrlFormatString, value)
End If
End Function
End Class
Saturday, May 10, 2008
ASP.NET - I'm starting to loose love for it!!
- URL Rewriting: Ok. It might not really be a .NET thing and IIS thing but unfortunately .NET doesn't run on Apache. Features that apache's mod_rewrite has been providing for so long are still difficult to achieve in IIS.
- SetMaxAge for caching: Unfortunately, whatever value I set, it sets it to Zero. Refer to http://msmvps.com/blogs/omar/archive/2006/08/02/cache-control-header-cannot-be-set-properly-in-asp-net-2-0-a-solution.aspx
- Removing a cookie from Cache: I thought it would be easy enough!!! Just set expiry of the cookie to a past date and you should be fine! In fact, I needed to remove all the cookies starting with "custom". The way I went ahead is...
HttpCookieCollection cookies = Request.Cookies;
for(int i=0; i<cookies.Count; i++) {
HttpCookie cookie = cookies[i];
if(cookie.Name.StartsWith("custom") {
cookie.Expiry = DateTime.Now.AddYears(-1);
}
}
- seems cool? No. turns out that if you modify cookies in Request, it doesn't help. You have a Response.Cookies collection as well. Unless you add a cookie to Response collection, it won't be sent to client and hence client will not know you changed the cookie. Anyways, I added a couple of statements to add cookies in Response collection. Then, another problem. When you add a cookie to Response collection, it gets added to Request collection as well!!! Another issue. So, as many people suggest, I had to take another variable cookieCount before the loop to avoid an endless loop! What a waste of time for simple Cookie manipulation that was so easy in languages such as PHP, ASP etc. etc.
All this has been forcing me to re-think my strategy and look back at PHP, ASP or Ruby on Rails to get sanity back to development as most of the front-ends have actually moved to HTML and JS and these languages just handle the server side manipulation. Wait for a few more days and you might see me changing my framework to PHP!!!
Saturday, May 03, 2008
दीवाना हमें बताती हैं!
लड़कों को अपने पीछे घुमाएँ
मगर आयें पीछे तो दूर भगाती हैं
दीवानी ख़ुद हैं और हमें दीवाना बताती हैं!
पहने कपड़े सेक्सी सेक्सी, फिर स्टाइल में चलती हैं
दिखाने को importance अपनी, हर पल अदाएँ बदलती हैं
देख के अदाएँ सीटी बजायें हम जो, लफंगा हमें बताती हैं
दीवानी ख़ुद हैं और हमें दीवाना बताती हैं!
पहनें sandle हील की ऊँचे, ख़ुद नागिन सी लहरायें,
देख के सेक्सी पतली टांगें लम्बी, जो कोई पीछे आए,
कभी कभी तो पब्लिक में ही, पब्लिक से पिटवाती हैं,
दीवानी ख़ुद हैं और हमें दीवाना बताती हैं!
काले काले नैना इनके, नजरें हैं मतवाली,
लगे इन्ही में है दुनिया सारी, जब तक न बने ये घरवाली,
फिर घरवाली बन के सुबह शाम ये, हमको यूँ सताती हैं,
जान बूझ के फंस जाते हैं हम, ये ऐसा हमें घुमाती हैं,
दीवाना बनाती हैं ख़ुद हमें और दीवाना हमें बताती हैं
और जब लिख दें ये जब ब्लॉग पर तो हम पर खूब चिल्लाती हैं,
दीवानी ख़ुद है और हमें दीवाना बताती हैं!
Tuesday, February 19, 2008
SQLite - A cool database engine
Saturday, January 12, 2008
Partition/ Data Protection and other tools I use
Personal data storage is always a tricky issue. For example, on my computer I usually store my accounts data, code that I wouldn't like to expose. In fact, for few of my old clients, I give them the source code in an encrypted mode so that it is their responsibility to backup/ save and they can get it modified by other programmers also if they wish to. In the past, I have used tools like:
- RAR/ PKZIP with Password: A bad choice but the only choice in DOS days. Ultimately, we had to de-compress to work and then again compress. This was a manual process and error-prone resulting in leakages sometimes. So, I moved on with better tools:
- BestCrypt: With advent This could create a protected file that can be mounted like a volume. However, the cost/ licensing of the tool prohibited me from installing the tool on the client sites. So, I primarily used it on my laptop and just copied the volume on their machines. But this was easier and provided good level of protection.
And now:
- TrueCrypt: Recently, during a visit to one of my client, I found that they were using TrueCrypt! That was interesting. I had never heard of this tool. I searched and found that it was FREE!! Offered everything I wanted and I can install it for my clients too. Reviews are great. That means, this is the tool of my choice now.
Then there is another issue. With so many sites, partitions and areas where we need to put in password the risk is - how do I record passwords so that I don't forget!! One of the easier route is - keep the password same but that's risky. In addition, many tools/ sites have different restrictions on password strength, length, combination, expiry etc. So this is not a good strategy. I want to keep strong passwords for any sites where I can shop (like Amazon, PayPal) and banks. So, I started using KeePass - another freeware that I can use to generate and store my passwords without the hassle of remembering every password.
Now, as of today, here is a list some tools I use:
- Protection: KeePass, TrueCrypt
- Version Control: VisualSVN Server (Subversion), TortoiseSVN, Perforce Diff/ Merge (For better diff and merge functionality)
- AntiVirus: Nod32 - found it to be quite fast. With other antivirus such as Kaspersky, McAfeee etc., my Visual Studio project compilation times were quite high. Even AVG was good in the past but its reliability score isn't that good.
- FTP: FileZilla
- CD/DVD Emulator: Daemon Tools
- CD/DVD Writer: InfraRecorder
- Media Player: Media Player Classic from K-Lite Codec Pack
- Remote Access: TeamViewer
- Web Conferencing: Yugma
- Messengers: Google Talk, Trillian, Skype - I hate multiple clients but have to use them :(
- Browser: Mozilla Firefox with Firebug
- PDF Reader: FoxIt Reader - thank got - no more Acrobat reader
- RSS Feed Reader: JetBrains Omea Reader (Though I'll be looking at NewGator products as well now as they went free)
- Compression: WinRAR
- Other Development Tools: Reflector, MyGeneration (Code Generator)
- Blog Writing: Windows Live Writer (for now)
Apart from these, I just use Visual Studio 2008, SQL Server 2005 (Developer Edition), Microsoft Office and sometimes Internet Explorer! I'm always looking for leaner, faster alternatives.
SQL 2005 - Some quirky findings
This week I was working on a performance related issue for one of the clients. They had about 3 million records in their order table and about 7 million records in a child table. They are going to provide the tracking/ search options online so we have created a tool for them to do so. However, there is a complex security criteria as well and the search time was horrible!! Most of the searches took 100+ seconds meaning the site was useless. While trying lots of alternatives I found out couple of things:
New SQL 2005 ROWNUMBER() function isn't that useful. In most of the sites, we need to show the total record count and then return the results for the requested page. So our query will be something:
DECLARE @PageNum AS INT;
DECLARE @PageSize AS INT;
SET @PageNum = 2;
SET @PageSize = 10;
SELECT COUNT(*) FROM [Order] WHERE [OrderDate] BETWEEN '1/1/2000' AND '1/1/2005'
WITH OrdersRN AS
(
SELECT ROW_NUMBER() OVER(ORDER BY OrderDate, OrderID) AS RowNum
,OrderID
,OrderDate
,CustomerID
,EmployeeID
FROM dbo.Orders
WHERE [OrderDate] BETWEEN '1/1/2000' AND '1/1/2005'
)
SELECT *
FROM OrdersRN
WHERE RowNum BETWEEN (@PageNum - 1) * @PageSize + 1
AND @PageNum * @PageSize
ORDER BY OrderDate
,OrderID;
The key thing you'll notice above is - we are executing the WHERE clause twice. Once when trying to find out the total records and then the records for the page requested. If the queries go complex, this means, we are spending twice the time we should have! In the old SQL 2000 way, the way we used to write the same query as:
DECLARE @PageNum AS INT;
DECLARE @PageSize AS INT;
DECLARE @RecordCount AS INT;
SET @PageNum = 2;
SET @PageSize = 10;
DECLARE @PagingTable TABLE ([Row#] int identity, [Id#] int)
INSERT INTO @PagingTable [Id#] (SELECT [OrderId] FROM [Order] WHERE [OrderDate] BETWEEN '1/1/2000' AND '1/1/2005' ORDER BY [Orderdate], [OrderId]
SET @RecordCount = @@ROWCOUNT
SELECT [Order].*
FROM [Order] INNER JOIN @PagingTable [PagingTable#] ON [Order].[OrderId] = [PagingTable#].[Id#]
WHERE [Row#] BETWEEN (@PageNum - 1) * @PageSize + 1
AND @PageNum * @PageSize
ORDER BY [Row#]
In this second query, if you notice, the query is run only once. This reduces the overall time it takes to return the results.
The second finding was even more intriguing. In my where clause I had something like:
WHERE [CustomerId] IN (SELECT [CustomerId] FROM [Customer] WHERE [CustomerName] LIKE 'A%'
. This was returning the results in about 100 seconds and was quite irritating. Then I tried a simple change. First I inserted the results in a temp table variable like:
DECLARE @Customers TABLE ([CustomerId] int)
INSERT INTO @Customers [CustomerId] SELECT [CustomerId] FROM [Customer] WHERE [CustomerName] LIKE 'A%'
And now my WHERE condition looks like
WHERE [CustomerId] IN (SELECT [CustomerId] FROM @Customers)
Now, the query returns the result in around ~250ms! Isn't it surprising. Anyway, this confirmed one thing - never get bogged down by what you already know! Every project, every situation is different and experimentation beyond the known always helps.
Tuesday, April 17, 2007
Using Inno-Setup for Excel Add-In Installation
[Setup]
AppName=My Excel Add-In
AppVerName=My Excel Add-In ver 1
DefaultDirName={pf}\Durlabh
[Files]
Source: MyExcelAddIn.xla; DestDir: {app}; AfterInstall: CheckRegistry(true);
[Code]
procedure CheckRegistry(Install: Boolean);
var
OfficeVersions: TArrayOfString;
I: Integer;
J: Integer;
Installed: Boolean;
Key: String;
Value: String;
Keys: TArrayOfString;
AlertMessage: String;
CurrentValue: String;
NewKey: String;
KeyNumber: Integer;
NewKeys: TArrayOfString;
begin
// Location of Add-In
Value := ExpandConstant('"{app}\MyExcelAddIn.xla"')
// List office versions
if RegGetSubkeyNames(HKEY_CURRENT_USER, 'Software\Microsoft\Office', OfficeVersions) then
begin
// Check all the office version
for I := 0 to GetArrayLength(OfficeVersions)-1 do
begin
// Initialize Installation Info
KeyNumber := 0;
Installed := false;
// Check if Excel is installed and has Options
Key := 'Software\Microsoft\Office\' + OfficeVersions[I] + '\Excel\Options';
if RegKeyExists(HKEY_CURRENT_USER, Key) then
begin
// List all the add-ins currently being shown - for this read all value name
if RegGetValueNames(HKEY_CURRENT_USER, Key, Keys) then
begin
// Process each value name
for J := 0 to GetArrayLength(Keys)-1 do
begin
// Check if it is really an ADD-IN
if (Length(Keys[J]) >= 4) AND (Copy(Keys[J], 1, 4) = 'OPEN') then
begin
// Read the add-in path
if RegQueryStringValue(HKEY_CURRENT_USER, Key, Keys[J], CurrentValue) then
begin
// Check if it is the add-in we are installing
if CompareText(Value, CurrentValue) = 0 then
Installed := true
else
begin
// Store all other add-ins in another array
// Will be used for uninstall
SetArrayLength(NewKeys, KeyNumber + 1);
NewKeys[KeyNumber] := CurrentValue;
KeyNumber := KeyNumber + 1;
end
end
end
end
end
if Installed then
begin
// Are we trying to uninstall?
if not Install then
begin
// Re-serialize all other add-ins
for J := 0 to KeyNumber-1 do
begin
NewKey := 'OPEN';
if J > 0 then
NewKey := NewKey + IntToStr(J);
RegWriteStringValue(HKEY_CURRENT_USER, Key, NewKey, NewKeys[J]);
end
// Delete additional keys
repeat
NewKey := 'OPEN';
if J > 0 then
NewKey := NewKey + IntToStr(J);
until (Not RegDeleteValue(HKEY_CURRENT_USER, Key, NewKey))
end
AlertMessage := 'Installed'
end
else // Not installed
begin
// We are trying to install - add to the last
if Install then
begin
NewKey := 'OPEN';
if KeyNumber > 0 then
NewKey := NewKey + IntToStr(KeyNumber);
RegWriteStringValue(HKEY_CURRENT_USER, Key, NewKey, Value);
end
AlertMessage := 'Not-Installed';
end
AlertMessage := 'For office version ' + OfficeVersions[I] + ', add-in is ' + AlertMessage;
//MsgBox(AlertMessage, mbInformation, MB_OK);
end
end
end
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
case CurUninstallStep of
usPostUninstall:
begin
CheckRegistry(false);
end;
end;
end;
Your comments/ feedback will be highly appreciated.
Tuesday, November 21, 2006
SPA-3102 Configuration for VoiceStick and InternetCalls
Get an incoming number from http://www.voicestick.com. At this moment, I found this to be easiest to set and most reliable. You can sign-up for a free account without outgoing options. They will ask for Credit Card information for authentication but they won't charge unless you opt for some credits.
Step 2
Get an internet calls account from http://www.internetcalls.com for outgoing calls.
Step 3
Configure your SPA-3102 adaptor
- After plugging in wires, in your internet browser go to http://192.168.0.1/admin/voice/advanced
- Click on Line 1 Tab and update the following settings
Proxy and Registration Section
Proxy: i2telecom.com
Use Outbound Proxy: Yes
Outbound proxy: 206.165.50.116
Use OB proxy in Dialog: Yes
Subscriber Information section
Display Name: Whatever you want
User ID: Your voicestick number
Password: Your voicestick password
Gateway Accounts:
Gateway1: sip.internetcalls.com
GW1 Auth ID: your internetcalls username
GW1 Password: your internetcalls password
Dial Plan:
Dial Plan:(000S0<:@gw0>|1xxxxxxxxxxS0<:@gw1>|<#9:>xx.<:@gw1>)
Note: This dial plans means all the numbers with 000 will be routed through gateway 0 (PSTN) and all the numbers starting with 1 followed by 10 digit number will be dialled using gw1 - your internetcalls account. In addition, you can use #9 to get line 1. - Click on Submit all changes and should all be set to go.
- Verify that Info page shows Registration State as Registered in Line 1 Status
Using SipNumber for incoming calls
Proxy and Registration Section
Proxy: proxy.freedigits.net
Use Outbound Proxy: Yes
Outbound proxy: outbound.freedigits.net
Use OB proxy in Dialog: Yes
Subscriber Information section
Display Name: Whatever you want
User ID: Your sipnumber number
Password: Your sipnumber password
Thursday, June 15, 2006
Must Watch Movie - Life is Beutiful
More than 2 weeks - no post - a summary to catch-up
On the long weekend of May 29th, we spent Saturday in watching movies mainly. Nothing much - just relaxing. On Sunday, we went to Thurmond lake with two other families in Augusta - one of Sunil Ji and another one of Sushanto. Sushanto has just moved to Augusta and he didn't had a car. So I helped him in some grocery shopping as well. Thurmond lake is a nice place to be and it is like beach. Since we didn't take our swim-ware so we spent most of the time on the shore. We enjoyed a lot by playing cards and chatting a lot. After returning to Augusta, I helped Sushanto in getting his electronic stuff hooked up properly.
May 28th
On May 29th, Monday I came to know that I need to go for a training to Dallas Texas. So Monday I spent in planning for the trip and purchasing some stuff. Being a holiday, most of the shops were closed. Anyways, I managed to get some stuff from Walmart - that's the advantage of it being 24x7 :)
May 29th
Cab ride to Augusta Airport
On Tuesday I left for Dallas. From my home to Augusta airport, I took a cab and driver was originally from Albania settled in USA since last 15 years or so. We had an interesting chat. He mentioned that he considers USA the country of GOD because USA has so many resources that people don't know how to utilize it. That's the reason why they don't care about utilizing so much of paper and water and other resources! I kind of agree with him. He was also impressed with the freedom and systems that are there in USA. It made my trip interesting. When I arrived at Augusta Airport, it was a pleasant surprise to find that the Airport is much better now.
Flight to Dallas via Atlanta
On my way to Dallas I read couple of books - "Pro VSTS" and "Framework Guidelines" for .NET. Both were a nice read and they gave me new ideas. I'm sure those will go a long way in further refining some of the stuff I'm doing.
Dallas Forthworth airport to Hotel
I took a cab and by chance the driver was a Pakistani guy. It was again a pleasant surprise. We talked a lot about stuff ranging from bollywood to politics etc. The whole ride was really enjoyable and the guy was really nice. It again reminded of the fact that differences exist between the politics but not in the heart of people.
After I reached hotel, I called my wife and immediately went to sleep! After all it was a long travel.
May 30th
My training was on Familiarization with Legacy Modernization and the trainer was Tim O'Brien from Fujitsu Computer Services. He was an amazing guy. Other people in training were Nicolas Legar from Borne group that Fujitsu had acquired earlier, Derrick Walsh from DMR Group and Siva from Rapidigm group. It was nice to meet people from different groups. It was an eye opener and I was amazed with the offering of Fujitsu for migrating Cobol Apps from mainframe to Windows platform.
May 31st
The training continued and it ended at about lunch time. Then we had lots of time so I asked Derrick to accompany me to downtown Dallas for a short trip. We took Dallas public transport to go to downtown and went to the place where John F. Kennedy was shot. We also went to Kennedy museum. It was a memorable trip with Derrick that I will remember forever. Once we were back Derrick left for his flight for journey back to Canada.
On 31st I also met Sunil Bansal - one of my collegues who recently moved to US on a project for Fujitsu. I told him about some of the things he should do and stuff like that. It was a nice meeting and a pleasant surprise.
Jun 1st
I took my flight back to Augusta. It was not a pleasant trip. I left hotel at 5:30am and reached home only at around 5:30pm. For a small flight time, the delay was much longer because of bad weather. Being a vegetarian I almost got starved because the food choices were limited. Anyways, I reached home and then just relaxed :)
Jun 2nd to Jun 6th
I spent these 5 days on catching up the work that piled up during my training. There were some issues in one of the application that we were supposed to deliver to a client. Ultimately we resolved those and after that we had long discussions on how to proceed further. So nothing much in those days except fire-fighting or writing some code. I also visited doctor and got a clean chit regarding my hand and ear and now both are okay :)
Jun 7th to Jun 9th
Client side lead was supposed to leave for a trip to Italy so I spent lot of time with him in understand where the team is and what we are supposed to achieve when he is gone for two weeks. I also had long meetings with client side project manager to discuss what offshore team did for the project and what are we supposed to do next. Again - hectic period. :) However, on 7th of June, I watched the movie "Life is Beutiful" and it was worth the watch!
Jun 10th
I spend most of the time watching movies - 5 to be exact -thanks to blockbuster. It was a relaxing day and did nothing. Just went to Vishal's place as he was supposed to attend a marriage. Arti helped his wife in getting ready for the function. I just relaxed as I wanted to give rest to my body :)
Jun 11th
We were invited by our friend Sunil Joshi to his place and we enjoyed lots of food stuff. It was an amazing get together for a foodie like me. We enjoyed "Bedai", "Dahi Wada", "Golgappas" and lots of other stuff. In the evening we returned and again - relaxed.
Jun 12th and 13th
It was normal day with work in office. After office hours I had very little time for myself as Sunil Ji caught serious viral infection "Strep throat" and later his daugter as well. We went to their place to help his wife and to play with his children so that he can relax.
Jun 14th
Again a normal day at office but I finally caught up with my learning ways. Restarted studying SQL Server 2005 and some new cool stuff with Google Maps API etc. Will be posting more on it as I go along. At the end of the day, I received an e-mail regarding a training on "Macroscope" that I was waiting for. Fortunately it is in Virginia close to my best friend Karan's house so it'll give me a chance to meet him after almost 1 and a half years. I am quite excited about it. I hope to catch up with
Jun 15th
Here I'm. Spent most of the time at work-place in meetings for one of the applications. In the evening, just got home and trying to catch up with blog. I hope that in future I'll be more regular.
Friday, May 26, 2006
Automated Testing of UI, and Visual Web Developer
Read more at .... http://blogs.msdn.com/scottlo/archive/2005/06/29/434121.aspx
Wednesday, May 24, 2006
CSSVista and SiteVista - Live CSS Editing and site browser compatibility testing
This is a free Windows application for web developers which lets you edit your CSS code live in both Internet Explorer and Firefox simultaneously.
http://www.sitevista.com/cssvista/
SiteVista
- Painless testing: Quickly see if your web site works with all popular web browsers. Receive screen captures from different browsers in minutes.
- Don't lose visitors: If your site breaks in some browsers, those visitors can't use your site (or purchase from you).
- Look more professional: Prove to your clients and co-workers that you've conducted thorough testing.