Out with the old in with WordPress

After 2 years of my portfolio site, I decided to do a ‘proper’ job of it.

The old version of my site was written in .NET using the RSS feed from eblogger as my data source. Not only was the site ugly, but it also meant that I had to hand code every feature of the site.

Though I knew of WordPress, I had never bothered as it was PHP / MySql, though thanks to a colleague, Agile Guru Simon Cromarty, he showed me his blog being powered by WordPress, boom, the admin instantly sold it to me and as of today this site is now being ran by WordPress.

 

Useful JavaScript Luhn Check

For those who work with handling credit card information you have either or soon will need to carry out a luhn check, below is a useful JavaScript luhn check;

< script type = “text/javascript” >//<![CDATA[
function checkCC(s) {
var i, n, c, r, t;
r = "";
for (i = 0; i < s.length; i++) {
c = parseInt(s.charAt(i), 10);
if (c >= 0 && c <= 9) r = c + r;
}
if (r.length <= 1) return false;
t = "";
for (i = 0; i < r.length; i++) {
c = parseInt(r.charAt(i), 10);
if (i % 2 != 0) c *= 2;
t = t + c;
}
n = 0;
for (i = 0; i < t.length; i++) {
c = parseInt(t.charAt(i), 10);
n = n + c;
}
if (n != 0 && n % 10 == 0) return true;
else return false;
}
function validateForm(f) {
var s = f.value;
if (checkCC(s)) alert("OK");
else alert("Please check your card number");
return false;
}//]]></script>

I haven’t added in checking the first number/s validation, as I have found there to be an inconsistency as to what number/s are used on what card type (an example was that I was told by one bank that a Maestro card couldn’t start with 67, only Solo, but I have a Maestro card that does!)

I’ll be posting a vb.net and c# version soon, as I still can’t believe how many of you Dev’s rely completely on client side JS as your only validation method.

 

Code formatter

started this morning looking for a code formater for blogger and I found;

http://formatmysourcecode.blogspot.com/

It was nice but there were no color coding options for the code. I dug further and found the following;

http://www.manoli.net/csharpformat/

Which is great for c#, vb.net and t-sql, but it isn’t blogger friendly (didn’t generate all the CSS inline).

What I have done for this site is to use the ideal of blogger friendly code formating from http://formatmysourcecode.blogspot.com/ and merge it with http://www.manoli.net/csharpformat/.

Another problem was that whilst I had now worked out how to generate the right look and feel for .NET / SQL, I didn’t have a JavaScript formater. I found http://www.felgall.com/jsformat.htm, which is great but again I have had to combine this formater with the idea of the http://www.manoli.net/csharpformat/

So after all the messing around I have downloaded http://www.manoli.net/csharpformat/ source code and will be adding the following functionality;

  • Blogger friendly formatting
  • JS formatting
  • CSS formatting

As soon as its completed I’ll post in on my Portfolio site (http://www.carlbruiners.co.uk) for you all to download and use.