JetPack Post Statistics Link Plug-in

January 25th, 2012 No comments

You may have noticed that the jetpack plugin provides you with some great statistics on the hits to your website.

It also allows you to drill down on the statistics for each post, with one problem…

If your post does not appear in the top 10 results for the day then you have no way to see the statistics.

That is where the “JetPack Post Statistics Link Plug-in” comes in.

The plug-in provides an extra column on your Posts admin page and provides a link to the statistics for each post.

To download a copy go to my main website.. >> Download Link <<

Categories: WordPress Tags:

Crysis 2 50Hz issue ATI Card on HDMI connection

January 16th, 2012 No comments

I have been running Crysis 2 on my DVI connection no worries, but recently I changed to a HDMI cable to connect my Benq E2420HD to my Msi R6850 video card.

If you see my previous post, Benq Monitor and HDMI not working you will see that I had some issues with getting my monitor to work, but I found the settings and all was good with the world.. until I launched Crysis 2.

Issue

When Crysis 2 runs with DX 11 in full screen mode, it runs @ 50Hz.

My monitor can handle 50Hz, (it is a supported refresh rate), but the game did not fill the full screen. The full screen was black but the edges of the game fell about 1cm short or the edge of my screen.

So WTF was going on?

Catalyst Control Centre.. again..

The issue is the overscan setting. As per the previous post (link above), I had to set the overscan setting to 0%. But when the monitor switches to 50Hz it also switches to a different profile, and this profile has the overscan setting to about the middle of this bar, (approx 7.5% underscan)

The solution is:

  1. Launch Catalyst control centre
  2. Expand “Desktop Management” and click on “Desktop Properties”
  3. Set the monitor to use 50Hz and click apply
    your monitor will switch and wow you suddenly see the black border similar to when you were playing Crysis 2
  4. Switch to the “Scaling Options” and set the Overscan to 0% and click apply

When you play Crysis it will now fill the full screen.

Got to go.. stuff to shoot .. ;-)

Categories: Hardware Issues Tags:

Benq Monitor and HDMI not working – FIXED

January 14th, 2012 No comments

Attaching a monitor to a pc via HDMI should be easy… right.

Well on hooking up a Benq E2420HD monitor to a MSi R6850 (PM2DIGD5), the image looked terrible.

It took a bit of tweaking but these are the steps you will need to follow to get things looking how they should.



Step 1. Catalyst Control Centre Settings

In my case the software was defaulting to set the scaling options to “under scaled”! (about -7.5%)

Turn the scaling off and set it to 0% as shown.

Step 2. Monitor Settings

You need to turn off the overscan feature, in the monitors OSD (on-screen display) settings.

  1. Go to the Picture Advanced page and choose display mode

    On Screen Display 1

  2. Set the Overscan feature to OFF

    On screen display overscan

    Problem solved :-)

Categories: Hardware Issues Tags:

SATA 3 SSD running on SATA II benchmark

January 11th, 2012 1 comment

This benchmark and review is to show what performance differences you can expect when you try to run a SATA 3 SSD on older hardware that only supports SATA II (300 Mb/s) connections.

I was recently looking to purchase a SSD drive as an upgrade for my old socket 775 Core 2 Duo machine to keep it alive a bit longer. This meant purchasing a current SATA 3 drive and running it connected via the on-board SATA 2 connection.

When attempting to research whether I needed an add-on SATA 3 card I was unable to find any real world reviews of this type of upgrade, so this review is designed to fill this gap.



The Rig

Mother Board: Socket 775, Gigabyte EP45-DS3
CPU: Core 2 Duo E8400 3.0Ghz, running overclocked @ 4.0Ghz.
Memory: 4GB (2x2GB) Corsair CM2X2048-8500C5C (1066Mhz)
Video: MSi R6850 Storm II 1G OC (R6850 PM2DIGD5)
SSD: Corsair Force GT 120GB, (1.3.3 firmware on SATA II in AHCI mode)
ATA Drive: Segate Barracuda® 7200.12 1 TB
OS: Windows 7 SP1 – 64 bit

SSD Benchmark

The SSD drive in question is a Corsair Force GT 120GB.

Full specs and details can be found here on guru3D

This is connected via the on board SATA II Connection.

