Tuesday, July 11, 2006

Just last month, I posted on how much I hated corporate content filters, specifically for blocking sites such as Scott Hanselman's site and del.icio.us, labeling them as "personal" sites. I've got good news and bad news regarding my rant from earlier. I spoke with some of my supervisors at work and the technology argument won over regarding Scott's site - they've unblocked it because it is a great technological resource. Unfortunately, del.icio.us does not fall into that category.

Today, I discovered another site that apparently is not a good resource for information: Wikipedia. I guess because users decide on the content of this online encyclopedia, it must be personal. In fact, here is what I see when I attempt to go there at work:

The following error was encountered:

  • Access Denied by SmartFilter: Forbidden, this page (http://en.wikipedia.org/) is categorized as: Personal.

I would post a screenshot, but it has the phone number for the corporate help desk and other related information. You know, one of the things that is most frustrating of all is that the entire content filtering system has nothing to do with productivity at work. Why? Because ESPN.com isn't blocked. And no, my company has NOTHING to do with sports. Enough people would complain if ESPN were blocked that they keep it open, while blocking sites that are actually beneficial to work, such as Wikipedia and del.icio.us. Oh, and by the way, Chris Sell's site is blocked because it is personal, too.

Just another frustration from the life of a programmer I suppose.

posted on Tuesday, July 11, 2006 3:39:37 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Monday, July 10, 2006

This will be a short post, but someone at work emailed me a link to a page that will let you see how fast you can type. Check it out here! Here are my results from my last run:

---------------------------
Windows Internet Explorer
---------------------------
Wow! Your typing speed (with 5 mistakes) is:

104.55 wpm
438.62 cpm
---------------------------
OK  
---------------------------

Not too bad, eh?

posted on Monday, July 10, 2006 9:08:02 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Wednesday, July 05, 2006
Just a short note, but for those who have been waiting for a version of NDoc that supports .NET 2.0 assemblies, there is a separate project out on SourceForge called NDoc 2005. It is still in beta, but it may be the way to go until NDoc gets moving again. Per comments at MSDN forums, it looks like the best way to go is to download the source and recompile it yourself. The binaries (at least the GUI binary) looks like it still has some issues.

Note: unfortunately, it still doesn't completely work for me... *sigh*

(from DotNetKicks)
posted on Wednesday, July 05, 2006 11:37:04 AM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Friday, June 30, 2006

If anyone out there knew about the BindingList before today, I sure wish one of you would have told me. Now I know, if you had known I was looking for something like the BindingList, you would have told me, but still...

Okay, all joking aside, the BindingList is what I've been trying to find for a long time. With Visual Studio 2005, the option to bind to an object data source is now possible (see screenshot).

The typical usage scenario for me with this data binding option is that I have just used .NET remoting to pull a collection of business objects back from a remote server. After that, I usually want to bind this collection to a datagrid or something like. For the past few months, I had used the new BindingSource object and set its DataSource property to my collection (usually a System.Collections.Generic.List<T> or a System.Collections.ObjectModel.Collection<T>). The problem I had was that any changes to either of those collections later would not fire ListChanged events. I had settled myself to the fact that I would have to reset the binding everytime.

Well, not so!

Dinesh Chandnani posted to his MSDN blog over a year ago about this subject. Too bad I didn't find it until today. In his post, he provides some very simple code examples, one of which details how to get a "DataGridView bound to business objects." *gasp!* Where have I been? This is what his code looks like:            

            DataGridView dgv = new DataGridView();

            BindingSource bs = new BindingSource();

            BindingList<Customer> bList = new BindingList<Customer>();

           

            // Fill bList with Customers

 

            bs.DataSource = bList;

            dgv.DataSource = bs;

 

I wish I known about the System.ComponentModel.BindingList<T> before now. It would've saved me so much time. If you're still trying to bind to a List or Collection like I was, take that guy out and bind to the BindingList instead! It really works the way you would expect it to!
posted on Friday, June 30, 2006 11:31:42 AM (Central Standard Time, UTC-06:00)  #    Comments [0]
I don't like repeating myself, but I need to again: if you're not subscribed to the PowerShell blog, then why in the world not?!? The PowerShell team has been on top of it lately providing some GREAT one-liner PowerShell scripts such as listing all of the sub-directories from the current directory or, as in the case today, listing all of the PROGIDs that you can use to instantiate your own COM objects from PowerShell script.

Sure, the scripts are fairly simple and are clearly obvious once you see them, but it displays the power right at your fingertips that PowerShell gives you. Currently, I'm not using it for any projects. I'm just using it as a productivity tool! The parsing you can do with directories and files is great and you can very quickly leverage your knowledge of .NET in the process.
posted on Friday, June 30, 2006 6:35:10 AM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Tuesday, June 27, 2006
I'm not sure how often people run into situations where the ManualResetEvent is needed, but I have a few times. System.Threading.ManualResetEvent provides an easy way to allow cross-thread communication and to let other threads know when something has completed. Most of the time that I've needed it, I have a property in a class that is loaded in another thread, but I want to prevent access to the property until it is loaded. From what I've seen, this is a great time to use the ManualResetEvent.

It is easiest to explain with some code snippets. Here's how you create the ManualResetEvent.

Private _dataLock As New ManualResetEvent(False)

The constructor takes a boolean that signifies whether the object is signaling or not. A signaling object implies that the action has been completed... we're done with the work. If signaling is false, the work hasn't finished yet.

To wait on the signal, use this code:

_dataLock.WaitOne()

You can also specify a period of time to wait instead of waiting indefinitely.

Once your background work is completed, you can call Set like so:

_dataLock.Set()

This begins signaling, so any calls to wait will stop blocking and will continue execution.

Here's a full code sample that shows how it would work and also gives a short example on the BackgroundWorker.

Imports System.ComponentModel
Imports System.Threading

Module Module1

    
Private _dataLock As New ManualResetEvent(False)

    
Sub Main()

        Thread.CurrentThread.Name =
"[Main]"

        Dim wkr As New BackgroundWorker
        
AddHandler wkr.DoWork, AddressOf wkr_DoWork
        
AddHandler wkr.RunWorkerCompleted, AddressOf wkr_RunWorkerCompleted

        wkr.RunWorkerAsync(
"Get to work!")

        Write(
"Waiting on the lock...")
        _dataLock.WaitOne()
        Write(
"we're back!")


        Console.WriteLine(vbNewLine &
"Press any key to continue...")
        Console.ReadLine()
    
End Sub

    Private Sub wkr_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
        Thread.CurrentThread.Name =
"[Work]"

        Write("DoWork just received this value: " & CStr(e.Argument))
        Thread.Sleep(
5000)

        e.Result =
"DoWork finished!"

        Write("DoWork is done so start signaling completion.")
        _dataLock.Set()
    
End Sub

    Private Sub wkr_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs)
        
