got net?

Kevin Hazzard's Brain Spigot

About the author

Welcome to Kevin Hazzard's blog.
E-mail me Send mail

Recent posts

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

Remembering the Sony Magic Link

Sony Magic Link PIC-1000

I admit that I've been a geek for a good long while now. 30 years ago, I was taking computers apart and soldering new things into them to experiment or to force them to suit my needs. Those were fascinating times in the computer industry to be sure. Operating systems were simple enough to be understood in their entirety by a single person. Software applications were also very simplistic. Kids in 2009 would LOL at our total lack of sophistication but we were enthralled to be able to move circle and squares sloppily about the screen to simulate bombs or gnomes or whatever we could imagine. We had to use our imagination more in those early days and it wasn't a bad thing per se. Poor graphics and poor sound weren't an impediment to us because we didn't know that they were bad. But we knew they could be better and that kept us going.

At the halfway point on my journey thus far, I bought a Sony Magic Link PIC-1000 handheld computer. It was 1994. I think I paid about $800 for it at the time. I remember the excitement I felt as I opened the package and powered it up. It ran the Magic CAP operating system from General Magic and it was a thing of pure joy, I'll tell you. The screen sporting 16 shades of gray was organized into a virtual desktop complete with drawers that you could open and close by tapping them. You could drag objects into and out of the drawers. It had a filing cabinet, an on screen keyboard and a graphical toolbar of contextual tool icons at the bottom of the screen. The built-in modem would allow you to connect an e-mail or fax provider to exchange messages and documents with others.

I used my Sony Magic Link every day for a couple of years and it taught me a lot about the value of good software design. Some of the applications were clunky but, for the most part, it was a very functional device. Sony positioned the Magic Link as an upscale alternative to Apple's Newton. Having used both of them, I believed the Magic Link to be a far superior device for getting things done. The screen was bigger. It did decent animations. It had a built-in modem and a PCMCIA card slot. And the sound was good for the period. The Newton was cool but it was a glorified notepad, in my opinion. There's no doubt that Apple studied the Magic Link with great care to learn from it. As an iPhone user today, I often think about how similar my iPhone is, in so many ways, to the seminal PDA from Sony. Many of the Magic Link's gestures and graphical metaphors live on in the iPhone today, with or without attribution from Apple. Microsoft didn't seem to learn much from it though as Windows Mobile 6.5 still feels like a desktop OS crammed into a device not so well designed to run it. The truth hurts, I know.

I'm pretty sure that I still have that old Magic Link lying around in the attic somewhere. As I sit here in the White Hawk Music Café waiting for my son to complete his guitar lesson, I bristle with some of that old excitement I felt in 1994, wondering if I find that old device in the attic, will it still work? Will it be as fun today as it was then? Is there something I can solder into it to make it do something fun and new? Some things never change, I suppose. And that's good, too. Never stop learning. That goes for you, too, Mr. Ballmer. Watch and learn.


Categories: CapTech | Fun
Posted by kevin on Wednesday, June 17, 2009 7:00 PM
Permalink | Comments (8) | Post RSSRSS comment feed

Service Toggler Source Code

I'm very active in the User Group community so I do a lot of presentations. I wrote a quick and dirty application called ToggleService which lets me start or stop a Windows Service in a visual way. The picture above shows three screen shots side by side. On the left, you see my application as it queries the service called SQL Server (KATMAI) in the stopped state as indicated by the red light bulb. After clicking the Start button, the state transitions which shows the middle screen with the yellow light bulb. After a few seconds the service goes into the started state as indicated by the green light bulb on the right. I wrote this application to give my User Group attendees some visual feedback whenever I needed to start or stop a service during a presentation. It's very effective for that. So effective, in fact, that many people have asked me for the source code.

One important note: when you create a shortcut for this application, you must pass the long or short name of the service to ToggleService.exe on the command line. You can see the long service names in the Services Control Panel applet. In the case of the screen shot above, I found "SQL Server (KATMAI)" as the long name and passed it to the ToggleService.exe application on the command line. To find the short name of a service, you can use the command line service controller like this:

sc \\machineName GetKeyName "SQL Server (KATMAI)"

Of course, you must substitute your own machine name and the long name of the service that your querying for. This will produce output something like this:

C:\>sc \\machineName GetKeyName "SQL Server (KATMAI)"
[SC] GetServiceKeyName SUCCESS
Name = MSSQL$KATMAI

So, to toggle the SQL Server instance on my computer in which I'm interested, I could pass either of the following arguments to ToggleService.exe:

  • "SQL Server (KATMAI)"
  • MSSQL$KATMAI

