Profilo di RobThe Ramblings of Rob Coo...BlogElenchi Strumenti Guida
06/06/2008

THIS BLOG HAS MOVED! robzyc.spaces.live.com > cantgrokwontgrok.blogspot.com

So, I was thinking last night, following on from me previous post, I am going to migrate to Blogger and cease posting to Live Spaces.

If you are intelligent/crazy enough to be following my blog, then please update your RSS reader to: http://cantgrokwontgrok.blogspot.com.

I like the title better, definitely describes me a lot more accurately :D

Hopefully this will give me the opportunity to get more feedback from [any] followers, as well as “do more” with the blog (polls etc). This will be both interesting for me as well as possibly enhance my learning, as well as others. We are all on a journey here.

Also, as a note to Microsoft and the People on the Live Team:

Just because I am leaving Spaces, it does mean I am leaving Live. I LOVE the other things happening with Live, and I really cannot stop praising Live Writer, Live SkyDrive and especially Live Mesh (as well as the other bits going on)! Keep up the great work, I really hope Spaces comes on enough to perhaps attract people wanting “more” back to it.

See you at “Can’t Grok, Won’t Grok”!

Share:  digg it! del.icio.us furl Live Technorati Facebook

05/06/2008

Thinking of Migrating from Live Spaces to Blogger

So, looks like I am again reviewing some of the services I use against others I could be.

I have actually been contemplating leaving Live Spaces for a while. Sadly, I don’t think Spaces have moved enough in the right direction. I think I have remained is due to the excellent production on the rest of the Live Services teams (Writer, SkyDrive, Mesh etc.). However, none of these require this blog.

Put simply, I dislike the following:

  • Ad banners.
  • Anonymous comments are not allowed.
  • Email notifications of comments etc are not available.
  • Unable to choose an address I want for the blog.
  • Lack of support for custom scripts.
  • Tagging/Categorisation is extremely limited.
  • Only 1 space/blog per account.

And I do like:

  • The look, I think its nice and clean.
  • Works superbly with Live Writer.

So, watch this space, I may be migrating, need to run a few more tests to see what Blogger can do for me, but so far looking positive.

Share:  digg it! del.icio.us furl Live Technorati Facebook

04/06/2008

Privacy Online – How Much Would a “I’ll Google You” Get About You?

Even though online privacy has been a subject that everyone has known about for a long time, I still cant help but feel that with the explosion in social networking, a lot of the basic principles seem to have been lost somewhere.

By “principles” I mean:

  • Make yourself as hard to personally identify as possible.
  • People on the Internet should not be able to find where you live (unless you want them to).
  • You need to protect your friends and family as well as yourself, don’t put their information on display without permission.
  • In short, people should only ever know what you would be happy with someone shouting from a top of the building, with everyone stood around it, and pointing at you.
  • Not sharing information from one source with another (e.g. automatic “I’ll email your friends for you, just give me your ID and password for [service]”.

Some of the Problems

There have been numerous issues with private information being found on the Internet about people ranging from silly pranks being pulled to people losing their money, jobs, or even their lives. People often only think about the former and never the consequences of the latter. It’s serious stuff.

Some obvious examples:

  • People are being fired for finding “inappropriate” items on Facebook (or whatever) of their staff members.
  • Obvious harassment and threatening behaviour towards individuals.
  • Children and Adults alike (not only children are at risk) being stalked, or worse.
  • Personally identifiable information being used to access other information (bank details etc.).
  • There are tons of website’s that regurgitate information on other sites, so you data can be inadvertently copied from one site to another, without you knowing about it.

As said before, a large part of this is due to the fact that social networking has exploded. With MySpace, Facebook, Twitter, and so on. There is literally MILLIONS of people posting huge amount of data about themselves on various servers around the world.

I, like a lot of others think social networking is great. I am now back in touch with people from school, I never forget friends birthdays, its nice to see us all growing up and doing our things and being happy.

What people fail to realise is that, left unchecked, ANYONE can see this, and this can be dangerous.

Some Solutions

So? What can we do to help get some sort of control over what the Internet can find out about ourselves? There are several things:

  1. ALWAYS, ALWAYS, ALWAYS check the privacy settings for ANY sites where you put information about yourself in any way, shape or form. If you cannot find them, check the help, if its not in the help, contact them, if they do not help you, then you may well want to consider not trusting them with your data!
  2. If your unsure, don’t. If you ever think “should I put this on here” then you are probably best not to.
  3. As mentioned above, never enter your password and ID for one service into another, unless you trust the application vendor. 9/10 if I see anything like that, I either get out or skip it. Remember, just because they may not use your information directly, they could sell it on.
  4. If you don’t want your employer to see photos of you throwing up in a gutter on Saturday night or doing inappropriate things with the girl next door then don’t give them access to such material. If you want them on your contacts on Facebook (or whatever) then put them on a limited profile, or not add them at all. There are other networking sites designed for work such as LinkedIn.

The Biggest Winner (IMO)

I am all for rolling your sleeves up and having a go. So, check yourself out. The first place most searches start is Google. So, go to Google, type in your name, what comes up? Can you find information about yourself? Are you happy with it being there? If not, change it, go to the website, log in and check the privacy settings!

Vary your searches, name? Phone number? Email address? As soon as you can see where your information is being leaked from, you can fix it.

Remember, Google also offers Google Alerts which is a great way to keep on top of it. I have several Google Alerts trawling the net for me to check for my personal information. As of yet, there is nothing on the Internet about me that I would either be unhappy about you knowing, or wouldn’t tell you myself.

Exactly how it should be.

Share:  digg it! del.icio.us furl Live Technorati Facebook

03/06/2008

Great GTD Post on RememberTheMilk (Thanks to Doug Ireton)

I have recently started trying to invest a little more time in GTD (Getting Things Done). Part of this investment has also meant me signing up to RememberTheMilk (RTM) which is a great, simple-yet-effective “ToDo” list site.image

Prior to reading this post from Doug Ireton (which RTM posted on their blog) I hadn’t really customised RTM a great deal. This was perhaps a mixture of me not really knowing what I am doing with GTD and lack of time to “play” (expect it was more the former).

I found the article clear, concise and damn useful! I spent a good chunk of this morning getting all my work, personal and study items nicely organised within RTM. I feel I perhaps have a little way to go before getting the system refined to my taste, but it’s certainly a hell of a lot closer than it was!

It sounds silly but I feel much more confident in the system and can happily “forget” about items and concentrate on actually getting the things done I am supposed to be working on.

I will continue to try and let you know how I get on with GTD and any other bits of productivity-boosting bits of information I come across.

Links:
RememberTheMilk
Doug Ireton’s Post on RememberTheMilk
GettingThingsDone on WikiPedia

Share:  digg it! del.icio.us furl Live Technorati Facebook

Its Been a While… Study, Exams, Thoughts and WoW

Hi All!

Sorry its been so long since my last post, been crazy busy of late!

Here’s a run down of the things that have been chewing up my time:

  • New project at work in ASP.NET, which is all new to me! So its been hard on the brain (trying to remain productive yet needed to consume a lot of info to *try* and make sure I do things right.
  • Study study study. Same old. Was studying extra hard since wanted to sit the 70-316 exam.
  • General thoughts (both personal and professional) that needed ironing out in my mind.
  • World of Warcraft is far too addictive, making my allotted “chill time” overrun. However, I think this is probably a good thing as I have been kinda needing it lately.

Good news is, the study and the work seems to be paying off!

I passed the 70-316 exam with a score of 906 (700 was pass mark)! Making me a happy geek! I am now studying towards 70-315 which coincides nicely with my current work project(s). This is one of the main reasons I was pushing hard for 70-316 since I desperately wanted to get into Web.

I believe thought and reflection is always good for the soul, so that always deserves some time :)

World of Warcraft is addictive! But I have started to limit my time somewhat more on there!

Expect more blog posts to follow. Good to be back on top of things :)

