Friday, May 31, 2013

Programming in Seychelles

Just kidding... It's impossible to concentrate on serious work in Seychelles, because it's paradise without any doubt. 

I had long vacation on Seychelles islands and i tell you now: i have never seen such a beautiful country before.

Anse Georgette beach(Praslin island):
Anse Georgette beach(Praslin island)

Giant Tortoise on Curious island:
Giant Tortoise on Curious island


Petite Anse Kerlan beach(Praslin island):
Petite Anse Kerlan beach(Praslin island)

Small and beautiful Coco island:

Small and beautiful Coco island

Sunset on Anse Lazio beach(Praslin island):
Sunset on Anse Lazio beach(Praslin island)

Grand Anse beach(La Digue island):
Grand Anse beach(La Digue island)


Friday, April 12, 2013

Good programmer is eternal student

Programming is not like most other professions. Programmer can't allow himself to relax, because technologies is always moving forward.

And if he does not follow this technologies, very soon, he will be useless for serious problems in IT world.

Good programmer is eternal student. He always should be on the lookout for new and more innovative solution, even if he knows good old solution for the problem.

How not to miss the right moment for changes?
  • Always read news in your focus area
  • Read new books by competent authors
  • Follow great projects
  • Try new solutions for old problems

Thursday, April 4, 2013

Git private repositories: GitHub vs Bitbucket

I'm really enjoying to use GitHub. It's incredibly comfortable service for sharing code using Git public repositories. But when it comes to private repositories - prices are biting(22$/month for 20 private repositories).

That's why, i've decided to try BitBucket which suggests unlimited number of private repositories for 5 users.
Besides, you can easily import you repositories, SSH keys etc. from GitHub.

So, for me, BitBucket is the best place for private Git repositories. But for public repos, however, it's better to use GitHub, because it's the place where the community is. But who knows, maybe little by little community will be moved to BitBucket for public repositories too.

Friday, March 22, 2013

Classic ASP is Hell

After working for the long time with C#, ASP.NET MVC, Unit Tests, NuGet, and other pleasures of .NET life, i was assigned to the old Classic ASP project.

I did not work with Classic ASP and VBScript before and i tell you now: it is absolute Hell.

Now I realized how far is Microsoft progress in this direction in the last 10 years:
  • C#- the most powerful Object Oriented language. It's even ahead of Java in many ways.
  • ASP.NET MVC - great framework for building lightweight, highly testable web-applications.
So, i am very happy that I did not catch the time when most web projects was written on Classic ASP.

Tuesday, March 12, 2013

Preloading assemblies from Application folder in C#

As you may know, AppDomain.CurrentDomain.GetAssemblies() returns list of assemblies that are loaded in current Application Domain. Even if your executing project has reference to some assembly there is no guarantee that this assembly has been already loaded. It will be loaded lazily on first use. But what if you need all assemblies now? For example, you want to search assemblies for classes that implement some interface or something else.

You can easily force loading assemblies into your Application Domain.

Let's create helper class to return list of all files in our Application folder(Bin folder in case of Web Application):
 public static class From  
 {  
   public static IEnumerable<FileInfo> AllFilesIn(string path, bool recursively = false)  
   {  
     return new DirectoryInfo(path)  
               .EnumerateFiles("*.*", recursively ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);  
   }  
   public static IEnumerable<FileInfo> AllFilesInApplicationFolder()  
   {  
     var uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);  
     return AllFilesIn(Path.GetDirectoryName(uri.LocalPath));  
   }  
 }  

So, now you can preload assemblies as follows:
 From.AllFilesInApplicationFolder().Where(f => f.Extension == ".dll").ForEach(fi => Assembly.LoadFrom(fi.FullName));  

This solution is applicable both for Desktop and Web Applications.

Friday, February 22, 2013

Safe forms without captcha - hybrid approach

Captcha is very annoying for users. How can we make safe forms without captcha?

Today's popular approaches are:
  • CSS technique. Idea about this is to create invisible field(hidden via CSS) in form. Silly spambots don't know that people can't see this field and fill it out. So, on server side you should make sure that this field is empty. 
  • Javascript technique. Idea about this is to generate and fill out some field using javascript. Silly spambots can't process javascript. So, on server side you should make sure that this field is not empty. This approach is good, but it has big disadvantage: if real user has javascript turned off he will not get this generated field, so he will not fill it out. Real user with disabled javascript = Silly spam bot. 
Problem with this approaches: What if spam bot is Not Silly ?

First approach is great in its simplicity, but i think that it is more easily for spam bots to overcome this obstacle, than second one. Javascript processing requires more brains in spambot head. So i like second approach more, but i do not like the fact that poor people with disabled javascript will suffer.

I want not to bother user with captcha if he has javascript enabled. But if poor user has javascript disabled, he will get captcha(and spambot will get captcha too).

So, my hybrid approach is to use captcha block(captcha image+ input field) wrapped in <noscript/> tags. And then use javascript to hide captcha block, remove <noscript/> tags, and fill out captcha with valid value.

As result, we have captcha that is showing for users that have javascript disabled(as well as spambots). If user has javascript turned on, then captcha will be hidden and filled out using javascript. 
On server side we just check if captcha is valid- it is not matter for us whether user has javascript enabled!




Saturday, February 2, 2013

10gen's MongoDB course - it was great!


Recently, I took a free course, organized by the 10gen company(it is famous for MongoDb NoSQL data-store). It was a great course that covered many interesting aspects about MongoDb. There are was video lectures, regular homeworks, and the final exam. You need 65% grade to pass course. I, actually, got 100% and earned beautiful "M101: MongoDB for Developers" certificate:


Thank's very much to 10gen. They have not only created a great free product(MongoDb), but also help developers to learn it.