Archives
-
Note to="self" message="read this"
Read this on Monday:
-
re: See no ..., hear no ...
-
One up, one down
First the good news, my regex article was published on 4Guys today:
-
Redmond trip booked
Booked my trip to Redmond yesterday :-) I'd love to catch up with anyone while I'm over there... here's the details of my trip.
-
PHP at Yahoo
Here's an interesting little presentation that outlines a case for Yahoo using PHP as their development language.
-
SizeOf
using System;
using System.Reflection ;
using System.Runtime ;
namespace ConsoleTests
{
/// <summary>
/// Summary description for TestSizeOf.
/// </summary>
public class TestSizeOf
{
static void Main(string[] args)
{
Student[] students = new Student[3] ;
string[] names = new string[] {"darren", "paul", "harry"} ;
int[] ages = new int[] {18,21,32} ;
string[] descriptions = new string[] {
"A",
"This is a medium description",
"This is a slightly longer description"
} ;
for(int i = 0; i <= names.GetUpperBound(0); i++)
{
students[i] = new Student(names[i],ages[i],descriptions[i]) ;
int studentSize = students[i].GetSize() ;
Console.WriteLine("The size of {0} is {1}{2}", names[i], studentSize, Environment.NewLine ) ;
}
Console.Read() ;
}
}
public class Student
{
string name ;
int age ;
string description ;
public Student(string name, int age, string description)
{
this.name = name ;
this.age = age ;
this.description = description ;
}
public int GetSize()
{
return 24 + (4 + (name.Length * 8) + (description.Length * 8)) ;
}
}
} -
Week in review
Here's some of the really cool things that I've seen this week...
-
New look for MSDN
-
More IDE tips that you can poke a macro at...
While showing-off the previous tip to a mate I was eagerly pointed in the direction of this link:
-
VS.NET & Source Safe tip
<Tip TipAuthor="J. Ambrose Little" TipAuthorUrl="http://www.aspalliance.com/Ambrose/">
<Question>
If a file is checked out in VSS, I would like to see who has the file
checked out through Visual Studio.Net. That would save a trip back to
the VSS client to try to track the person down.
</Question>
<Answer>
There are two ways (that I know of). One is to add the source control
toolbar to your toolbars and choose the properties button, which has a
status tab, IIRC. The other is to select the file and go to
File -> Source Control -> Properties.
</Answer>
</Tip> -
70-310/70-320 Certification resources
Useful study resources for the 70-310/70-320 exam...
-
The magician's nephew
The Narnia series of books is my favourite series, and Digory Kirke is my favourite character in the series. I can relate to his character in many ways; he lives in two worlds, he constantly being tempted to do the wrong thing :-) and in the end things seem to work out well for him. Narnia is a simple story told simply and elegantly, the depth of the characters is simply amazing.
-
It's a .... VB Programmer!!!
2 newsworthy items tonight:
-
Kickstarter.net
Recently I've been trialling a product called Kickstarter [ Kickstarter website ] with a view to using it for:
- Stored Procudure generation
- Data Access Layer code generation
- Business Objects code generation
- Web Forms Creation
-
The great Right to Left assignment debate :-)
There's a conversation occuring on serveral other blogs about the validity of statements that assign to multiple variables in a right to left manner. Methinks that a few people are confusing C# with VB :-) - oh well, at least I get to show off the amazing powers of the MarkItUp component again ;) - http://www.markitup.com/Client/MarkItUpNew.asp
-
Kickstarter.net
Recently I've been trialling a product called Kickstarter [ Kickstarter website ] with a view to using it for:
- Stored Procudure generation
- Data Access Layer code generation
- Business Objects code generation
- Web Forms Creation
-
Windows development by a Web developer
Man, is it just me or what? Everytime I decide to stray from my territory (Web) into other precincts (Windows) I get lost.
-
MarkItUp.com
If you'd like to be able to post colorized Html snippets, you can use this page:
-
dotNetSnippets
If you'd like to enable Tips-n-Hints on your site try this. Save the following file as C:\Inetpub\WwwRoot\TestWidget.html Then fire up a browser and point it at http://localhost/TestWidget.html '''''''''''''''''''''' ' TestWidget.html '''''''''''''''''''''' <html> <head> <script language="javascript" src="http://www.flws.com.au/Snippets/Snippets.asp"></script> </head> <body> <a href="javascript: showTips() ;" class="SnippetHyperlink">Display Tips</a><br /> <a href="javascript: hideTips() ;" class="SnippetHyperlink">Hide Tips</a> </body> </html>
-
Blog your Messenger conversations :-)
For anyone else that likes to archive or post MSN messenger conversations to their 'blog, here's a little RegEx that I wrote to convert the messages into Html. To use it just save your message as a text file and open in VisualStudio .NET:
-
ASP Context Module - Framework
<% '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Module: MarkItUp_BeginRequest.asp ' Author: Darren Neimke ' Created: 23-May-2002 ' Purpose: Refer notes: AuthenticationArchitecture.txt ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''' 'Public Module Level Variables ''''''''''''''''''''''''''''' Public Current ' As CurrentSession Public CurrentPage ' As Page Public CurrentUser ' As User Public FormsAuthentication ' As AuthenticationProvider ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Sub BeginRequest() ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim curPage ' As Page Dim curUser ' As User Dim curSession ' As CurrentSession Set curPage = New Page Set curUser = New User Set curSession = New CurrentSession Set FormsAuthentication = New AuthenticationProvider Set CurrentUser = curUser.FromString( Session( "CURRENT_USER" ) ) Set CurrentPage = curPage Call curSession.SetEnvironment( CurrentUser, CurrentPage ) Call curSession.Authorize() Set Current = curSession End Sub ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Sub OnAuthenticate() ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Session( "CURRENT_USER" ) = CurrentUser.ToString() End Sub ' Fire the init event Call BeginRequest() ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Class CurrentSession ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public User ' As User Public Page ' As Page ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Sub SetEnvironment( user, page ) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Set Me.User = user Set Me.Page = page End Sub ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Sub Authorize() ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' If Not ( Me.Page.IsAuthenticationPage ) And ( Me.Page.RequiresAuthentication ) Then If Not Me.User.IsAuthenticated() Then 'Response.Write Me.Page.IsAuthenticationPage & "<BR>" 'Response.Write Me.Page.RequiresAuthentication & "<BR>" 'Response.Write Me.User.IsAuthenticated() & "<BR>" 'Response.Write Session( "CURRENT_USER" ) & "<BR>" 'Response.End FormsAuthentication.RedirectToLoginPage() ' TODO: Add logic to allow for role based checking End If ElseIf Me.Page.IsAuthenticationPage And Not Me.User.IsAuthenticated() Then FormsAuthentication.RedirectUrl = Request.QueryString( "RedirectUrl" ) End If End Sub End Class ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Class Page ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public RequiresAuthentication ' As Boolean Public IsAuthenticationPage ' As Boolean ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Sub Class_Initialize() ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim bRequires Dim i Dim arrSecured bRequires = False arrSecured = Split( Application( "MIU_PAGES_TO_SECURE" ), "," ) For i = 0 To UBound( arrSecured ) If Request.ServerVariables( "PATH_INFO" ) = arrSecured( i ) Then bRequires = True Exit For End If Next Me.RequiresAuthentication = bRequires If Request.ServerVariables( "PATH_INFO" ) = Application( "MIU_LOGIN_PATH" ) Then Me.IsAuthenticationPage = True Else Me.IsAuthenticationPage = False End If End Sub End Class ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Class AuthenticationProvider ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private pRedirectUrl ' As String ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Sub Logout() ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Session( "CURRENT_USER" ) = "" Response.Redirect( Application( "MIU_DEFAULT_ENTRY_PATH" ) ) End Sub ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Property Let RedirectUrl( vnt ) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' If Len( Trim( vnt ) ) > 0 Then pRedirectUrl = vnt End If End Property ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Property Get RedirectUrl() ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' If Len( Trim( pRedirectUrl ) ) > 0 Then RedirectUrl = pRedirectUrl Else RedirectUrl = Application( "MIU_DEFAULT_ENTRY_PATH" ) End If End Property ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Sub RedirectFromLoginPage() ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' If Len( Trim( Me.RedirectUrl ) ) > 0 Then Response.Redirect( Me.RedirectUrl ) End If End Sub ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Sub RedirectToLoginPage() ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Response.Redirect( Application( "MIU_LOGIN_PATH" ) & "?RedirectUrl=" & Request.ServerVariables( "URL" ) ) End Sub End Class ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Class User ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' TODO: implement as private vars with public accessors Public ID ' As Int Public Email ' As String Public Roles ' As Int() ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' construct a user instance from a userID Public Sub Init( ByVal userID ) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Me.ID = userID Me.Email = DBLookup( "[User]", "[ID]", userID, "[Email]", False ) Me.Roles = DBLookup( "[User]", "[ID]", userID, "[UserTypeID]", False ) End Sub ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Function Authenticate( sEmail, sPassword, bPersistCookie ) 'As Boolean ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' If Len( Trim( sEmail ) ) > 0 And Len( Trim( sPassword ) ) > 0 Then Dim pwd, iId, ut iId = Nz( DBLookup( "[User]", "[Email]", sEmail, "[ID]", True ) ) pwd = DBLookup( "[User]", "[ID]", iId, "[Password]", False ) ut = DBLookup( "[User]", "[ID]", iId, "[UserTypeID]", False ) If sPassword = pwd Then Dim sql sql = "UPDATE [User] Set [LastLoginDate] = Now(), CountOfLogins = (CountOfLogins+1) WHERE [ID]=" & iId Call OpenDB() conn.Execute( sql ) Call CloseDB() Me.ID = iId Me.Roles = ut Me.Email = sEmail Call OnAuthenticate() Authenticate = True Else Authenticate = False End If Else Authenticate = False End If End Function ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Function IsAuthenticated() ' As Boolean ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim authString Dim userID, userType If InStr( 1, Session( "CURRENT_USER" ), "!!" ) <> 0 Then On Error Resume Next authString = Split( Session( "CURRENT_USER" ), "!!" ) userID = Split( authString( 0 ), "=" )( 1 ) userType = Split( authString( 0 ), "=" )( 1 ) On Error Goto 0 End If If Len( Trim( userType ) ) > 0 And IsNumeric( userType ) Then IsAuthenticated = True Else IsAuthenticated = False End If End Function ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Function IsAdministrator() ' As Boolean ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' If Len( Trim( Me.Roles ) ) > 0 Then Dim dbIsAdminRole dbIsAdminRole = Trim( DBLookup( "UserType", "[ID]", Me.Roles, "[IsAdministrator]", False ) ) IsAdministrator = CBool( dbIsAdminRole ) Else IsAdministrator = False End If End Function ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Function IsInRole( sRole ) ' As Boolean ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim dbRoleID, arrRoles, bFound, i bFound = False dbRoleID = Trim( DBLookup( "UserType", "[Description]", sRole, "[ID]", True ) ) arrRoles = Split( Me.Roles, "," ) If IsNumeric( dbRoleID ) And dbRoleID > 0 Then For i = 0 To UBound( arrRoles ) If arrRoles( i ) = dbRoleID Then bFound = True Exit For End If Next End If IsInRole = bFound End Function ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Function IsInRoles( sRoles ) ' As Boolean ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim arrRoles, i, bResult arrRoles = Split( sRoles, "," ) For i = 0 To UBound( arrRoles ) bResult = IsInRole( arrRoles( i ) ) If bResult = True Then Exit For Next IsInRoles = bResult End Function ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Function ToString() ' As String() ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ToString = "Id=" & Me.ID & "!!Roles=" & Me.Roles & "!!Email=" & Me.Email & "!!" End Function ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Function FromString( sUser ) ' As User ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim authString Dim userID, userType If InStr( 1, Session( "CURRENT_USER" ), "!!" ) <> 0 Then authString = Split( Session( "CURRENT_USER" ), "!!" ) On Error Resume Next Me.ID = Split( authString( 0 ), "=" )( 1 ) Me.Roles = Split( authString( 1 ), "=" )( 1 ) Me.Email = Split( authString( 2 ), "=" )( 1 ) On Error Goto 0 End If Set FromString = Me End Function ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Sub SetCookieExpires( dDate ) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' End Sub End Class %>
-
Developer tutorials
-
Sledging
I discovered today that the term "sledging" is not widely known outside of Australia! Basically - in my own words - it's a term that means: saying things to or about an opponent that are derogatory.
-
New remoting resource
I see that Ingo Rammer [ Ingo's blog ] is creating a new weekly'ish newsletter to advise of Web Services (i.e.: Remoting) tips-n-tricks. You can go here to subscribe:
-
Bob from sysadmin
Error message:
-
Ordering Foccacias
The local shop where I buy my lunch is great - too great actually! Between the hours of 12:00pm and 1:30pm the popularity of the shop rises to the point where you, generally have an extended wait between ordering and receiving your food.
-
Pedantically speaking...
Took part in an interesting but highly pedantic discussion about the relative speeds of 4 different ways to remove a trailing comma from a string. It actually started out discussing purely the performance aspect, then drifted into elegance. Of course I came up with the least most efficacious option, but, IMHO the most elegant!! :-D
Anyways, here were the different ways that the group arrived at:
-
Re-read some unit testing tips
Followed up more on unit testing again today by turning to my trusted tome "Code Complete" [ Code Complete ] to read what it had to say on the topic of unit testing. Here are some interesting snippets taken from Chapter 25 (p.589):
-
A new Regular Expression article in the wind
I actually started putting pen-to-paper tonight for a new Regular Expression article that I've been meaning to write for some time. The goals of the article are to provide an explanation of each of the following items:
-
Windows Media Player
Cool news today, it seems like I'll get to be dev lead on a "jukebox" product for a customer that involves providing a touchscreen interface to select music stored in MP3 format. I'll use Duncan's great new article [ Coding4Fun ] as the basis of my learning. Thanks Duncan! :0)
-
Making money out of software.
Some of us started writing code recently, most of us started a while ago, and some of us started before that.
-
Dem's fighten' werds
"Standards are bullshit. XHTML is a crock. The W3C is irrelevant"
- Read Article -
NUnit rocks man - there, I said it :-)
All of the discussions on the lists ( ASPAdvice.com ) about NUnit lately finally aroused my interest so I decided to read about it; seems pretty cool. The article that I read was quite simple and well illustrated ( NUnit tutorial ). I think that I'll do some roadtests with it on my current project!
-
Tool building - datagrid with checkbox column
Spent a stack of time trying to teach myself component building tonight. I've started building a component that is derived from DataGrid and binds some additional properties.
-
A longer introduction...
Started thinking more about my WebLog today and how I might use it. This, as usual, led me to Google in search of what other people do with their 'Blogs. This led me to an interesting article titled "Becoming Part of the Blogging Community" [ Becoming Part Of The Blogging Community ]. The section at the bottom of that page titled: "Fitting in with the Community" explains what you have to do to become a good Netizen :-)
-
First post
Here's my first post on my own Web Log! Thanks to Scott for setting this up.