Share:  digg it! del.icio.us furl Live Technorati Facebook

06/05/2008

The Ultimate Pro-Vista Argument EVER!

While the usual thoughts were flying around between us geek's on Twitter, Windows Vista came up. Basically the general theme was "we don't know why the haters hate it so much, we have no problems and enjoy working with it".

I replied to a tweet from Jeff Atwood @ CodingHorror with this, which did make me chuckle to myself after sending:

image

Top that haters! :D

Share:  digg it! del.icio.us furl Live Technorati Facebook

02/05/2008

YouTube Upgrade Quality of Videos

Got a Tweet from Loic Le Meur saying that YouTube have upgraded the quality of their videos/videio player. Great stuff, there is nothing worse than watching an awesome video of big squares flying around.

Here are some screen shots from Loic's HQ video posted, in Low (on the left) and High (on the right) quality for comparison (click to enlarge):

image image

Great improvement! You can switch to High Quality (where available) by clicking "View in High Quality" under the player.

Links:
YouTube
Loic Le Meur's Blog
Loic Le Meur's Coverage of the World Economic Forum

Share:  digg it! del.icio.us furl Live Technorati Facebook

James Buck - Demonstrating the Power of the "Tweet"

This story came through in the Twitter newsletter:

Bucking The System

Last weekend CNN lead with a big story about James Buck, a graduate student in journalism from the University of California-Berkeley who was arrested last month in Mahalla, Egypt while covering an anti-government protest. Thinking quickly, James was able to send a one-word Twitter update: "Arrested." His followers in Egypt and back in the US reacted by contacting the university and the consulate on his behalf. Before long, James was updating Twitter with another one-word message, "Free."

The CNN coverage can be found here: http://tinyurl.com/4b4hsg

I know a lot of people still think Twitter is lame, and I guess there is a part of me that is yet to be convinced, but I think this is an awesome display of the power of short, sharp updates.

I think the main part of my problem is that I don't have enough UK/EU contacts on my friends list. Most of my contacts are in the US, and due to obvious time zone differences, we often miss a lot of what each other have to say.

So, if you're a UK/EU geek and you fancy another geek to bounce ideas etc. off, feel free to tweet me at http://twitter.com/robzyc.

Links:
CNN Coverage on James Buck "Freedom Tweet" Story
My Twitter Address

Share:  digg it! del.icio.us furl Live Technorati Facebook

01/05/2008

MSDN RampUp - Helping Developers on Older/Other Technologies to.. well "Ramp Up" to .NET

This came through on the MSDN Flash newsletter. Microsoft have launched a section on MSDN called "RampUp". Offering materials to help assist developers/aspiring developers that are used to working with VS 2003/2005 or VB6 to get up to speed on .NET 2.0. It also has a track/route for Java developers  for those that are interested.image

