Saturday, January 15, 2011

From start to parse, the 4 Guys from Rolla show off the HTML Agility Pack

4 Guys from Rolla - Parsing HTML Documents with the Html Agility Pack

Introduction

Screen scraping is the process of programmatically accessing and processing information from an external website. For example, a price comparison website might screen scrape a variety of online retailers to build a database of products and what various retailers are selling them for. Typically, screen scraping is performed by mimicking the behavior of a browser - namely, by making an HTTP request from code and then parsing and analyzing the returned HTML.

The .NET Framework offers a variety of classes for accessing data from a remote website, namely the WebClient class and the HttpWebRequest class. These classes are useful for making an HTTP request to a remote website and pulling down the markup from a particular URL, but they offer no assistance in parsing the returned HTML. Instead, developers commonly rely on string parsing methods like String.IndexOf, String.Substring, and the like, or through the use of regular expressions.

Another option for parsing HTML documents is to use the Html Agility Pack, a free, open-source library designed to simplify reading from and writing to HTML documents. The Html Agility Pack constructs a Document Object Model (DOM) view of the HTML document being parsed. With a few lines of code, developers can walk through the DOM, moving from a node to its children, or vice versa. Also, the Html Agility Pack can return specific nodes in the DOM through the use of XPath expressions. (The Html Agility Pack also includes a class for downloading an HTML document from a remote website; this means you can both download and parse an external web page using the Html Agility Pack.)

This article shows how to get started using the Html Agility Pack and includes a number of real-world examples that illustrate this library's utility. A complete, working demo is available for download at the end of this article. Read on to learn more!

pagesnap…”

HTML Agility Pack is my favorite HTML parsing tools and this article does a great job in show why it’s cool… If you need to parse, search, screen scrape, etc HTML then this should be one of your first starting points when looking for a library to help.

 

Related Past Post XRef:
HTML Agility Pack gets LINQ’able (and more) in the new v1.4 release
HTML Agility Pack (Think Managed HTML DOM Parser, with XPath)
.NET Html Agility Pack

IntelliTrace & *.itrace files eating your drive space?

ObjectSmart - Steve's Identity Blog - Missing Drive Space? Check IntelliTrace Files

“..

To find out where my space went, I turned to a simple little tool called Disk Space Finder by IntelliConcepts.  There are probably a million applications like this, but this is the one I always seems to remember.  It scans through your hard drive checking file sizes and breaks down usage as necessary.

If you leave IntelliTrace enabled for all debugging you could potentially end up with a couple hundred *.itrace files like I did (not actually pictured).  It looks like an itrace file is created every time the debugger is attached to a process, so effectively every time you hit F5 a file is created.  Doubly so if you are debugging multiple launchable projects at once.

The quick fix is to just delete the files and/or stop using IntelliTrace.  I recommend just deleting the files because I think IntelliTrace is an amazing—if not a little undercooked – tool.  It’s a v1 product.  Considering what it’s capable of, this is a minor blemish.

The long term fix is to install Visual Studio 2010 SP1, as there is apparently a fix for this issue.  The downside of course is that SP1 is still in beta.  Hence long term.” [GD: Click through to for the path. I didn’t want to leach too much from the original post, walking that fine web curation line]

This tip helped me recover a couple gigs of drive space across a couple of machines. Now this amount might be an edge case, given I launch a number of VS solutions as part of my blogging. Still I was surprised at the amount used and how much drive space I was able to recover (hence my sharing of the post ;) 

Final note, my favorite “drive space usage spelunking tool” is WinDirStat (blog post). Whenever I need to hunt drive space hogging files, this is my utility of choice…

A tip for using InstallShield and TeamBuild 2010 while living in a x86/x64 world

Visual Studio ALM Blog Building InstallShield based Installers using Team Build 2010

