Wednesday, January 26, 2011

java: Jira Plug-in for Confluence


This is a plug-in for Confluence wiki to pull Jira defects to generate product release notes. We are using Jira to track defects, features and documentation on products.
This plug-in uses Jira's Issue Navigator xml link to pull defects pertaining to a particular release. Once the defects are retrieved, the xml is parsed through a home grown XSLT template to group issues, transform links and format output. The resulting html is processed through ScrollWiki plug-in to convert to a pdf file that can be included in the product release.
We are using a generic user credentials to fetch records from Jira. This user has read permission on all projects and the password is stored in a secured password keeper.


The hard part was setting up the environment. Even though the documentation is clear on how to setup the project, it took a good amount of time to setup the project and dependencies for the confluence version that we are running.

If you are using NetBeans to develop the plug-in, you need to manually edit the build file to include the plug-in xml file to jar. I started with IntelliJIDEA template to develop and build plug-ins and later switched to NetBeans.

download code

-paul

Thursday, January 20, 2011

aspnet: Add Plug-in Capability to a web application

Adding plug-in capability to a web application is not something you will need for every applications. If you want to hook up to a web application for specific events (eg a defect is created in the defect tracking system) and you don't have or want to mess with the original application, plug-ins are a great way to handle these situations. In order to support plug-in, you need to define your plug-in interfaces, base classes, abstract classes and event model.

Once you have these setup in your main application, you can write the plug-ins based on the interfaces and base classes. Your main application will invoke events and based on what events you are subscribed to, your plug-in class will be called. An object with current state will be passed to your class as the event args.


During the application start-up, check for any plug-in files in the configuration file and cache an instance of all plug-ins in an application variable. On all defined events, loop through this array and call the appropriate method to invoke the plug-in method.


download code

-paul

Monday, December 20, 2010

wpf: Setting folder permissions on NetApp server.


Recently I was working on a project to set folder permissions on one of our file servers. We are migrating to a new corporate domain structure with new user names.
Neither the old and new domains are in a single forest nor do have a two way trust. Once we are migrated to the new domain, we want the users to have access to their files with their new user credentials. This file server is a NetApp server and folders are secured using NTFS file system permissions. Even though this server can be managed using windows explorer, it doesn't support WMI or RPC to get/set permissions. Luckily I was able to use ICACLS to enumerate and set permissions on these folders.

[If you want to set permissions on a windows based file server, you can use ICACLS or the native DirectorySecurity namespace or WMI.]

Highlights:
- If the log on user is a department owner, he can specify the folder to start
- Use background thread to do the job. This will free up the mail UI thread and better program responsiveness
- Log results to a database for reporting
- Email the user once the process is finished
- Display % completed, total directories, completed directories and currently executing commands
- Display vista style progressbar on non vista platforms.

download code

-paul

Sunday, December 12, 2010

c#: Outlook plug-in


Many people prefers to work directly from their email program. Even though you may have a cool website, the convenience of working directly from your email program in response to an email is one of the best way to boost the productivity of people. This is an outlook plug-in designed to full fill the needs of an offline system with ease and convenience of working directly from Outlook.

If you have a web service and a mailbox processor, writing an Outlook plug-in is very easy and rewarding. You can easily add offline capability for many tasks without needing any special software on users computer. If you are connected to a back-end system, this plug-in forwards all calls to the back end system. If you are offline, this plug-in formats the message in a specific way and then emails to a mailbox which will process and update the back end system.

Based on the currently selected item in outlook, this plug-in enables or disables appropriate buttons. For eg, if you select an existing ticket email, then CreateTicket button is disabled.

It may be necessary to add toolbars to the Outlook menu bar and/or to the Message Item window. By adding to the menu bar, you can respond to many emails at once without opening one at a time.


Programming Logic:
- Create new buttons and attach event handlers to each for them.
- OnButtonClick event, check the sender and take appropriate actions
- When the selected email changes, check and enable/disable buttons
- If online, use the back-end system directly.
- If offline, compose new email with commands and send to a monitored mailbox
- Create Windows Forms for Configuration and additional data

download code

-paul

Friday, November 5, 2010

c#: POP3 mail processing Windows Service

Often times we need to process mails in a mailbox and based on the subject or message body, take actions in back-end systems. This was a project to process POP3 mailbox using c# implemented as a Windows Service. You can use TCP/IP to connect and process mails on a POP3 server. If your server requires SSL, use SSLStream on top the existing TCP stream to establish communication with the server. Sending commands to POP3 server is quite simple as writing the command (eg "DELE\r\n") to the TCP/IP socket and check the response.
Unlike IMAP, pop3 server doesn't keep track for message status (read/unread) so you cannot just fetch all unready message from the server. Once you are done with processing, delete the mail or keep track of the message guids to exclude in the next batch.