Each route offers insights into fundamental areas of .NET 2.0, geared towards your previous knowledge, there is also access to free Microsoft E-Learning Courses, which is pretty cool. I will definitely look this over since I am studying for the (now outdated) MCAD certification, so there may be a few things I can learn in here to help with work.

If there are any Java developers reading this that want to get all pissy and suggest that ".NET from Java would be ramping down lol ha :P" then don't, its a free offering from Microsoft, if you want it, take it, if not, shut up and keep developing your Java applications (as you may have noticed, I am a geek who gets real tired of geek fanaticism).

I hope you find some of the content useful!

Links:
RampUp Website
MSDN Flash

Share:  digg it! del.icio.us furl Live Technorati Facebook

30/04/2008

Great Not-So-WTF-y Post on TDWTF

I read "The Daily WTF" religiously. I love it, it provides both laughs and plenty of examples of how not to code. For a newbie like me, I find these sorts of real-world examples of crappy coding, it may not necessarily show me what to do, but if you are shown enough of what not to do, then you will tend to end up somewhere on or near the right trail. We have this as children all the time, we soon learn after being sent to our room enough times that colouring in the wall with crayons is not acceptable. I can now proudly say at age 23, I have shaken this habit as I know it is wrong, and you don't need to send me to my room. :)

This morning however, it wasn't really a WTF post, but a good serious post on turnover in the IT industry, and I strongly recommend reading it. I have mentioned this to a couple of friends in the past, one thing I noticed while reading some of my favourite blog posters employment history (where available) I noticed a lot of them changed jobs frequently. Initially, I didn't know how to view this, but I came to the conclusion that its very easy for aspiring developers to become restless. 99.99% of the time, us geeks are consuming huge amounts of information, learning lots, and forever wanting to learn more, there just does not seem to be enough hours in the day. The problem with this, is that the rate of business change is far slower than that. Which simply means that with these energetic developers that are keen to "keep the pace up" they can quickly find themselves wanting more from "9-5". Is this a bad thing?

I do not run a software house or manage a software team, but my thoughts would say that even staff turnover would be bad (sorry to lose a good member of the team, pain in the ass of recruiting) I would much rather have a highly motivated team, than a team that feels they are stagnating. This is not necessarily through fault of the business, but simply, the individual outgrowing the business.

We always here it, but so few truly believe it. Embrace change!

Links:
"Up or Out: Solving the IT Turnover Crisis" Post on TDWTF

Share:  digg it! del.icio.us furl Live Technorati Facebook

29/04/2008

This Geek Becomes a "Real" Geek and Gets on "World of Warcraft" (WoW)

I have finally done it. Some of the people who's blog I watch play World of Warcraft (Rob Conery springs to mind). I decided to give the study a bit of a break this weekend, and had nothing much else on. I got bored and watched a South Park episode, and it happened to be the one all about World of Warcraft ("Make Love, Not Warcraft"). And I thought "that game does look pretty cool" (being the geek I am, I do remember the good old days playing RPG's for ridiculous amounts of time). So I thought I would check it out :)

Blizzard offer a 10-day free trial (with restrictions) after a night of sitting there for hours playing drinking beer I managed to max those out, so my account is currently being upgraded from Trial to Full :)

<geek>My little n00b Hunter kicks ass :) He's like level 21 now, I have a pet cat thing in my "stable" called Leo and currently training a pet wolf called Fido. I was training in tailoring and enchanting, but that was kinda pissing me off because it was taking so long to skill up on the enchanting. So I dropped both those (with tailoring at 150!) and re-skilled in leatherworking and skinning. They compliment each other quite well, levelling up much more quickly (too quickly TBH - I am starting to need to skin animals above my level) and making more money from selling my awesome leather goods :)

Now, I know you can only find me on my server, but I forgot what that is, and apparantly I have no way of finding out from my account page (which is kinda silly) so I will update this post once I home to say where you can find me :) What ever server I am on, I am currently tearing it up in "Ashenvale Forest" with "Astranarr" being my current home.</geek>

On a side note, WoW is where the famous "Leeroy" came about from (if you have never seen it, WATCH IT!). Leading to things such as this Lolcat :)

Links:
World of Warcraft
World of Warcraft Europe
Trial Account Restrictions
Leeroy Jenkins
Leeroy Lolcat
Rob Conery's Blog

Share:  digg it! del.icio.us furl Live Technorati Facebook

28/04/2008

Vista Speech Recognition Macros CTP Released

This has been sat in my Inbox for a while as I have yet to play with it, but I thought I should at least do my bit to spread the word, this could be an exciting bit of technology depending on how well it works!

Microsoft released the Community Technology Preview (CTP) for Windows Speech Recognition Macros Tool (WSR Macros) on 23/04 (or 04/23 for across the pond!). You can download the CTP from here.

I really like the Speech Recognition feature of Vista, contrary to popular belief, it does seem to work well, and I have a cheap crappy headset. I know Scott Hanselman uses speech recognition (mentioned here in his post on his new home) and he reports fantastic detection rates.

With macros to perform multiple functions on key words/phrases, the possibilities are endless! Awesome!

Note: This is obviously only for Windows Vista!

Links:
WSR Macros Download
Scott Hanselman's Blog
Vista Speech Recognition Overview

Share:  digg it! del.icio.us furl Live Technorati Facebook

Windows Live FolderShare 14.0.1331.0415 Released - Changes!? Hell if I Know!