The theoretical throughput is 300Mb/s. The following is the results of AS SSD.

The overall score is comparable with the results from the guru 3d review with the obvious difference being the Sequential Read maxing out at 263Mb/s.

Here is the compression benchmark, so clearly the drive is not being pushed very hard..

OS Benchmark

The machine is running Windows 7 – 64bit, plus all the services and software one would expect, including:

  • AVG Anitvirus
  • Catalyst control centre
  • HP Printer Software
  • Msi Afterburner
  • Core Temp
  • Network and All CPU meter gadgets

The Test

This benchmark recorded the total time to startup the PC on the 7200RPM 1TB drive vs the SSD. The benchmark recorded the time from when windows started loading after the POST screen, until a working desktop was available. This was identified as the time at which the Gadgets appeared on the desktop. This was split into 4 timing points:

  1. time to login screen
  2. time to login
  3. time to see the desktop
  4. time until the gadgets loaded.

The windows startup time is now 4 times faster with the SSD drive, launching to a working desktop in less than 25 seconds, (including typing my password!)

Windows Experience Score

The windows experience went from…

to..

The slowest component is now my CPU.. may have to tweak that overclock ;-)

Edit Caveat: Note you will have to factor in the fact that the SSD benchmark is on a clean install Windows 7 whilst the ATA Drive have been running for a while, but even so I have been using the SSD setup over the past few weeks since writing this review and start up is still very quick with only a few seconds between clicking login and being able to use the computer :-)

Crysis

I timed the loading of the application and the loading of a new game.
With the following results.

The load times were generally faster on the SSD drive and seem to have a larger performance gap as we moved from Crysis to Crysis 2.

Crysis Benchmarks

I ran both the Crysis and Crysis 2 benchmarks with no consistent pattern of improvement. The tests were within 2 fps of each other but in some cases the SSD was better and some worse. So it appears the Disk has no real impact on Crysis frame rates.

General Performance

The general performance of loading applications like Internet Explorer and Firefox, windows media centre was recorded. In most instances the load times on the SSD drive was around the 0.5 – 2.0 seconds, whilst load times on the hard drive were sometimes comparable but more often they were slower (Browsers took approx 4 seconds to load to Google homepage), but the hard drive was inconsistent in performance with load times as high as 14.5 seconds for IE being recorded.

PC Mark – Vantage (1.0.2.0)

To give some kind of industry benchmark for the entire PC experience I benchmarked the machine for overall performance using PC Mark, the results were

Hard Drive Score – 6313
SSD Score – 10683

This is a 70% improvement over the Hard drives score.

Conclusion

The general feal of the machine is much snappier with the SSD drive. Applications install really fast, open quickly and it is a nicer experience to use with no major delays when using the applications. Also I just realised my computer is also eerilly silent on start-up no more mechanical whirring and noises

I would say that it was worth the money even with just an old SATA II connection. Also this drive will be a useful addition to my Laptop at some point in the future ;-) .

SATA 3 add-on Cards

The next stage of this benchmark test will be to get my hands on a SATA 3 card like the ASRock SATA 3 card or the ASUS U3S6 and see if these cards actually provide any performance benefit, stay tuned…

Categories: Hardware Review Tags:

Use CKEditor on MVC 3 Razor Website

December 6th, 2011 5 comments

This post provides the basic steps the implement a CKEditor control into your MVC Razor web page.

This post assumes you have a working MVC website, with a standard _Layout.cshtml page.

Follow these easy steps:

  1. Download the latest version of the CKEditor from here
    You only need to download the basic package.

    At the time of writing I downloaded the zip file of CKEditor 3.6.2

    You will see there is an ASP.net control that can be downloaded but this is not required to make it work with MVC.

  2. Unzip the downloaded package
  3. In windows explorer copy the “ckeditor” folder into the root folder of your website.
  4. In Visual studio and click the “Show All Files” icon.
  5. right-click on the ckeditor folder and choose include in project, this can take a little while..
  6. In the <head> of your _Layout.cshtml file reference the ckeditor.js file
    
    <script src="@Url.Content("~/ckeditor/ckeditor.js")" type="text/javascript"></script>
    

  7. Create a model class with a property you wish to bind to your HTML editor
  8. Create a strongly-typed view (use scaffold template of edit if you like)
  9. Now the easy bit, the way this works is by generating a <textarea> control with the class of “ckeditor” and an id, so the html for this would look like the following. Note the id can be anything you want.
    
    <textarea class="ckeditor" id="text-details" name="Details">some text</textarea>
    

    To generate this in MVC use the following
    
    @Html.TextAreaFor(model => model.Details, new { @class="ckeditor", @id="text-details"})
    

    where model.Details is the property of the strongly-typed class you passed through

