Entries from January 2009
http://en.wikipedia.org/wiki/Warren_Buffett
> An inscription of Warren Buffet for people around the World:
> =================================================
>
> "We begin this New Year with dampened enthusiasm and dented optimism. Our
> happiness is diluted and our peace is threatened by the financial illness
> that has infected our families, organizations and nations.
>
> Everyone is desperate to find a remedy that will cure their financial
> illness and help them recover their financial health. They expect the
> financial experts to provide them with remedies, forgetting the fact that it
> is these experts who created this financial mess.
>
> Every new year, I adopt a couple of old maxims as my beacons to guide my
> future. This self-prescribed therapy has ensured that with each passing
> year, I grow wiser and not older. This year, I invite you to tap into the
> financial wisdom of our elders along with me, and become financially wiser.
>
> Hard work: All hard work brings profit; but mere talk leads only to poverty.
>
> Laziness: A sleeping lobster is carried away by the water current.
>
> Earnings: Never depend on a single source of income.
>
> Spending: If you buy things you don ‘t need, you ‘ll soon sell things you
> need.
>
> Savings: Don ‘t save what is left after spending; spend what is left after
> saving.
>
> Borrowings: The borrower becomes the lender ’s slave.
>
> Accounting: It ’s no use carrying an umbrella, if your shoes are leaking.
>
> Auditing: Beware of little expenses; a small leak can sink a large ship.
>
> Risk-taking: Never test the depth of the river with both feet.
>
> Investment: Don ‘t put all your eggs in one basket.
>
> I ‘m certain that those who have already been practicing these Principles
> remain financially healthy. I ‘m equally confident that those who resolve to
> start practicing these principles will quickly regain their financial
> health.
>
> Let us become wiser and lead a happy, healthy, prosperous and Peaceful life.
> Warren Buffet"
Categories: LifeFactor
Tagged: Buffet, forbes, inscription of warren buffet, investment, making money, Richest person, Warren
I have found the following solution to disallow multiple instances of my WinForms application:
using System.Diagnostics;
if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)
{
Process.GetCurrentProcess().Kill();
}
This works for me but I am not sure if this is the right mechanism. My gut feeling is that this can easily be dogded but I am not sure HOW. Anyone?
Categories: .NET
Tagged: .NET process, disallow, GetCurrentProcess, GetProcessesByName, Kill Process, multiple instances, ProcessName, System.Diagnostics.Process, WinForms
During WinForms programming you might (chances are that you SHALL) come across a situation where you do not want to open a form multiple times on an event. A common practice in the event handler function is:
UserForm UForm = new UserForm();
UForm.Show();
This will open your form, fine! But what if the event happens again and the previously opened UserForm has not been closed yet? A new UserForm will be opened and this will go on if the user loves that event ^o
The prevention strategy is to check whether the form is already opened or not.
public static Form IsFormAlreadyOpen(Type FormType)
{
foreach (Form OpenForm in Application.OpenForms)
{
if (OpenForm.GetType() == FormType)
return OpenForm;
}
return null;
}
This little function will help in determining if a particular form is already opened or not. You can open it or focus it later.
UserForm UForm = null;
if ((UForm = IsFormAlreadyOpen(typeof(UserForm)) == null)
{
UForm = new UserForm();
UForm.Show();
}
else
{
UForm.DoWhatever(); // may be UForm.Select();
}
This works perfect for me. I don’t like that loop though.
Categories: .NET
Tagged: already open, Application, C# WinForms, check already open, Form select, Form.show, OpenForms
Today I was writing a query trying to eliminate NULL values and empty strings from a column. I found a strange behavior in Oracle that it considers NULL and empty strings ( ” ) equal which is not ANSI. Other database systems which are more compliant to ANSI like PostgreSQL differentiate between NULL and ( ” ) correctly.
Check this out:
SQL> create table tes (a varchar2(2));
Table created.
SQL> insert into tes values (''); -- inserted an empty string
1 row created.
SQL> select * from tes where a is not null;
no rows selected
Gives me no rows although it has a string with zero length in it.
SQL> select length(a) from tes;
LENGTH(A)
----------
Even the length function shows a NULL it should have been saying “0″.
This brings another interesting scenario. What if you want to find out empty strings in your column?
SQL> select * from tes where a = '';
no rows selected
This does not bring in any rows because a NULL is not equal to NULL. The correct query would be:
SQL> select * from tes where trim(a) is null;
A
--
Now it brings in one row because the TRIM function returns null if no characters are left in the given string after trimming. A more ANSI compliant database would have returned an empty string ( ” ) though.
Categories: Oracle · PostgreSQL
Tagged: ANSI, ANSI Compliant database, comparing empty string, empty string, NULL value, Oracle, PostgreSQL
January 11, 2009 · 1 Comment
I have not posted anything for quite sometime now and wanted to test my new RSS reader too. Now my RSS reader is running and detecting new posts. Hopefully when I publish this post the reader will show ‘1′ new post
Categories: .NET · LifeFactor
Tagged: Random, RSS Reader