So, when signing on to my machine at home over the weekend, and of course my work machine this morning. FolderShare automatically loads and I get a little box pop up telling me that it is unable to sign in because I am running an old version, which needs to be updated.

So I figure "cool" I will update, I know normally these sorts of releases are security-critical, to stem people logging in when a known issue is located. I thought we'll soon find out once its installed.

I go ahead and install the new version (14.0.1331.0415) and wait for the release notes to pop up.. Nothing happens.. "Hmm that's odd" so I begin clicking around to see if I can find a document, web site, anything. And nothing. Zip. Nada.

So I Google "foldershare 14.0.1331.0415 "release notes"" and I have a single hit. One single hit, which takes me to a blog of some dude called Blake Handler, his blog looks interesting so I also added it to Google Reader, great. The post Google found had a link to the FolderShare team's blog, which, incidentally I never had on Google Reader, because I had never been told about it. And the development teams very own blog was almost as useful as a Google search with no real results. Not Much From the Horses Mouth...

Do you think releasing a new version with no actual release notes is acceptable?

Links:
Blake Handler's Blog
A "I'm Feeling Lucky Search" That Returns 'The One and Only' Actual Result
FolderShare Site
FolderShare Team Blog

PS: On a side note, "Nada" wasn't picked up by the spell checking in Live Writer (which I love BTW), so I Google'd that.. Interesting results! And by "nada" I do mean "nothing" :)

Share:  digg it! del.icio.us furl Live Technorati Facebook

22/04/2008

Finally The Truth About "using" and Dispose()

The Problem

During the good chat with some fellow students last night, the top of whether or not "using" should be used over an explicit Dispose() method call when using objects like Graphics came up.

Now, this one has been bugging me for some time, and I have never actually sat down to investigate it, so I thought I should. I have been told on several occasions that I should use "using", but when questioning why, I get no real answer that makes any sense. Seems like a classic "every knows the best practice but doesn't understand the practice or why its best" scenario!

So, I made some very small code samples, one using "using" the other using Dispose(). Here are the samples FYI:

"using" Code

   1: private void Form1_Load(object sender, EventArgs e)
   2: {
   3:     using (Graphics g = Graphics.FromHwnd(this.Handle))
   4:     {
   5:         MessageBox.Show("this is between the graphics instantiation and disposal");
   6:     }
   7: }

Dispose() Code

   1: private void Form1_Load(object sender, EventArgs e)
   2: {
   3:     Graphics g = Graphics.FromHwnd(this.Handle);
   4:     MessageBox.Show("this is between the graphics instantiation and disposal");
   5:     g.Dispose();
   6: }

As you can see, nothing fancy! And here are the results (intermediate language - "IL") courtesy of ILDASM:

"using" IL

   1: .method private hidebysig instance void  Form1_Load(object sender,
   2:                                                     class [mscorlib]System.EventArgs e) cil managed
   3: {
   4:   // Code size       36 (0x24)
   5:   .maxstack  1
   6:   .locals init ([0] class [System.Drawing]System.Drawing.Graphics g)
   7:   IL_0000:  ldarg.0
   8:   IL_0001:  call       instance native int [System.Windows.Forms]System.Windows.Forms.Control::get_Handle()
   9:   IL_0006:  call       class [System.Drawing]System.Drawing.Graphics [System.Drawing]System.Drawing.Graphics::FromHwnd(native int)
  10:   IL_000b:  stloc.0
  11:   .try
  12:   {
  13:     IL_000c:  ldstr      "this is between the graphics instantiation and dis"
  14:     + "posal"
  15:     IL_0011:  call       valuetype [System.Windows.Forms]System.Windows.Forms.DialogResult [System.Windows.Forms]System.Windows.Forms.MessageBox::Show(string)
  16:     IL_0016:  pop
  17:     IL_0017:  leave.s    IL_0023
  18:   }  // end .try
  19:   finally
  20:   {
  21:     IL_0019:  ldloc.0
  22:     IL_001a:  brfalse.s  IL_0022
  23:     IL_001c:  ldloc.0
  24:     IL_001d:  callvirt   instance void [mscorlib]System.IDisposable::Dispose()
  25:     IL_0022:  endfinally
  26:   }  // end handler
  27:   IL_0023:  ret
  28: } // end of method Form1::Form1_Load

Dispose() IL

   1: .method private hidebysig instance void  Form1_Load(object sender,
   2:                                                     class [mscorlib]System.EventArgs e) cil managed
   3: {
   4:   // Code size       30 (0x1e)
   5:   .maxstack  1
   6:   .locals init ([0] class [System.Drawing]System.Drawing.Graphics g)
   7:   IL_0000:  ldarg.0
   8:   IL_0001:  call       instance native int [System.Windows.Forms]System.Windows.Forms.Control::get_Handle()
   9:   IL_0006:  call       class [System.Drawing]System.Drawing.Graphics [System.Drawing]System.Drawing.Graphics::FromHwnd(native int)
  10:   IL_000b:  stloc.0
  11:   IL_000c:  ldstr      "this is between the graphics instantiation and dis"
  12:   + "posal"
  13:   IL_0011:  call       valuetype [System.Windows.Forms]System.Windows.Forms.DialogResult [System.Windows.Forms]System.Windows.Forms.MessageBox::Show(string)
  14:   IL_0016:  pop
  15:   IL_0017:  ldloc.0
  16:   IL_0018:  callvirt   instance void [System.Drawing]System.Drawing.Graphics::Dispose()
  17:   IL_001d:  ret
  18: } // end of method Form1::Form1_Load

