Tuesday, January 4, 2011

Find locks in Oracle Tables

A lot of time we as developers see Oracle tables being locked. As we all share one dev database, the reason might be some long running query or service on some other workstation.

An easy way to find it out is through a query:


SELECT s1.username
'.'
s1.program
'@'
s1.machine
' ( SID='
s1.sid
' ) is blocking '
s2.username
'.'
s2.program
'@'
s2.machine
' ( SID='
s2.sid
' ) '
AS blocking_status
FROM v$lock l1,
v$session s1,
v$lock l2,
v$session s2
WHERE s1.sid = l1.sid
AND s2.sid = l2.sid
AND l1.BLOCK = 1
AND l2.request > 0
AND l1.id1 = l2.id1
AND l2.id2 = l2.id2

Tuesday, August 10, 2010

Seattle - Seafair Parade and visit to USS Port Royal

This weekend saw the Airshow as part of the Seattle Seafair. Videos are available in the site : http://www.seafair.com/weekend/airshow/. The start was boring but when the F-18's came, it was good. They were so fast that even when they reached the center show point, there was no sound (as it was trailing behind). So if one is not focused, then he can miss half of the show. That was followed by the thundering engine noise. Once it passed over our head at like 1500 feet (500 mts) and it was deafening. Saw in the news later that some windows in nearby house broke due to it.




Followed that, we had a visit to USS Port Royal. More about it in here. One of the last of its kinds, it had some big 5 inch guns, and house Tomahawak Cruise Missiles and had a stealth coating in it. It was a guided tour for 1 and half hours but was worth it. Built in 1994, it still had Windows 95 as OS for one of its radars :) - and we blame India for carrying legacy systems.

Thursday, April 29, 2010

Youtube - My Speed

Now YouTube too is providing a free service to display your downstreaming speed history.

Lookout for http://www.youtube.com/my_speed

Wednesday, April 14, 2010

Strategic Decision Making

Just attended a workshop on Decision Making and found it very interesting. So wanted to write about it.
Key Points :


  • Lower level employees work with certainty whereas higher level employees work under ambiguity. Like in a software company a coder will be given a design, explained what to do - now all he has to do is to write the code and test it out - which is pretty certain. A higher level manager will get a job like "bring more projects".

There are three types of decisions:

  • Strategic - Have Long Term Impact, are Less Frequently made, and have a High Cost of Change.
  • Tactical - Something that can change based on time and situation.
  • Operational - Opposite to Strategic i.e. have Short term impact, are made on regular intervals, and can be changed easily.
  • Decisions which are strategic for low level folks can be operational for higher level ones and vice-versa.

Strategic Decision Framework:

  • Information - Fact or Assumption
  • Challenges (Internal or External) - Fixed or Changeable
  • Specialized Knowledge - Accessible or Inaccessible (now made more accessible due to Internet)

Finally, build a Story to support your decision - very important for a manager to become a leader to convince all those impacted by the decision.

Finally :

  • Define the objective - half the job is done.
  • Apply the Framework (above)
  • Look for Changeable Challenges
  • Build Specialized Knowledge
  • Develop articulation skills (for convincing)
  • Review the decision as its strategic
  • Document it
  • Finally detach yourself and don't make the failure of the decision impact your ego

Friday, April 9, 2010

QwestIndia @ Facebook

Earlier I was trying to make a Qwest Page for Facebook. I was able to do a few things as posted on this earlier post.

So now I started working on a page for Qwest India. Its currently up in facebook although I have not been able to get a absolute URL for it. It can stil be searched or accessed from here.

Qwest India folks, please join it and provide some suggestions to improve it.

Also a Facebook App has been created to display the current job listing.

Visual Studio 2008: Can not locate Microsot Internet Explorer

Of late, while debugging from Visual Studio by pressing F5, I got the error:









I was still able to debug it by using "Attach to Process" but its not as easy as pressing F5.

So I looked for a solution and the solution is:
Visual Studio looks for the following registry key to locate Internet Explorer:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\iexplore.exe]



Open regedit and locate this key.

If its not present, then create one with the Default value pointing to your Internet Explorer location. Normally it will be c:\Program Files\Internet Explorer\iexplore.exe.

If its already present then check the default value and correct it.



To check if its working, open run command, and type in 'iexplore' and it should launch the Internet Explorer.

Now try doing a F5 on your Visual Studio and it should work.

Tuesday, March 9, 2010

C# generic list : How to get the type and object of T?

Today I faced an interesting problem regarding GridView. We are using a enhanced GridView control as a reusable component in different applications.

In one of the application, we got an issue : when all the rows in the Gridview get deleted - we still need to show the Header portion of the Gridview with the "No rows" information displayed on the first row.

Its very simple to do, just bind the GridView to its datasource with 1 empty row and then while rendering, remove all controls from the 1st row and render only the label. The problem we faced was we did not know the Type of GridView's datasource. We can not hardcode as its a bad practice and also we did not know which types are being binded to the Gridview by the Page developers of the application.

So we have to find out the type of the datasource then create an instance of it and then add a new object of that type in to the datasource so the gridview gets rendered. I tried something like :


Type T = GridView1.DataSource.GetType();
T newRow = (T)Activator.CreateInstance(T);


This is something I wanted but the problem is that Activator.CreateInstance() returns an object of Type Object and the generic T can not be used to cast it. This gives a compilation error. Without the cast, I cannot do something like :

GridView1.DataSource.Add(newRow);

which is what I want. To overcome it I had to somehow force .NET to recognize the Object as of Type T and allow me to add it to the GridView1.DataSource.

To achieve it, I tried a hack which worked. Its a mix of reflection and generics and looks like:


Type T = GridView1.DataSource.GetType();
Type V = T.GetGenericArguments()[0];

Object o = Activator.CreateInstance(V);
Object[] ObjectArray = new Object[]{o };
T.GetMethod("Add").Invoke(GridView1.DataSource, ObjectArray);
GridView1.DataBind();


As the datasource for the GridView always implements IEnumerable interface we did the following steps:
  1. First get the Type of the Datasource which was like List
  2. Used "GetGenericArguments" to get the Type of the Object of the GenericType object.
  3. Created an instance of that GenericType
  4. We need an Array of object to call the reflection method.
  5. Use Reflection to add the Add method and pass the Object Array hosting the GenericType object.
  6. Bind the Grid

Now although .NET did not allow us the explicitly cast the GenericObject to its Type, it allowed us to do it in runtime.

I think, .NET should allow us to do in explicitly as thats more intuitive than this cumbersome way. Anyone having a better approach to this problem , please comment below.