“Last few weeks, I have been working on Application Packaging stuff using all the widely used tools like InstallShield, WISE, WiX and Visual Studio Installer. So, I thought it would be good to post about how to Build the Installers developed using these tools with Team Build 2010. This post will focus on how to build the InstallShield generated packages using Team Build 2010. For the release of VS2010, Microsoft has partnered with Flexera who are the makers of InstallShield to create InstallShield Limited Edition, especially for the customers of Visual Studio.

First Microsoft planned to release WiX (Windows Installer Xml) with VS2010, but later Microsoft dropped WiX from VS2010 due to reasons which are best known to them and partnered with InstallShield for Limited Edition. It disappointed lot of people because InstallShield Limited Edition provides only few features of InstallShield and it may not feasable to build complex installer packages using this and it also requires License, where as WiX is an open source with no license costs and it has proved efficient in building most complex packages.

Only the last three features are available in InstallShield Limited Edition from the total features offered by InstallShield as shown in below list.

pagesnap…”

Given that more of us may be using InstallShield in the future (link), and be in a TeamBuild environment, I wanted to capture this for future reference.

 

Related Past Post XRef:
Visual Studio Setup & Deployment Projects declared dead & retired. VS2010 will be the last…
Free InstallShield Limited Edition 2010 coming to help our VS2010 Windows Installer and TFS/automated building woes

The PowerShell Survival Guide (Brought to you by the Microsoft TechNet wiki)

Wiki - TechNet Articles - Windows PowerShell Survival Guide

“At customer events a few years ago, we started handing out one-page "Survival Guides" (printed both sides and laminated) with links to important resources. The wiki versions of the Survival Guides are meant to do the same things without killing trees or using laminating machines.

Essential Windows PowerShell Resources

Windows PowerShell Scripts

Windows PowerShell Modules…

Fun Modules

Forums

Newsgroups

User Groups

Windows PowerShell Cmdlet Reference Material

Windows PowerShell Third party Cmdlets

Video:

Windows PowerShell Blogs:

Whitepapers and Guides:

Additional PowerShell Resources:

Social Networking Accounts to follow:

Windows PowerShell Training

pagesnap…”

In short, if you’re looking for some PowerShell information or resources, this is good place to start…

(via Ignition Showcase - How to Survive with Windows PowerShell)

 

Related Past Post XRef:
How do you learn PowerShell? One bit at a time…(and with a little help from Doug Finke)
Note to Self: Learn PowerShell by using it. Do one PS thing a day…
Free PowerShell Introduction/Getting Started book from MS Switzerland
DBA’s & PowerShell? Yep, PowerShell is not just for your IT brethren, you can have PS fun too!
Want to try PowerShell? Then “Try PowerShell”
Who needs a stink’n PowerShell Owner’s Manual? (Cough… ME!... cough… ;)
PowerShell Quick Reference & Graphical Help File(chm)
Is this you? “I’m an IT Admin and I’m being told to use this PowerShell thing… What is it… Help!” Here’s a free eBook [reg-ware] just for you, “The Administrator Crash Course: Windows PowerShell v2”

Writing a MMC Plugin, with MVP and Unity

Damian SchenkelmanMMC 3.0 Sample Plug-In using MVP and Unity

“The last couple of days I have been working on a MMC spike that leverage dependency injection and some kind of presentation pattern (in this case MVP), to search for ways to make MMC applications more testable. The scenario I chose for the spike was having a plug-in that could connect/disconnect network adapters through a service that used WMI objects. The sample is very fresh, and there is still work to do to decouple things a bit more (for example, moving strings for WMI objects to config files).

To work with MMC, you need the Microsoft.ManagementConsole.dll assembly, which comes as part of the Windows SDK 6.1 for Windows Server 2008. This is important because versions 7.0 and 7.1 do not include this assembly. Additionally,  “MMC is one of the very few extensibility point in the OS that will not support .NET 4. MMC ” (from this thread), which is why MEF went out the door and in came Unity.

pagesnap…”

This is one of the edge case dev projects that many of us don’t usually encounter, the writing of an MMC Plugin. Given that I really like Damian’s approach the building of this MMC Plugin sample. MVP & Unity is just not something I’d really have thought of, though I should have, when building one…