Conclusion

So, as you can see, the "using" method wraps the code inside the scope of the statement within a "try" block of a "try/finally", placing the Dispose() call in the finally, meaning it will always get executed even if an Exception is thrown. However, using the explicit Dispose() method, if an Exception is thrown, then it will not get disposed of, meaning it could be sat on the heap for a few milliseconds or even a few minutes, not good!

I guess this is why MSDN refers to the "using" statement as the "convenient syntax for correct use of IDisposable objects".

I believe the VB developers out there do not have an equivalent available, so make sure you are wrapping all of your disposable objects calls in try/finally blocks!

Update: I have been told that VB.NET 2.0 does actually have a "using" statement as well, which looks surprisingly like the C# syntax! http://msdn.microsoft.com/en-us/library/htd05whh.aspx

Share:  digg it! del.icio.us furl Live Technorati Facebook

13/04/2008

Vista Problem - Debugging "[Application] has stopped working"

Well, it was bound to happen, and it finally has! I have found something I genuinely do not like in Vista.

While working on some code while studying Code Access Security (CAS). CAS basically allows you/your admin to control what resources .NET code has access to when running. This can be Dialog boxes, the Registry, Printing, Windows Services, Data Access, whatever, it seems pretty complete.

The idea behind the exercise that I was doing was to demo "Imperative" and "Declarative" CAS. "Imperative" checks the permissions before loading the assembly/code, "Declarative" checks the permissions at run-time. So, I create a simple application that will present a FileDialog box to the user prompting to select a file. Nothing flashy. The idea is that initially the application runs OK, I then configure the CLR to restrict access to FileDialog's for the application, then the application should throw an Exception saying "I can't do that".image

In XP, the code works exactly as expected, you get a nice dialog box with a big fat red "X" telling you there is a problem. However, in Vista, you do not. You get the ever-so-helpful "[Application] has stopped working" error message (shown to the right):

This is not good, because this means that if an exception occurs outside of my development machine, the user has no information to report back to me! Now, if I click the "Debug" button, it takes me to Visual Studio and gives me the full exception details that I need to know in order to fix it.image

I am unsure as to what happens if there is no debugger available on the machine, so I thought I would dig around in the "Problem Reports and Solutions" centre. So I located the crash reports and checked the details:

As you can see from the screen shot, not a lot of information is provided!

So I thought I would check out the settings for "Problem Reports and Solutions", and looking around, all I can see is how to disable the automatic submission, nothing suggesting a way of getting back to the old error dialog in XP. Is was ugly, but informative!image

Even disabling the feature all together just creates a simple dialog asking to close or debug!

Does anyone know if this is only occurring because I have Visual Studio installed? I cannot test what will happen without because I only have one Vista machine!

 

Share:  digg it! del.icio.us furl Live Technorati Facebook

06/04/2008

Vista "Unidentified Network" Issue - Revisited! [TOTALLY RESOLVED NOW!]

Well, I am not sure if you guys found my previous post on this, here's some [really] quick history.

Brand new PC, Had for about three days, all working fine, one morning, no Internet, Vista Network and Sharing Centre is telling me I am on an "Unidentified Network". I troubleshoot as much as I can, to no avail. I contact the PC vendor, their tech support is also stumped. I send the PC Vista Unidentified Networkback, and await a  replacement since we both write it off as a hardware failure.

So, yesterday my new PC arrives! I get it set up, everything is running great, I leave it on when I go to bed to allow the drive to defrag (since I had been putting lots of software on etc.). I wake up in the morning, come to my desk, wake the computer up and BAM! "Unidentified Network". I said something that sounded very much like "You gotta be hitting me", I couldn't believe it.

This time was different though, I had a lead :)

So, I get the name and model of my motherboard, its an "Asus P5N32 SLI". So I google "Asus P5N32" LAN Sleep Vista "Unidentified Network". To get some interesting results..

Looks like this motherboard does not like going to sleep. Tried resetting and going into safe mode, disabling the onboard LAN and re-enabling, all to no avail.

I then came across this site - and I came across the best tech support ever - "just pull the plug out". So I did :) Plugged it back in, Vista told me off for not shutting down, back into my desktop, back on the Internet. Problem solved! I repeat: just pull the plug out, while the computer is switched on and running. DO NOT push the power button as it is likely to put the computer to sleep again.

I will play with the settings to see if I can get the computer to sleep without destroying the onboard LAN, but in the mean time, I will be getting on to the vendor to get them to send me a NIC.

I hope this helps you guys. Fun fun fun!

Share:  digg it! del.icio.us furl Live Technorati Facebook

05/04/2008

Visual Studio Code Snippets - Part 2 - Creating Code Snippets

Following on from my previous post on code snippets, here's instalment two! In this part, I want to guide you through creating your own basic code snippets, in part three, we will cover a few "advanced" features of code snippets.

To avoid any confusion, I will demo everything in Visual Studio 2005 since 2008 has a few features that may take us away from what we are doing here.

Creating a Code Snippet

Snippets are basically just XML files that contain some code and metadata. As covered in the introductory post, the code is inserted when you type the shortcut into Visual Studio. The XML files are then stored in "My Code Snippets" (or another folder of your choosing) for use by the IDE. There are a number of ways to create these XML files, and I will talk you through a couple of them.

Good Ol' Fashioned Text Editorimage