In this program, I am fetching all messages into an array and then sort them based on sent date. All attachments are saved to the file system and a handler is saved in the database.


The windows service that hosts this library has a timer which calls the StartMailBoxProcessor code on a user defined time intervals. This service is deployed to two servers with fail over capability.

download code

-paul

Thursday, September 9, 2010

wcf: MS Exchange Agent


An Ajax enabled web application that communicates with a wcf service for getting appointment items from Exchange Server. This service defines interfaces for create/update/delete/get appointments from Exchange server.
Users can click on any date in the calender control and Outlook appointments will be presented in an Ajax enabled web portlet.

In the past I have used .Net remoting to communicate with the server to get results from a service to the web page. It was slow and was kind of ugly to write code to interpret the integer command argument (only way to communicate with a service) for processing.


Proxy files are generated using svcutil.exe. We chose to host the service in Windows Services rather than IIS. This enables us to take advantage of Corporate Service Monitoring application to monitor the service. This service is installed on two servers with a fail-over capability.

download code

-paul

Tuesday, August 3, 2010

wood working: Rails



I saw this style of railing in a movie long back and it looked pretty cool. This is a common style used in most temples in South India and recently a lot of new houses are built with this style of rails. I decided to build a railing for my patio and here is the end result. I made a template in mdf and then replicated on pine. First I rough cut the wood using a band saw and then routed the final piece using the template.
The most tedious job was drilling the through hole for the bar. I couldn't find a drill bit that matches the rod diameter, so I have to enlarge the hole by sanding using a hand held drum sander.
I thought drilling the hole in the stone/concrete floor would be tougher job. But it turned out to be the most easy one. I was able to attach the post to the concrete in less than 10 minutes.
After sanding, 3 coats of exterior paint and 2 coats of polyurethane, this is how it looks.


Post: 2x2 Redwood.
Rail: 2x10 Pine.

-paul

Friday, June 4, 2010

sqlclr: RegEx search in Sql Server

Even thought T-SQL is very efficient in processing set based data, it is very inefficient in executing many string based operations (eg extract strings from a text column based on search patterns). Unfortunately Sql Server doesn't have any native support for Regular Expressions to do this efficiently. Because of the .Net CLR integration, we can write a sql clr function to achieve this functionality. Here is a generic regular expression search function using RegEx that can be used to extract any pattern matched strings from any text column from Sql Server.
You can use the same logic to extract pattern matched strings from files, network shares etc.
1. define an IEnumerable static method with SqlFunction attribute.
2. define a GetRow method to return a single row for the tvf. Sql CLR will call this method to populate the tvf.
3. use a case-insensitive compare method to remove duplicates. You can either omit this method or use a DISTINCT clause in the select statement in Sql Server query.
[SqlFunction(FillRowMethodName = "GetRow", DataAccess = DataAccessKind.Read, TableDefinition = "found varchar(8000)")]
public static IEnumerable GetRegExSearch([SqlFacet(MaxSize = -1)]SqlString text, SqlString regExSearchFor)
{
List allFound = new List();
MatchCollection matchCollection = Regex.Matches(text.ToString(), regExSearchFor.ToString());
for (int i = 0; i < matchCollection.Count; ++i)
{
String found = matchCollection[i].Value.ToString();
if (FoundInList(found, allFound) == false)
allFound.Add(found);
}
return allFound;
}
public static void GetRow(Object obj, out String found)
{
found = obj.ToString();
}
I am implementing this functionality as a table value function (tvf) so that we can use this to join with other tables or tvfs.

To register this assemby in Sql Server, use the deploy option from Visual Studio or copy the dll to sql server and execute

CREATE ASSEMBLY SqlCLR
FROM 'C:\SqlCLR.dll'
GO
CREATE FUNCTION [dbo].[fxGetRegExSearch](@text [nvarchar](max), @regExSearchFor [nvarchar](4000))
RETURNS TABLE (
[found] [nvarchar](max) NULL
) WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [SqlCLR].[Functions].[fxGetRegExSearch]

download code

-paul

Monday, April 5, 2010

car: Head Light Restoration and Spark Plug Change

My antique gem's headlight is fading faster. One side is completely yellowish. Normal washing and cleaning is doing nothing to bring back the old glory.
I saw a couple of web sites and videos showing how to restore the headlight.
This is my take on cleaning my car's headlight. It took almost 30 minutes to clean both lights. Very simple to use, just apply the chemical to the pad and use a drill to polish. Looks pretty good to me.
Here is the before and after pics:

 

It was time to change the spark plugs. After almost 85k miles, the OEM plugs were still going strong. Changing the spark plug was a quick and easy task. Remove one plug at a time, put some anti-siege component on the new plugs thread and tighten to the correct torque.


Previous >> Throttle Body clean

-paul

Friday, March 5, 2010

c#: Spell checker control using jQuery

Recently I needed to add spell checking functionality to a web page. I wanted to exclude a list of strings from spell checking (like first and last names) and this list of exclusions should be customizable easily. I couldn't find any controls that fits into this need in the aspnet world.
I found this article that uses php and google's spell checking api with jQuery. I thought of porting this as an aspnet control so that I can use it without adding too much scripts on any aspnet pages.


Most of the heavy work is already done by the original author, so all I need to do was call google's api, parse the result and return the result as a JSON object to jQuery. Once the JSON is received, we build a div element with the bad spelled words with a click handler to get the suggestions. When building the div element, use the parent element's width and some images to show the progress or no bad words indicator. Wrap all these scripts and images in a server side control, so to use the spell checker, add the control to the web page and set the TargetControlID to the textbox's ID.




download code

-paul

Friday, February 5, 2010

c#: Exchange Mailbox Processing

This is a windows service that processes mailbox on an Exchange Server. Since the introduction of Outlook Security feature, accessing certain properties (like email) will trigger the Outlook prompt. To circumvent this prompt, we are using Redemption Extended MAPI library to fetch outlook messages.

We can use a profile to login to the mailbox or use profile-less (LogonExchangeMailbox) method to login. As I am processing the mails in a mailbox, I am moving them to a Processed Folder. I am fetching all messages into an array and then sort them on date sent descending order.


All attachments are saved to the file system and a pointer is saved in the database.


The windows service that hosts this library has a timer which calls the StartMailBoxProcessor code on a user defined time intervals. This service is deployed to two servers with fail over capability.

download code

-paul

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

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

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 nice tools for you jewelry for your lady for the money you saved.

<< 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

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

Monday, December 22, 2008

car: Radiator flush and fill

I have been looking for a radiator flush and fill for my car for the last couple of months. Dealers are insane when it comes to service your cars. After searching through a couple of forums, I decided to do the flush and fill myself.
My biggest problem was to locate the drain cock. Almost all websites says "locate the drain cock and drain the coolant". I looked under the radiator, back and front, still no luck. Some sites mentioned to remove the protective plastic/metal frame from under the hood so that you can see the drain cock. When I looked under the hood, there are almost 15 screws you need to remove to remove the protective frame. Since so many people are doing the flush and fill as DIY, I thought there has to be an easy way to flush and fill the radiator. I put my hand under the radiator and searched for any kind of connections and there it is!


CAUTION: Unless you want a face transplant, before even opening up the hood, please make sure that your car is completely cooled off. Serious injury can occur if you remove radiator cap or drain cock when the engine is hot. And remember to properly dispose the used coolant in a recycling center.

Now let's get back to the drain part.

Drain:
Once you locate the drain cock, put a 2 gal pan under the hood. Remove the radiator cap and then unscrew the drain cock slowly. As you turn, coolant will start flow through the drain valve. Don't remove the drain cock fully. Let it sit half way until no more coolant is flowing out. Remove the drain cock completely and allow the drain to complete.

Remove the coolant reservoir from the body. Unscrew 3 bolts and lift the reservoir. Remove all coolants from the reservoir. Secure the reservoir back and fill with fresh coolant.

[If you really want to get rid off all the old coolant, you should drain the engine block. To do this, locate the engine drain cock. This is at the back side of the engine. Remove this drain cock and drain the engine block completely]

Fill:
Fill the radiator with fresh coolant (50/50) or add water (Toyota manual says "preferably distilled water") to coolant concentrate to make it 50/50.Make sure you squeeze the top/bottom radiator hose so that trapped air can escape.Top off your radiator and start the engine without the radiator cap. Run for 15-20 min, top off the radiator, close radiator cap, fill reservoir. Take her for a test drive, keep an eye on the engine temperature gauge. Park the car and walk away. Top off the radiator and reservoir after the engine is completely cooled down(couple of hours).


Next >> Car Detailing: The Clay Way

-paul