Showing posts with label Tools. Show all posts
Showing posts with label Tools. Show all posts

Monday, March 23, 2009

yEd Graph Editor Replacement For Visio

yEd by yWorks is a very nice graphical editor which can be considered a very perfect replacement for Visio. The tool is very simple and provide most of the functionalities of Microsoft Visio. It doesn't provide a very large collection of graph types like in Visio but at least it provides the most used and popular ones. You can create UML diagrams, flowcharts, block diagrams, networks and more. You can have glassy figures, rounded corners, curves, edges and shadows. Although, it's a Java tool, I didn't find it slow or heavy in loading. It's a very powerful graph editor tool and it really worth a try: Download yEd Graph Editior


Wednesday, March 18, 2009

Blocking IP Addresses Using MMC

I was searching for a solution to block any communication with specific IP addresses. I have come to this solution using MMC (Microsoft Management Console). The following steps will allow you to block any communication - whatever the protocol is - with specific IP addresses or subnet:

1. Open Start Manu > Run > Write "MMC". Then press Enter.
2. In the Management Console > File > Add/Remove Snap-in...
3. In the opened dialog, leave "Local Computer" as it's and click "Finish".



4. You will have a new node in the left tree called: "IP Secuirty Policies in Local Computer".
5. Right click on this node and select "Create IP Security Policy".
6. In the opened dialog, write "Block IP".
7. Click Next till the end of the wizard and then "Finish".
8. You will have an item in the left pane called: "Block IP". Right click on it and select "Properties".



9. In the opened dialog, click "Add".
10. Go through the wizard, till you reach a step called: "IP Filter List".
11. Click "Add". IP Filter Dialog will open.



12. Modify the name of your IP Filter and click "Add" to add an IP filter policy.
13. Click "Next. Leave "Source Address" as "My IP Address".
14. In the destination address, you can select "A specific IP Address". You can also filter by DNS or subnet. Enter the IP address to block. Then click Next.



15. Leave the protocol to be "Any" and click "Next".
16. Then click "Finish".
17. Apply all changes, and close all the opened windows. You may have to add "Block" action if it doesn't exist.
18. After you finish, don't forget to write click on "Block IP" policy and select "Assign".



Now try to ping the blocked IP addresses. You should get "Destination Unreachable" message.


Tuesday, March 17, 2009

Maintenance Plans in SQL Server

Creating backups for your database is an essential task in every environment especially for critical data storage. But have you ever ask yourself how to create your backups in a periodic manner - say every week or so? If you was able to do so, how will you manage the space in your disk? Maybe you don't want to keep any backup files older than one month.

The first solution you may think about is to create a SQL script and execute it in a custom job. But wait, SQL Server can do it for you and save alot of this implementation hassle. In the SQL Server, you have the option to create "Maintenance Plan" for your database. This plan provides you with more advanced options for creating backups for the data and the transactions logs.

When you create a new plan, you will have to go through a configuration wizard. The interesting part is in the backup configurations. You can provide how often you want to backup your database (i.e every week, month or so). You also specify how long you want to keep the backup files and when to remove it (i.e You may remove any backups older than one month) so that you save your storage space. Another interesting point, you can create only one plan for more than one database. The plan can be configured also to create a separate backup folder for each database.

The maintenance plan is a periodic task which needs a running job. This is why it requires a running SQL Server Agent in your database server.


Wednesday, October 01, 2008

NeatUpload - File Upload Open Source Library

NeatUpload is a very nice open source ASP.NET component which allow you to make file uploads to file system or database storage with customized AJAX-like progress bar indicators. The library is made in .NET and it works under Mono's XSP/mod_mono or Microsoft's ASP.NET implementation. You can easily download the source code and even modify it to match the required behavior of your project.

The library features 2 custom web controls: InputFile allows the user to select a file to upload, and ProgressBar displays the upload progress either inline or in a popup. ProgressBar uses AJAX-style refreshless updates on modern browsers when JavaScript is available, but also allows users without JavaScript to see upload progress. HttpModule is included as well to get the upload progress and handle the upload context states.

You can download and give it a try from this link: Brettle Development NeatUpload


Friday, September 05, 2008

TeamCity - Continuous Integration Server and Build Management Tool

TeamCity is a continuous integration & build management solution for both .NET and Java development. TeamCity is developed by JetBrains - the producer of the famous Resharper - and shipped in two editions: Professional Edition and Enterprise Edition. The Professional Edition of the team city is free and you can use it without a need for any kind of licenses. This edition is more than enough for small and medium size company or teams.

Build Servers are very useful tool in any development environment where you need to track the build state of your team code. It make sure that all the committed code is not in a breaking state. The integration with the build servers and the continuous integration tools like SVN and sourcesafe help you to assign the responsibilities of the breaking code to specific developer to fix.







TeamCity is a a very powerful build server which has many features to facilitate your project building process. You can download the last version of TeamCity from here. I have downloaded the last version and played a little bit with it and it seems very interesting tool. When you run it for the first time, you will be asked to make a new account. Then you will have to create a new project by entering the main project information. Afterwords, you will be asked to enter the general settings of the project. Then, you will have to enter a new build configuration. You can have more than one build configuration in the same project allowing a kind of switching for the build needs and requirements for your project.







In "Build Configuration" step, you need to define the build numbers format. You can have your own format for the builds numbers like "CG-01" or "MX-01" or whatever suitable format. You can define the criteria of the build failing. For example, you can define the failing criteria if the building execution itself failed, the project test failed, error reported by the build runner and/or the build take more than a specified number of minutes (timeout).

Also in this page there is a nice feature called "Status Widget". This means you can include the status of your build in any external web page or whatever external tracking site you may use internally. When you enable it, you will have to copy and paste small HTML and CSS tags inside this external page to show your build status.




Then you will be asked to enter the build runner information in "Build Runner" step. In this step, you need to define the platform you will use to build the project. Team City provide several build runners for .NET and Java projects as well. I am working with .NET so I choose MSBuild as a build runner. Then I specified the build file virtual path which is the solution file of my project (ex. teamcitytest.sln). When you select MS Build, you define the suitable .NET Framework version for the build. You also define more command line parameters for MSBuild.exe if required.







Then, you will enter the version control settings like the checkout path if it's different than the default directory of the agent. You can also make automatic labeling if the build succeeded.

There is another nice setting in TeamCity which allow you to run the build periodically. You set it by clicking "Edit Configuration Settings" in the top panel of the build progress screen. Then in the left tabs, choose "Build Triggering". Select "Other Triggering". Check "Automatically start a new build when the previous build failed." and specify the time intervals between the builds.





This was a very quick walkthrough for TeamCity. I really like it and recommend it for your development team as a very efficient and customizable build server.


Friday, June 13, 2008

Code Style Review Using Microsoft Source Analysis

Today, I gave a try for Microsoft Source Analysis aka StyleCop. The tool was internally used inside Microsoft and it's now publicly released. It nicely integrates with Microsoft Visual Studio with the ability to attach the analysis process with the project build - See this post. The tool scan all your C# code and gives you hints for better coding style according to the best practices followed in writing C# code. It gives for example notes regarding the missing comments, formating, missing or extra spaces, extra blank lines and unnecessary brackets.

Here are some sample error messages resulted after running the Source Analysis on one of my projects

- The class must have a documentation header.
- The property must not be placed on a single line. The opening and closing curly brackets must each be placed on their own line.
- Property names begin with an upper-case letter: projectspath.
- All using directives must be placed inside of the namespace.
- The body of the if statement must be wrapped in opening and closing curly brackets.
- Statements or elements wrapped in curly brackets must be followed by a blank line.
- The code must not contain multiple blank lines in a row.
- All properties must be placed after all constructors.



However, there is some drawbacks regarding the tool like it targets only C# developers. More so it can't recognize the spelling mistakes in the code and comments which is one of the most common issues. Another point is that the tool is not flexible regarding its guidelines rules. It doesn't give you the option to exclude a rule in the next time of the analysis scan. For example, it consider putting a preceding underscore in the class private members as a breaking style. However, it is common for most of the C# developers. I think there is already a debate about the best style guidelines for C# coding to follow. The issue even seems to have some historical sides..

I really recommend this tool if you want your team to follow the basics of the C# coding guidelines without caring much about going in details while reviewing their code. It just help you, so that you ignore all the small crappy notes giving all your attention to the real massive mistakes in the coding logic and modules interactions.

You can find more about the tool releases and the future expectations in the Source Analysis blog.


Thursday, June 12, 2008

MbUnit 2.4 - Avoiding Crappy Data Resulted From The Test

One of the nice features in MBUnit 2.4, is the ability to rollback the crappy data in the database resulted from running subsequent test methods. This is really interesting because this crappy data can become a nightmare during the application development or even after the deployment. You will spend pretty much time exploring your data to filter the dirty ones which can lead sometimes to some mistakes.

MbUnit give you the ability to rollback any changes made in the database during the test. Using MbUnit 2.4, this can be done by referring MBUnit.Framework.2.0 in the project references and using RollBack2 attribute for each test method.

[Test]
[RollBack2]
public void InsertNewProductTest()
{
      Product product = Product.CreateNew('Nokia 800', 2300, true);

      Assert.AreEqual('Nokia 800', product.Name);
      Assert.AreEqual(2300, product.Price);
      Assert.AreEqual(true, product.InStock)

      ProductRepository.Persist(product);
}

In the later example, any changes made in the database by persisting the Product object will be rolled back after the test execution. This will keep your tables clean containing only your application live data.

MBUnit uses TransactionScope in System.Transactions to provide the rollback functionality. However, you will need to set some security configurations for the DTC settings in order to make the TransactionScope properly work. To set these settings, open the Component Services in the Administrative tools. Then, show the properties of your computer and select MSDTC tab. Open the Security configurations and setup the needed settings for the remote and local authorization of the transactions on your machine.