Dim wkr As BackgroundWorker = DirectCast(sender, BackgroundWorker)
        
RemoveHandler wkr.DoWork, AddressOf wkr_DoWork
        
RemoveHandler wkr.RunWorkerCompleted, AddressOf wkr_RunWorkerCompleted
        wkr.Dispose()
    
End Sub

    Private Sub Write(ByVal s As String)
        Console.WriteLine(
String.Format("Thread: {0}, Message: {1}", Thread.CurrentThread.Name, s))
    
End Sub

End
Module

The output from running looks like this:
Thread: [Main], Message: Waiting on the lock...
Thread: [Work], Message: DoWork just received this value: Get to work!
Thread: [Work], Message: DoWork is done so start signaling completion.
Thread: [Main], Message: we're back!

Press any key to continue...
One thing to remember: do NOT put the call to Set (i.e. _dataLock.Set()) in the thread where you are waiting (i.e. _dataLock.WaitOne())! You'll never get the signal because that thread is already blocking! Because of this, make sure your call to Set always happens in the DoWork event of the BackgroundWorker instead of the RunWorkerCompleted event.
posted on Tuesday, June 27, 2006 11:59:56 AM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Thursday, June 22, 2006
I can't help myself, PowerShell is great and I keep finding useful things to do with it. Most of what I've been finding is easily accomplished in other ways, but this just goes to show the power available straight from the PowerShell command prompt.

What if you want to know the full path to all of the solutions in a sub-directory?

You could try this:
PS C:\Dev>dir -recurse -include *.sln . | foreach { $_.FullName }
This builds on my post from yesterday.
posted on Thursday, June 22, 2006 2:42:46 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
I hate corporate proxies and content filters!

First, it starts blocking Scott Hanselman's site for "personal" reasons. Apparently, we can't be looking at the "personal" weblog of a technical speaker and great technical resource!

