Friday, October 26, 2007

Download Picasa Gallery

This utility help in downloading images and creating a similar structure as in picasa[dot]google[dot]com galleries.

A very basic and simple app. Least of all, handles your mistakes. so be sure your entering the right gallery address and that you are connect to web.
You can provide multiple gallery addresses separated by ','.
Requires .net 2.0

Download


Feedback and Feature request are welcome. just comment onto this post

Friday, October 19, 2007

How to protect ur code

Obfuscation

Obfuscated code is source code that is (usually intentionally) very hard to read and understand. Some languages are more prone to obfuscation than others. C, C++ and Perl are most often cited as easily obfuscatable languages. Macro preprocessors are often used to create hard to read code by masking the standard language syntax and grammar from the main body of code. The term shrouded code has also been used.

There are also programs known as obfuscators that may operate on source code, object code, or both, for the purpose of deterring reverse engineering.

Obfuscating code to prevent reverse engineering is typically done to manage risks that stem from unauthorized access to source code. These risks include loss of intellectual property, ease of probing for application vulnerabilities and loss of revenue that can result when applications are reverse engineered, modified to circumvent metering or usage control and then recompiled. Obfuscating code is, therefore, also a compensating control to manage these risks. The risk is greater in computing environments such as Java and Microsoft's .NET which take advantage of just-in-time (JIT) compilation technology that allow developers to deploy an application as intermediate code rather than code which has been compiled into machine language before being deployed.

for dot net there a tool called 'Dotfuscator' which provides ways to protect ur code from being disassembled in a human eye readalbe format, the way reflector.exe does disassabled all the dll & exe.

Example :- open reflector.exe in reflector itself. U'll see that all names will be displayed as '[]', and u'll not be able to link and find references between classess.
the logic behind having '[]' is to replaces all named things with '?'.

refer :

Based on these way there are also belief that developer can speed up the code upload in case of scripting languages by removing white space charaters form the code.
You can make a short program which will read all files with specifc extension like '.js' and edit the file, before deploying them.

Creational Design Pattern

Singleton

The singleton pattern is implemented by creating a class with a method that creates a new instance of the class if one does not exist. If an instance already exists, it simply returns a reference to that object. To make sure that the object cannot be instantiated any other way, the constructor is made either private or protected. Note the distinction between a simple static instance of a class and a singleton: although a singleton can be implemented as a static instance, it can also be lazily constructed, requiring no memory or resources until needed. Another notable difference is that static member classes cannot implement an interface, unless that interface is simply a marker. So if the class has to realize a contract expressed by an interface, you really have to make it a singleton.

The singleton pattern must be carefully constructed in multi-threaded applications. If two threads are to execute the creation method at the same time when a singleton does not yet exist, they both must check for an instance of the singleton and then only one should create the new one. If the programming language has concurrent processing capabilities the method should be constructed to execute as a mutually exclusive operation.

The classic solution to this problem is to use mutual exclusion on the class that indicates that the object is being instantiated.



C# (using generics)

This example is thread-safe with lazy initialization.

///
/// Generic class implements singleton pattern.
///

///
/// Reference type.
///

public class Singleton where T : class, new()
{
///
/// Get the Singleton Instance.
///

public static T Instance
{
get { return SingletonCreator._instance ; }
}

class SingletonCreator
{
static SingletonCreator() { }

internal static readonly T _instance = new T();
}
}

C# (using generics and reflection)

This example is thread-safe with lazy initialization. In addition, this example is suit for classes which have private constructor.

///
/// Generic class implements singleton pattern.
///

///
[CLSCompliant(true)]
public static class Singleton where T : class, new()
{
private static T _instance;

static Singleton() {
Type type = typeof(T);
BindingFlags searchPattern = BindingFlags.NonPublic |
BindingFlags.Public |
BindingFlags.Instance;
ConstructorInfo constructor = type.GetConstructor(searchPattern,
null,
Type.EmptyTypes,
null);

_instance = (T)constructor.Invoke(new object[0]);
}

///
/// Get the singleton instance of the type.
///

public static T Instance {
get { return _instance; }
}
}

public class Session
{
private Session() {
}
}

public class Program
{
private static void Main() {
Session instanceA = Singleton.Instance;
Session instanceB = Singleton.Instance;

// Are they the same?
Console.WriteLine(instanceA == instanceB); // true
}
}

Source :