Obviously, XML is plain text and can be edited in Notepad, Notepad2 (or your text editor of choosing). I like to use Notepad2 for my basic text editing, and here is a screen shot of my "ToDo" code snippet  within Notepad2:

As you can see, it looks pretty straightforward. I strongly recommend that if you are going to create code snippets in this way, then you copy and paste and existing one and edit that. This makes sure you don't miss any details, and its obvious "what does what". This is especially useful if you are new to code snippets.

Snippyimage

While using a text editor is fine, I find that when you are creating a lot of these, or trying to maintain them, then you start to get fed up with it. So I began searching the Internet for a code snippet editor. A Google returns a lot of results and I tried several until I found Snippy. Snippy is a lightweight, simple tool (now found on CodePlex). The screen shot to the right is the same "ToDo" code snippet in Snippy:

So, I found Snippy and stuck with it, I didn't want anything fancy, just something to make my life easier, so lets go through creating a code snippet in Snippy!

Walkthrough

NOTE: In the following scenario, I know I could use generic events etc. but I have opted for the explicit declarations so the code is clear to anyone unfamiliar with generics.

OK, let's outline the scenario:

I don't know about you, but I create utility methods to raise my Events, since you need to check that the Event is not null, as well as possibly allowing the Event to be raised by subclasses of a superclass, such as the following:

   1: public delegate void MyEventHandler();
   2: public event MyEventHandler MyEvent;
   3:  
   4: // event can only be raised by this class.
   5: void RaiseMyEvent()
   6: {
   7:     if (MyEvent != null)
   8:     {
   9:         MyEvent();
  10:     }
  11: }
  12:  
  13: void Foo()
  14: {
  15:     // ... some stuff
  16:     RaiseMyEvent();
  17: }
  18:  
  19: public delegate void MyEventHandler2(EventArgs e);
  20: public event MyEventHandler2 MyEvent2;
  21:  
  22: // this event can be raised by this class, and subclasses.
  23: protected void RaiseMyEvent2(EventArgs e)
  24: {
  25:     if (MyEvent2 != null)
  26:     {
  27:         MyEvent2(e);
  28:     }
  29: }
  30:  
  31: void Bar()
  32: {
  33:     // some other stuff...
  34:     RaiseMyEvent2(new EventArgs());
  35: }

So as you can see, the code is pretty simplistic, and repetitive. This is an ideal example of when a code snippet would be useful.

Creating the Code Snippet in Snippy

So, lets make this into a code snippet! Fire up Snippy and you will be presented with a blank form. Enter the following info into the fields provided. These fields are pretty self-explanatory, but "Shortcut" deserves a special mention, this is the shortcut that you type in Visual Studio, so keep it short and understandable:

Title: RaiseEvent Wrapper
Shortcut: re
Author: Your Name (obviously replacing with your own name!)
Description: Creates a wrapper method for raising an event. The method is marked as protected, allowing subclasses to raise the event. (or whatever you feel is appropriate)

Ignore the "namespaces" section, this doesn't seem to do anything (yet).

Literals and Objects

The next section is the "Literals & Objects" section. So "what are these?" you ask. Well, in a code snippet you have replaceable values that you can tab through, as described in Part 1. Literals & Objects are these replaceable values, but they are each intended for different meanings.

Literals are should be things like text and values that exist within the code snippet and may be used after. So things like variable names, connection string etc. should be defined as Literals.

Objects are elements that are normally defined outside of the code snippet, such as Forms, controls. Object references require that the type is specified.