You might observe at this point that the SC.EXE utility which I used to discover the short name of my service could have been used to start and stop the service during my presentations. Yes, that's true. But the little GUI I built is more colorful and exciting. You have to sell the sizzle and the steak, right? Anyway, the C# source code attached below requires Visual Studio 2008. There's nothing special about it but since so many people have asked for it, I thought I'd oblige. Enjoy!

Source code for Kevin Hazzard's ToggleService Utility (26.73 kb)


Tags:
Categories: C# | Fun | Pres Skills
Posted by kevin on Sunday, May 17, 2009 10:05 PM
Permalink | Comments (1) | Post RSSRSS comment feed

English Words Database from 11 Sources

I am working on a project where I needed a list of English words in a Microsoft SQL Server database. I found some public domain lists of English words at:

ftp://ftp.ox.ac.uk/pub/wordlists/dictionaries

There are 11 interesting word lists here including:

  • Unabridged
  • CRL
  • Roget
  • Unix
  • Antworth
  • Knuth
  • KnuthBritish
  • Englex
  • Shakespeare
  • Pocket
  • UU.net

Most of these lists haven't been updated since the mid-1990s so if you find a more updated (free) source of English words, please let me know. I loaded all the data into a table that has these attributes:

  • [WordGuid] [uniqueidentifier] NOT NULL
  • [WordText] [nvarchar](30) NOT NULL
  • [WordLength] [tinyint] NOT NULL
  • [SoundexGroup] [nchar](1) NOT NULL
  • [SoundexValue] [smallint] NOT NULL
  • [GroupId] [smallint] NULL
  • [IsPalindrome] [bit] NOT NULL
  • [InUnabr] [bit] NOT NULL
  • [InAntworth] [bit] NOT NULL
  • [InCRL] [bit] NOT NULL
  • [InRoget] [bit] NOT NULL
  • [InUnix] [bit] NOT NULL
  • [InKnuthBritish] [bit] NOT NULL
  • [InKnuth] [bit] NOT NULL
  • [InEnglex] [bit] NOT NULL
  • [InShakespeare] [bit] NOT
  • [InPocket] [bit] NOT NULL
  • [InUUNet] [bit] NOT NULL

The [WordGuid] is actually the MD5 hash of the [WordText] expressed as a UNIQUEIDENTIFIER so it makes a nice universal primary key. I've precomputed the [WordLength], [IsPalidrome] and a couple of Soundex values to make querying the table a bit more efficient. I've also computed a [GroupId] for each word. Every word that shares a [GroupId] is composed of exactly the same letters in various orders. You could find all the whole word anagrams for a given word using the [GroupId] for example. Finally, I've created a handful of [In*] flags to tell me which word file(s) each word was sourced from. I've made the database available in two forms below:

Attachable (as MDF/LDF) Microsoft SQL Server 2005 Database (21.20 MB)

Tab-delimited CSV File with Table Creation Script (11.10 MB)

Please see the licenses in the files at the source web site listed at the top of this post. All of the licenses are academic and free for use but your company may want to read and catalog them for full compliance.

Enjoy!


Categories: Fun
Posted by kevin on Saturday, April 04, 2009 8:47 PM
Permalink | Comments (2) | Post RSSRSS comment feed

Flickr Photo Viewer in Small Basic

My sons, 10 and 15 years old, and I were sitting around this evening playing with Microsoft Small Basic. I've been trying to get my kids interested in writing software for years. But they didn't take to it. Small Basic made their eyes light up though. It has a Turtle graphics class like Logo had back in the 80s. You can make the turtle object move and turn to draw on the screen. It animates the whole thing. For capturing the imagination of children and getting them interested in writing algorithms, Logo was brilliant back in the 1980s and it's still brilliant today. Small Basic also has a Flickr class that you can use to download images by keywords. My sons and I wrote this little Small Basic program for taking keyword input from the user and then starting a Flickr slide show. They were so proud of themselves. Too much fun!

TextWindow.WriteLine("Welcome to My Flickr Picture Viewer")
TextWindow.ForegroundColor = "Cyan"
TextWindow.Write("What kind of pictures do you want to see? ")
TextWindow.ForegroundColor = "Yellow"
keywords = TextWindow.Read()
TextWindow.Hide()