As a side note, you are able to track the operating transactions by putting some break points inside your test method. Then, in the Component Services under the Transaction list you will find your active transactions listed there. More so you can check the Transaction Statistics to track the committed and aborted transactions of your test operations.


Monday, March 24, 2008

jQuery Validation Plugin

We start to see several plugins in the web based on the jQuery library. I have the chance today to work a bit with a plugin called: jQuery Validation Plugin by Jörn Zaefferer - which enable you to apply client validation to your web forms using jQuery.

To get started, you have to download the plugin files from this link. And sure the jQuery library as well: jQuery 1.2.2. Then, you should have: jquery.validate.js and jquery.js files reside on your project somewhere and linked in your markup.

IMPORTANT NOTE: I had a problem when using jquery.validate with the new vesrions - higher than 1.2.2 - of jQuery library. jquery.validate uses functions in jQuery library which no longer exist.

The following sample is the simplest one. You use the selector to get the form element. Then, you call the validate function.

<script language="text/javascript">
    $(document).ready( function() {
         $("#simpleSignUp").validate();
    }
</script>


In this case, you will have to set some predefined metadata in the class attribute of the elements telling the library the required rules to apply for the form inputs.
<form id="simpleSignUpForm" action="" method="get">
        <input type="text" id="firstname" class="required" minlength="2"/>
        <input type="text" id="lastname" class="required" minlength="2"/>
        <input type="text" id="username" class="required" minlength="2"/>
        <input type="text" id="email" class="required email" minlength="2"/>
        <input type="text" id="password" class="required" minlength="8" />
        <input type="text" id="website" class="url" />
        <input type="submit" value="Submit" />
</form>


In this case, the plugin will use some defaults error messages for validating the inputs. However, you can have more controls on the errors and rules. The following sample show in details how you can validate a full sign up form elements by specifying the rules with the associated error messages. In this sample, you won't have to apply any CSS styles as you already defines explicitly your rules.
<script type="text/javascript">
        $(document).ready( function() {
               $("#signupForm").validate({
                           rules:{
                                           username:{
                                                               required:true,
                                                               minlength:2
                                           },
                                           password:{
                                                               required:true,
                                                               minLength:5
                                           },
                                           confirm_password:{
                                                               required:true,
                                                               minlength:5,
                                                               equalTo:"#password"
                                           },
                                           email:{
                                                               required:true,
                                                               email:true
                                           },
                                           topic:{
                                                               required:"#newsletter:checked",
                                                               minLength:2
                                           },
                                           agree:"required"
                            },
                            messages:{
                                           username:{
                                                               required:"Please enter a username",
                                                               minLength:"Your username must consist of at least 2 characters"
                                           },
                                           password:{
                                                               required:"Please provide a password"                                                                minLength:"Your password must be at least 5 characters long"
                                           },
                                           confirm_password:{
                                                               required:"Please provide a password",
                                                               minLength:"Your password must be at least 5 characters long",
                                                               equalTo: "Please enter the same password as above"
                                           },
                                           email: "Please enter a valid email address",
                                           agree: "Please accept our policy"
                            }
               });
        }
</script>






For more information about the methods you can use for the validation, check it here.

The way you define your rules and messages are unified and configurable. You define a message per rule which is extremely a need in any web project. It's common to have several validation rules with different error messages in the same web form. When I see this style, I just remember the Design by Contract style in which your requirements (contract) are easily mapped to rules (benefits and obligations). It's similar as you put all your quality matrix in one place. Besides, it's easy to modify as like as you set some configurations to your web form!

Another point to mention is the different scenarios you can have and how this library fit it. In the last sample, you can see how you check for password confirmation, input formats (emails, URLs ... etc.) and user selections.

You can modify the CSS style of your validation errors - i.e how the input controls will look like in case of a validation error occurred. You simply modify the following snippet to have different look for the validated inputs.

div.error { display: none; }
input { border: 1px solid black; }
input:focus { border: 1px dotted black; }
input.error { border: 1px dotted red; }




This plugin is perfect for ASP.NET MVC. Actually, there is already some tries like Validator Toolkit for ASP.NET MVC which enable client and server side validation for MVC. It uses jQuery as well for the client validation. I don't think jQuery Validation is easy to be used in ASP.NET web forms as the page structure actually differs. However, we may find some other versions suitable for ASP.NET Web Forms in the future.

Unlike the ASP.NET validation controls which you need to inject inside your markup, jQuery Validation Plugin puts all the validation rules in one place. I think this really a benefit. In fact, this is one of the benefits of using jQuery itself - thanks for the nice selectors. This style definitely enhance your code readability by separating the validation stuff away from the markup giving the designers - and even the devs - more clean markup to work in.


Sunday, August 05, 2007

SubSonic - Free DAL Generator

Data Access layer generation is one of the exhausting tasks in building any multi-tier software projects. SubSonic is one of the free .NET Data Layer Generators which can help to make your life easier. The generator is really simple to use and efficient. You can do almost all the needed SQL operations using simple method calling. Moreover it's an Open source and the source is available on CodePlex.

Learn More About SubSonic
HOW-TO Video

Information Source: Mohammed Tayseer