Thursday, January 31, 2008

This was Wayne Berry's presentation about real-world crypto coding for web sites. The presentation was identical to his asp.net user group presentation. He stayed calm with 15 minutes of Digipen equipment not working and two room switches. But it was a great presentation and the level of detail and code was just right. He said he will post the presentation here at some point.

.net | Dina
Thursday, January 31, 2008 1:08:13 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Wednesday, January 30, 2008

This presentation was given by Zlatko Michailov & Asad Khan, PMs, Microsoft ADO.NET. The best thing said in the entire presentation was that if your model is well built you shouldn't have to do any group bys or joins. Drink the kool-aid, swallow the pill, enjoy that illusion in a real-world situation. Especially some piece of $%^@ database that is mission critical and the data is 10 years old, not normalized, and some one else's baby. But if you are going to dream, dream big, right?

Their blogs can be found at: http://blogs.msdn.com/esql/. E for entity. Why be normal? right?

 

 

.net | Dina
Wednesday, January 30, 2008 1:03:54 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Tuesday, January 29, 2008

Rod Paddack gave this session wearing a great geek shirt. His enthusiasm for open source was reciprocated by many in the audience. Here is the list:

Mentions during session included http://code.google.com/

What are your top tools?

 

.net | Dina
Tuesday, January 29, 2008 12:54:50 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 

Charter Communications officials believe a software error during routine maintenance caused the company to delete the contents of 14,000 customer e-mail accounts.

http://www.foxnews.com/story/0,2933,325338,00.html

I am glad today that I didn't do this and force my company to give a $50 credit to each customer.  Ouch.

{6230289B-5BEE-409e-932A-2F01FA407A92}

Tuesday, January 29, 2008 9:11:44 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Monday, January 28, 2008

From https://seattle.codecamp.us/ 

Jonathan Carter, Microsoft Developer Evangelist, gave an introductory talk about the Entity Framework which has just had a Community Preview release. It is basically a middle layer framework driven by Domain Driven Design for creating and extending objects on top of a data source. The data source presented was SQL Server but you could imagine all sorts of layers. There are two parts, the Entity Model and the framework for asp.net. A simple but nowhere complete comparison could be drawn to CodeSmith. Open Visual Studio, create a "file". You are asked for a data source and data objects to include. The framework displays an Entity Relationship diagram which you can dink with to create the objects the way they will work for the upstream code and not the downstream DB.

While the presentation was a tad buggy, the framework looks like it is going someplace cool.

The best part was the intellisense to your objects you just created via the framework as well as the underlying data. This was best represented by a URI demonstation to get at the data - similar to a web service test page. Type in your URI for an object called customer with a customerid of 23 to get the Title of the customer: http://server/page.x?customer(23)/Title/ displays the result.

 

Community Preview Download http://www.microsoft.com/downloads/info.aspx?na=47&p=3&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=e9ba57aa-2a27-4658-ad04-4380a2df836c&u=details.aspx%3ffamilyid%3dD8AE4404-8E05-41FC-94C8-C73D9E238F82%26displaylang%3den

ADO.NET Team Blog http://www.microsoft.com/downloads/info.aspx?na=40&p=1&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=d8ae4404-8e05-41fc-94c8-c73d9e238f82&u=http%3a%2f%2fblogs.msdn.com%2fadonet%2f

.net | Dina
Monday, January 28, 2008 12:22:43 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Sunday, January 27, 2008

Wayne, Rusty, Andy, and I went to code camp yesterday. The speakers were good, and there was a lot of code. I focused on the asp.net and core .net sessions. I attended two talks on Entity Framework, one on top 10 open source .net tools, one on crypography given by Wayne, and one on xUnit. By far the most interesting one was the xUnit discussion with it's dev team.

I'll give sessions reviews and related links in the following days.

 

.net | Dina
Sunday, January 27, 2008 12:27:57 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Friday, January 25, 2008