That’s it. Run the site and visit the page. Your text area control will be rendered as the CKEditor control.

Happy editing

Categories: MVC Tags:

Distributed Transaction Failure – Race Condition

November 18th, 2011 No comments

I have a process that is using MSDTC (Microsoft Distributed Transaction Co-ordinator) to manage the transaction.

The transaction is controlled inside a c# .Net windows form executable that manages the transaction by the TransactionScope() object.

The transaction is maintained across 2 SQL server and an Oracle server and it all works… most of the time.

All transactions are opened inside a using statement, as follows



using (TransactionScope scope = new TransactionScope())

Or similar.

The overview of the .exe is it monitors a queue of jobs to process. It processes the work inside the transaction successfully commits, and then after that updates the status on the job queue to success or failure.

When there is an application error, the program throws an exception which means it ends the main transaction and in an outer transaction updates the status to failure.

Intermittently when the core logic was throwing errors on many jobs the entire process would fail with the following error:


Connection currently has transaction enlisted.  Finish current transaction and retry.

But it was intermitted. I had the same 12 jobs throwing errors on every run and sometimes it would crash with the above error after 2 jobs, 8 jobs, 4 jobs or it would actually not crash at all. On my development box I could not replicate it at all?

So I figured I had a race condition.

The fix


After the main transaction block of code and before opening the next TransactionScope object to update the status, I put a 100ms sleep.

    // Stop race condition
    System.Threading.Thread.Sleep(100);

    item.Success = false; // <-- this is my object for updating the success or failure
    using (TransactionScope scope = new TransactionScope())
    {
        context.SubmitChanges();
        scope.Complete();
    }

The problem has disappeared. I think the re-opening of a new TransactionScope() object did not allow enough time for MSDTC to close the previous transaction and it was crashing.

Cheers
John

Categories: c# Tags:

How to move wordpress.com site to a sub domain hosted on IIS – Tips and tricks

November 12th, 2011 No comments

I have recently moved my free wordpress.com blog (the one that you are reading) to my own domain.

If you read the contents on this site I hope you think I am reasonalby technically savy, but the feat of moving my site and redirecting the wordpress.com links was problematic and it took me a few days and many wrong turns to get it done.

I found that most instructions are based on apache/linux hosted solutions and I had issues using my IIS/Windows based host. My windows based host uses Plesk 10 (@ the time of writing).

Before you even begin to touch a computer there are a few things you have to think of first!

1. Root site or sub-domain?

Is this the only thing that you will have on your domain or are you going to have something else hosted on http://www.yourdomain.com? You need to answer this now as when you go to buy your domain mapping from wordpress.com you can only map a whole domain. So you would be better off hosting it @ http://blog.yourdomain.com, leaving the www for other things.

I started by creating my wordpress site with a click once install under a sub-directory in my httpdocs folder (main root web folder on my host), so I had my wordpress site setup @ http://www.homedev.com.au/ntsblog but as you can’t register a sub directory I had to start again.

So in my case I went and created a new sub-domain, http://ntsblog.homedev.com.au, and now I could register the sub-domain with my wordpress.com site.

2. Permalinks!!!!

Before you go any further you need to consider permalinks.

The issue

WordPress.com by default uses links that are styled as “Pretty Links” and default to a format of /%year%/%monthnum%/%day%/%postname%/” which means a posts will appear as http://blog.yourdomain.com/2011/11/31/post_title

The problem is that with version 3.2.1 of wordpress on a Windows host the “Pretty Link” is not supported by default and most “Permalinks” contain “index.php” in the path. see image..

Why is this a problem? Consider the link to your wordpress.com article that gets returned in a google search. When you try and do the domain mapping from wordpress.com to your domain, google will pass through a URL that your hosted wordpress site cannot handle.

