Plip's Weblog

Phil Winstanley - British .NET chap based in Lancashire. Enjoys tea and tech. Working for Microsoft.

October 2006 - Posts

Spectrum of Knowledge

Mike Taulty posted a great piece on the Spectrum of Richness an Reach which talks about and shows how the different technology platforms we have differ in terms of their power vs cost.

I've put together something similar for Knowledge of both users and developers.

I think HTML is the easiest for developers to use (think back to the 90's every man and his dog was writing HTML) and that the web is the most comfortable for 99% of users out there, they know and understand the web and how to use it, Windows Applications are much less comfortable to most.

Not sure it's 100% accurate but as a Web Developer it's certainly how I see it.

What do you think?

P.S. I'm loving Office 2007's drawing features.

Posted: Oct 26 2006, 05:05 PM by Plip | with 3 comment(s)
Filed under:
SQL Server 2005 Backups

This post is more for my memory than anything else but ... I've had issues restoring a SQL 2005 database from a backup today using the SQL Workbench with the following error message: -

The backup set holds a backup of a database other than the existing 'MyDatabase' database.
RESTORE DATABASE is terminating abnormally. (Microsoft SQL Server, Error: 3154)

I spoke to a good friend (Tony Rogerson) and he sent me a command to run: -

restore database MyDatabase from disk = 'C:\MyDatabaseBackup\MyDatabase.BAK' with replace

And it worked a treat!

I didn't sacrifice a chicken

So it seems god (whichever one you happen to believe in) hates me.

I do presentations at usergroups and conferences, and invariably things go wrong, but with me, they're usually so wrong that I have a heart attack just before or just after a session.

Whilst in Finland in August I was giving two sessions on Atlas security and Atlas performance, just before the session I accidentally deleted all my source code and has to recreate it from a camtasia recording I'd made and during the session the projector failed on me for a good fifteen minutes so I had to entertain the audience by using nothing more than a sock and parts of my anatomy.

Last night I was giving a talk to the VBUG .NET Usergroup in Newcastle. This time I was going to be prepared, everything would work fine, I'd rehersed my session, I had instructions for every one of my demos, I'd triple checked each demo on the train, then in my hotel, everything was working fine.

I was happy, relaxed and really looking forward to the session. Then it happened, I got to the venue, and booted up my laptop, up comes the login screen and I tap my password in and wait, then wait some more, followed by a little more waiting followed by ... the dialogue which comes up when you log onto a machine for the first time (you know the one setting up start menu, setting up preferences blah blah).

Windows (XP) has lost my profile completly, I looged in but my desktop wasn't there, my documents were not there, my code was not where I'd left it, everythign was gone.

I shat myself.

After reconfiguiring my desktop (I run with my start bar up the left), changed the font sizes, sorted out the resolutions, moved all the documents around on disk from my now "old profile" (which had 30 minutes previously been my current profile!) to my "new profile", reimporting all the settings into VS.NEt that I use (Mike Taulty very kindly shared with me his VS.NET presentation settings), recreated all my desktop shortcuts that I'd need for the demo's, gotten the system working through the projector, I was still crapping my pants a bit. This all happened in the 10 minutes before the session is due to start.

I then recalled, I'd made the buggest mistake I could have made, I'd not sacrificed a chicken.

Edit: When I got home and logged in everything was back to normal - WHAT THE £"$!@%$$£%$£$%£ !!!!!

 

This week I 'ave mostly been eating MbUnit

In the famous words of Jesse from the Fast show...

This week I 'ave mostly been eating MbUnit.

Andrew has spent several months persuading me of the virtues of MbUnit and it's finally paid off. I've moved the last of my NUnit tests over the MbUnit today.

What's sparked off this mass migration is one really simple feature that MbUnit provides that NUnit does not, the RowTest.

The RowTest allows me to pass in different arguments to the same unit test in an itterative fashion, effectivly reducing the number of tests I have to write by a factor of the variations of parameters a sequence of code could possibly have, in some cases this can be hundreds.

Here's a test I've put together for a session on unit testing in .NET and ASP.NET that I'm giving in Newcastle later this week.

[RowTest()]
[Row(0, 0, false)]
[Row(0, 1, true)]
[Row(0, -1, false)]
[Row(0, 0.1, true)]
[Row(0, -0.1, false)]
public void CheckNorthOfEquator(double Longitude, double Latitude, bool IsInNorth)
{
    OurClassLibrary.Point P = new OurClassLibrary.Point();
    P.Longitude = Longitude;
    P.Latitude = Latitude;
    bool Actual = OurClassLibrary.PositionManager.IsNorthOfEquator(P);
    Assert.AreEqual(Actual, IsInNorth);
}

The RowTest is a really slick feature and it's one I've fallen in love with.

Windows feature which kicks the crap out of OSX

I recently found a way to increase the DPI of my Windows XP laptop which runs at 1680x1050 up to 125, which has made reading the content on the screen much easier (I am getting old and my eyesight is failing me).

On XP you can increase the font size of the system fonts and control the look and feel of the whole operating system, not so on OSX.

I'm writing this post now on my Mac Mini plugged into a 21" widescreen monitor also running at 1680x1050, but the fonts are *tiny*, there's no way that I can find to increase the core system fonts in size, apparently there's a tool in the developer toolkit to let me change the DPI but come on - I need the developer toolkit to increase a font?!

Anyway, I love my Mac, but it's these little things which are irritating me, I end up having to increase the font size of my browsers which mucks up so many sites and only some sites let you do it, most frustrating. 

Posted: Oct 22 2006, 11:57 AM by Plip | with no comments
Filed under: , , , ,
Why can't people write signs properly?

I'm on a train and have just seen a sign on a warehouse wall ouside Wolverhampton which read: -

Smile you bastards, your on camera.

It was in 5 foot tall letters, I wish whomever had written it had at least realised that it's "you're" ;-)

Web 2.0 Attack Vectors

On Tuesday I'm speaking at the VBUG 2006 Conference in Reading (England).

My talk is on Atlas security, although is much more generally about AJAX security so this article is great - I actually cover 8 out of the 10 points in this article within my session.

http://www.net-security.org/article.php?id=949

Posted: Oct 15 2006, 10:47 PM by Plip | with 2 comment(s)
Filed under: , ,
Windows Live OneCare - VPN

Today I installed Windows Live OneCare and my VPN stopped working it would just hang on the "Athenticating username and password ..." section.

I found the solution to this issue here: -

http://www.windowsonecare.com/support/help.aspx?querytype=keyword&query=TROU_ICC_WITH_RAS.HTM

Just in case someone at Microsoft removes the data (would they? surely not?), here are the steps to follow: -

When you try to connect to a network or server by using a VPN connection with RAS software, the software can't make the connection.

You may have to allow a protocol for VPN to work. For example: you would have to allow the built-in GRE (General Routing Encapsulation) protocol for Microsoft VPN to function as expected. For Nortel VPN, you would allow the built-in ESP (Encapsulating Security Payload) protocol. If you are unsure of which protocol to allow, check with your VPN provider to confirm which one you should use.

To resolve this issue by using built-in protocols, follow these steps:

  1. On the left side of the Windows Live OneCare display, click View or change settings.
  2. Click the Firewall tab.
  3. Under Other settings, click Advanced Settings.
  4. Click the Ports and Protocols tab.
  5. Click to select the check box for the protocol you want to turn on.
  6. Click OK.

Thanks,

Phil.

Posted: Oct 14 2006, 07:20 PM by Plip | with 5 comment(s)
Filed under: , ,
Increase your DPI

At a usergroup meeting a few weeks back Graham and I got chatting about laptop resolutions. I have a widescreen HP nx9420 (17") which runs at 1680x1050 and Graham suggested I increase the DPI if I could.

So I went into the display properties and increased my DPI from 96 to 120 (which is 125% of the normal size).

What this basically did was increase the fonts on screen for every item which ordinarily I'd say was a bad thing, but you know what, it's really grown on me, everything feels more chunky and readable, my eyes will thank me for this even if I get RSI from the extra scrolling I'm doing.

One thing I have noticed is that many applications are not tested to run under different DPI's, Red Gate tools and Spherical Timesheet both have text rendering issues at a higher DPI which is interesting.

VS.NET copes really well with the DPI changes, in fact I'd say I'm finding using VS.NET with an increased DPI much more fun - it feels more alive.

Posted: Oct 13 2006, 10:26 AM by Plip | with 1 comment(s)
Filed under:
Migrations - they're lovely

We're not talking about swallows (African, European or otherwise) but Database Migrations that ship with Ruby on Rails.

There's a cool bit of functionality which lets you stores database schema and incrimental changes in code files as well as a framework which offers the ability to roll the database forwards or backwards through versions.

The code is really simple, here's some code which creates a Users table: -

class AddUsersTable < ActiveRecord::Migration
  def self.up
    create_table :users, :id => false do |table|
      table.column :UserId, :integer
      table.column :Username, :string
      table.column :Password, :string
      table.column :EmailAddress, :string
    end
  end
  def self.down
    drop_table :users
  end
end

So, what does this do? Well this code is stored in a file inside my migrations folder called "001_add_users_table.rb". Take note of the "001" that indicates that this file is the first inside my Migration, it's the first step to creating my schema.

Notice there's a self.down towards the bottom of the file, this is executed when the database schema is rolled backwards to version 0 (remember that file is version 1 so version 0 is the database before version 1 ran, thus we need to drop the table).

I can tell the framework to change my database to a particular version by executing the following command line: -

rake migration VERSION=1

The framework stores the current database "version number" inside the database in a special single column single row table.

So, when I run that command line the following SQL get's executed against my SQL Server.

set implicit_transactions on 
go
CREATE TABLE schema_info (version int)
go
select * from CREATE TABLE schema_info (version int)
go
CREATE TABLE schema_info (version int)
go
select * from CREATE TABLE schema_info (version int)
go
CREATE TABLE schema_info (version int)
go
select * from CREATE TABLE schema_info (version int)
go
SELECT COLUMN_NAME as ColName, COLUMN_DEFAULT as DefaultValue, 
	DATA_TYPE as ColType, IS_NULLABLE As IsNullable, 
	COL_LENGTH('schema_info', COLUMN_NAME) as Length, 
	COLUMNPROPERTY(OBJECT_ID('schema_info'), COLUMN_NAME, 'IsIdentity') as IsIdentity, 
	NUMERIC_SCALE as Scale 
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_NAME = 'schema_info'
go
SELECT TOP 1 version FROM schema_info
go
CREATE TABLE schema_info (version int)
go
select * from CREATE TABLE schema_info (version int)
go
CREATE TABLE schema_info (version int)
go
select * from CREATE TABLE schema_info (version int)
go
CREATE TABLE schema_info (version int)
go
select * from CREATE TABLE schema_info (version int)
go
SELECT TOP 1 version FROM schema_info
go
CREATE TABLE users ([UserId] int, 
			[Username] varchar(255), 
			[Password] varchar(255), 
			[EmailAddress] varchar(255)) 
go
IF @@TRANCOUNT > 0 COMMIT TRAN
go
UPDATE schema_info SET version = 1
go
IF @@TRANCOUNT > 0 COMMIT TRAN
go
SELECT @@ROWCOUNT AS AffectedRows
go
SELECT TOP 1 * FROM schema_info
go
SELECT table_name from information_schema.tables WHERE table_type = 'BASE TABLE'
go
SELECT COLUMN_NAME as ColName, COLUMN_DEFAULT as DefaultValue, 
	DATA_TYPE as ColType, IS_NULLABLE As IsNullable, 
	COL_LENGTH('users', COLUMN_NAME) as Length, 
	COLUMNPROPERTY(OBJECT_ID('users'), COLUMN_NAME, 'IsIdentity') as IsIdentity, 
	NUMERIC_SCALE as Scale 
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_NAME = 'users'
go
EXEC sp_helpindex users
go
IF @@TRANCOUNT > 0 COMMIT TRAN
go

Now, when I run the reverse command and roll the system back I run this: -

rake migration VERSION=0

Which in turn pumps the following SQL into the database: -

set implicit_transactions on 
go
CREATE TABLE schema_info (version int)
go
select * from CREATE TABLE schema_info (version int)
go
CREATE TABLE schema_info (version int)
go
select * from CREATE TABLE schema_info (version int)
go
CREATE TABLE schema_info (version int)
go
select * from CREATE TABLE schema_info (version int)
go
SELECT COLUMN_NAME as ColName, COLUMN_DEFAULT as DefaultValue, 
	DATA_TYPE as ColType, IS_NULLABLE As IsNullable, 
	COL_LENGTH('schema_info', COLUMN_NAME) as Length, 
	COLUMNPROPERTY(OBJECT_ID('schema_info'), COLUMN_NAME, 'IsIdentity') as IsIdentity, 
	NUMERIC_SCALE as Scale 
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_NAME = 'schema_info'
go
SELECT TOP 1 version FROM schema_info
go
SELECT TOP 1 version FROM schema_info
go
CREATE TABLE schema_info (version int)
go
select * from CREATE TABLE schema_info (version int)
go
CREATE TABLE schema_info (version int)
go
select * from CREATE TABLE schema_info (version int)
go
CREATE TABLE schema_info (version int)
go
select * from CREATE TABLE schema_info (version int)
go
SELECT TOP 1 version FROM schema_info
go
SELECT TOP 1 version FROM schema_info
go
SELECT TOP 1 version FROM schema_info
go
SELECT TOP 1 version FROM schema_info
go
SELECT TOP 1 version FROM schema_info
go
DROP TABLE users
go
IF @@TRANCOUNT > 0 COMMIT TRAN
go
UPDATE schema_info SET version = 0
go
IF @@TRANCOUNT > 0 COMMIT TRAN
go
SELECT @@ROWCOUNT AS AffectedRows
go
SELECT TOP 1 * FROM schema_info
go
SELECT table_name from information_schema.tables WHERE table_type = 'BASE TABLE'
go
IF @@TRANCOUNT > 0 ROLLBACK TRAN
go

Pretty cool isn't it? :-)

Well - why does this matter? Just think source control and you'll have the same.

More Posts Next page »