Thursday, October 28, 2010

SET STATISTICS IO - Sql Server - tune performance

Say hello to one of may friends: SET STATISTICS IO [ON|OFF]
Information it provides helps identify problems and tune performance. Though you will have to have a lot of practice before this info will became useful. I am still not 100% sure I fully understand data this statement provides. Example:
SET STATISTICS IO ON

SELECT my_user.*, user_profile.*
FROM my_user 
 JOIN user_profile on my_user.id = user_profile.user_id

SET STATISTICS IO OFF
Results:
(3 row(s) affected)
Table 'user_profile'. Scan count 0, logical reads 6, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'my_user'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Syntax and explanation of results read here...

Wednesday, October 27, 2010

NEW YORK (CNNMoney.com) - Microsoft is a dying consumer brand

NEW YORK (CNNMoney.com) -- Consumers have turned their backs on Microsoft. A company that once symbolized the future is now living in the past.Read more...

Tuesday, October 26, 2010

Your time is limited, so don’t waste it living someone else’s life...

Your time is limited, so don’t waste it living someone else’s life. Don’t be trapped by dogma, which is living with the results of other people’s thinking. Don’t let the noise of others’ opinions drown out your own inner voice, heart and intuition. They somehow already know what you truly want to become. Everything else is secondary...

Amazing Speech by Steve Jobs at Stanford University Stay Hungry Stay Foolish!

Monday, October 25, 2010

Jogging again...

It is amazing how jogging cleans your thoughts... I will try to start jogging regular again...

Tuesday, October 19, 2010

Facebook in Privacy Breach

Top-Ranked Applications Transmit Personal IDs, a Journal Investigation Finds

Therefore they attempt the impossible – and achieve it

The young do not know enough to be prudent,
and therefore they attempt the impossible – and achieve it,
generation after generation.

Pearl S. Buck

Wednesday, October 13, 2010

Why I hate Entity Framework - EF is tied to specific Net framework version

One big issue the Entity Framework that it is tied to specific version of Net framework. Say if I started using EF1 which is tied to Net framework 3.5 sp1 and Visual Studio 2008 you just can't switch to EF4 which fixes many EF1 annoyances (one of them is lack of POCO support). You would have to switch to Net 4 framework and buy Visual Studio 2010. However I must admit Linq to Entities is nice feature.

Using SELECT to INSERT records – SQL

How to populate one table with data from other table by using one SQL statement?
Normally you would use INSERT statement to populate table with data like this:

INSERT INTO books_csharp(id, title)
VALUES (1, 'Agile Principles, Patterns, and Practices in C#');

but suppose we have already populated table books like this:
id: integertitle: nvarchar(256)tag: nvarchar(32)
1Agile Principles, Patterns, and Practices in C#C#
2Pro C# 2010 and the .NET 4 Platform, Fifth EditionC#
3Agile Testing: A Practical Guide for Testers and Agile TeamsTesting
and we would like to populate similar table books_csharp. So here we go:
INSERT INTO books_csharp (id, title)
SELECT id, title
FROM books
WHERE tag = 'C#'
results:
id: integertitle: nvarchar(256)
1Agile Principles, Patterns, and Practices in C#
2Pro C# 2010 and the .NET 4 Platform, Fifth Edition

P.S. Test and works on Microsoft SQL Server 2008 & PostgreSQL 9

Tuesday, October 12, 2010

Portable way for setting all bits to true in C

I found this discussion in stackoverflow.com Short summary:
unsigned int flags = -1; /* is portable. */
unsigned int flags = ~0; /*isn't portable because it relies on a two's-complement representation.*/
unsigned int flags = 0xffffffff; /* isn't portable because it assumes 32-bit ints. */
If you want to set all bits in a way guaranteed by the C standard, use the first one.

What would happen if you stuck your hand into the Large Hadron Collider - ANSWERED or not?

So finally we have clear answer to the following question:
What would happen if you stuck your hand into the Large Hadron Collider?

Here is the answer or not?

mssql: insert values into table with identity column

You should use IDENTITY_INSERT command like this:
SET IDENTITY_INSERT YourTableName ON

INSERT INTO YourTableName (YourIdentityColumn, ValueCoulmn)
VALUES (1, 'Value')

SET IDENTITY_INSERT YourTableName OFF

Saturday, October 9, 2010

Silverlight and WCF CommunicationException (Cross Domain Issue)

Recently I got the following error while trying to execute Silverlight project:
“An error occurred while trying to make a request to URI '…'. This could be due to
attempting to access a service in a cross-domain way without a proper cross-domain
policy in place, or a policy that is unsuitable for SOAP services. You may need to
contact the owner of the service to publish a cross-domain policy file and to ensure
it allows SOAP-related HTTP headers to be sent. This error may also be caused by
using internal types in the web service proxy without using the
InternalsVisibleToAttribute attribute. Please see the inner exception for more
details.”
After hours of troubleshooting finally I managed to solved problem. It was a silly mistake of launching the Silverlight project directly (as the default start up project when hitting F5) instead of the web project that references the Silverlight project.

I hope this post will save others some time :)

Wikileaks publishes documents on plan to curb free software in the European Union

Wikileaks publishes documents on plan to curb free software in the European Union