GraphicsWindow.Title = "My Flickr Picture Viewer"
GraphicsWindow.Left = 0
GraphicsWindow.Top = 0
GraphicsWindow.Width = Desktop.Width - 20
GraphicsWindow.Height = Desktop.Height - 100
GraphicsWindow.FontSize = 18
GraphicsWindow.Show()
GraphicsWindow.MouseDown = OnMouseDown
GraphicsWindow.DrawText(10, 10, "You are about to see Flickr pictures with the keyword(s) '" + keywords + "'.")
GraphicsWindow.DrawText(10, 50, "Click in this window to begin. Click when you want to see a new picture.")

Sub OnMouseDown
  GraphicsWindow.Clear()
  GraphicsWindow.DrawText(10, 10, "Downloading...")
  img = Flickr.GetRandomPicture(keywords)
  GraphicsWindow.DrawResizedImage(img,0,0,GraphicsWindow.Width,GraphicsWindow.Height)
EndSub


Categories: Fun
Posted by kevin on Thursday, December 18, 2008 11:44 PM
Permalink | Comments (6) | Post RSSRSS comment feed

Microsoft Small Basic Is Fun

I've been so busy writing for my book recently that I've not been blogging as I should. Oh, well. But I stumbled on a great little programming language called Microsoft Small Basic today that I thought I should share with you. It comes from the Microsoft DevLabs. You can learn more about Small Basic here. Essentially, Small Basic is a BASIC-like development tool aimed at beginners. It has primitives for reading and writing to a text-based console window and it can do graphics manipulation, too. It's really fun. I can't wait to turn my kids onto it. They'll be cranking out fun Small Basic programs and e-mailing them to me soon, I hope. I've wanted to find a way to get my younger children interested in what I do for a living but I just couldn't find anything that was simple and fun with enough power to do impressive stuff. I think Small Basic might be exactly what I was looking for. It requires the .NET Framework 3.5 and installs in about one minute. Be sure to download the Introducing Small Basic Guide, too. Lots of great examples in there. And the Intellisense feature in this environment is very cool. My kids are going to be spoiled! Here are a couple of screen shots. Enjoy.

Update: if you use low-privilege login accounts for your kids on a shared PC, be sure to put the MSI installer package in a shared location before running it as an administrator. When your kids log in with their reduced privileges and try to run Small Basic, they will need access to the installer package from that shared location. Don't delete it.

The Small Basic Development Environment

Running the Program


Categories: Fun
Posted by kevin on Thursday, December 18, 2008 5:33 PM
Permalink | Comments (1) | Post RSSRSS comment feed

Mixing Static & Dynamic .NET Languages - November 2008 Update

This is the November 2008 update of my now famous "Mixing Static & Dynamic .NET Languages" presentation. OK, so it's not a famous talk. But it still rocks and the folks at the code camps love it. This is the material I will be using at my talk at the upcoming Raleigh Code Camp on 11/15/2008. The source code and slides are attached below. When you run the demo code, you'll see a dialog that looks like this: 

The application, written primarily in C#, implements a shopping cart to which various products can be added. The shopping cart isn't the cool part, of course. What's interesting is the use of Python code to implement the discounting/marketing rules within the cart. If you press the Show Rules Editor button at the top of the form, you'll see the rule editor dialog: 



Python code is pretty easy to read isn't it? You can probably follow the logic to see that if certain counts of Entertainment products are added, they get discounted at various levels. And a trigger is set on the total count of items in the cart, too. There's a bug in the code though. But that's part of the demo. Can you find the bug?

Hopefully, if you run this code and understand it, you mind will be expanded a bit. One of the most often asked questions I get when talking about IronPython is, "How do I convince my boss to let me write that application in Python?" My answer is, "You don't have to write the whole thing in Python. With the fantastically rich hosting APIs in the .NET Dynamic Language Runtime (DLR), you can write the portions that need dynamism in Python and write the rest in C# or VB.NET." In fact, for most applications, the portion that can benefit from dynamic behavior is usually fairly small as a percentage of the application's total surface area. So this model of mixing static and dynamic languges is a nice approach to those kinds of problems.

Slides for MixingStaticAndDynamicDotNETLanguages 20081115.pptx (251KB)

Source Code for MixingStaticAndDynamicLanguagesInDotNet 20081109 (43KB)


Posted by kevin on Friday, November 07, 2008 5:17 PM
Permalink | Comments (3) | Post RSSRSS comment feed

Why F# is So Important to the Future of Software Development

I am a big C# fan. As a general purpose, imperative, object-oriented language, C# has begun to take on some functional language capabilities that I like very much. LINQ just rocks, for example. And LINQ is a very functionally-oriented technology. It's so easy and expressive to get set-oriented work done using LINQ and it's functional underpinnings are the reason why.

