Entries from March 1, 2013 - March 31, 2013

Tuesday
Mar262013

Interlude: Giant Steps Animated by Michal Levy  

This truly cannot be captured in screencaptures and words. You'll have to watch.

Watch it here: http://www.michalevy.com/gs_download.html

(But here are some screen captures anyway)

Snap00281

 

Snap00282

 

Snap00283

 

 

Snap00287

Monday
Mar252013

Interlude: Beck Reimagines David Bowie's "Sound and Vision"  

Beck has covered Bowie before –  his rendition of Diamond Dogs in Moulin Rouge back in 2001 for example. I enjoyed that one, but this new version of Bowie's “Sound and Vision” is stunning.

Friday
Mar222013

Raymond Hettinger's Amazing PyCon 2013 Talk: Transforming Code into Beautiful, Idiomatic Python  

If you write Python code then watching this video of Raymond Hettinger describe how to improve your Python code is worth 49 minutes of your time. Even though the original description of the talk, describes its audience level as “Novice” –  there's something there for even advanced Python developers because since Python has grown so much as a language there are many features or idioms developers may not be taking advantage of.  Raymond's talk is fast-paced, practical, and immediatley useful. Watch this talk and share it widely.

The slides are available here: https://speakerdeck.com/pyconslides/transforming-code-into-beautiful-idiomatic-python-by-raymond-hettinger

Additional PyCon videos can be found here: http://pyvideo.org/

YouTube: Transforming Code into Beautiful, Idiomatic Python

-

Wednesday
Mar202013

Getting a Depth of Field effect with Visio 2013 and the Soft Edges Feature  

The new shape formatting options in Visio open up some new expressive opportunities for your diagrams.

In this post, we'll simulate a depth-of-field effect. First, to clarify, below is one of the samples from Wikipedia showing what the effect looks like.

DOF-ShallowDepthofField

 

NOTE: You can download the Visio 2013 VSDX file used for this blog post here: http://sdrv.ms/Y0BbEi

In Visio 2013 (in fact in many of the Office applications), we can simulate this effect by using the “Soft Edges” feature. Below is an example of what could be done in Visio.

Snap00265

 

The technique is very simple, for any shape – I'll get to the limitations later –  simply apply a varying amount of Soft Edges.

First, draw a simple shape with a solid fill color, right-click on the shape and select Shape Format.

Snap00266

 

And then under Format Shape, select the Effects icon (the pentagon) and then soft edges

 

Snap00267

They key is to vary the Size value.

Snap00275

 

Below are some examples of how size effects the shape. The first shape has no Soft Edges applied, the 2nd  has the Soft Edge size set to 12pt, and then the 3rd  set to 24pt. Notice that the Soft Edges effect diminishes the apparent size of the shape. Compare no soft edge with 12 pt and 24 pt soft edge.

Snap00276

 

Keep in mind that “soft edges” is not the same blur. It won't affect the internal components of a shape. This is easy to demonstrate if you apply Soft Edges to a bitmap. Notice that as the edge gets more blurred, the internal contents are not changed.

Snap00280

Soft Edges also affects grouped shapes by softening each individual component shape and not the edge of the group.

Snap00278

Snap00277

 

 

 

 

 

 

 

Monday
Mar182013

A Simple Example of Web Scraping With the Html Agility Pack  

A coworkers wanted to learn how to do basic web scraping –  for example finding all the <A HREF> links on a webpage. Naturally I directed him to the Html Agility Pack. He wanted a .NET Framework solution, otherwise I would have recommended Python's Beautiful Soup library.

To get him started and to show how simple it was, I provided the following demo code. It doesn't do much, but will give anyone a quick start.

using System;
using System.Linq;
using HAP=HtmlAgilityPack;
namespace DemoHtmlAgilityPack
{
    class Program
    {
        private static void Main(string[] args)
        {
            using (var client = new System.Net.WebClient())
            {
                var filename = System.IO.Path.GetTempFileName();
                client.DownloadFile("http://python.org", filename);
                var doc = new HAP.HtmlDocument();
                doc.Load(filename);
                var root = doc.DocumentNode;
                var a_nodes = root.Descendants("a").ToList();
                foreach (var a_node in a_nodes)
                {
                    Console.WriteLine();
                    Console.WriteLine("LINK: {0}", a_node.GetAttributeValue("href",""));
                    Console.WriteLine("TEXT: {0}", a_node.InnerText.Trim());
                }
            }
            Console.ReadKey();
        }
    }
}

Not hard at all!