Thursday, December 10, 2009
aspnet: jQuery Grid View Control
This is a report writer control that uses jQuery and CSS to render reports in a grid layout fashion. Developers have the option to cache the output and use the cached dataset for sorting. This is extremely useful when you are pulling data from very expensive/slow running queries or from a remote server.
Data can be rendered using jQuery's table sorter or using a menu style css.
This control supports server side events and client or server side sorting.
Users can rename header columns, setting default sorts and hide/show columns using the preference link rendered at the bottom
download code
-paul
Monday, November 16, 2009
car: Throttle Body clean
My antique gem started having an accelerator sticking problem lately. I have been ignoring for weeks now and the recent Toyota's recall related to accelerator pedal sticking pushed me to get to the bottom of this issue. Many forums mentioned that this could easily solvable by cleaning the throttle body. A typical dealer charge for throttle body clean is $125 (I paid the same amount last year, looks like the dealer did nothing or my car is determined to go for a shopping).
Here is what I did to clean the throttle body:
-Make sure your car is shut off for at least couple of hours
-Put some weight on your accelerator pedal so that it is pressed all the way down
-Remove the hose clamp on air intake using a scree driver
-Pull the air intake out
-Put some clothes under the throttle body so that any dripping will be caught on the rag
-Spray a good carburetor cleaner into the throttle body
-Let it soak for 10 min, use a tooth brush to brush off the gunk and wipe clean
-Repeat until all gunks are gone from the butterfly valve and throttle body
-Put everything back and start the engine
-You may have to press the accelerator pedal down to get it going in the beginning
-Let it run for 10-15 min. You may notice some smoke from the tail pipe, it will clear out in 5-10 min
-If you have rough idle, you can spray some clearer into the IAC valve (the square hole in the throttle body. This normally fixes the rough idle or minor problems related to odb code for IAC valve.
<< Next Head Light & Spark Plug | Previous >> OBD Code P0125
-paul
Here is what I did to clean the throttle body:
-Make sure your car is shut off for at least couple of hours
-Put some weight on your accelerator pedal so that it is pressed all the way down
-Remove the hose clamp on air intake using a scree driver
-Pull the air intake out
-Put some clothes under the throttle body so that any dripping will be caught on the rag
-Spray a good carburetor cleaner into the throttle body
-Let it soak for 10 min, use a tooth brush to brush off the gunk and wipe clean
-Repeat until all gunks are gone from the butterfly valve and throttle body
-Put everything back and start the engine
-You may have to press the accelerator pedal down to get it going in the beginning
-Let it run for 10-15 min. You may notice some smoke from the tail pipe, it will clear out in 5-10 min
-If you have rough idle, you can spray some clearer into the IAC valve (the square hole in the throttle body. This normally fixes the rough idle or minor problems related to odb code for IAC valve.
<< Next Head Light & Spark Plug | Previous >> OBD Code P0125
-paul
Monday, October 5, 2009
c#: Getting Foreign Security Principal Displayname
While working on a project, I needed to enumerate all Foreign Security Principals (FSP) and capture their display name from Active Directory.
Enumerating FSP is very easy by using DirectorySearcher class:
DirectoryEntry userEntry = new DirectoryEntry("LDAP://domain/CN=ForeignSecurityPrincipals,DC=domain,DC=com");
DirectorySearcher userLookup = new DirectorySearcher(userEntry);
SearchResultCollection results = userLookup.FindAll();
foreach (SearchResult result in results)
{
DirectoryEntry childEntry = result.GetDirectoryEntry();
foreach (String val in childEntry.Properties.PropertyNames)
{
Debug.WriteLine(val + "\t" + childEntry.Properties[val].Value);
}
}
This produces the following results:
objectClass System.Object[]
cn ForeignSecurityPrincipals
description Default container for security identifiers (SIDs) associated with objects from external, trusted domains
distinguishedName CN=ForeignSecurityPrincipals,DC=,DC=com
instanceType 4
whenCreated 4/21/2001 3:00:47 PM
whenChanged 8/12/2005 11:51:48 PM
uSNCreated System.__ComObject
uSNChanged System.__ComObject
showInAdvancedViewOnly False
name ForeignSecurityPrincipals
objectGUID System.Byte[]
systemFlags -1946157056
objectCategory CN=Container,CN=Schema,CN=Configuration,DC=,DC=com
isCriticalSystemObject True
dSCorePropagationData System.Object[]
nTSecurityDescriptor System.__ComObject
From this you can see that the AD entry for FSP doesn't contain the Displayname field. However if you use Active Directory Tools for Users, you can see the SID and Displayname under FSP folder. If you have access to the other domains, you can do a SID lookup on the other domains to get the Displayname. Otherwise to get the Displayname of a FSP, you need to call a win32 api function and pass the SID. So import the advapi32.dll and call LookupAccountSid api to resolve the name like this:
[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool LookupAccountSid(
string lpSystemName,
[MarshalAs(UnmanagedType.LPArray)] byte[] Sid,
System.Text.StringBuilder lpName,
ref uint cchName,
System.Text.StringBuilder ReferencedDomainName,
ref uint cchReferencedDomainName,
out SID_NAME_USE peUse);
LookupAccountSid(null, Sid, name, ref cchName, referencedDomainName, ref cchReferencedDomainName, out sidUse))
download code
-paul
Enumerating FSP is very easy by using DirectorySearcher class:
DirectoryEntry userEntry = new DirectoryEntry("LDAP://domain/CN=ForeignSecurityPrincipals,DC=domain,DC=com");
DirectorySearcher userLookup = new DirectorySearcher(userEntry);
SearchResultCollection results = userLookup.FindAll();
foreach (SearchResult result in results)
{
DirectoryEntry childEntry = result.GetDirectoryEntry();
foreach (String val in childEntry.Properties.PropertyNames)
{
Debug.WriteLine(val + "\t" + childEntry.Properties[val].Value);
}
}
This produces the following results:
objectClass System.Object[]
cn ForeignSecurityPrincipals
description Default container for security identifiers (SIDs) associated with objects from external, trusted domains
distinguishedName CN=ForeignSecurityPrincipals,DC=,DC=com
instanceType 4
whenCreated 4/21/2001 3:00:47 PM
whenChanged 8/12/2005 11:51:48 PM
uSNCreated System.__ComObject
uSNChanged System.__ComObject
showInAdvancedViewOnly False
name ForeignSecurityPrincipals
objectGUID System.Byte[]
systemFlags -1946157056
objectCategory CN=Container,CN=Schema,CN=Configuration,DC=,DC=com
isCriticalSystemObject True
dSCorePropagationData System.Object[]
nTSecurityDescriptor System.__ComObject
From this you can see that the AD entry for FSP doesn't contain the Displayname field. However if you use Active Directory Tools for Users, you can see the SID and Displayname under FSP folder. If you have access to the other domains, you can do a SID lookup on the other domains to get the Displayname. Otherwise to get the Displayname of a FSP, you need to call a win32 api function and pass the SID. So import the advapi32.dll and call LookupAccountSid api to resolve the name like this:
[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool LookupAccountSid(
string lpSystemName,
[MarshalAs(UnmanagedType.LPArray)] byte[] Sid,
System.Text.StringBuilder lpName,
ref uint cchName,
System.Text.StringBuilder ReferencedDomainName,
ref uint cchReferencedDomainName,
out SID_NAME_USE peUse);
LookupAccountSid(null, Sid, name, ref cchName, referencedDomainName, ref cchReferencedDomainName, out sidUse))
download code
-paul
Saturday, July 4, 2009
car: OBD code P0125
My check engine light came on today. I didn't notice any driving issues, so I drove to the near car repair shop. After checking the odb code, I was told I have a bad oxygen sensor (odb code 0125). After spending $250 for replacing the sensor, I thought it was the end of the check engine light saga.
After couple of weeks, that darn light came back on again. This time I decided to find out the code and see what others are saying. I went to one of those "zone" shops and they hooked up a nice snap-on scanner and show me the code. "P0125-insufficient coolant temperature". I was very happy that they showed me the code and cleared it off and they were very happy to help me. When I asked what should I do about this code, they told me the stupidest answer that I ever heard from a car mechanic.
"Yo, you need to drain your coolant and put a gallon of 100% coolant (don't add any water) and this should be fine". Every single manual that I ever read told NEVER put the concentrated coolant.
Confused, I went to the dealer and asked for their opinion. They told to change the O2 sensor and I should be fine. When I told them they changed the O2 sensor last month, they told to change the thermostat. I came back home and after reading through some forums and consulting with my neighbour car guru, I decided to give it try.
Here is how to change the thermostat on 2000 Camry:
-Drain coolant from radiator
-Remove the two nuts holding the thermostat
-Pull the black pipe and remove the thermostat with the gasket
-Put in the new gasket and align the thermostat's mark to the mark on the engine body
-Tighten the nut
-Fill the coolant
-Start the engine and wait for 10-15 min to clear the check engine light
If you get P0125 obd code, before changing the expensive O2 sensor, try changing the thermostat. It is under $10 and all you need is a 10mm wrench and 10 min. Buy some nicetools for you jewelry for your lady for the money you saved.
<< Next Throttle Body Clean | Previous >> Car Detailing: The Clay Way
-paul
After couple of weeks, that darn light came back on again. This time I decided to find out the code and see what others are saying. I went to one of those "zone" shops and they hooked up a nice snap-on scanner and show me the code. "P0125-insufficient coolant temperature". I was very happy that they showed me the code and cleared it off and they were very happy to help me. When I asked what should I do about this code, they told me the stupidest answer that I ever heard from a car mechanic.
"Yo, you need to drain your coolant and put a gallon of 100% coolant (don't add any water) and this should be fine". Every single manual that I ever read told NEVER put the concentrated coolant.
Confused, I went to the dealer and asked for their opinion. They told to change the O2 sensor and I should be fine. When I told them they changed the O2 sensor last month, they told to change the thermostat. I came back home and after reading through some forums and consulting with my neighbour car guru, I decided to give it try.
Here is how to change the thermostat on 2000 Camry:
-Drain coolant from radiator
-Remove the two nuts holding the thermostat
-Pull the black pipe and remove the thermostat with the gasket
-Put in the new gasket and align the thermostat's mark to the mark on the engine body
-Tighten the nut
-Fill the coolant
-Start the engine and wait for 10-15 min to clear the check engine light
If you get P0125 obd code, before changing the expensive O2 sensor, try changing the thermostat. It is under $10 and all you need is a 10mm wrench and 10 min. Buy some nice
<< Next Throttle Body Clean | Previous >> Car Detailing: The Clay Way
-paul
Monday, May 18, 2009
web: Detecting Concurrency Violation in aspnet
Being a stateless protocol, it is very hard to detect concurrency violation and alert users in a web application. I was burned couple of times by 2 or more users simultaneously updating the same data and over writing the first update. I was able to solve this problem with an aspnet custom control and some back end logic to detect and show the user if somebody else updated the data after you fetched the data from the database.
[This is written in Sql Server, but can easily ported to any database]
1. Create a table to hold a reference number
2. SPROC to create the reference record anytime a row is updated in a relevant table. You can use a trigger or call this sproc from the business layer in applications.
3. Function to check if the reference number is still valid.
4. Create aspnet custom control to render a div if we detect a concurrency violation.
5. A non-intrusive pop up layer to alert the user that the data is out of scope when we detect a concurrency violation.
6. Create a derived class from System.Web.Page to expose CreateConcurrency, TrackConcurrency and HandleConcurrency methods. TrackConcurrency retrieves the last reference number for the relevant data object name and stores it in the viewstate. HandleConcurrency method takes this reference number and checks the database for any updates to this data object. If an update is detected, throw an error.
If you just want to detect the concurrency violation in business layer or sproc and don't bother to display a visual alert, you can do that by adding a timestamp column to the table and compare the timestamp value with what is passed from the view page and then throw an exception from the business layer or sproc.
download Framework, Sql, aspx and code behind files
That is it.
--paul
Monday, March 9, 2009
wood working: Inspired by The Man with No Name
I was thinking about building a bed for my son for a couple of months now. I looked at numerous designs and finally settled on this particular style because the arching headboard looks really nice to me. Head board is made from Burch plywood. I Cut the arch using a jig saw and sanded smooth with a power sander.
Head board without any decorative elements looked very blank to me. So after building the project, I thought of adding two decorative elements to the Head Board to decorate it up a little. I was planning to put a bird's outline on to the headboard. During the making of this project, I saw a couple of Clint's western spaghetti movies and decided to cut a piece of a man on a horse (this is somewhat similar to the opening sequence in the The Good, The Bad and The Ugly movie). I also added the Golden Leaf decoration that I saw in a History Channel show.
Here is the final product.
Bed Size : Twin
Finish: Cherry
Material: Pine and Burch Plywood
-paul
Monday, February 16, 2009
car: To Clay or To Not Clay
I never find any interest in spending too much time cleaning and detailing my car. Years passed by with just a wash and a spray wax and my car now looks really horrible. I really didn't know that what I see was water spots until I saw an episode in a TV show featuring Jay Leno. It was about detailing a car, not just a simple wash and wax routine that I was so comfortable and accustomed but a five step process that takes almost 3-4 hours of rubbing and cleaning. This is how my car looks like just after washing (by washing I mean using a market leading car wash with wash pads and rinse in soft water. It cannot get any better than that). sheeeewww!
I watched the show and still didn't think I need to CLAY my almost 10 year old car. Months went by with out doing anything to the car. I was watching a motivational / tele-vangelical program and something caught my attention. The thing I like about that program is that he talks about simple things in everyday life to make it better and to feel good about yourself. He was saying, instead of complaining about how horrible the traffic is, you should Thank God that you have car to drive, a good health to go places, a Job to take care of your family. That was the trigger point, I decided to do something with the water spots.
I browsed couple of sites and was still skeptical about the process and results. Some sites suggested to wipe vinegar to remove the water spots. It didn't work for me. I decided to go with the heavy artillery this time. I took a couple of shots before and after the process to compare the results. After all, I wanted to check is it really worth spending money and time on an old car with a lot of water spots.
Here is how I did the Claying:
-Wash and completely dry the car
-Apply the quick detailer to a small area and rub the clay bar over it without much pressure.
-When the clay starts to slide without any grip, wipe off this area clean and move to the next section.
-After the entire car is clayed, apply a car polish
-Next apply a paste wax.
-Buff the car after the wax is dried
It took almost 4 hours to wash, clay, polish and wax the car. I used a power buffer (some day I may buy the coveted Porter-Cable 7428) in the final stage. Here is a snap of the moon reflecting from a 10 year old car. Now, that is a job well done!
<< Next OBD P0125 | Previous >> Radiator Flush
-paul
I watched the show and still didn't think I need to CLAY my almost 10 year old car. Months went by with out doing anything to the car. I was watching a motivational / tele-vangelical program and something caught my attention. The thing I like about that program is that he talks about simple things in everyday life to make it better and to feel good about yourself. He was saying, instead of complaining about how horrible the traffic is, you should Thank God that you have car to drive, a good health to go places, a Job to take care of your family. That was the trigger point, I decided to do something with the water spots.
I browsed couple of sites and was still skeptical about the process and results. Some sites suggested to wipe vinegar to remove the water spots. It didn't work for me. I decided to go with the heavy artillery this time. I took a couple of shots before and after the process to compare the results. After all, I wanted to check is it really worth spending money and time on an old car with a lot of water spots.
Here is how I did the Claying:
-Wash and completely dry the car
-Apply the quick detailer to a small area and rub the clay bar over it without much pressure.
-When the clay starts to slide without any grip, wipe off this area clean and move to the next section.
-After the entire car is clayed, apply a car polish
-Next apply a paste wax.
-Buff the car after the wax is dried
It took almost 4 hours to wash, clay, polish and wax the car. I used a power buffer (some day I may buy the coveted Porter-Cable 7428) in the final stage. Here is a snap of the moon reflecting from a 10 year old car. Now, that is a job well done!
<< Next OBD P0125 | Previous >> Radiator Flush
-paul
Thursday, January 8, 2009
charity: Helping The Helpless
This was my first charity endeavour and my target was $250.00. As I wrote earlier, I built 2 crosses and one Hanuman for the charity. At first I was skeptical about the success. Many friends came forward to help raising money. Some of them offered a place for raffle, some offered ideas for next fund raiser. To my surprise I was able to raise $890.00 for the charity.
Here is how we spend the money (2 charity organizations and a brain cancer patient):
-Christmas day Lunch for 323 people : $170
-New year's day lunch for 323 people: $150
-Rice, vegetables and Medicine for 420 people: $320
-Part of Medical cost for a brain cancer patient's operation: $250
All these people are either mentally challenged or orphans thrown to the streets. I am extremely happy to help them with the generous hands of a group of people whom I am privileged to call as FRIENDS.
This charity fund raiser taught me some valuable and well known lessons of life:
- You never know until you try
- You have to ignore the ney sayers and press forward
- Not everyone shares the same idea or enthusiasm as you do
- Do your part and hope for the best.
I hope and pray that I will have the energy, enthusiasm, health and opportunity to do another charity fund raiser for 2009.
On behalf of all these Helpless people,
Thank You Friends!
-paul
Here is how we spend the money (2 charity organizations and a brain cancer patient):
-Christmas day Lunch for 323 people : $170
-New year's day lunch for 323 people: $150
-Rice, vegetables and Medicine for 420 people: $320
-Part of Medical cost for a brain cancer patient's operation: $250
All these people are either mentally challenged or orphans thrown to the streets. I am extremely happy to help them with the generous hands of a group of people whom I am privileged to call as FRIENDS.
This charity fund raiser taught me some valuable and well known lessons of life:
- You never know until you try
- You have to ignore the ney sayers and press forward
- Not everyone shares the same idea or enthusiasm as you do
- Do your part and hope for the best.
I hope and pray that I will have the energy, enthusiasm, health and opportunity to do another charity fund raiser for 2009.
On behalf of all these Helpless people,
Thank You Friends!
-paul
Subscribe to:
Posts (Atom)