Links for MVC development

Today’s links on MVC development and related technologies, read at your own peril ; )

  • General Discussion

    http://www.dnnsoftware.com/community-blog/cid/155035/the-future-of-dnn-speaks-razor–1-you-have-to-migrate-now

  • Javascript

    https://angularjs.org/

  • CSS

    http://getbootstrap.com/

    http://foundation.zurb.com/

    http://metroui.org.ua/

Why you need to sign up to Microsoft’s BizSpark program now!

I recently purchased Windows 8.1 but as it turns out, perhaps I didn’t need too.

I recently signed up for Microsoft’s BizSpark program to develop software solutions for my customers. I was accepted, and within a few day I was gifted with over 900 products from Microsoft’s software library and hundreds of licence keys… essentially for free! Included in the MSDN Library of downloads was Windows 8.1 – Doh!

Oh well… I’ve got my sights on the bigger picture. I was also given $160 worth of credit per month, for three years, to spend on Windows Azure cloud. This is pretty cool. It’s early stages so far, but it appears that this blog will cost me about $20/month to run on Windows Azure… which is about on par with Amazon’s offerings.

I’ve decided to blog my experience with Windows Azure, it’s various cloud offerings and my experience creating software for my customers and market.

If you are a software developer struggling to afford client or server software from Microsoft, then I strongly urge you to seek out the BizSpark program and sign up now!

Test data generator

Background

I’m currently designing an MVC ASP.NET web application with a SQL Server database.

I want my application to process hundreds or thousands of transactions every hour. That being the case, I need to stress test every part including the web server, slq database, indexes, paging, filtering and many other parts of my application.

test data

Solution

I developed a c++ console application that will generate as many test records as I want (into the millions). The file below contains about 100,000 test records containing randomized first and last names. (The last names are country specific and the first names are gender specific).

  1. Download Test Data.
    TestData.zip
  2. Unzip file and import into a temporary table in SQL Server.
    (Note to the Novice: Creating a temporary table might seem like a wasted step, but it’s actually the correct way of doing this).[sourcecode language=”sql”]
    USE MyDatabaseName
    GO

    CREATE TABLE CSVImport (FirstName nvarchar(20),
    LastName nvarchar(20),
    Gender nvarchar(7),
    Country nvarchar(20))
    GO

    BULK INSERT MyDatabaseName.dbo.CSVImport
    FROM “C:TestData.txt”
    WITH (FIELDTERMINATOR=’,’, ROWTERMINATOR= ‘n’)
    GO
    [/sourcecode]

  3. Inserted the imported data into an existing table in your database.In this example, the ‘People2′ table.[sourcecode language=”sql”]
    INSERT INTO People2 (FirstName, LastName)
    SELECT FirstName, LastName FROM CSVImport
    GO
    [/sourcecode]

Amazon Cloud is my new best friend

After a long hiatus, my website is back online and hosted in the Amazon cloud at Sydney (aws.amazon.com). I’m gradually migrating all my computer services to the Ubuntu Operating System (LTS) both at home and professionally. My new home office is located in Boorowa and with a bit of luck I’ll get back into programming soon.

BoorowaSunset
Sunset at Boorowa, NSW

Working on the Gold Coast – Part 1

When I worked on the Gold Coast, I was responsible for the networking infrastructure, maintenance and technical support for 250 workstations and 33 critical business servers spanning 18 companies across multiple sites around the Gold Coast and Australia. Daily duties included troubleshooting applications, systems, networks and helping non-technical users over the phone and in person. To learn more about my employment visit my LinkedIn profile.

WorkingOnTheGoldCoastTypical Software Managed while I worked on the Gold Coast included:

  • Microsoft Business Server
  • Microsoft Server 2003 and 2008
  • Microsoft XP, Vista, Windows 7 desktops
  • Microsoft Exchange Server… plus many others.

It was crazy fun, hectic, stressful and rewarding all at the same time. My time there was short, but I enjoyed myself. Despite all the technology, the best part was working within walking distance to Broadbeach where I would frequently have lunch. It was also nice working close to a large shopping center as my previous employment at Mt. Stromlo had no shops (and frequently no people either)… but that’s another story.

error C2065: 'M_PI' : undeclared identifier

Problem

error C2065: 'M_PI' : undeclared identifier

If you’ve checked the obvious stuff and you still can’t get M_PI declared, it’s probably because another file or library has already included the header before you, but didn’t include the necessary macro.

Solution

Instead of the following:
[sourcecode lang=”cpp”]
#define _USE_MATH_DEFINES
#include
[/sourcecode]
…include the macro in the Projects Preprocessor Definitions. In this way, the macro will be included at compile time solving the problem

The curious problem with msxsl:node-set()

After wrestling for hours over a tricky problem with xx:node-set(), I finally found the reason:

…Within xsl:for-each select=”xx:node-set()”, the current document is the result tree fragment itself. I suspect you are looking for nodes in the original source document.

- Michael Kay

Thank God for Author’s like Michael Kay. He not only wrote the book on XSLT but takes an active role in answering questions all over the place! ┬áHonestly… I can’t praise the man enough. I’ve put together a short snippet to show the problem and a solution.

Assume the following XML document in a file called people.xml

[sourcecode lang="xml"]<br />&lt;People&gt;<br /><%%KEEPWHITESPACE%%>  &lt;Person FirstName="Michael" LastName="Kay" /&gt;<br /><%%KEEPWHITESPACE%%>  &lt;Person FirstName="Peter" LastName="Wilson" /&gt;<br />&lt;/People&gt;<br />[/sourcecode]

Symptom:
In the following XSLT fragment, the scope of the current document changes inside the for-each loop, such that the current document is the result tree fragment instead of the XML file above. In the example below the XPATH expression “Person/@FirstName” will not work because there is no Person element in the Result Tree Fragment [document/variable] $varRTF.

[sourcecode lang="xml"]<br />&lt;xsl:for-each select="msxsl:node-set($varRTF)/whatever"&gt;<br /><%%KEEPWHITESPACE%%>	&lt;xsl:value-of select="Person/@FirstName" /&gt;<br />&lt;/xsl:for-each&gt;<br />[/sourcecode]

Solution:
Whenever you want to access elements of the source XML file within a for-each loop based on a variable holding a result tree fragment, qualify the expression with the document() function.

[sourcecode lang="xml" highlight="2"]<br />&lt;xsl:for-each select="msxsl:node-set($varRTF)/whatever"&gt;<br /><%%KEEPWHITESPACE%%>	&lt;xsl:value-of select="document('people.xml')/Person/@FirstName" /&gt;<br />&lt;/xsl:for-each&gt;<br />[/sourcecode]

I hopes this helps someone. I saw many people asking for help, but not many answers or solutions.

XPath for finding distinct elements

Sigh… it’s times like this (well… yesterday actually… the 13th of the 12th of the [20]11th), that I think I should get out of the computer industry and write music or books for a living.

I wrote the following XPath expression to find distinct elements in an XML document.

[sourcecode lang=”xml”]
Keys/Key[@Type=’adKeyForeign’ and self::*[not(@RelatedTable = preceding-sibling::*/@RelatedTable)]]
[/sourcecode]

It works but sometimes my heart says, this ain’t for me. Don’t get me wrong, I probably love functional recursive programming better than many others (it’s a form of self abuse – ha ha)… but it’s not always that fulfilling as a life mission. None of my friends or family talk this language, I can’t really show it to anyone and talk about it. It seems pretty pointless in isolation.

Ever seen the TV show Dirty Jobs by Mike Rowe? Well… the XPath expression above is like one of those dirty jobs for programmers… the kind people don’t normally get to see. I suppose I would like to occasionally say to people, “hey, this is my dirty job.”

So why write complicated crap like XPath and XSLT? I love the fact it leverages my programming ability unlike any other language and multiplies the output of my productivity 10 or 100 fold. The smarter I am with XSLT, the higher the multiplication factor is. It becomes addictive to push myself to see how high I can multiply my skills… and hopefully, use that skill to make money.

Professional Software Lovingly Handcrafted by Zen-Masters of the Software Trade