I have been thinking a lot recently about why F# might be important to the future of all software development. If you think about it, there's really little in F# that doesn't already exist in other languages like OCaml and Haskell. But F# is significant and different because Microsoft is behind it and because of the tight integration with the .NET framework. But beyond the who of F# is the why of its importance. And the why, in my mind can be summed up with these five bullet points:

  • ORMs are failing to gain mindshare not because they aren't good domain modeling tools (as some complain about). They are failing because the imperative, object-oriented languages in which we use ORMs are unfriendly to sets and tuples.The database is full of nothing but sets and tuples. So we read them into objects and wonder why there's an impedence mismatch. F# is not only set and tuple friendly. You can't really think properly in F# without these first-class constructs.
  • Domain Specific Languages (DSL) are becoming more and more important in the marketplace. And functional languages are great for building language compilers. Language parsing into discrete intermediate forms is a problem that benefits greatly from the lambda calculus and functional decomposition. F# is appearing at the right time and place in history to serve in the critical role of helping us to build new DSLs.
  • Many of our time-honored design patterns are workflow-oriented. So, why do we shoe-horn them into data structures? Workflows are, by definition, composed of functions invoking higher-order functions. Step 3 invokes on the result of Step 2 which invokes on the result of Step 1. So, why do we code the Visitor Pattern to walk a tree into a data structure like an object? It makes no sense, really. F# allows us to revisit these time-tested patterns and view them in the light of functional decomposition. And the result will allow many who have been unable to grasp those patterns though an imperative lense to "get it" for the first time.
  • Service-Oriented Architecture (SOA) is predicated on the idea that strict operation contracts exist that take discrete, strongly-typed inputs and return strongly-typed results. F# rolls like that. There's no object-orientation in SOA, per se. In fact, SOA sort of shuns OOP to a certain degree. And good service design also avoids side effects, another tenet of functional languages. So, if SOA is important, and I think it is, then languages that follow the patterns of SOA will also be important in building compliant architectures. I think good architects will recognize the pattern and find interesting ways to expose services via F#. We will code the guts of services in C# and Java in the future. No question there. But the workflow, scheduling and execution core of SOA will be based on functional languages like F# instead.
  • Moore's law is breaking down. Intel and other companies are all moving to put more computing cores into their packages because they can't scale computing power vertically beyond what modern physics will allow. So, they are scaling horizontally to meet customer demand. The problem with this concept is that the marketplace isn't really ready for this kind of change. Massive pools of threads attempting to use Many Reader, Single Writer Mutexes with Starvation Avoidance ain't gonna work, my friends. We need a new model that will make parallelism invisible. But for parallel computing to become invisible, we need to move to a model that doesn't require the programmer to be involved in locking and serializing access to their code. F# is ready to help us think that way. And it's .NET! Beauty, eh?
These ideas aren't all mine. I borrowed heavily from Amanda Laucher and Ted Neward. But, I've added my twist, ideas and opinions of course. What you do think F# means for our industry and our profession? I'd love to hear from you.

 


Posted by kevin on Wednesday, September 17, 2008 6:30 PM
Permalink | Comments (4) | Post RSSRSS comment feed

Follow Me Follow You Source Code

A few weeks ago, I blogged about a tool I had written called Follow Me Follow You to help me understand who was following me on Twitter.com and, from that group, who I was following. See the Venn diagram below to see what I was after. Since then, the idea of understanding who's who in your TwitterVerse has become somewhat fashionable. This is probably due to the low signal-to-noise ratio that you get when you follow a lot of people.

Dunbar's number says that we primates are limited to about 150 meaningful relationships. This seems to hold true in the social networking space, too. In the TwitterVerse, for example, when the number of friends you have approaches about 150, there's so much noise, you can't get much value from the tool without other tools like TweetDeck which allow you to create sub-groups within your tribe. So, understanding your friends and your mutual friends as shown in this diagram can be helpful. Also, being able to quickly scan those who follow you but you don't follow from time to time, can help you from becoming a Twitter snob, if you know what I mean.

I finally found a couple of hours to clean up the Follow Me Follow You source code. I've linked to a ZIP archive containing the source code below. It's C# 3 code and includes a stripped-down version of my Mingle.NET social networking API. The TwitterClient class demonstrates how powerful lambda expressions are in C# 3. Check out the code required to load up the NonFollowingFriends (green), MutualFriends (blue) and NonFriendedFollowers (yellow):