Wednesday, January 12, 2011

Now that NuGet.org is live, just how do you create and upload packages? Phil Hack's got your back…

You’ve Been Hacked - Uploading Packages To The NuGet Gallery

“As David Ebb blogged today, the NuGet Gallery is now open to the public. The goal of the NuGet Gallery is to be the hub for NuGet users and package authors alike. Users should be able to search and discover packages with detailed information on each one and eventually rate them. Package authors can register for an API key and upload packages.

We’re not quite where we want to be with the gallery, but we’re moving in the right direction. If you want to see us get there more quickly, feel free to lend a hand. The gallery is running on fully open source code!

In this blog post, I wanted to cover step by step what it takes to create and upload a package.

Create Your Package

Uploading Packages To The NuGet Gallery…”

Phil walks you through the steps, from package creation to sign-up and upload.

 

Related Past Post XRef:
Sharing NuGet packages with the world is now just an NuGet.Org away… or The NuGet Gallery and package submission is now live at NuGet.Org!
Want your own “Gallery” (think something like the Visual Studio Gallery and future NuGet home) site and server? Check out the Orchard Gallery/Gallery Server Projects…

Using Simplify and NuGet to automate and share Visual Studio Solution creation
Another way to deploy/share code and code snippets… NuGet
A “Hello [NuGet] World”
Unpacks = NuGet (Think “A New way to Get libraries”)
I “Nu” I needed you… Unpacks v1 Developer Preview/CTP 1 Released (Think, “Where have you been all my dev. life… finally an package management system/installer for .Net”)

Sharing NuGet packages with the world is now just an NuGet.Org away… or The NuGet Gallery and package submission is now live at NuGet.Org!

David Ebbo - Introducing the NuGet gallery

“Back in December, I blogged about how poor the NuGet package submission process was. You had to clone a HUGE repository that had all the other packages, add your package files to it, and submit a pull request. It was something that we had meant to last a couple weeks, and it lasted a few months, way overstaying its welcome.

The good news is that that process is now obsolete! Instead of have a brand new gallery site that lets authors publish packages very easily.

And the site it.. drums… http://nuget.org!

Who is this site for?

To set expectations, please note that this site is not feature complete yet, and is still rough in many ways. Eventually, it will be a place for both package authors and consumers, but in the short term, it’s primarily useful to package authors.

So basically, this site provides a complete (and much better) replacement for the old package submission process, and at this point that is its main focus.

So if you are using NuGet from Visual Studio to install packages, you can probably ignore this site for now. It will be come interesting later, but it isn’t now. You’re certainly welcome to browse around it, but there is no point in creating an account now unless you have packages to submit.

Getting started with the site

…”

nuget.org

“NuGet is a Visual Studio extension that makes it easy to install, remove, and update .NET libraries and tools in Visual Studio. When you use NuGet to install a library or tool, NuGet copies the files to your solution and will automatically update your project (add references, change config files, etc). When you remove a library, NuGet reverses whatever changes it made in your project so that no clutter is left.

The NuGet Gallery allows you to search for and browse available NuGet packages. When you find the package you want, install the package using NuGet within Visual Studio.

nuget…”

nuget.org - Contribute

nugetcontribute

I think 2011 is going to be a great year for NuGet…

And remember that the gallery, front and backend, are available as OSS projects too (post)…

 

Related Past Post XRef:
Want your own “Gallery” (think something like the Visual Studio Gallery and future NuGet home) site and server? Check out the Orchard Gallery/Gallery Server Projects…

Using Templify and NuGet to automate and share Visual Studio Solution creation
Another way to deploy/share code and code snippets… NuGet
A “Hello [NuGet] World”
NuPack = NuGet (Think “A New way to Get libraries”)
I “Nu” I needed you… NuPack v1 Developer Preview/CTP 1 Released (Think, “Where have you been all my dev life… finally an package management system/installer for .Net”)

