Carl Bruiners Agile / IT Development Consultant

27Oct/091

VB.NET Luhn Check

As promised here is the VB.NET luhn check. As I haven't been able to carry out any work on my formatter yet, this will remain unformatting until complete.

Public Function luhnChk(ByVal ccNo As String) As Boolean
Dim i, w, a As Integer
Dim x As String
a = 0

ccNo = ccNo.Trim()
w = 2 * (Len(ccNo) Mod 2)

For i = Len(ccNo) - 1 To 1 Step -1
x = Mid(ccNo, i, 1)
If IsNumeric(x) Then
Select Case (i Mod 2) + w
Case 0, 3
a = a + CInt(x)
Case 1, 2
x = CInt(x) * 2
If x > 9 Then
a = a + (x  10) + (x - 10)
Else
a = a + x
End If
End Select
End If
Next
a = 10 - (a Mod 10)
If a > 9 Then a = 0
Return (CStr(a) = Right(ccNo, 1))
End Function

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!) 

Tagged as: , , 1 Comment
25Oct/090

CSS Play

Some people are made equal, others aren't.

Checkout Stu Nicholls work over at CSS Play;

http://www.cssplay.co.uk

I've been using his examples for inspiration for sometime, this man truely knows how to push CSS

24Oct/090

Silverlight 3 in Sharepoint

A brilliant article on integrating Silverlight 3 content into Sharepoint.

http://karinebosch.wordpress.com/2009/07/17/integrating-silverlight-3-in-sharepoint-2007/

24Oct/090

Code formatter

I 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.

23Oct/090

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.

Tagged as: , , No Comments
22Oct/090

WSS – Don’t install Search Server Express

Do NOT install Search Server Express onto WSS, 8 hours trying to fix the WSS after uninstalling Search Server Express.

You won't encounter this issue UNTIL you try to remove Search Server Express.

After much reading I found that the following resolved my problems;

  • Run aspnet_regiis.exe -i in the directory of the .NET framework
    (Example: C:WINDOWSMicrosoft.NETFrameworkv2.0.50727)
  • Run SharePoint Products and Technologies Configuration Wizard
  • Open up your root Sharepoint web.config, Ctrl-F and type 'Microsoft.Office.Server'
  • Remove the whole line as found above
  • Save web.config
  • All should be well

* Note: The above works if you've already uninstalled Search Server Express, and at this moment in time I haven't figured out how to sucessfully uninstall Search Server Express without hitting problems.

Filed under: Misc Stuff No Comments