Archive for February, 2010

Command line to delete every file older than 30 days

I found a new command line directive i’d never heard of today, along with a brilliant example of it’s use- once you have changed your working directory, running this will remove any files or folders older than 30 days;

FORFILES /D -30 /C "CMD /C IF @isdir==FALSE (echo Deleting File @file) & (ATTRIB -H @file) & (DEL /F /Q @file) ELSE (echo Deleting Directory @file) & (ATTRIB -H @FILE) & (RD /S /Q @FILE)"

As an example, I’ve since used this to iterate over a bunch of folders, deleting any files over 30 days;

for /f "delims=|" %%f in ('dir /b D:\_SQL_Backup\') DO (
  cd \_SQL_Backup
  cd %%f
  FORFILES /D -14 /C "CMD /C IF @isdir==FALSE (echo Deleting File @file) & (ATTRIB -H @file) & (DEL /F /Q @file)"

No Comments

WCF 404.3 Errors

I built a WCF service recently which would run fine in the visual studio test web server, but when i tried to actually hit it from real life IIS7 also on my local box, i receievd the following error:

HTTP Error 404.3 – Not Found

The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

Luckily, i found the solution on David Waddleton’s blog and it was as simple as turning on a windows feature in add remove programs- on my vista box i had to go to Control Panel > Programs and features > Turn on/ off Windows features > Microsoft.NET framework 3.0 and tick the WCF activitation options!

No Comments

Getting started with WCF and REST web services

I’m building some REST WCF services at the moment and found this great guide online

The HiREST stuff shows you how to create fully fledged REST services utilising all of the HTTP verbs.

Heres a quick summary of the most useful bits;

The service itself is just added to the project as a normal WCF service. The following needs adding to the Web.config to setup the end


      <behavior name="AJAXFriendly">
        <enableWebScript />
      <behavior name="RESTFriendly">
        <webHttp />

    <service      name="MyNamespace.AjaxServiceClassName">
      <endpoint   address=""
        contract="CatalogService" />
    <service      name="MyNamespace.RESTServiceClassName">
      <endpoint   address=""
        contract="MyNamespace.IRESTServiceInterfaceName" />

Remember the class names in the web.config need to be fully qualified.

An example class for passing around the service;

public class ProductData
    public int ProductId;

    public string ProductName;

    public string Description;

    public decimal Price;

    public string ProductImage;

The service itself is just a normal WCF service so consists of its usual two parts- the interface and the class. Here’s an example interface

demoing the various access methods and return serialisations;

    public interface IRESTServiceInterfaceName
        // responds to a GET request to
        // return is serialised to JSON  
        [WebGet(UriTemplate = "products/", ResponseFormat = WebMessageFormat.Json)]
        List<FlotChartSeries> GetProducts();

        // responds to a GET request to{product_id}
        // return is serialised to JSON  
        [WebGet(UriTemplate = "products/{product_id}", ResponseFormat = WebMessageFormat.Json)]
        List<FlotChartSeries> GetProductById(string product_id);

        // responds to a GET request to{brand}
        // return is serialised to JSON  
        [WebGet(UriTemplate = "products?brand={brand}", ResponseFormat = WebMessageFormat.Json)]
        List<FlotChartSeries> GetProductsByBrand(string brand);

	// responds to a POST, but still passing a bunch of parameters into the querystring
	// no return type
        [WebInvoke(Method = "POST", UriTemplate = "product/{product_id}/rate?score={score}")]
        void PostProductAppRating(string product_id, string score);

	// accepts a POST with a JSON encoded product data, to allow for an update
	// no return
	[WebInvoke(Method = "POST", UriTemplate = "product/{product_id}", RequestFormat = WebMessageFormat.Json)]
	void PostProductUpdate(string product_id, ProductData data);

	//responds to a PUT- passing a querystring variable for the filename- it expects the body of the push request to be a file stream
	// no return type
        [WebInvoke(Method = "PUT", UriTemplate = "products/{product_id}/desktopimage?filename={file_name}")]
        void PutProductImage(string product_id, string file_name, Stream fileContents);

Note the variables in the curly braces must match the real parameters to the method signitures for the value to be automatically mapped.

Responses are generally done using HTTP response codes. At the top of each method you need to grab the current WebOperationContext which

will allow you to set the return codes;

    WebOperationContext ctx = WebOperationContext.Current;

    ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.OK;		// .. if everything is ok!
    ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.BadRequest;	// on error
    ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Created;	// after an insert

    // all of the http response codes are mapped here

    ctx.OutgoingResponse.SetStatusAsNotFound(); // if record cannot be found or similar

, ,

No Comments


Where do you setup and managed your Gravitar image, used by many wordpress and other blogs I hear you ask?

No Comments

I absolutely love these. They came at the lace wigs are good quality, and very soft. Absolutely love these extensions. I just love this hair. Hair came on time, I waited until after hair extensions uk very full, no shedding and it is been installed for 3 weeks now and yes I jus ordered 3 more bundles. Lol. I definitely recommend this company for your bundles ladies. They are soft, hair bundles on the head for human hair wigs and I would continue to recommend them. I have thinner hair so they cover and blend nicely.