This article discusses the various ways of mapping pretty links, and the section you are taken to is specifically for IIS/Windows systems.

http://codex.wordpress.org/Using_Permalinks#Permalinks_without_mod_rewrite

My hosting provider already had a copy of Microsoft “URL Rewrite Module”, so I created a web.config file as per the suggestion in this article and applied it to my site but it would not work.

Assume the URL was
http://ntsblog.homedev.com.au/2011/11/09/how-to-move-wordpress-com-site/

The URL re-writer would try to go to:

http://ntsblog.homedev.com.au/2011/11/09/how-to-move-wordpress-com-site/index.php/2011/11/09/how-to-move-wordpress-com-site/

In the end I did a little bit of tweaking and came up with the following solution…

web.config

Put this is the root directory of your wordpress site.


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
  <rewrite>
    <rules>
      <rule name="Main Rule" stopProcessing="true">
        <match url=".*" />
        <conditions logicalGrouping="MatchAll">
          <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
          <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        </conditions>
        <action type="Rewrite" url="redirect.php?path={R:0}" />
      </rule>      
    </rules>
  </rewrite>
  </system.webServer>
</configuration>

If you look at the “Action Type” link this is re-writing the url to go to a page called “redirect.php” passing in a parameter of the relative path. So we now need to create the “redirect.php” page.

redirect.php

Again, create this file in the root of you wordpress site.


<?php

  $relative_url = $_GET['path'];
  $new_relative_url = 'index.php/'. $relative_url;
  $hostname = $_SERVER['SERVER_NAME'];
  $new_url = 'http://' . $hostname . '/' . $new_relative_url;
  
  header("Location: " . $new_url)

?>

So what is this doing?
The URL re-writer matches the invalid URL and re-writes the url to “redirect.php”. This page then takes in the parameter, and rebuilds the full url to the site based upon inserting “index.php” in the chain. This works and also the “referrer” and “search engine” stats are not affected by the extra redirect.

To test this take an existing post on your new site, remove the index.php and paste that into a new browser window. The site should redirect to the index.php version. This means any link to your wordpress.com site will redirect to your new domain and be successfully passed along to the index.php page.

The only problem with this is that I don’t see how you could reverse the process and return to your wordpress.com site. The new articles will be found with index.php and if you try to go back to worpress.com as the primary domain the links with index.php will all break. Solution don’t go back. I will follow this up with wordpress and see if I can find a better solution.

Buy a domain from wordpress.com

Before you buy a domain read these wordpress articles about mapping domains or mapping sub-domains

Now seeing as I had created a sub-domain I went down the route of creating a CNAME entry. In plesk this means going to your DNSSettings and adding in a new CNAME. But being new to plesk I did not notice that when you make a DNS setting the settings shows with a warning like this
and right up on the top of the page you need to confirm the change by clicking Update.

So failing to notice that I handn’t saved the CNAME entry I gave up in frustration. So even though it told me not to I bought a domain and followed the full domain mapping instructions and it worked.

The instructions are fully mapped out in the mapping domains article but here are some extra tips.

  1. Go to your domain name provider site and find your name server settings, copy and paste them into a .txt document so you don’t forget them.
  2. With my name server provider, my names servers had a “Registrar Lock” on them. To update the ns1.wordpress.com, ns2.wordpress.com, ns3.wordpress.com, I had to
    1. Un-tick the checkbox and click save to clear the registrar lock.
    2. add the wordpress name servers and click save.
  3. now go to your wordress.com site and go to Store –> Domains.
  4. enter your domain, blog.yourdomain.com and click Add, follow the process to purchase the domain mapping
  5. Once registered, select your domain as the “Primary Domain” and click “Update Primary domain”
  6. Return to your name server and enter in the previous name server settings that you backed up to the text file.
  7. Re-enable the “Registrar Lock” if you have one.

Your wordpress site should now all be working.

What Plugins?

Now you’ve been using wordpress.com for a while and you probably have it configured how you like it, so how do you make your new site just like wordpress.com.
Most of the plugins on wordpress.com are special to wordpress.com, so I found it difficult to find and install the plugins to get the functionality I am used to.
So here is a mapping between functionality and the plugin you can freely download and install:

# wordpress.com Plugin Equivalent
1. Site Statistics Jetpack
2. Importer WordPress Imported
3. Ratings GD Star Rating

Other plugins I have found of interest;

  • Easy AdSense Lite
  • Google Analytics for WordPress
  • Preserve Code Formatting – keeps spaces and formatting when posting code snippets into your post.

Thats it for now.

Cheers
John

Categories: Blogging Tags:

How to run MvcMusicStore v3.0 with SQL Server Express

November 11th, 2011 No comments

I’ve been trying to do the MVCMusicStore v3.0b tutorial, and I wanted to use SQLExpress rather than SqlServerCe.4.0.

When trying to do this I ran into a number of problems but I finally figured it out.

This guide assumes you already have a working copy of SQL Server Express and that your user account is a System Administrator for the database.

This is the link to the PDF document for the v3.0b tutorial. MvcMusicStore v3.0

(*all page numbers quoted as on the document, page 45 is actually Page 46 when listed in Acrobat)

Below is what I did and the 2 solutions that I found..

  1. As on page 45* I created the AppData Folder.
  2. I downloaded the MVC assets and extracted the files from the zip file.
  3. Right click on AppData and add an existing file, and add in the MvcMusicStore.mdf.
  4. Edit the web.config and added the following connection string:
    
    <connectionStrings>
      <add name="MusicStoreDb"
        connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|MvcMusicStore.mdf;Integrated Security=True;"
        providerName="System.Data.SqlClient" />
    </connectionStrings>
      

  5. Added the MusicStoreEntities.cs as on page 47.

At this point Debug the site and I was getting errors. First I was getting errors about meta data failures.
I managed to play a bit more and somehow fixed the meta data issues so that it was no longer erroring, but the queries were not returning any data.

Then I noticed the following 2 issues:

  1. Write some code like the following

    
          MusicStoreEntities db = new MusicStoreEntities();
          string connection = db.Database.Connection.ConnectionString;
        


    Run up in debug and check the value stored in the connection string.

    Note that the database name is related to the application MvcMusicStore, “MvcMusicStore.Models.MusicStoreEntities”? WTF?
  2. Put a watch on the db.Database.Genres object and note the sql statement is is going to execute. The table name is “dbo.Genres”.
    The issue? Your datbase doesn’t have a “Genres” table it has a “Genre” table (minus the ‘s’).

Solution 1

So to fix these issues I have done the following:

  1. Create a default constructor in the MvcMusicStoreEntities class like follows:
    
    public MusicStoreEntities()
    {
        this.Database.Connection.ConnectionString = 
               ConfigurationManager.ConnectionStrings["MusicStoreDb"].ConnectionString;
    }
    

    This over-rides the connection string with the one that we have specified in the web.config.

  2. Pluralise your database.

    If your hosting your database on SQL Server you can use the SQL Management studio, or if you are hosting it in AppData then use the server explorer.
    Right click on each table and select “Open Table Definition”. Press F4 to view the properties window, Edit the “Name” property and change the name of the table and add an ‘s’ to the end, Genre -> Genres, Album -> Albums, Artist -> Artists etc. Save the file to apply the name change.

  3. Edit: A bit more digging and I also found this solution to the Pluralised problem, this removes the pluralised table names. Probably a bit easier than the above solution
    In your MusicStoreEntities class add the following
    
            using System.Data.Entity.ModelConfiguration.Conventions;
    
            protected override void OnModelCreating(DbModelBuilder modelBuilder)
            {
                modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
            }
    
  4. Debug your site and it should all work now.

Solution 2

In attempting to work out the above solution I also found a second solution.

  1. Ensure the constructor is removed from the MusicStoreEntities class.
  2. Edit the web.config file and add the following connection string
    
        <connectionStrings>
          <add name="MusicStoreDb"
            connectionString="Data Source=.\SQLEXPRESS;Integrated Security=True;"
            providerName="System.Data.SqlClient" />
        </connectionStrings>
        
  3. Add the Sample Data as on page 47 & 48 of the PDF guide.
  4. Debug your site and it should work.

    Launch SQL Mangement Studio and refresh the list of databases, you will see you new database [MvcMusicStore.Models.MusicStoreEntities] and look at the tables and they have pluralised names.