I was recently working with an RDP settings file and its myriad of settings and corresponding lines. I couldn’t find what I needed so I thought it would be nice to sort the lines. I am sure there are utilities out there that can quickly sort a bunch of text lines but like most programmers, I thought it best that I develop my own solution. So I fired up VS and created a new Windows Forms project, added a standard TextBox and Button control to my form and wired up the following OnClick event:

private void ButtonSort_Click(object sender, EventArgs e)

{

    TextBoxMain.Lines = TextBoxMain.Lines

        .OrderBy(s => s)

        .ToArray();

}

Just too simple. Man I love LINQ!

LINQ | Andy
Friday, January 25, 2008 2:01:37 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [1]  | 

Will be presenting at the Seattle Code Camp https://seattle.codecamp.us/ this Saturday.  My talk is entitled "Kick Your Hash" and I will attempt to bridge the cryptography gap between code and theory by showing SQL Server and .NET code, real life examples, and practical correct uses for Hashing.

Example 1:

SELECT HashBytes('MD5','password')

SELECT HashBytes('MD5',CONVERT(varchar(max),'password'))

SELECT HashBytes('MD5',CONVERT(nvarchar(max),'password'))

Example 2a:

ALTER PROC CheckLogin
@Login varchar(50),
@Password varchar(50),
@Valid bit OUTPUT
AS

SET NOCOUNT ON

SELECT *
FROM [User]
WHERE @Login = [User].[Login] AND [User].Hash = 
    HashBytes('MD5',CONVERT(varchar(max),[User].Prefix) + @Password)

IF (@@ROWCOUNT>0)
    SET @Valid = 1
ELSE 
    SET @Valid = 0

Example 2b:

CREATE TABLE [dbo].[User](
    [UserId] [uniqueidentifier] NOT NULL CONSTRAINT [DF_User_UserId]  DEFAULT (newid()),
    [Login] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [Hash] [varbinary](16) NOT NULL,
    [Prefix] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED 
(
    [UserId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

Example 2c:

DECLARE @Prefix uniqueidentifier
SET @Prefix = NewId()

INSERT INTO [User]
(
    [Login],
    Hash,
    Prefix )
VALUES(
    'wayne',
    HashBytes('MD5',CONVERT(varchar(max),@Prefix) + 'password'),
    @Prefix)

Example 3:

CREATE PROC ChangePassword
@Login varchar(50),
@OldPassword varchar(50),
@NewPassword varchar(50)
AS

UPDATE [User]
SET Hash = HashBytes('MD5',CONVERT(varchar(max),[User].Prefix) + @NewPassword)
WHERE @Login = [User].[Login] AND [User].Hash = 
    HashBytes('MD5',CONVERT(varchar(max),[User].Prefix) + @OldPassword)

Example 4a:

CREATE PROC AddData
@Data varbinary(max)
AS

INSERT INTO Data
(
    Data,
    Hash,
    [Size]
)
VALUES
(
    @Data,
    HashBytes('MD5',@Data),
    DATALENGTH(@Data)
)

Example 4b:

CREATE PROC FindData
@Data varbinary(max),
@Id uniqueidentifier OUTPUT
AS

DECLARE @Hash varbinary(16)
SET @Hash = HashBytes('MD5',@Data)

DECLARE @Length bigint
SET @Length = DATALENGTH(@Data)

SELECT @Id = DataId
FROM Data
WHERE @Hash = Hash AND @Length = Size
{6230289B-5BEE-409e-932A-2F01FA407A92}
 
T-SQL | Wayne
Friday, January 25, 2008 11:28:56 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Thursday, January 24, 2008

I have been adding {6230289B-5BEE-409e-932A-2F01FA407A92} at the bottom of my posts.  What posts you ask?  Well every post I am doing on the internet.  MSDN Managed Newsgroup forms, woodworking forums, and this blog are just some of the places.  Why you ask?  Well I want to be able to find all my posts that are unique to me.  It just so happens I share my name with several other people on the Internet so I wanted a unique name that was anonymous that would find only my stuff.  I will be adding to my BIOs when I write articles, and my web sites.  This way I can go to Google and search for my GUID and find everthing on the Internet that I have done.  You can do the same, just generate yourself a GUID at: http://www.guidgen.com/ and get started.

{6230289B-5BEE-409e-932A-2F01FA407A92}

 

Thursday, January 24, 2008 9:20:01 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [1]  | 
 Wednesday, January 23, 2008

I was reading this article from a http://www.digg.com link (sorry I lost the link to the article) about how to be a faster developer and at the top of the list is becoming very good at your editor.  The author pointed out that the hot keys (the ability to navigate and execute commands without using your mouse) where essential.  I agree with him, the more you have to move your mouse the less you can type and it is a real waste of time going between the mouse and the keyboard.  However, he was ranting about EMACS and of course the Windows programmer's editor of choice is Visual Studio.

My favorite hot keys right now in Visual Studio:

Ctrl K-D : To reformat the code.  Type whatever I want, not tabs, no enter. Ctrl K-D and it is formatted correctly.

Ctrl M-O : To collapse all the regions.  Finish a bug fix, Ctrl M-O to collapse, Run Unit Test, Handle Exception in Code (automatically expands) and ignore all the collapsed code.

Ctrl F : For Quick Find.  I use find so much -- just have to hot key.

Ctrl-Atl-F : For Find in Files.

Ctrl H : For Quick Replace

Ctrl-Atl H: For Replace in Files.

Home / Ctrl-Shift-End : For Selecting All.  This works in most Microsoft products.

Ctrl -Arrows : For moving by expression as compared to the arrows which move my character.  Walk the XML quickly scanning for what I want to edit.  Press the control key to highlight (while Ctrl-Arrowing), and then delete to remove that whole word.

Ctrl-J: Reactivate Intellisense.  I use this all the time, cut and paste some text into a case sensitive language like C#, Ctrl-J to find the class with the same name -- different case, and press Enter to select it from the Intellisense list.

/// : For adding comments to method and properties. Thanks Andy.

However, this one: Ctrl-Tab is awesome.  I read about it in this MSDN Blog: http://blogs.msdn.com/vbteam/archive/2008/01/09/3-did-you-know-ctrl-tab-to-navigate-windows-in-vs-lisa-feigenbaum.aspx.  It allows you to select any open window (much like Atl-Tab in Windows).

{6230289B-5BEE-409e-932A-2F01FA407A92}

Wednesday, January 23, 2008 11:19:39 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Tuesday, January 22, 2008

In C# we can have nullable types, like this:

Boolean? isValid;

Which means that isValid can be true, null, or false.  It is like a three way switch.  I use it to represent a bit field in SQL Server that can have a null value.  For example I might have this table:

CREATE TABLE Account (IsValid bit)

Which creates me a table with a bit column that can be NULL.  I usually don't like to do this -- in fact I never do, however I am working with some people that don't bother to check the NOT NULL when they use the designer so I have to deal with it in my C# code.  So I ask the table designer what NULL means in the IsValid coulmn and he tells me it means false (not valid).

So I query the database and set the result to isValid, in the C# class above.  So now I need to check to see if the account is valid.  It might seem like this would work:

if (isValid) {...}

However, that throws a compiler error, becuase you can't have Nullable type default expression.  So I have to do this:

if (isValid == true) { }

Notice that the second statement is really saying that the expresion fails if the IsValid is false or null.  This is also the same but weak:

If ((isValid!=null) && (((Boolean)isValid)==true)) { }

{6230289B-5BEE-409e-932A-2F01FA407A92}

 

C# | Wayne
Tuesday, January 22, 2008 9:18:07 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [1]  | 
 Monday, January 21, 2008

"When you program by yourself do you use source control?"

What I want to hear is that they use source control.  Source control -- even by yourself -- is an important tool that helps you backtrack out of coding tangents that fail.  Hosted on another server it is a valuable form of backup off your own box.  It also shows that the person has programmed in a shop where source control was enforced (rightfully so) and understand how it beneficial it is.

 

Monday, January 21, 2008 7:28:36 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [2]  |