Archive for August, 2011

Useful Android development resouce

Just googled onto this site which is an awesome resource if you’re new to Android- lots of code examples of common (and not so common) tasks!

No Comments

Command Line- create a folder named with todays date

mkdir %date:~-4,4%%date:~-7,2%%date:~0,2%
will produce a folder named like this; YYYYMMDD

Thanks to Mr Carmichael for this..

No Comments

IIS7 UrlRewrite Outbound links with Compression Enabled

I’ve recently started using the outbound link rewriting feature in the url rewrite module for IIS7, but initially ran into some problems.

In my web.config, my rewrite section (under system.webServer) looked something like this;

        <rule name="InboundFriendlyAboutUs" stopProcessing="true">
          <match url="^about-our-car-finance$" />
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          <action type="Rewrite" url="About-Us.aspx" />
        <rule name="OutboundFriendlyAboutUs" preCondition="IsHtml">
          <match filterByTags="A, Form" pattern="^(.*)About-Us\.aspx$"/>
          <action type="Rewrite" value="{R:1}about-our-car-finance"/>
          <preCondition name="IsHtml">
            <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html"/>

However when I tried to view the page I received a server error;

HTTP Error 500.52 – URL Rewrite Module Error.
Outbound rewrite rules cannot be applied when the content of the HTTP response is encoded (“gzip”).

This is because I also had the IIS7 dynamic and static compression enabled, as is sensible for any website. It turns out that, while dynamic compression is supported, static is not- and dynamic requires a little bit of fiddling to get going. I’ll boil it down to a few steps;

  1. On the machine running the web site, from the command line run:
    reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\Rewrite /v LogRewrittenUrlEnabled /t REG_DWORD /d 0
    You may need to follow this up with an iisreset
  2. Add the following to the top of your system.webServer section of your web.config file to disable the unsupported static compression while leaving dynamic unharmed;

    <urlCompression doStaticCompression=”false” doDynamicCompression=”true” dynamicCompressionBeforeCache=”false” />

  3. The final step, is probably not needed- but! Open up your IIS management console- Click on the top level item, from the IIS segment open the “Modules” component. From within here on the right hand side bar, click “View ordered List…” and make sure RewriteModule appears in the list BELOW the DynamicCompressionModule. For me, this was already the case- my RewriteModule appeared at the very bottom, but this may not be the case for you.

If you’re after more details- my source was here;


Best program for creating favicon’s– infact maybe the best program… ever!

Well maybe not ever.. but it’s pretty good for Icons. It’s called IcoFX – and it’s free!!

No Comments

Refactoring a web project so you can share user controls across others

I recently built a brand new site, which launched last week and have now been tasked with adding an additional B2B component to it. The B2B site will have all the same styling as the B2C site, and will share a lot of functionality that I’ve already written into User Controls for the main web site. So I was faced with a problem- How can I share these controls across both projects? I don’t want to simply copy and paste, because then I have two controls to maintain, so I took to Google where I found this old article by Scott Guthrie.

I figured I would document the re-factoring exercise I went through.

So I started with my main web project which looked like this;

I shall break down the refactor into some simple steps;

  1. I created a new class library project which could be shared between the two web projects, in this instance I called mine Chinook.Web.Helpers
  2. Create a “Controls” folder and drag all the controls from the original web project, into the new shared projects control folder (Make sure both the ASPX and the code behind parts came across!). Build the new shared project- you will probably find some build errors and will need to add references to some web specific .net dll’s- I needed
    • System.Configuration
    • System.Web
    • System.Web.Extensions
    • System.Web.Extensions.Design
    • System.Web.Services

    As well as these I also had to add references to my .Model and .Interfaces projects, but this will be different depending on how you’ve setup your project. At this stage I had a projects which built and looked like this;

  3. I updated the namespace for each controls code behind and the first line of each ascx to reflect the namespace of the new project;

    //namespace Chinook.Web.Controls
    namespace Chinook.Web.Helpers.Controls
        public partial class QuickContact : System.Web.UI.UserControl

    ..and the new inherits parameters in the ascx;

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="QuickContact.ascx.cs"
        Inherits="Chinook.Web.Helpers.Controls.QuickContact" %>
  4. Next I added a reference in my web project to the new shared project, then deleted the controls from my controls folder, leaving an empty controls folder. All the references to the controls in your pages remain the same; for example
    <%@ Master Language="C#" AutoEventWireup="True" CodeBehind="Site.master.cs" Inherits="Chinook.Web.SiteMaster" %>
    <%@ Register Src="Controls/RSSLister.ascx" TagName="RSSLister" TagPrefix="uc1" %>
    <!DOCTYPE html>
    <html lang="en">
    <head runat="server">
    <ul id="rss" class="orange-bullets">
      <uc1:RSSLister ID="BlogRSSFeed" runat="server" />
  5. So the project is now happy- we just need to add the pre-build step which will copy the ascx files (but not the code behind) over to each projects control folder on pre-build. So in the original web project, right click the project and go to properties -> Build Events and set the pre-build event so that it copies;

    copy $(SolutionDir)\Chinook.Web.Helpers\Controls\*.ascx $(ProjectDir)\Controls\
  6. Build and run your web project!

