Errr, some catchy title.... RSS 2.0
 Thursday, March 22, 2007

I just finished week long second trimester of my Masters course. The module was about Design Patterns. Every day we had lectures in the morning and then labs in the afternoon. During the lectures we went through most of the Gang of Four patterns, they were pretty interesting even though I knew most of the stuff. What I really loved about the course were the labs.

 

Every day we were given some working application and we were supposed to apply some specific pattern to extend the functionality of the application. I always believed, that it’s impossible to learn design patterns just by reading a book, you gotta look at the code and try to incorporate it into it, or just ‘get it’. What was good about the exercises in the lab is the fact that the applications were easy enough to understand their inner workings immediately, but complicated enough to see, that some pattern would help here a lot.

 

Oh yeah, and I was able to refresh my memory of Java and Swing. Win-win situation.

Thursday, March 22, 2007 3:00:34 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Other
 Wednesday, February 28, 2007

I’ve just finished writing a small application for myself. It’s called Application Launcher and yes, it does launch applications…..

 

There were two reasons for writing this small app:

  1. It takes forever to start my system since there are over 10 applications that are invoked at startup. What is ever more annoying all of them start at the same time! This leads to 1-2 minutes after system starts when I cannot use the system since everything is stating up.
  2. I needed a sort of like a Startup utility for my USB key. When I put it in, I want to be able to start my email client, calendar, and RSS reader with least amount of clicks and of course I want to avoid the ‘Startup freeze’.

 

Welcome the application launcher.

 

Features:

  • Launches applications (duh)
  • After each launch there is a configurable delay before the next application launches
  • When closing the application it tries to close all the started applications.
  • When needed it uses relative path (which is great when you’re using USB key)
  • If you want, you can have various configurations of what applications are starting even in one directory, simply rename the application and for each name it will have different configuration.

 

Here is the exe (ApplicationLauncher.zip (74.87 KB)) and the source code (ApplicationLauncher - source.zip (181.58 KB)) of the application. It has been written in .NET v2.0.

 

 

 

Wednesday, February 28, 2007 4:20:15 PM (GMT Standard Time, UTC+00:00)  #    Comments [2] -
Tools | Application Launcher
 Wednesday, February 14, 2007

For most situations we want the users, not the computers to be the audience of our websites. Therefore, there are situations when we must protect ourselves from automated bots that obtain information from our website, eat the bandwidth or just consume our services (create new email accounts, send text messages to cell phones and so on). The tool for this job is called CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart). If you’re interested how it came into being go to CAPTCHA on Wikipedia.

 

Below is a list of three CAPTCHA solutions that vary from easiest to implement and of course least secure to the safest one (which also involves most work).

 

Hidden input

 

The simplest of the techniques is to embed in the page a HTML input element.

 

<input name="address2" type="text" runat="server" />

 

Next, we make it invisible on a page by applying CSS style (just one of the possibilities). On the submit, we check if the value has been filled. If it has, then that means a bot was going through the page, not the user (as user could not see the textbox). This solution is very easy to implement and should work if the bot is completely automated (there was no recording of what type of fields should be filled in).

 

NoBot from AJAX Control Toolkit

 

One security level higher is the NoBot from ASP.NET AJAX. It is again, a solution that does not need user interaction; therefore it is not very reliable. Also, as it is part of ASP.NET AJAX it will only work in AJAX enabled environment. On the plus side, the user is not bugged by filling out some extra fields.

 

NoBot employs several techniques to prevent bot attacks:

  • Forcing the client's browser to perform a configurable JavaScript calculation and verifying the result as part of the postback. (Ex: the calculation may be a simple numeric one, or may also involve the DOM for added assurance that a browser is involved)
  • Enforcing a configurable delay between when a form is requested and when it can be posted back. (Ex: a human is unlikely to complete a form in less than two seconds)
  • Enforcing a configurable limit to the number of acceptable requests per IP address per unit of time. (Ex: a human is unlikely to submit the same form more than five times in one minute)

 

If you want to see a live demo, go to NoBot Sample from Ajax Control Toolkit

 

CAPTCHA Image Control

 

Safest on the list is CAPTCHA Image Control. Since everyone has used these CAPTCHAs as user it’s best to just show how this solution looks.

 

 

The image displayed is distorted not to allow machine to find out the text on a picture. There are a lot commercial solutions that offer these controls for ASP.NET, however there is also a bunch of them free. I particularly like the one written by Jeff Atwood, author of the brilliant www.codinghorror.com blog. He published this control on CodeProject, it is located here. Go check it out!

 

Note:

 

Last solution is not suitable for blind or visually impaired users. Therefore, sometimes you can find sound CAPTCHAs for these scenarios.

Wednesday, February 14, 2007 4:15:46 PM (GMT Standard Time, UTC+00:00)  #    Comments [3] -
Other
 Friday, February 09, 2007

I stumbled upon an amazing explanation of Web 2.0. Not only it's highly entertaining, but also shows what Web 2.0 is all about. Now, if anybody asks what is Web 2.0 I'll point them towards this clip.

Friday, February 09, 2007 12:07:57 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Other
 Wednesday, January 24, 2007

This is certainly the news for the day. Finally v1.0 of ASP.NET AJAX (previously known as ATLAS) is released.