NOTE: Snippy makes no differentiation between Literals and Objects and treats them equally (i.e. no type specification. I have suffered no negative side-effects of just defining everything as "Literal" although of I have yet to investigate this to see the difference between the two (added to ToDo!).

I often find that it is easier to complete this section after writing the code, so lets go ahead and put the code in first.

The Code

Paste in the following base code taken from the above sample into the big text box in the "Code" section:

   1: protected void RaiseMyEvent2(EventArgs e)
   2: {
   3:     if (MyEvent2 != null)
   4:     {
   5:         MyEvent2(e);
   6:     }
   7: }

OK, first off, we need to identify what elements of the code are going to change when we use it, from the RaiseEvent code, we will need to change:

  • The method name to "RaiseEventName", where "EventName" is the name of the event we are raising.
  • "EventArgs" to the type name of the EventArgs that we are passing.
  • "MyEvent2" (in both parts of  the "if" statement to the Event name.

So, we essentially need two pieces of information, the event name, and the EventArgs type. It would also be useful if the "EventArgs" type defaulted to "EventArgs" since all classes should derive from this.

So we know what we need to replace, so before we need to set the placeholders within the code that will later be replaced by the customised values. You do this by adding an ID to the code, surrounded in dollar symbols ($). As with code, name your values appropriately. We will call our placeholder ID's "$name$" and "$argstype$". Edit the code in the "Code" TextBox to:

   1: protected void Raise$name$($argstype$ e)
   2: {
   3:     if ($name$ != null)
   4:     {
   5:         $name$(e);
   6:     }
   7: }

As you can see, its pretty straightforward what is going on here, the placeholders defined will be replaced with the values we enter when using the code snippet in the IDE.

Once the code has been entered, change the "Language" drop down list to whatever language the code is in. This is important because Visual Studio will only allow you to use C# code snippets in C# source, C++ snippets in C++ source and so on.

Now we need to go back to our Literals and Objects and define the Literals that we are going to be replacing.

Literals Revisited

Click the "Add" button to add a Literal, we will start with the Event Name.

Enter the following into the fields provided and click "OK":

ID: name
ToolTip: Enter the name of the Event, as declared in "public event ..."
Default Value: EventName
Function: [leave blank]
Declaration Type: Select "Literal" from the drop-down list.
Ensure "Editable" is checked.

This tells the code snippet (or the IDE) that when creating the code snippet, any elements in the code block defined as "$name" will be replaced by what we enter. In Visual Studio, the text entered for ToolTip will be displayed, and it will default to "EventName". The "Editable" flag indicates that we want to be able to tab through it and change it.

That said, lets go ahead and define the Literal for the "argstype" element.

ID: argstype
ToolTip: The Type name for the EventArgs class being used for this Event.
Default Value: EventArgs
Function: [leave blank]
Declaration Type: Select "Literal" from the drop-down list.
Ensure "Editable" is checked.

OK, that's it! We are done, lets go ahead and save the snippet!

Saving the Snippet

Click File > Save As. Then navigate to where you want to save the code snippets, I recommend you save them in My Documents > Visual Studio 2005 (or 2008) > Code Snippets > [Language] > My Code Snippets. As this folder is automatically monitored by the IDE for code snippets. Lets go ahead and name the file "RaiseEvent Wrapper Method".

Once saved, we can close Snippy and return to the Visual Studio IDE.

Using the Snippet

Simply go to the point in the code where you want to insert the code snippet and enter the shortcut and press TAB twice, in this example, the shortcut was "re", and here are the results:

image

image 

image

Excellent! As you can see, we can then type over the "EventName" with our own event name, and TAB to and replace the EventArgs type definition (if required). This is an excellent example of not only boosting productivity for mundane code, but also enforcing naming conventions by using and adhering to templates.

Points to Note:

  • Notice how the IDE only allows one "tabbable" placeholder and automatically updates the other references.
  • If you duplicate shortcuts, Visual Studio will prompt you to select the appropriate shortcut (nice to see someone was thinking ahead!). This is great if you want to set up similar code blocks but keep the number of shortcuts to remember down (for example, another RaiseEvent block that takes no event args can share the "re" shortcut).

Summary

So in this post we:

  • Looked at creating basic snippets to use within Visual Studio.
  • Created a basic code snippet that creates a method to act as a wrapper for RaiseEvent calls.
  • Then enabled us to customise the code block by defining our own Event name and EventArgs type.
  • Looked at some of the key points when using code snippets, such as duplication of shortcuts and the number of tabbable placeholders.

In the next instalments of this series, we will look at some more advanced code snippets such as using functions and creating larger code blocks.

I hope you found this post useful and as always, if you have any questions/comments, then please feel free to comment below!



Share:  digg it! del.icio.us furl Live Technorati Facebook

01/04/2008

Visual Studio Code Snippets - Part 1 - Using Code Snippets

I recently read this blog post from Peter Lanoie, a great guy who I met through p2p.wrox.com about Visual Studio code snippets, it really got me thinking that I should post my own experiences to try and get more people into using them, and perhaps sharing their own snippets.

A Code What?

Not sure what a code snippet is? Well, a code snippet is simply some code that can be inserted into Visual Studio by typing a shortcut. These are designed to be time savers, as well as provide the added benefits of consistency of coding standards and style.

For example, lets take the most common, as mentioned in Peter's post, the property.

Whenever we write classes we need to define fields and properties to enable the outside world (code?) to access it. We can literally do hundreds of these over the course of a project. So it quickly becomes very annoying creating them. Situations like this are the ideal scenarios where a code snippet can save A LOT of time.

OK, Sounds Good, How Do I Use It?

Inserting a code snippet is easy, thanks to Intellisense. As I said before, each code snippet can be assigned a shortcut, you simply type in this shortcut into your code, and Intellisense will pop up and let you know that you can insert a snippet, see the image, here I am inserting the 'prop' (Property) code snippet:

image

Now, you are probably asking, "fine, I see the 'prop' and the nice Intellisense description, but where's my code?!" Good question, once the item code snippet is highlighted in Intellisense, you simply press TAB twice to insert it, you then get the following:

image

But I Don't Want an 'int' and I Don't Want It Called "MyProperty"!

That's fine, they are just the defaults! As you may have noticed, the 'int' and 'MyProperty' are highlighted, this means that you can TAB through them and replace their text. In my example, I want a string called 'Name', so I:

  • Type 'pro' (Intellisense picks it up the 'prop' as the closest match).
  • I press TAB twice. The code is inserted.
  • I type 'string' and the 'int' is replaced.
  • I press TAB again and the cursor moves to 'My'Property' and selects it.
  • I type 'Name' and 'MyProperty' is replaced.

IMPORTANT NOTE: I am using Visual Studio 2008 for this, which has automatic properties (which is what Peter's post was discussing), note, then you are using 2005, you also have the ability to tab over the private field declaration, as shown below:

image

Notice when you change the private field declaration, the values in the getter/setter change? Neat!

These are a powerful part in your arsenal of weapons to help make you a more productive developer/programmer. Use Them! One this I am always conscious of is "how long do I spend doing this, is this too long? Can I speed it up?". If you find you are writing the same/similar blocks of code more than once/twice a day, it may well be an excellent candidate for a snippet. For example consider these scenarios:

  • Comment block headers.
  • "ToDo" notes.
  • Wrapper methods.
  • Standard Exception type declarations.
  • "Using" statements, of both types! (as in 'using System' and 'using (Graphics g ...)'
  • Templates for double-buffered graphics.
  • Data access code, query execution etc.

Think about the common code that you type daily and whether or not it may be worth "snipping" it.

Remember, they are freely definable, in part two, I will go over how to create them!



Share:  digg it! del.icio.us furl Live Technorati Facebook
31/03/2008

Adding Social Bookmarks to Posts Using "Dynamic Template" Plugin

Following on from my previous post on trying to get myself organised and utilising social networking/bookmarking more, I figured I should try and help myself a little and be adding social bookmark links on my blog posts.

Sounds easy huh? Well, it's not really the case. I use Windows Live Writer to write my blog posts, its a great tool and I'm well happy the Live Writer Team have created it for us (thanks guys!). Developers are able to create plugins for it, which open up many, many possibilities! So I thought I would check out what plugins could help me out in the Live Writer Gallery. I found two possible candidates:

1. Digg This Plugin for Live Writer by Leo Vildosola (http://tinyurl.com/3x92b6)
This looks like it would be nice as you get the nice "digg this" button.

2. Social Bookmarking Tags by Rahul Soni (http://tinyurl.com/3cf6xr)
This looked great as it added lots and lots of social bookmark providers!

The Outcome

So what did I go with? Neither. Why? I'll explain...

Digg This Plugin
Looked great, didn't work. I don't think this is due to the plugin itself though, since the "digg this" button is based on JavaScript, Live Spaces was blocking it from be posted for security reasons. I believe WordPress does the same, although not sure about Google Blogger. Also, even if it did work, I wanted more than just digg on each post.

Social Bookmarking Tags
This did look promising, however, the developer seems to have put some JavaScript in the OnMouseOver and OnMouseOut events. This works fine on his own blog, since the code is hosted there. However, when you add your tags in Writer, it gives you lots of scripting errors that are a real pain in the ass. I have notified the developer of this, and hopefully they will be able to resolve it. Note: since Live Spaces blocks JavaScript, it will work fine once posted. Other than that, it seems like a great plugin!

The Result

So I engaged my grey matter to think about what I could do. I know all of these sites just take the URL and pass it to a script for processing, which then adds it to their cloud. So, all I need is some HTML right with my post address and some images to sexy it up right? That's not hard in itself, the hard bit is entering it quickly onto each blog post.

Enter "Dynamic Template" Plugin from Joe Cheng (http://tinyurl.com/24bzp3)

I've had this plug in for a while now, it's freaking awesome. It allows you to put ASP-esque C# code to create a template for output. The really cool thing is that you can also make it prompt for input. Sounds like just the tool! So here's what I did (or you would need to do):

  • Installed the plugin.
  • Enter the HTML code to render the links and images, replacing the URL's the HTML encoded user input for "URL" and "Title" (most bookmark sites need these).
  • Created the variables.
  • Tested it a bit.
  • Looks good - happy face :)

You can see the result for yourself at the bottom of this post! Be aware, that the address of your post is not available until after you have posted, so you need to do the following :

  • Write your post.
  • Click "Publish", your post is then sent to Live Spaces (or wherever).
  • DO NOT CLOSE LIVE WRITER!
  • Right-click the post title in your browser, this ensure the POST address is captured, not your BLOG address. Click "Copy".
  • Go back to Live Writer.
  • Click the bottom of your post to move the cursor there if it is not already.
  • Click the "Insert Template" button in the "Insert" menu.
  • Select "Social Bookmarks" and click "Continue".
  • A little dialog will then pop up asking for the URL and Title. Paste in the URL copied and enter your post title.
  • Click "OK". You will then see your bookmarks appear!
  • Click "Publish" again to update your post online with the new bookmarks.

These instructions are based on using the template I have created, if you would like to download this template file, it's available on my Live SkyDrive here (http://tinyurl.com/37fpdw).

NOTE: I have used the images that Rahul Soni's plugin links to, based on the assumption that if he is happy for users to anonymously download his plugin and use them, you are able to do the same. If he is not happy with this, I will remove them from my template and politely request that you do the same.

I would like to say a special thanks to Leo, Rahul and Joe for their efforts in making all this stuff possible :)

Share:  digg it! del.icio.us furl Live Technorati Facebook

30/03/2008

Now Digging, Feeding my Friends and a Facebook App Worth Installing!

OK, just a quick update that serves two purposes:

  1. I've signed up to a couple of new services. And I installed a Facebook application! I can't remember the last time I did that!
  2. I am testing a new Live Writer plug in :)

OK, in an effort to try and organise myself a bit better online, I have finally signed up to the two following services/sites:

digg (http://www.digg.com)
I think digg is a great idea, and since I spend so much time checking out blog posts, I kind of owe it to digg them more, and hopefully one day get some digg's myself :)

Digg also serves as a great hub for finding new content.

FriendFeed (http://friendfeed.com)
Another fantastic site designed to aggregate data from several social networking sources as well as website's. I think key ones here are blogs, twitter, Facebook, LinkedIn and Google Reader. Updates to all of these are then centralised on your personal FriendFeed page. Excellent stuff. Good news is that anyone who is a friend of mine on Facebook doesn't need to check it as you can also add a neat little application to Facebook that broadcasts updates to your news feed and profile. Very, very nicely done!

Special thanks to Loic Le Meur for inspiring me to do it via his blog post!