Tuesday, January 11, 2011

“Microsoft Mathematics 4.0” - Free graphing calculator for the student in the house…

Microsoft Downloads - Microsoft Mathematics 4.0

“Microsoft Mathematics provides a graphing calculator that plots in 2D and 3D, step-by-step equation solving, and useful tools to help students with math and science studies.

MSetup_x64.exe: 18.9MB

MSetup_x86.exe: 17.6MB

Version: 4.0

Date Published: 1/11/2011

Language: English

Microsoft Mathematics provides a set of mathematical tools that help students get school work done quickly and easily. With Microsoft Mathematics, students can learn to solve equations step-by-step, while gaining a better understanding of fundamental concepts in pre-algebra, algebra, trigonometry, physics, chemistry, and calculus.Microsoft Mathematics includes a full-featured graphing calculator that’s designed to work just like a handheld calculator. Additional math tools help you evaluate triangles, convert from one system of units to another, and solve systems of equations

…”

Since I indeed have a student in the house, I’m going to see if he’s interested (or if I get the “zomg, you are SUCH a parent” eye-roll… lol )

 

Here’s a snap of it. It looks pretty cool, doesn’t it? How it “shows the work” of solving an equation made my chuckle (man, I hated having to do that…)

image

How do you learn PowerShell? One bit at a time…(and with a little help from Doug Finke)

Development in a Blink - How To Practice PowerShell

“…

I am reading

Seven Languages in Seven Weeks” by Bruce Tate and it is a great book. Looking through the Ruby chapter, I was struck by how well Mr. Tate communicates key concepts of the language and saw how the examples could be demonstrated in PowerShell.

I do a talk on PowerShell for .NET Developers (code camps and user groups), you can see the video I did for Microsoft’s Channel9  Geek Speak. I cover some these examples and more.

Let me know what else you’d like to see.

Launch a PowerShell Console and type along

Type along or copy and paste the examples to see how they work. At the end is a short Self-Study section. I added a sections for piping objects in PowerShell and accessing with the .NET framework.

Lightning Tour with the Console

Launch PowerShell. Type a command and get a response: Give these a try:

pagesnap…”

Note to self: Stop clicking and start PowerShell’ing! (Oh and “Delete DOS.Commands FROM Greg.Brain; Insert PowerShell INTO Greg.Brain;”)

Sigh, I’ve been living in DOS land for so long I find it hard, even with the DOS alias’s in PowerShell, to make the jump to PowerShell. So here’s my commitment, my kick-in-the-butt, the next time I fire up CMD, stop, drop, and fire up PowerShell instead. If I don’t start getting comfortable with PowerShell, I’ll never get comfortable with PowerShell (gee, imagine that… lol ;)

 

Related Past Post XRef:
Note to Self: Learn PowerShell by using it. Do one PS thing a day…
Free PowerShell Introduction/Getting Started book from MS Switzerland
DBA’s & PowerShell? Yep, PowerShell is not just for your IT brethren, you can have PS fun too!
Want to try PowerShell? Then “Try PowerShell”
Who needs a stink’n PowerShell Owner’s Manual? (Cough… ME!... cough… ;)
PowerShell Quick Reference & Graphical Help File(chm)
Is this you? “I’m an IT Admin and I’m being told to use this PowerShell thing… What is it… Help!” Here’s a free eBook [reg-ware] just for you, “The Administrator Crash Course: Windows PowerShell v2”

Monday, January 10, 2011

goo.gl gets an official API (You hear that rapid typing? That’s a ton of dev’s already pounding out the code to use it…)

Google Code - Google URL Shortener gets an API

“When we launched Google’s URL shortener externally back in September, there was no accompanying API to allow people to integrate goo.gl into their applications and web pages. However, we said that we were working on one, and today we're happy to announce that we’ve launched the goo.gl API in Google Code Labs. The documentation can be found on the Google Code site, with example code in the Getting Started section.