You can download it from here

Also, check this calendar control. This is the coolest thing ever:

Note: This control is not part of core AJAX Framework. It is a part of ASP.NET AJAX Control Toolkit which is a collaboration project between MS and non MS coders on CodePlex.

Wednesday, January 24, 2007 11:29:56 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Ajax
 Tuesday, January 23, 2007
Using Extension Methods with C# 3.0 and Orcas

I finally got around to play with January CTP release of Orcas (which is a codename for Visual Studio 2007). The first thing I wanted to try out are Extension Methods which are a new feature in C# 3.0 and VB 9.0 (and are included in .NET Framework 3.5).

 

Intro

 

So what are those Extension Methods?

 

In short: Extension Methods are static methods that are invoked with instance method syntax.

 

Why would I be interested in using them?

 

Well, they make your life easier. Isn’t that what it’s all about? J.

 

How to use it?

 

If you want to write a class that implements Extension Method, you must make it static. Furthermore the method must be static. Take a look at the code below:

 

public static class FirstExtension

   {

    public static int ToInt(this string target)

    {

    return Convert.ToInt32(target);

}

   }

 

 

Notice the keyword this in the method parameter. This indicates to the compiler (and IntelliSense) that this is an Extension Method. As you can see, the method takes in as a parameter a string and converts it into an integer. So one way of calling that method is:

 

string temp = "5";

int t = FirstExtension.ToInt(temp);

 

Nothing original here, but take a look at that:

 

string temp = "5";

int t = temp.ToInt();

               

 

So what exactly happened here? We created an instance of string object and we called a ToInt static method of class FirstExtension. So, as noted before this is nothing original, it just helps the developer to spend his time more productive.

 

 

There are a couple of things to consider:

  • Instance methods have always priority over Extension Methods.
  • It works with IntelliSense!
  • Checking for available Extension Methods is based on using / imports directive.
  • Currently, only Extension Methods are supported, properties, events and operators are currently being considered.

 

Usage

 

What I generally like about Extension Methods is the fact, that I’ll be able to write myself a Class Library, which will make my life easier. The first example provider is a great helper, because when you’re using DropDownLists and such, you always put the ID of the field in the Value and the Description in the Text.

Sooner or later you’ll have to convert the ID from string back to int. This extension will make the code more readable (and less writing for meJ).

 

Here are few other examples of the top of my head:

 

public static class CollectionHelper

    {

        public static void Consolize<T>(this IEnumerable<T> enumerable)

        {

            foreach(T ob in enumerable)

            {

                Console.WriteLine(ob.ToString());

            }

        }

    }

 

Usage:

 

Will iterate through whole collection and print out all objects to console.

string[] names = { "Burke", "Connor", "Frank",

"Everett", "Albert", "George",

"Harris", "David" };

 

names.Consolize();

 

Or another one:

 

public static class LogExt

{

public static void LogIt(this object ob)

{

Logger.Write(ob);

}

}

 

This will simply log all the data from the object (if you have overwritten ToString).

 

Note:

 

If you’re using Orcas January CTP and you copy pasted the code above you’ll get this exception:

 

Cannot use 'this' modifier on first parameter of method declaration without a reference to System.Core.dll. Add a reference to System.Core.dll or remove 'this' modifier from the method declaration

 

Simply add reference to System.Core.dll which is located in:

C:\WINDOWS\Microsoft.NET\Framework\v3.5.11209\System.Core.dll

Tuesday, January 23, 2007 1:15:38 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
C# 3.0 | Orcas

Nowadays everybody has a USB key. They are also getting really big right now. I don't see people with keys smaller then 512 MB. What else? Oh yeah, most people have a computer at work and at home. True? True.

So what's the problem here, well let's say you're at work and want to check your personal email, or add a personal calendar entry. Well, there are couple ways to do that.

-> Log into your computer from work (has anyone ever done it?) -> Use new web apps (like google's calendar and such), of course then you agree that google will harness all the information you provide there to sell it later to advertisers.... -> Use Portable Apps! (yup, this is the right way to go....)

So what are those Portable Apps?

Well, they are basically applications we all know and love, that are slightly modified; so that they don't need a hard drive to run (they run from the USB key). When I say that they don't need a hard drive to run, I mean, that they don't store anything in AppData, registry and so on.

So now, if you want to check your personal email without the need to go to the website, plug in your USB key, and run Thunderbird.

Maybe the email application is not the best example, but think about some diagnostics applications. Furthermore, wouldn’t it just be nice, to plug in your USB stick to a machine, and have Skype, MSN and such already installed, with all the history. Beauty.

Currently available in the Portable Apps Suite we have a whole list of goodies: web browser, email client, office suite, calendar/scheduler, instant messaging client, antivirus, sudoku game, backup utility.

So go on. Download the application and start converting old applications into Portable Applications.
Go to: Portable Apps

Being on the subject Apple recently patented (of course it’s not out yet) a patent, that you will be able to plug a portable device (I’m thinking iPod) into any Mac and it will instantly become your computer: your applications, documents, wallpaper. Everything….

Tuesday, January 23, 2007 12:25:25 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Tools
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2009
Marcin Waligora
Sign In
All Content © 2009, Marcin Waligora
DasBlog theme 'Business' created by Christoph De Baene (delarou)