Give me a break!

Well, now it is blocking del.icio.us!!! For "personal" reasons!

I've got plenty of technical related bookmarks stored out there! It is a great resource!

Who knows, my blog may be blocked soon for "personal" reasons!

Who runs this junk anyway?!?

(I realize that there are completely legitimate reasons for proxies and content filters, but blocking sites for blanket personal reasons is a little ridiculous.)
posted on Thursday, June 22, 2006 6:36:13 AM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Wednesday, June 21, 2006
dir -recurse -include tempproj.proj | foreach { rm $_ }
Awesome!

Recursively removing files!
posted on Wednesday, June 21, 2006 3:40:16 PM (Central Standard Time, UTC-06:00)  #    Comments [0]

Has anyone ever heard that saying? One of my MBA professors said that it was the number one rule for managers. "You get what you reward." Basically, the idea is that if you want a team to work together, then you need to reward good team behavior. It is all about recognizing what true motivation is, because the reward has to be perceived as a reward. A nice pat on the back isn't a real reward for someone unless that pat on the back will motivate them.

Hacknot recently posted an article related to technical leadership and common mistakes related to leading in a technology environment. One of the mistakes he lists is "employing hokey motivational techniques."

...managers value perception and status, so being presented with an award in front of everyone, or receiving a plaque to display on their wall where everyone can see it, may well be motivating to them. However programmers tend to be focused on the practical and functional, and value things that they can use to some advantage. Programmers regard the sorts of rewards that managers typically receive as superficial and trite.

How true that statement is. One of the things I've learned to think about in my MBA program is that good leaders recognize that not everyone is the same. In the same way that people from different cultural backgrounds are motivated by different things (i.e. an individualistic culture versus a collective culture), people in different professions are also motivated by different things. Honestly, different professions ARE different cultures.

It sounds like a fairly simple concept, but apparently it is a lot harder to understand than I realize. That, or more people need to start reading Hacknot.

posted on Wednesday, June 21, 2006 11:56:40 AM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Thursday, June 15, 2006

We were working with partial classes recently at work and we came up with a best practice usage for naming them, at lease for our needs, and I thought I would share it with you.

Basically, do it the way Visual Studio does. For example, with GUI components such as forms, VS2005 names the main class Form1.vb, while it names the partial class Form1.designer.vb. So, if you want to make your Shipment class have a partial piece, have a file that is Shipper.vb and Shipper.stuff.vb.

This way, it is clear by the naming that the files are related. Otherwise, I would think there would be a lot of confusion on how the files are related.

Any thoughts on this?

posted on Thursday, June 15, 2006 11:44:28 AM (Central Standard Time, UTC-06:00)  #    Comments [1]
 Wednesday, June 07, 2006
Most of you probably are already aware of this little development, but there is a freeware IDE for PowerShell development (Scott beat me to the post...). It really is great. One of the most interesting parts about it, at least at first glance, is that it gives a first look at what an IDE might look like if it were to use Office 2007's ribbon. Not only that, but it even has an Mac OS X styled (or ObjectDock if you're so inclined) tool section in the bottom right.

Sweet!
posted on Wednesday, June 07, 2006 6:58:55 AM (Central Standard Time, UTC-06:00)  #    Comments [0]
I'll apologize ahead of time... one of the features that I am (or was?) looking most forward to in Office 2007 is the ability to save as PDF. Will I ever use it? I have no idea, but I've really wanted to be able to do that for a long time. And then Adobe goes and messes the whole thing up. How in the world can they truthfully justify letting everyone else (Apple, OpenOffice, etc) have this feature, but Microsoft can't?!? Give me a break! If they didn't want companies putting this feature in, they never should have opened the format in the first place! Via this digg post, I came across this article from the Washington Post. The article states it best:
Then there's the thought that Adobe's Acrobat, at $299, will compete poorly with any free save-as-PDF option. But Adobe had to have foreseen that possibility when it issued a blanket invitation to the world to write PDF-compatible software. As its own documentation reads, "Adobe gives anyone copyright permission, subject to the conditions stated below, to . . . Write drivers and applications that produce output represented in the Portable Document Format."
Super.

By the way, totally unrelated to this entire post, if you haven't checked out Foxit Reader, I would highly recommend it. :-)
posted on Wednesday, June 07, 2006 6:36:15 AM (Central Standard Time, UTC-06:00)  #    Comments [0]