I also moved over a few other bits. I had an ashx file which handles file uploads- so I moved the code behind to the shared projects and just updated the ashx file to inherit from the same class, but in it’s new namespace. I also had a resx file which contained user friendly error messages which I moved to be central. My final helper looked like this;

Make sure that you don’t edit the ascx files that now exist within your web project, as there will be overwritten by the versions in the shared project everytime you re-build.

If you use the publish option (you probably do!), make sure you “show all files” on your web project after a build include the ascx files into your web project, so it gets copied up.


Wizard generated SSIS package dumps critical files in Temp folder- breaks after a log out!

I’ve recently spent a day of so of my life doing something which I did in minutes using DTS (And I’m sure on SSIS in the past??). I selected export data from a database in sql 2005 and chose my destination database and a bunch of tables. At the end I select save as SSIS package; everything runs fine.

I can exit the sql management studio, run the package again– all ok.

I then log out, log back in, run the package, and I’m swamped with errors about missing tmp files.

It turns out that the ssis wizard, dumps critical parts of the ssis package (table schema and the like) out into temp files (Only when you tick optimize for multiple tables- whcih I had to in order to be able to use transactions), which on our system gets wiped on logout- so when you come back, the package is crippled.

I found a solution on from user jaegd;

The Import/Export wizard created files are stored in the TMP environment variable by default.

To store the Import Export Data wizard files with a checked “Optimize for many tables” setting in a particular directory, create a batch file with the following contents (change the dir name to one you want) and run it.

set TMP=c:\place_for_files

This approach just changes the TMP location temporarily to a place you’d prefer.

If you don’t want to create a batch file, just run the following from Start/Run…

cmd /c set TMP=c:\place_for_files && dtswizard.exe

This has fixed it! Such a relief- I set the env var tmp to c:\scripts\SSISFiles then generate the SSIS package, and save it to the file system in c:\scripts\ with no sensitive data embedded, then fire it off from the command line, supplying the connection strings.

dtexec.exe /FILE "C:\scripts\MySSISPackage.dtsx" /CONNECTION DestinationConnection;"\"Data Source=SiteDB\SQLEXPRESS;User ID=sync-user;Password=abc123;Initial Catalog=Chinook;Provider=SQLNCLI;Auto Translate=false;\"" /CONNECTION SourceConnection;"\"Data Source=CentralSQL;User ID=sync-user;Password=abc123;Initial Catalog=ProductDataStore;Provider=SQLNCLI;Auto Translate=false;\"" /MAXCONCURRENT " -1 " /CHECKPOINTING OFF  /REPORTING V  /CONSOLELOG NCOSGXMT >Log.txt

This way everything is kept nicely grouped together. Thought I would blog it for future me, and to prevent anyone else shaving 3 years off their life with stress.

No Comments

New Adobe HTML5 Animation tool “Edge”- free tech preview

A real nail in the coffin for Flash, as it’s own parents (Adobe) release a free tech demo version of Edge- A new editor that lets you make flash style animations– without Flash! Instead the animations are scripted using standards html5, JavaScript and CSS3. Having been hand coding stuff like this over the past year (for 8week game and the like) I’m interested to see what kind of code this tool actually spits out! Check it out herel;


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.