Hope this works for you as it did for me. Happy MVC’ing.

Categories: c#, MVC Tags:

Hyper-V Server virtual machine network connection failure – vm network issues

October 12th, 2011 No comments

Hi,

This has been a problem that has haunted me for over 18 months now and finally I have a solution.

The Problem

I have been creating virtual machines and been getting inconsistent success with getting the virtual network card inside the Virtual machine to successfully connect to the network. It will start up with a yellow “Warning” icon showing and when you confirm the IP Addres settings it is an invalid 169.x.x.x address. I am attempting to use DHCP to assign the IP.

I this situtation I have tried the following:

  1. netsh int ip reset – followed by a reboot.
  2. stop the VM, remove the network card completely, start the VM and login, shutdown the VM, add the network card back, start the vm and login
  3. changed the MAC ADDRESS on the virtual card to ensure it is not conflicting on the network.

All of these have failed.

This has been really confusing as I have created 2 Virtual Machines at the same time, from the same sysprep’d .vhd image and one will succeed and one will fail!!!

The only thing that has worked is to assign a static IP address.

Solution

A friendly member of the infrastructure team where I am working fixed it in about 2 seconds.

Apparently due to the way the newtork as been configured we run a virtual Lan, its number so happens to be 100.

So in hyper-v server find this screen:

And change it to something like this:

This sovled my problem.

I don’t know why sometimes it was set correctly and other times not, but this definitely solved my problems.

Let me know if it works for you.

Categories: Servers Tags:

Setup App.Config during .msi install, msi re-installing

August 17th, 2011 No comments

The Issue

I wrote a windows form application that deployed  via an .msi installer.

The application has an App.Config file which contains a single configuration value. I wanted to prompt the user for this value during the installation wizard and write it to the application.exe.config file as part of the installation process.

I used the built in Setup project in Visual Studio 2010.

The solution

I could write it all here in my post but I have found one that was created earlier:

http://raquila.com/software/configure-app-config-application-settings-during-msi-install/

I essentially implemented the same solution but I wrote my .config file using a StringBuilder and deleted and re-wrote the.config file in the Post install custom action.

The other thing is that I created short cuts to the application by right-clicking on the primary output and chosing “Create Shortcut”, then I copied this to the desktop and users program menu locations.

The problem

I was installing this for “Everyone” and it would work fine for me, but when other people logged in and tried to launch the program the .msi would run and the application.exe.config file was being overwritten with the orginal version that was deployed with the .msi, which does not contain the users input.

The Fix

The problem is complicated and is related to the application short-cut.

It appears that by default the short-cuts created in the msi are “Advertised ShortCuts”.

According to microsoft when an advertised shortcut is activated “.. the installer verifies that all the components in the feature are installed before launching this file”.

This means that if you delete any of the files that were deployed to the installation location then the .msi will attempt to fix them and re-install the missing components, which in my case means that the application.exe.config is overwritten.

You can identify the “Advertised” short cut by looking at the “Properties” of a short-cut and the “Target” will be greyed out.

I found the post below that identifies an easy way to disable advertised shortcuts.

You need to set the “DISABLEADVTSHORTCUTS” property on the .msi. This can be done easily in the installer, I have my custom UI that is getting details from the user for the “Edit1Property” so in the Edit2Property I set these values and keep it invisible.

  • Edit2Property: DISABLEADVTSHORTCUTS
  • Edit2Value: 1
  • Edit2Visible: false

This updates the property table in the .msi and now all your short-cuts will be normal standard shortcuts.

http://social.msdn.microsoft.com/forums/en-US/winformssetup/thread/b0a3e6d5-38f0-4a37-9418-dd8d9297ef97/

Cheers :-)

Final Tip: Setting the shortcut icon

Another tip is to set the icon based on the icon embeded in your .exe.

  • In the File System Editor, click on the ShortCut and view the properties
  • Click on the icon property
  • choose browse,
  • change from .ico to .exe
  • browse to the “Primary-Output for…” and choose OK.

It will show you the icons embeded in your .exe and this way you don’t need to deploy a seperate .ico file.

Categories: c#, Windows Forms Tags: