Saturday, March 06, 2010

Formula 1 – 2010 Season

Who would have thought once Michael Schumacher retired after 2006 season will be back in action in F1.He tried to return back last year in place of injured Felipe Massa at Ferrari but couldn’t make it due to his neck problem.But this time around it has indeed happened and I can’t wait to see him on the track in season opener at Gulf Air Bahrain on next week end representing the team Mercedes GP which was the title winner last year  under the name of Brawn GP.
It will be fascinating to see the races with the new rule changes for this year.One of the biggest change is that there won’t be refueling during pit stops during the race which means the cars will have a much larger fuel tank which resulted to have a different weight distribution to the that of last year’s car.The other major change is the point system where first 10 finishers will get points as the number of teams are 13 this year hence 26 drivers.
Return of Michael Schumacher will really make this season interesting and will get to know whether he is still the master class in F1.

Sunday, November 15, 2009

Antique world map jig saw puzzle


Recently I completed assembling the 1500 pieces jig saw puzzle.Before this my first puzzle was a 500 pieces one.It was a gift from my good old friend Amila Jayaratne and this one was presented by my father-in-law, Mr. Gunatilake.
This new puzzle by no means a easy walk in the park as you can see in the image above.
Normally you start the puzzle by separating the border pieces.So I too stuck to that but to no avail.The reason being there are no contrasting images to identify the correct pieces(Its just a single color boarder ss you can see in the image ).Then I was thinking how I am going to tackle this new challenge.So I changed my strategy.

Since there are clear lines , circles and letters , I started to separate them out.That was indeed the way to go.Then I first assemble the circle area.
After that it became relatively easy till I getting closer towards the border area.It was very hard to find the correct pieces and it took a considerable amount of time too.
After spending around 30 hours within the span of 2 months, finally , I managed to completed this.

My ultimate goal is to complete the world’s largest jig saw puzzle which has 24000 pieces.I have already ordered the miniature version of that which has 3000 pieces.Nishad ayya will bring that for me from UK end of this month.
Waiting for that .

Saturday, November 14, 2009

Monday, November 09, 2009

Bandaranayaka College past pupil’s association’s new look web site launched


It is my pleasure to inform that the much awaited new look past pupils association’s web site lunched yesterday during the 2009 OBA day.
I would like to take this opportunity to thank Rasika Mahindasiry for his valuable efforts for the design of this new site.And further I should mention the name of Roshan Sooriyarachchi who is behind this entire project and making it a success.Job well done.
And looking forward to introduce more features into this in future.

Thursday, October 29, 2009

Embedding YouTube videos in your blog

Very simple to do this.Just open the video you want to embed in YouTube and then right click on the video and click on the “Copy embed html” and then copy that copied html code into your blog entry markup.

Here is the embedded video into this blog entry :



References : http://www.youtube.com/youtubeonyoursite

Monday, September 21, 2009

Event full weekend



Saturday, yesterday , started the day by going to the service station at 6:30AM in the morning.As usual I was the first to the service station and I was walking up and down in the premises till they started.Then came the owner of the station and he opened the doors to the pump house and generator house.
After about 45 minutes , the service man started the work with my car.It took 3 hrs to finish the job.
Then I took the car to the Tissa Electricals to check my radiator fan.The problem I had was , it was boiled when I come to the office on last Monday and I thought this may be due to the fact that my AC condenser fan was not working, the clue was I saw my heat indicator going up and when i turned off the AC it came back to the normal.So that was the history.
I told that story to the technician who run the place and I told I need to lay a harness to my power doors.After the removal of manual doors last year I replaced them with power doors, which has the options of power shutters , power mirrors , central locking , but never had a chance to complete the laying of the harness.

Then owner asked one of his technicians to take a look at this and Sampth is the name of this guy.Very talkative guy.After spending few minutes with him , I realized that he is not only talkative but also competent which is the most important thing.
Then he started to explore the vehicle.
First what he did was took the Carman Scan II diagnostic tool (a hand held device) which can be connected to the ECU via the interface provided (OBD-II),see the image at left.
Using that device he turn on/off the radiator fan,that concludes the signal is correctly passed into the fan, from the control unit.Then he concludes that by judging the speed of the fan, it has to be replaced and further checking the AC condenser fan it also has to be replaced.
Found a original AC condenser fan and get the fan unit and put it into the existing bracket.And found a radiator fan and replace it.Since Tissa electricals had recondition items , it wasn’t a difficult job for me to get the required fans.That saved me a lot of time.
The story was not ended there.While inspecting the fan, learn that the two power transmission belts also need to be replaced.One belt was already started to break from the edge.He said better to replace both at the same time.If I drive another hundreds of Km’s with those two, I could well be sit on the edge of the road with hazards on.
He recommended two brands to me which I haven’t heard.Because I am new to this belts.One was “Brando” and the other one was “Mitsuboshi”.
Then they started to remove the belts from the engine and by no means that was an easy job.
While it was going on Sampath started to remove all the door covers(apostings) and and estimated the length of wires required for the wire harness.
Estimation was 30m from number 14 and 10m from number 9.The number indicates the number of threads in the wire.That is 14 threads and 9 threads respectively.Plus power mirror switch and 3 gum tapes.
I had to go to “Pathma Motors” at kadawatha to bring those belts plus others.It took 1.5hrs by bus.

Once they got the stuffs started working on the harness and the belts.The time was 6:00PM , and stumps of the day.
Sunday morning at 8:30AM commenced the laying the harness.

To be continued…

Tuesday, September 15, 2009

Internal names should be used in SPQuery

Today I found out an interesting issue when I accidentally changed a field name used in a query used in SPQuery.

I wanted to change the display names of my fields and after doing that I renamed all the usages of that field name in my web part code.

After deploying the solution I got the error message "One or more field types are not installed properly. Go to the list settings page to delete these fields"

I had no clue what so ever when you read that error message.This is not the only error message that share point generates which we cannot figure out by looking at this.

I spent considerable amount of time debugging the solution until I decided to Google the error message.

Then found that in one of the msdn forums that the internal names of the fields should be used in the CAML queries.

reference : http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/a2c6bed0-eee1-4f9b-b468-fc57c2e45c16

And that was indeed the trick.

Monday, September 14, 2009

US Open 2009 Men’s single final


Who would have thought, the world number 6 seed Juan Martin Del Porto , Argentinean, will storm into final , by beating Rafael Nadal in straight sets to face non other than world number one Roger Federer who never loss at US Open since 2004.Without a doubt Federer will do everything to make it 6 in a row at Flushing Meadows.

Even though Federer has a 6:0 winning ratio against Del Porto , he will be a tough opponent in this final.I cannot wait to see this match which is schedule at not before 16:00Hrs which is early tomorrow morning in my time.That’s a worrying sign for me.

more info at www.usopen.org

Wednesday, September 02, 2009

How to create active directory users programmatically

Recently one of my colleagues wanted a piece of code which can be created 500 users in Active Directory for some testing purposes.Knowing that this won’t be a big challenge I said I will give it a try.

Frankly speaking, initially I thought this will be a easy walk in the park.Creating the user in AD part was a piece of cake but the created user was not enabled by default.

I had to figure out how to enable a user account programmatically.That was the only tricky part.

Check the user enabling code segment in the code.(Setting the "userAccountControl" property of the user)

Here is the code

string ldapPath = "LDAP://" + server + "/cn=Users,dc=ec,dc=test";

DirectoryEntry entry = new DirectoryEntry(ldapPath, user, pwd);

for (int i = 0; i < userCount; i++)
{
string tempName = userPrifix + i;
DirectoryEntry newUser = entry.Children.Add("CN=" + tempName, "user");
newUser.Properties["givenName"].Add(tempName);
newUser.Properties["userPrincipalName"].Add(tempName + "@ec.test");
newUser.Properties["sAMAccountName"].Add(tempName);
newUser.Password = userPwd;

newUser.CommitChanges();

// Enabling the above created account
int flags = (int)newUser.Properties["userAccountControl"].Value;
newUser.Properties["userAccountControl"].Value = flags & ~0x2;

newUser.CommitChanges();

newUser.Close();
entry.Close();
}
References :

http://www.codeproject.com/KB/system/everythingInAD.aspx

http://www.computerperformance.co.uk/Logon/LDAP_attributes_active_directory.htm

Tuesday, August 18, 2009

How to avoid recursive calls in list item event receivers in SharePoint

I wanted to insert a value into a column in a list when adding and updating items in the same list.

First I registered the item event receiver into the list.

SPList list = web.Lists[listName];
list.EventReceivers.Add(eventType, assemblyName, className);

Then in the actual event receiver class I override the “ItemAdded” and “ItemUpdated” methods.



public override void ItemAdded(SPItemEventProperties properties)
{
SPListItem item = properties.ListItem;
string itemStatusValue = string.Format("Item added @ {0} by {1}", DateTime.Now.ToLocalTime(),
properties.UserLoginName);
item["columnName"] = itemStatusValue;

item.Update();
}

public override void ItemUpdated(SPItemEventProperties properties)
{
SPListItem item = properties.ListItem;
string itemStatusValue = string.Format("Item updated @ {0} by {1}", DateTime.Now.ToLocalTime(),
properties.UserLoginName);
item["columnName"] = itemStatusValue;

item.Update();
}

But when I debug this in VS2008 I noticed that, as the item get updated or added it always calling to the “ItemUpdated” method.Of course that is understandable since I am updating a column in the same list.

But I didn’t want that to happen.Then I found out that you can enable/disable event firing.

So the solution for that is ,

DisableEventFiring();
item.Update();
EnableEventFiring();

It is pretty straight forward once you get to know it.

More references on this : Visit BinaryJam

Friday, August 14, 2009

How to avoid inline codes in user controls in SharePoint web parts

When I was at the beginning of developing web parts for SharePoint , I wanted to find a way of reducing the time consume to develop web parts using Web User Controls (*.ascx) as web parts.Otherwise you will have to write all the mark ups in the CreateChildControls method.

Check here how to use web application projects to develop web parts.

So I was very fond of that method till I figured out, this is not going to inline with the SharePoint deployment techniques.Especially if you are using wsp solution packages and 12 hive structure in Visual Studio with WSPBuilder.

Recently in a project that I was working with, I used a slightly different approach to which I was used to.That is not using web application projects but I used the user control(*.ascx file) with inline codes for the web part in the templatecontrol folder.

There are pros and cons having inline codes.

The code is visible to a person who has access to the server directly.

If it is a complex web part your lines of code will be very high and which will lead to readability and maintainability issues.

Today I managed to figure out how to move inline code into your main assembly of your SharePoint solution and I thought of sharing that with you.

SampleWebPartControl.ascx (user control)

What is important here is that the entry in the RED box in above image.That is the way you specify where the code behind can be found for this user control.

SampleWebPartCOntrol.cs(code behind)

The initialization of user controls you are using is paramount(check the RED box in this image).I had all sorts of problems till I sorted that out.

Solution Structure

Check where the items in the RED box in this image.

Thursday, August 13, 2009

Subscribe to RSS feed of my blog




Now you can subscribe to my blog using RSS.


Steps

  • Go to this RSS Feed.
  • Select the “Subscribe to this feed using” as you need.My recommendation is “Microsoft Office Outlook”.
  • Click on the “Subscribe Now” button.
  • Click on the Advanced… button.
  • Change the details as you want.
  • Click Ok and then click on Yes.

Now you have my blog feeds at your finger tips.

OR you can add the "Feed" gadget into your blog with the given feed url.

Friday, August 07, 2009

List content type troubleshoot

Recently I had a problem with the default content types that are bind with a custom list.

I created an Announcement list and I have bind my own content type into it.Then I wanted to hide the default content type which is the “Announcement”.Initially I used the name to get the content type from the list but later I had to re factor it simply because, if we are to support multilingual we should not use names but id’s.

Then I thought this should be a piece of cake and I re factored it like bellow.

SPList list = web.Lists[listName];
SPContentType item = list.ContentTypes[SPBuiltInContentTypeId.Announcement];
item.Hidden = true;
item.Update();
list.Update();

To my amazement , as I activated the updated feature I got the error “Object reference not set to an instance of an object”.

And then I open this list from the SharePoint Manager and checked the ID of the content type “Announcement” and it is totally different one to the default content type id which is the “0x0104”.

Then I got some expert help on this and got to know that this is because what ever the bind content types in lists are a copy of the site content type.Thank you Bjorn for letting me know about it.

So here is the new code of doing it.

SPContentType item = list.ContentTypes[list.ContentTypes.BestMatch(contentTypeId)];

It was that simple once you got to know it.

So what you need to understand here is that adding a content type to a list means that you actually adding a copy of the content type.

Tuesday, July 28, 2009

SharePoint 2010 Sneak Peak

Are you wondering about how will SharePoint 2010 look like.Here we go click on SharePoint Sneak Peek.

Tuesday, July 07, 2009

My new digital camera – Sony DSC-W270

Time had come to change my very good old HP digital camera which is still working well apart from the noise in the image when took pictures with flash on.It really has a very good video recording without any issues.

The new one , Sony DSC-W270 looks really a good one and looking forward to the new experience with this.In a nutshell this camera has a 5x optical zoom and 12.1M pixels.More details on this camera can be found here.