With this API, developers are able to programmatically access all of the fast, sleek goo.gl goodness that we currently provide via the web interface. You can shorten and expand URLs using the API, as well as fetch your history and analytics. You could use these features for a wide variety of applications, enabling behaviors ranging from auto-shortening within Twitter or Google Buzz clients to running regular jobs that monitor your usage statistics and traffic patterns. You can check out the Google APIs console to get started.

We’re very excited to be able to offer you this API to access one of the fastest URL shorteners out there. …”

Do you smell that? There’s nothing like the smell of a new API in the morning…

.Net Reflector 7 Beta released, with added Jason Haley Power Commands goodness right in the box!

simple-talk - Bart - More Big News: .NET Reflector 7 Beta, Integrating Jason Haley's Power Commands Add-in is Now Available

“I'm very pleased to announce the release of .NET Reflector 7 Beta. As ever, you can get it from

http://reflector.red-gate.com/Download.aspx

I've been holding off for a week or so because I wanted to be able to announce the great news that we've acquired the excellent Power Commands add-in from Jason Haley, and have integrated it directly into .NET Reflector. The amount of time Jason's invested in Power Commands really shows, because it provides an extremely powerful set of extensions to the core Reflector functionality. To illustrate, here's a summary of the complete feature list which Jason provided us:

  • Assembly browser treeview
    • Import/export assembly lists
    • Sort assembly list alphanumerically
    • Find what other assemblies reference an assembly
    • Open assemblies embedded as resources
    • Open items with an external application, e.g.,
      • Open code with Notepad
      • Open modules with ildasm
    • Open zip files
    • Run executable assemblies
    • Copy assembly path to clipboard
    • Open containing folder
    • Create desktop shortcut to item using code:// URL
    • Open Visual Studio 2005/2008/2010 command prompt in containing folder
    • Create assembly binding redirect XML for .config file
    • Collapse all nodes in the assembly browser tree
    • Toggle assembly browser on/off
  • Decompilation
    • View enumerations and calculate bit flags for those marked with the [Flags] attribute
    • Copy decompiled code as HTML, RTF or plain text
    • Email decompiled member code
  • Resources
    • Export embedded resources (.resources files) as .resx files
    • Open resources with Paint
    • Open resources as .resx files in Visual Studio
  • Other
    • Bookmarks menu
    • Write LINQ queries against loaded assemblies
    • Export analyzer tree to text file
    • Close all windows

You can find out more about PowerCommands on Jason's website at http://jasonhaley.com/blog/post/2009/09/07/PowerCommands-for-Reflector.aspx, and I'd highly encourage you to experiment with the functionality it offers. Many of the commands are exposed via the context menu for, e.g., items in the assembly browser treeview.

In addition to this we've done some more work on the tabbed decompilation. …”

That’s AWESOME! I really dig it when some who’s worked as long and hard as Jason has is recognized in this very big way (cough… No MS MVP for Jason yet?… hint… hint… nudge… nudge…)

Congrats to Jason and the Reflector team on this officially cool release. :)

 

Related Past Post XRef:
Jason Haley, Mr. Reflector Add-in Guy, is at it again, this time Babel’ing - Reflector.Babel Addin v1 released
Creating a Reflector Addin? Check Out this Cool Walk Through from Jason Haley
The Reflector Add-in Starter Kit from Jason Haley - Hard to think of a way to make creating Reflector Add-in's much easier...

Reflector (yes that one) now a Redgate Property
.Net Reflector 5.1 Released
Reflector 5 Released
Reflector 4.2 Released...
.NET Reflector Add-Ins 4.0.3.0
Reflector for .NET 4.0.0.0
Reflector for .NET - Lutz Roeder's Programming.NET C# .NET VB .NET CLR

OneNote Powertoys Rollup

OneNote Testing - Powertoys from the OneNote Test Team for 2010

“Every January, I compile a list of the powertoys the test team gave out the previous year. This year, there are a few new ones (table sorting, bulk import images and remove ink from a page) for OneNote 2010 and a section color changer for OneNote 2007. Several updates for getting some of the more popular powertoys to OneNote 2010 happened as well. Here goes:

New for OneNote 2010:
Table sorting and table of contents:

A tool to bulk import images:

An addin to remove all ink, and only ink, from a page:

Extract OCR data on a page:

Updates to existing addins for 2007 to work with 2010:
Privatizer:

Word Count:

Sort Sections alphabetically:

Calendar/Planner creator:

Text file importer:

A quick start article for converting addins from OneNote 2007 to OneNote 2010

For OneNote 2007:
…” [GD: Click through for all the links… ]

There are a number of OneNote add-in updates that I had missed, so this roll-up was prefect for me… :)

“XNA for Silverlight developers: Part 0 - Why should I care?”

Silverlight Show - XNA for Silverlight developers: Part 0 - Why should I care?

Introduction

Around the time the first Windows Phone 7 devices were released to the market, one popular sentence you heard was "every Silverlight developer is a Windows Phone 7 developer" – and that's true. Silverlight is Microsoft's main platform to do Windows Phone 7 development, and every desktop Silverlight programmer will feel comfortable in the new mobile programming environment instantly. Sure there are differences and libraries specific to the devices, but you won't have to learn a new programming language or new ways to define your UI, and you can use the same development environment you've been using for normal Silverlight development all the time. That's great!

However, Silverlight is not the only possibility to create software for Windows Phone 7 devices, there's also XNA. Most people that are interested in developing for the new mobile platform probably have already read about it, mostly in the context of game programming. This article tries to give a quick overview of XNA on the mobile platform for Silverlight developers who have not dealt with XNA in detail before. It explains the possibilities of interaction between Silverlight and XNA, and why you as a Silverlight developer should care about XNA even if you don't want to develop games.

In successive parts of this series, we'll go into the details of programming 2D games for Windows Phone 7 using XNA, with special focus on those parts that require a change of thinking when you are coming from a Silverlight background. I strongly encourage you to comment on each part and request more information about topics you are interested in. If possible, your feedback will directly result in the design of future articles.

Summary

In this article we have learned that Silverlight and XNA, although very different in their programming models, are not that far apart on Windows Phone 7. Both are based on a common foundation, and parts of the libraries can be and already are shared between those two worlds easily.

We have also seen that game development for the new mobile platform is not something exclusive to XNA, but can be accomplished using Silverlight too. In fact, both technologies have their advantages when it comes to effectively programming games for Windows Phone 7.

I hope that by giving a glimpse of XNA, I've sparked some interest for those who had no motivation to delve into it so far. In the following parts of the series, we will shed light on several aspects of programming games with XNA and also focus on the differences to Silverlight's programming model to ease the learning curve for those who didn't engage in XNA development yet.

Please feel free to add your comments and thoughts, or contact me directly with any questions you have

pagesnap…”

XNA is an interesting beast. It has .Net goodness we’re used to, yet lives in a “game loop” world. If you’re a WinForms/WebForms/Silverlight dev, pure play XNA development can be jarring at first. But the level of control and power it gives you, once you “get it”, is a heady thing…

The Noun Project, XAML’ified… or The Noun Project converted for you to XAML and PNG’s

Fear and Loathing - 500 Metro Style WP7 Icons

“I was inspired by The Noun Project, a project that offers up “Metro-style” icons in SVG format. The project is licensed under a public domain license and while it’s a great project, all of the content is in SVG format. Jon Galloway has a great post (from 2007) talking about the differences between SVG and XAML so I highly recommend that for some background. I thought it would be helpful to the WPF/Windows Phone 7/Silverlight community to provide the content in alternative formats for use in your applications.

The Goods

I’ve put together a package of the 500 icons (502 actually) in PNG, XAML and the original SVG format along with a couple of sample projects so you can see them in action.

pagesnap…”

Nice! ‘nuff said…

 

Related Past Post XRef:
“The Noun Project” + SVG + Free + Metro like look and feel + 500 = Happy Windows Phone 7 Developers