private void LoadFriendsAndFollowers( object sender, DoWorkEventArgs e )
{
 if (_creds == null)
  throw new ApplicationException( "The credentials are null. " +
   "The user must be known to complete this operation." );

 _friends = FetchTwitterUserScreenNames( String.Format(
  _friendsListUrlTemplate, ScreenName ), false );

 _followers = FetchTwitterUserScreenNames( String.Format(
  _followersListUrlTemplate, ScreenName ), true );

 // left side of Venn diagram - friends who don't follow me
 _nonFollowingFriends = _friends.FindAll(
  friend => _followers.BinarySearch( friend ) < 0 );

 // right side of Venn diagram - followers who aren't my friends
 _nonFriendedFollowers = _followers.FindAll(
  follower => _friends.BinarySearch( follower ) < 0 );

 // intersection of Venn diagram - my mutual friends
 _mutualFriends = _friends.FindAll(
  friend => _nonFollowingFriends.BinarySearch( friend ) < 0 );

 var onLoadComplete = e.Argument as
  Action<ICollection<string>, ICollection<string>>;

 if (onLoadComplete != null)
  onLoadComplete( _friends, _followers );
}

Follow Me Follow You C# Source Code (19KB)


Tags:
Categories: C# | Fun | Software Dev
Posted by kevin on Saturday, August 23, 2008 2:20 PM
Permalink | Comments (0) | Post RSSRSS comment feed

On Quitting Your Job by James Avery

James Avery and I spent some time together at CodeStock this past weekend. He told me that he was tired of doing technology presentations. I entirely understand what he means. Education in the developer community is very important but at some point, you just want to switch gears and talk to your peers about other stuff that's important in our space. We're all geeks, that's for sure, but we need to be savvy business people, too. And that requires just as much peer training and influence.

James floated an idea past me for a presentation he would like to do and I liked it a lot. It's not your average Code Camp faire but I asked James if he would travel up from Raleigh on October 4th to present this session to our Richmond attendees. He agreed to come do it. The session is called "Tune In, Turn On and Quit Your Job" and it goes something like this:

Tune In, Turn On and Quit Your Job by James Avery

"We don't have a lot of time on this earth. We weren't meant to spend it this way. Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about mission statements." - From the Movie Office Space (1999)

Stop working for the man and learn about writing a software product, building a successful web application or becoming an independent consultant.

I can hardly wait to attend this talk. I predict a packed house. I hope James keeps going on this vein and writes his next book on this topic.

James is one of many great regional and local speakers who will be presenting in Richmond at the upcoming Code Camp. Want to learn more about the Richmond Code Camp on October 4, 2008? As of August 11, 2008, we still need a few more speakers. Don't miss your chance to show the central Virginia developer community that you want to contribute your ideas, too. Submit your presentation abstract and bio here.


Posted by kevin on Monday, August 11, 2008 5:45 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Follow Me Follow You

I've been playing around with the Twitter API and some of the more popular Twitter clients. My favorite desktop client for Twitter is TweetDeck. But one feature I really would like to have is a view of the relationships between my friends and followers. I want to see something like this:

I thought if I could manufacture that sort of diagram where the people in each part were clickable, I would be able to see and manage the relationships in my "tribe" more clearly. Tonight, taking a break from work coding, I created a desktop application that isn't as pretty but does what I want. It's called Follow Me Follow You and it looks like this:

OK, I warned you it wasn't pretty. But it is pretty cool. You can see the three parts of the Venn Diagram shown above as listboxes on the left side. The left side and right side are independent except that if you click on the screen name of a user on the left, it loads that user's Twitter page in the browser on the right. That feature alone is nice. Having persistent access to your tribe in a directory format is handier than I thought it would be. I can see part of a conversation in the browser window and hop around to related parties without having to use Summize, aka the Twitter search engine.

I can also scan the lists to find out other interesting information. For example, in the "Followers not Friended" list, I can scan for new names that I may have missed in e-mails that Twitter.com sends to me when someone starts following me. After clicking on their name and logging in within the web browser on the right side, I can look at their timeline and decide whether or not to follow them from there.

I used my new Mingle.NET library, a social networking library for the .NET Framework, to build the new tool in about an hour. I haven't released Mingle.NET or the Follow Me Follow You tool. If you're interested in them, let me know and I'll get them ready for production. I can only work on them in my spare time and there isn't much of that these days. :)


Categories: Fun
Posted by kevin on Monday, August 04, 2008 11:06 PM
Permalink | Comments (4) | Post RSSRSS comment feed