# Tuesday, June 02, 2009
I have added a Twitter counter for all you Twetties out there. If you would like to be informed about new blog posts, you will find there announcements, among other.

If you wish to be even more up to date, you can subscribe to the RSS feed. I have created one on the Feedburner is spite my blog already provide one (with feedburner you get nice counter and more control over feeds). RSS feed is a nice approach of reading blogs, since computer do the checking work for new content insted of reader.

UPDATE: Oh yeah, my home site, have been completely renewed over weekend. You can check it out. Currently is more or less boring, because it contains almost no content, really. But I have plans. :) I will not revel them completely, you can already see now I will have more "open" blog (not just about software development) on it. When it will something interesting happen, I will post it. Then I (will) have picture gallery, same applies here as for personal blog. And more (I hope). Stay tuned. :)

posted on Tuesday, June 02, 2009 9:54:15 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
Have you ever asked yourself, why C# string type works somehow different than other reference types?
  • First, when you declare them, you don't have to use a reserved word, which is used for reference type initialization - "new". You can also easily "overwrite"* them.
  • Second, when it is passed as a parameter to method, it does not reflect possible changes of this parameter inside a method (as reference types would normally do).
So what this animal really is? To explain string behaviour in deep, you have to know all about:
- immutability
- value type vs. reference types
- parameter passing
- C# reserved word "implicit"
- ...

All these interesting topic I will cover in the following days.

*As straight forwards as it may seems, we will see this is not really true.

posted on Tuesday, June 02, 2009 1:09:08 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Wednesday, May 27, 2009
I always wish to have my own e-mail domain space. You know, something like yourName@yourDomain. It just rulez. :)

Well a lot of things is nice to have, but you have to ask yourself is it feasible? Optimal? The right question about having your own e-mail domain is: Is this optimal?

If you think about it, you will figure out that even nearly is not. First you have to have a server that's mean the hardware (even in virtual machine it demand some hardware resources), a fail safe one. It demands power, power costs ... And this is just beginning. Then you have to install and configure SMTP server, anti virus, anti spam software ... And all of this you have to maintain, backup ... If you sum up, despite if you are an computer geek. You do not want your own email server at home. It just takes too much resources and it is just too unreliable. Period.

But we still want our "own e-mail". What to do? Well it turns out that Google have an answer (as almost always). You surely hear about Google apps. It perfectly solve our problem. It provide e-mail address with our domain on well tested Gmail infrastructure. All you have to to is to play a little with CNAME settings at your domain provider and that's it.

It is perfect example of cloud computing service. It is personalized and it persist in internet realm, somewhere.

From now on I am officially in the cloud, you can reach me at peter@stegnar.com.

PS: You can start here. You can choose two account types. For normal usage, standard version will do.

posted on Wednesday, May 27, 2009 6:46:19 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Tuesday, May 12, 2009
It just come out - Stack Overflow DevDays conference will be held in couple of cities:

October 19 San Francisco
October 21 Seattle
October 23 Toronto
October 26 Washington, DC
October 28 London

We Europeans have only one choice- London. I have already make a reservation and so should you! I believe this will be great conference.

Right now about 2h after Joel's announcement are 231 and 14 tickets available of 300. In less then one day there will be none, when it seeds out (what I am actually doing right now).

posted on Tuesday, May 12, 2009 9:52:31 PM (Central European Daylight Time, UTC+02:00)  #    Comments [1] Trackback
# Monday, May 11, 2009
Most application need some kind of localization, really. Today I will represent one simple possible solution for this in ASP.NET.

This localization is based on .NET resources (.resx). As name tells us resource is, well (re)source of something, typically strings. So as it looks like this resource file seems like perfect for our localization problem.

Resource file is XML base file type, it looks like this:


It also exist a resource editor, where you can easily edit resources:



Let's say our web application need localization support for two languages, English (default) and Slovene. First we create resource file for each supported language and for default one. So we create something like that:


Here we have a default support language (English) and other supported languages (for our case Slovene). You have to be careful with naming - naming convention is resource_name.[language code].resx.

And to the best part - code. All you have to is to set a CultureInfo to a current thread, and ASP.NET will automatically resolve a proper resource file. You can set in in your ASP.NET application file (Global.asax) like:
 System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(cultureName);
Well, you a done, with localization of you application!

All is left is an actual use of it. Here you have one example:
 <asp:Literal runat="server" Text="<%$ Resources:Resource, strForm1Hello %>"/>
You can see I use build-in ASP.NET functionallity of resource reading instead of hard-coded string. Which is anyway good practice not to have it.


posted on Monday, May 11, 2009 7:59:23 AM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Saturday, May 09, 2009
Yesterday I was debugging an ASP.NET application based on database (MS SQL Server). I was getting a strange error:
EXECUTE permission denied on object 'sp_sdidebug', database 'master', owner 'dbo'.
Well store procedure 'sp_sdidebug', enable debugging on SQL Server. Since this SP is in "master" database, you have to have proper access and execute rights on this master DB.

posted on Saturday, May 09, 2009 8:41:15 AM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Friday, May 08, 2009
One of the most basic action in web development is redirecting. Redirecting basically mean that browser show other resource URL than was requested. This is useful to enhance usability and to achieve control over user request. There exist two levels of redirecting. First level is on IIS server named "Default content page", you can enable it to order an IIS server to automatically redirect request to specified resources.

Second level of redirecting can exist in your code. All you have to do is to use a Response.Redirect(string url) directive. This directive orders a client (web browser), that requested resource was moved.
HTTP 1.0 302 Object Moved 
Location
www.domain.com
Then browser do request again with given URL.

posted on Friday, May 08, 2009 1:23:39 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Sunday, May 03, 2009

I have played around and I write "testing environment" for this Rand(7) algorithm. For example if you want to try what distribution gives your algorithm or how much iterations takes to generate all distinct random values (for Rand(7) 1-7), you can use it.

My core algorithm is this:

return (Rand5() + Rand5()) % 7 + 1;

Well is no less uniformly distributed then Adam Rosenfield's one. (which I included in my snippet code)

private static int Rand7WithRand5()
{
   
//PUT YOU FAVOURITE ALGORITHM HERE//

   
//1. Stackoverflow winner
   
int i;
   
do
   
{
        i
= 5 * (Rand5() - 1) + Rand5(); // i is now uniformly random between 1 and 25
   
} while (i > 21);
   
// i is now uniformly random between 1 and 21
   
return i % 7 + 1;

   
//My 2 cents
   
//return (Rand5() + Rand5()) % 7 + 1;
}

This "testing environment" can take any Rand(n) algorithm and test and evaluate it (distribution and speed). Just put your code into the "Rand7WithRand5" method and run the snippet.

Few observations:

  • Adam Rosenfield's algorithm is no better distributed then, for example, mine. Anyway, both algorithms distribution is horrible.
  • Native Rand7 (random.Next(1, 8)) is completed as it generated all members in given interval in around 200+ iterations, Rand7WithRand5 algorithms take order of 10k (around 30-70k)
  • Real challenge is not to write a method to generate Rand(7) from Rand(5), but it generate values more or less uniformly distributed.
Discussion on this is on Stackoverflow.

posted on Sunday, May 03, 2009 1:21:22 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Saturday, May 02, 2009
Software development shoud be fun. At least sometimes! Today I watched some past episodes of 10-4 show and among them, show 14 shows a fun side of software development. You should see it, if you didn't already.

posted on Saturday, May 02, 2009 8:21:19 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback

It is decent for developer to start a computer related stuff with "Hello world!", so I can not be an exception. I decided to write a more or less software development oriented blog. I will post everything interesting that will come on my mind or I will face it.


posted on Saturday, May 02, 2009 4:32:30 PM (Central European Daylight Time, UTC+02:00)  #    Comments [1] Trackback