Windows PowerShell Cookbook Review

Picture of cover of Windows PowerShell CookbookI’m a fan of the Cookbook series from O’Reilly Media.

The idea is a book covering a development topic by showing you how someone experienced with that technology would solve specific problems that you are likely to need to solve yourself at some point.

I’ve read a number of them and they have all been very helpful.

The one I am currently reading is the Windows PowerShell Cookbook, and it is no exception.

Most books I will only review once I am finished, but the nature of a Cookbook is that you don’t read it cover to cover. You look up recipes. Since this book is over 1,000 pages long I am writing the review now rather than waiting…

You wouldn’t want a Cookbook to be your only book on a topic, but once you have the basics down it can be a lifesaver.

The author, Lee Holmes, works on the PowerShell team at Microsoft and knows PowerShell inside and out. I’ve heard Lee on podcasts speaking about PowerShell and he not only talks about what PowerShell does, but why.

A good example that flicked the switch on one of my little mental lightbulbs was his discussion of Execution Policy on the PowerScripting Podcast.

I’ve always found it very annoying that you have to set the remote execution policy to allow scripts to run. It seems dumb to make every person who uses PowerShell issue the command, as administrator no less, Set-ExecutionPolicy RemoteSigned (or one of the more permissive settings).

Lee explained why this is the case, and I realized that, duh, of course this was the right choice.

Yes it is true that every person who uses PowerShell will have to make this change. BUT it is also true that 99% of Windows users won’t be using PowerShell. Think about that for a second. Then remember the bad old days when people would get an email that would run some dandy VBScript scripts without their knowledge that would propagate all manner of nasty malware. Imagine if that malware couldn’t run because the user hadn’t turned on the ability to run scripts.

If you go from 100% of users vulnerable to such scripts down to 1%, and then imagine that the 1% who are now vulnerable are probably the most likely to know how to prevent or fix the problems, then you see why we have to set our execution policy. Actually brilliant.

If you want to know how to enable scripts, see recipe “18.1 Enable Scripting Through an Execution Policy”.

This is a very thorough book. The recipes take you from very simple, generic tasks like “1.2 Run a PowerShell Command” and “9.2 Search a File for Text or a Pattern” to very complex, specific tasks like “28.7 Improve the Performance of Large-Scale WMI Operations”.

If you plan to work with PowerShell I would recommend this book as the anchor of your PowerShell library. No, seriously, this book is HUGE and would totally hold your boat in place.

Don’t buy this book as your first or only PowerShell book because it is not a tutorial, but once you have read a tutorial book (or watched a video or taken a class), then you will need the cookbook.

 

Teaching PowerShell To Speak

This is a quickshot tip with some silliness thrown in for good measure.

One of the cool bits of PowerShell is that it is very easy to call COM objects from the command line and therefore in scripts.

I can’t take credit for any discovery here except to point you once again to the excellent video Continuous Integration: Char by char – PowerShell by Harald Fianbakken.

In his continuous integration script, he demonstrates calling the text-to-speech API built into Windows. That derailed me from finishing his video for an hour or more as I played with PowerShell and the speech API.

To start let’s see how we get hold of the API.

$speechy = New-Object –ComObject SAPI.SPVoice;

That’s it.

Now to make it speak we just do this:

$speechy.Speak(“This is a test”)

You want to see it again? How about in one line?

(New-Object –ComObject SAPI.SPVoice).Speak(“This is a different test”)

That is pretty easy.

On Windows 8 we have different voices available.

If you want to make a function that says something in each of the voices registered on your system, try this (link to this function on GitHub Gist):

function Out-Speech($text) {

  $speechy = New-Object –ComObject SAPI.SPVoice;

  $voices = $speechy.GetVoices();

  foreach ($voice in $voices) {
    $voice.GetDescription();
    $speechy.Voice = $voice;
    $speechy.Speak($text);
}

Now you can simply call the function:

Out-Speech(“This is a test”);

If you’ve never created a function in PowerShell before, just remember to open the PowerShell ISE (Integrated Scripting Environment). That will let you write a script instead entering text one line at a time in the command line PowerShell console.

My next blog post will do something useful with this, but not this post. Oh no. Now we get silly.

You see way back before the dawn of time when a Macintosh was either a Macintosh or not (aka the mid ‘80s), I found a speech to text program on our school’s Mac.

After the novelty of making it swear wore off (two, maybe three years I think), I began to try to make it speak with an accent.

Me, I’m a hillbilly from North Carolina, so first thing I *needed* to do was make it threaten someone in as close to a southern Appalachian way as possible.

Through much experimentation with phonemes and other highly linguistical sounding hoo-ha, I arrived at the following (DO try this at home):

Out-Speech(“"Eye m gunna ki ick yur ice, you sum bee itch!"”)

This upset the speech API who replied:

Out-Speech("Oh no you dih-int.")

Next I tied the JFK API:

Out-Speech("Ahsk naught wot yawr con tree con dew far you, ahsk wot yew con dew far yawr con tree")

That kind of bored me so I fired up the SNES API:

Out-Speech("Eets a ME, Ah Mahd Eo")

Unfortunately the inner 3rd grader came out next:

Out-Speech("Oh, dear! My bum is itching most terribly! I must scoot around on the rug to scratch it! Oh yes! That is SPLENDID!")

At this point I noticed that the Zira voice sounds like a GPS turn-by-turn voice, so I create the WORST… GPS… EVAAR.

Out-Speech("Turn left, in 100 feet and plow into that bus full of nuns.")
Out-Speech("Accelerate up ramp and leap over all those stupid buses Evil K-neivel!")
Out-Speech("In 100 feet you will die in a fiery explosion of death and molten car parts. So says the Oracle Of The Dashboard!")

SkyDrive and Windows 8: A Match Made In Limbo

SkyDrive and I have had an on-again-off-again relationship for several years.

My very first cloud syncing app was Windows Live Mesh back in aught-something. It was great. Install the app, point it at directories and bam.

Then Microsoft introduced SkyDrive. You installed an app, pointed it at directories and bam.

But they weren’t the same. Two apps, two cloud syncing options from the same company and conflicting reports about what was going to happen to them.

Then came DropBox. With DropBox you install an app… OK, you get it. They pretty much all do the same thing.

Now I have an embarrassment of syncing options: DropBox, SkyDrive, Amazon, Google, heck I suspect Burger King may offer me cloud storage if I buy a Whopper.

Each of these options has its ups and downs.

The one awesome artifact of having bought a Windows Phone 7 early on was that I was grandfathered in and kept my 25 GB of SkyDrive storage. It is also awesome that you can get yourself 20GB for about $10/year.

That is a pretty big incentive to use SkyDrive since it gives me enough room to sync up my older photos.

Now that I’m using Windows 8 as my primary OS at home AND I’m logging in to said OS via my Microsoft account (Live.com account actually, but the twitch engendered by that chain of name changes is not the focus of this post), it seemed like a slam-dunk to use SkyDrive.

By now I’m in the groove with Windows 8. Hit the Windows Key and start typing. “SkyDrive”. Bam.

Wait, I have two choices: SkyDrive and SkyDrive Pro 2013. Which one should I choose?

Batch file, please! I’m a Pro all the way.

At the first dialog I began to have my doubts.

OK, off to Google.

Two seconds later I’m reading that SkyDrive Pro is a “cousin” of SkyDrive that is designed for businesses and based on SharePoint. I’m assuming it rode along with Office 2013.

Batch file, please forgive me for the disrespect I formerly showed you. I was wrong. This is not the droid I’m looking for.

That little twitch should be telling me something.

Now, start over, but this time pick SkyDrive.

Super! I’m automatically logged in and seeing my files and photos of Christmases Past in all their Windowless Windows Modern Metro Store UI App glory.

That is SO easy! Windows 8 FOR THEWIN. Hot smile

Now I just need to set up my directories to sync, and Bob will apparently be my uncle.

Hmm. Nothing on the screen. Metro Powers, ACTIVATE! Form of RIGHT CLICK!

Nope. Nothing here about syncing folders.

Windows 8 Learned Behavior #3: Charms Bar. FYI: that does not imply I’ll be drinking with a Leprechaun. No, instead I’m giving the high-sign to get to the super-secret, hidden settings menu.

“Cut to the chase, man!”

OK, not only is it not there, IT ISN’T ANYWHERE.

Whaaaaat?

It is more than a little messed up that I had to go back to Google and hit a couple of sites before I found this: Windows 8 Tip: Use SkyDrive to Sync Your Documents and Pictures by Paul Thurrott over at his excellent Supersite For Windows.

The crux is that the SkyDrive app that comes with Windows 8 is only HALF the story. You still need to go download the quaint, old-fashioned, antediluvian desktop app. OMG! Even in this Modern Metro Windows Store UI world of tomorrow, I still need the unsightly Windows application, not just the Space Age Polymer Based app?

Yes, I am exaggerating for comic relief. My HMO says laughter is the best medicine.

To be serious for a moment (even at the risk of damaging everyone’s health), the problem here is that the Windows 8 Style (*whatever* they are calling them now) app not only didn’t do the job, it didn’t point me to it’s big brother that would. For that matter, why aren’t both halves installed by default with Windows 8?

This is a far more disjointed experience than I expected.

Yes, I suspect it will work great and be super beneficial, but just damn. It could have been a much, much smoother experience.

If I didn’t have a fair amount of experience with SkyDrive, would I have figured it out? If so, how long would it have taken?

This is one experience Microsoft needs to fix ASAP. It is low hanging fruit. One intern with one pizza could fix this.

Resources For Learning PowerShell

Here are some of the resources I am finding helpful as I learn PowerShell. I hope this list is helpful to anyone who stumbles upon it in their quest to learn PowerShell.

Videos

Pluralsight has a number of great courses on PowerShell. That number is growing.

As of this posting the PowerShell specific courses are:

  • Introduction to PowerShell
  • Creating PowerShell Modules
  • Everyday PowerShell for Developers
  • Formatting With PowerShell
  • PowerShell and SQL Server
  • Top 10 Cool PowerShell v3 Features with Windows Server 2012
  • What’s New In PowerShell Version 3
  • WMI and PowerShell

I have viewed a few of them and they were all of high quality. I particularly enjoyed the Everyday PowerShell for Developers by Jim Christopher since it was geared exactly towards what I want to do with PowerShell.

The Intro courses by Robert Caine and Thomas Lee are great as well. They each have a course covering the new bits in PowerShell 3 — one in general and one specifically looking at Windows Server 2012.

In addition to Pluralsight, I have watched a very interesting video by Harald Fianbakken over on Vimeo. This is his presentation Continuous Integration: Char by Char – Powershell. Harald walks us through setting up a PowerShell script that can run on a timer and do the following:

  • Check for changes in source control (he uses Subversion, but Git, TFS, etc. would work)
  • Pull latest changes
  • Use the Psake project to orchestrate the build (it calls MS Build in the background)
  • Run unit tests
  • Deploy project to server

PowerShell is a great tool for use on a build server.

There is overlap between Harald’s presentation and the Everyday PowerShell for Developers course, but naturally the course goes into much greater depth. On the other hand Vimeo is free and Pluralsight requires a subscription. I learned from both, and recommend both.

Books

Most of the books I have read so far have been from O’Reilly books.

I plan to write reviews of several of them, but for now I’m just listing them.

Windows PowerShell For Developers

By Douglas Finke

I have finished reading this one and it is very good. I wish it went into greater depth on Psake and other continuous integration topics, but it does cover them.

I’m not sure I should have read it first, but it held the most immediate interest for me.

Windows PowerShell Pocket Reference, 2nd Edition

By Lee Holmes

I’m currently reading this one and it is very well written and like the other Pocket Reference books from O’Reilly, it is concise and full of handy tips and reference material.

I won’t go into great detail since I plan to review it.

Windows PowerShell Cookbook, 3rd Edition

by Lee Holmes

This looks to be a real winner. The other books in the Cookbook series offer concrete solutions to specific problems solved using the technology in question. I have the jQuery Cookbook, and learned much from it. You can use them as literal cookbooks and use the solutions they provide, but the greater value is that they allow you to see how someone skilled in that technology approaches problems

To be completely transparent, I did receive my copy of this ebook for free as part of the O’Reilly Blogger Review program. If I had not, I would have bought it as I bought the other two books on this list.

Podcasts

I find podcasts a great way to both learn about a topic and motivate myself to learn more.

The PowerScripting Podcast is very well done and engaging. In addition to listening to the latest podcasts, you can also go through their extensive archive of past episodes.

One relatively new feature on their website is a mind-map app that lets you explore the archives based on various categories. Very interesting!

I like listening to their guests who shed light on the uses to which they are putting PowerShell. Some topics are more interesting to me personally than others, but I still like them because I often learn something I might have missed if I had stayed in my comfort zone.

Learning PowerShell

So this is my year for learning PowerShell.

I think I should answer the question, “Why PowerShell?”

PowerShell Hello WorldI am a big fan of the Unix philosophy of small programs that do one thing and do it well. Further you should be able to write lightweight scripts that chain those little programs together to perform larger tasks.

This granularity allows admins and sophisticated users to perform useful work without resorting to a compiled language.

One of the keys is that these programs have inputs and outputs that allow the output from one to be piped to the input of another. In Unix everything is passed around as text. In PowerShell everything is passed around as .Net objects.

Each of those approaches has strengths and weaknesses.

The strengths of passing .Net objects are:

  1. Objects can have methods as well as properties
  2. TONS of .Net objects already exist and can be accessed with PowerShell
  3. The bulk of Windows developers work with .Net.

The strengths of passing text around are:

  1. Text is easily understood by virtually any programming language
  2. Nothing exotic needs to be marshaled or parsed.
  3. XML and JSON are text…

I couldn’t pick a clear winner between these two approaches. They each have merit.

If you really, really want to stick to the pure Unix approach you can install the awesome Cygwin, but with it I definitely get the feeling that Windows and Windows apps want to see my passport before doing business with me. I am a stranger in a strange land for sure.

PowerShell has the advantage on Windows of being a native citizen. Microsoft has mandated that server software must work with PowerShell in order to ship. That is a strong incentive to learn PS!

As more and more of Microsoft’s server technologies rely on PowerShell, I suspect more and more folks will decide to move it up their list of technologies to learn.

My journey to learn PowerShell is just beginning.

2013: New Year, New To-Learn List

NewYear012012 was a year of indecision and turmoil for IT folks who use Microsoft technologies.

There were new versions of Windows, Windows Server, SQL Server, Visual Studio, Office, and on and on and on…

Microsoft switched into Apple mode and refused to offer guidance to developers or IT pros in any but the vaguest of terms. Is Silverlight dead? Is it wounded? Have you knowingly led me over a cliff?

In my post Developer Spin Cycle back in September, I talked about my personal cross-roads and trying to figure out which way to go.

I was burned by Windows Phone 7 and unlikely to shell out money to be in an app catalog again. I decided to focus on web technologies since HTML, CSS and JavaScript are not beholden to any one company.

Now it’s time to refine my thinking a bit.

Here is my list of topics I plan to work on for at least the first bits of the new year:

  1. PowerShell
  2. Continuous Integration
  3. Cloud Infrastructure
  4. EaselJS
  5. JavaScript
  6. Game development

PowerShell

For better or worse, I will continue to use Windows and Windows Server as my primary operating systems. I like Linux, but I don’t like any of the alternatives I examined for server-side web work. I am currently most productive with the .Net stack, and as long as my employer is paying for the licenses, I’m not overly bothered by the “Microsoft Tax.”

If I am going to stay in the Microsoft world a bit longer, I want to bring some of the efficiencies I’ve enjoyed in Linux and Unix (specifically Solaris) to this world.

In particular I want a rich scripting environment.

PowerShell fits that bill, and has been on my “to-learn” list for years. I’ve always had other items higher on the list, so PowerShell just didn’t bubble to the top.

Over the holidays I decided that the time had come to shift my priorities a bit and bubble PS right to the top.

My next few blog posts will be about learning resources for PowerShell and some of the good bits I’m finding.

Continuous Integration

One of the top factors in moving PowerShell to the top of my list is a desire to improve our workflow. Back in the late ‘90s and early aughts, I was working primarily in Java and rocked the build scripts with Ant. It was a great way to set up a build server and make sure builds and deployments were handled in a repeatable and trustable fashion.

I’ve never gotten there with the Microsoft stack. For whatever reason, a large number of us in the MS world wind up building and deploying directly from Visual Studio. Visual Studio is very high on the list of reasons I choose to work with Microsoft tech, but it does become a crutch I can lean on a bit too much.

Psake entered my radar last year, but at a time I didn’t have much time to investigate it.

I’m getting ahead of myself. Ant was a great tool when it came around because it greatly simplified the process of building and deploying compared to the venerable “make” app.

It was a child of the ‘90s when XML was the new hotness.

The Ruby community took a different approach with their build utility Rake. With Rake you could script out your builds and deploys using Ruby, the language you were already working with.

Enter Psake.  In simplest terms, Psake uses PowerShell (and therefore .Net) to define a small, domain specific language for building and deploying projects.

My interest was kindled by a video I watched by Harald Fianbakken titled Continuous Integration: Char by char. He also has a related series on his blog starting with Continuous Integration From Scratch Using PowerShell.

I’ll be posting much more on this topic later.

Cloud Infrastructure

Not much to say yet here except that I’ll be working with both Amazon and Microsoft cloud offerings this year.

EaselJS

Hobby-time is moving towards some casual game development. EaselJS is a nice library for creating games in HTML/CSS/Javascript. More to come.

JavaScript

I’ve spent a fair bit of my time on JavaScript in the past year. I still find it a bit like changing gears sans-clutch, but I keep on grinding. Lowest common denominator often wins in the long run… I’ve played with Node as well as client side browser JavaScript and a teeny bit with Windows 8 apps. I hope to continue my growth in JavaScript this year.

Game Development

As I mentioned in the Easel topic, I want to create some casual games this year. Not sure if I’ll ever get to the point that other people actually want to play my games, but hey, everybody needs a hobby, right?

Here’s Hoping

Here’s hoping 2013 will be a productive, happy year for everyone!

My Current GitHub Activity For The Morbidly Curious

Octocat - GitHub's Mascot

This post started life as an email to Mark Ewald in response to a conversation I had with him and Ritesh Kothari following Mark’s presentation to our user group last night (Gwinnett, Georgia, Microsoft User Group: GGMUG). He was asking if Ritesh or I had used GitHub. What follows is my response (warning, I am not an expert, just a happy user).

If you want to see what I’ve done on GitHub my account is http://github.com/jeffa00

The hurdle is really getting used to Git, not GitHub.

One thing I picked up on that other people were doing is putting their settings files for various tools on github. I use Vim a fair bit and it is really, really cool to be able to clone a repository from GitHub onto darn near any system and have all my settings and extensions show up. My Vim settings are found at https://github.com/jeffa00/dotvim.

One very important file when working with git is the .gitignore file. It tells git which files it should not add to a repository. For example the binaries that are produced when you compile many kinds of projects, or for Vim the temp files created while working on a file. I keep my personal global .gitignore file at https://github.com/jeffa00/MyGit.

I decided earlier this year to focus my personal projects on open source for a while, so I haven’t bothered to set up a private repo on GitHub. If I decide to do something private, I’ll just put that on my own server VM, not GitHub. That’s one of the nice things with Git. All repos are equal from a technical perspective. If you decide that one of them is the “master” repo, then you just treat that one repo specially.

I have a few little projects I have done to various levels of incompleteness.

Pomodoro

https://github.com/jeffa00/pomodoro

This is a little Pomodoro time management timer written in JavaScript. It uses jQueryUI for some of the UI. I made this for my own use and just to have a little project to do in JavaScript.

Quirkety Export Node

https://github.com/jeffa00/quirkety-export-node

Quirkety Export Node is a little Node.js app that uses Node as more or less a cross platform shell scripting language to convert a directory full of Json metadata and Markdown content into a static website. It uses the Mustache templating library among others. Not meant to be useful to anyone but me, hence the name Quirkety.

Posh Markdown

https://github.com/jeffa00/posh-markdown

This is my first PowerShell commandlet. It takes an input containing Markdown text and outputs HTML. Hopefully useful in PowerShell scripts so that you can pipe in the inputs from a variety of sources and pipe out the output to wherever you need it.

Markdown Test File Generator

https://github.com/jeffa00/Markdown-Test-File-Generator

Not ambiguously named. It is a .Net commandline app to spit out as many Lorem Ipsum style Markdown documents to use for testing as you need. It contains some error messages of which I am particularly proud.

Developer Spin Cycle

Confused, young businessman looking at chalk drawn arrows

Decisions, Decisions
© rangizzz – Fotolia.com

The past two years have seen the biggest career-related mental churn I’ve ever experienced.

Quick History

’97 to ’05 I did Java coding primarily. Loved it.

’05 I bought a Pocket PC. Desire to code for it led me to C# and .Net. Since then (2012 at the moment), I’ve played mostly in the Microsoft space. It is an awesome space to play in, I must say.

’08ish I began coding for WebOS. ’10 saw me move to Windows Phone.

What Went Wrong

I loved coding for Windows Phone.

C# feels natural to me. Linq, lambdas and generics make for code that feels satisfying.

I started working for Black Book in January ’11. My first project was to write a Windows Phone version of their Used Car app.

I also had a couple of my own apps in the Windows Phone marketplace.

Here’s what went wrong. Not very many people bought Windows Phones.

SALES of the WebOS version of my Galactic Beacon app are still greater than DOWNLOADS of the free Windows Phone version.

Having paid $99/year for two years means I spent $198 for the privilege of developing for Windows Phone. When I cancelled my developer account, they sent me a check for my portion of the sales of my apps. That check was almost $9.

Negative ROI is not a good thing.

Houston We Have A Problem

The average consumer didn’t really dig Windows Phone. At least not enough to buy it.

The natural conclusion for Microsoft then would be to redesign ALL of their software in the same UI paradigm.

Wait. Does that make sense?

Whether or not Windows 8 will become accepted is not the focus of this post.

Either way, my experiences with Windows Phone showed me that Microsoft could fail.

One Basket

OK, so I’ve spent the past several years getting all my eggs into one basket.

That’s fine as long as that basket doesn’t have any holes in its bottom.

Now it looks like there is a fair chance there might be some holes.

Distributed Baskitechture

Time to get some more baskets, hedge some bets and mix some metaphors.

The feeling that the money I paid to develop for Windows Phone was eaten by a black hole made me think.

This was a microcosm of my larger choices.

To develop for the Microsoft ecosystem you really need an MSDN subscription. Those are not cheap. Without it you cannot legally set up server VMs for development. You are hamstrung.

If you look to the open source side of things, you do not need those expensive licenses for development OR production.

really like ASP MVC and C#. However, I know that I have been productive with open source tools in the past. Hmm.

What’s The Plan?

I’m still formulating my plan, but here’s the current status.

My notebook has:

  • Windows 7
  • Windows 8
  • Ubuntu 12.04

Those are the bootable options. I’ll also throw several others into VMs, including server OS installs.

My websites are:

On the Microsoft/.Net front I’m working with:

  • ASP.Net 4 Web Forms (Black Book apps)
  • ASP.Net 4 MVC (Personal Projects)

For the time being I’m ignoring anything other than web development. I may or may not build some Metro Nom-Du-Jour apps. I’m waiting to see what happens with Windows 8.

 Other Baskets

Obviously Ubuntu isn’t in the Microsoft camp, but it is just the beginning.

Now that I own an Android phone, it might make sense to look into Android/Android-Java.

I am evaluating other web stacks that work on Ubuntu/GNU Linux.

Possible stacks:

  • Java/JEE/Spring – Obvious choice since I was a Java head once upon a time
  • Node.js – The cool kids seem to be hanging out here
  • Ruby On Rails – The cool kids used to hang out here
  • PHP/LAMP – Love the LAM part, just not sure about that P
  • Mono/ASP MVC – Haven’t found implementation yet

I really don’t know which of these options will make sense, but this outlines my current base of exploration.

I will blog about what I learn and what I decide.

Stay Tuned.

Quick Tip: Simple WordPress Theme Improvement

You can buy an awesome theme for WordPress. But spending money is painful.

jeffa Blog Screen Capture

Basic look and feel of this blog as of pub date.

So if you are as cheap as I am, you might say to yourself, “Self, why am I so cheap?”

No, wait, you might wonder how you can spruce up the default theme without breaking the bank.

That’s exactly what I did for this blog. Assuming I haven’t changed it by the time you read this…

 

Two very quick, very simple things you can do are:

  1. Add a background image
  2. Color coordinate your site with your banner image

 Background Image

The right background image can make your site POP. Zing even.

You can pick a large image to fill up the background or a small image that can be tiled.

Both approaches can work, but the large image needs to be small enough in size that it doesn’t choke your reader’s bandwidth.

For this site I chose to use a flat color for the background, but for Galactic Beacon I used a large image I grabbed from NASA.

Galactic Beacon Screen Capture

Another of my sites as it appeared at pub time.

That image is a 1024 x 768 picture, but I jacked up the compression/lowered the quality so that it is only 54 KB. Since it is in the background, I don’t need it to be super hi fidelity.

I also set it to repeat horizontally and NOT scroll.

The effect is that it stays put and the content scrolls up over it.

Both sites use the TwentyEleven theme that is the current default for WordPress.

Another little trick is to use your image editing software and put a gradient over it so that it blends down to your background color towards the bottom. That works whether you let it scroll or not. The effect is that you don’t have to have a staggeringly tall image.

Color Coordination

The next tip is really simple, but can make your site look like someone way smarter designed it. Well, smarter than me, at least…

Here’s the 30 second version:

  1. Pick banner image you like
  2. Submit that image to Kuler
  3. Pick a color set you like
  4. Set the theme colors to those colors

The folks at Adobe know more about color theory than I do. They built Kuler to help people like me color coordinate.

For this site I used a picture of a couple gators I took at Busche Gardens in Tampa several years ago. Kuler picked a palette that I applied to the background color, text, etc.

I’m no designer, but I like the way it turned out. The picture seems to blend into the background of the site.

That pretty much exhausts my knowledge of design.

I’d love to hear what you think of these ideas and if they are helpful.

Understand that I get a TON of spam comments, and I don’t let ANY of them through. I moderate 100% of the comments on this site. Do leave a comment, but don’t be surprised if it doesn’t show up.

Good luck and happy blogging.

Vim Eye For The Visual Studio Guy

OK, first take a deep breath and repeat after me, “Jeff is not asking me to give up Visual Studio.”

Far from it. Visual Studio is without question the most productive environment for developing for Windows.

When everything is going well it functions like your little robotic code-monkey assistant. Memorizing a million API calls and settings is dumb. They will change. Your little robo-minion, however, has those APIs hardwired into his mechano-simian brain. Start typing and he will start suggesting possible matches.

So, relax, sip some nice, calming herbal tea and rest-assured that I’m not asking you to give anything up. Prying things from your cold, dead hands will not be required.

Having said that, [click] you have to admit [click, click] that Visual Studio [click] sure does make you [click] reach for the mouse WAY too often [click, click, clickety-click].

It also displaces memory the way the Titanic displaced water. It also occasionally behaves like the Titanic in a very crash and sink way.

Sometimes you need something light, fast and simple. In true “pick any two” fashion, you can try Vim. It is light and fast. It sure as heck isn’t simple.

Vim In All Its Glory

Vim In All Its Glory - Click for full-size. Really. It’s animated. ANIMATED. CLICK IT!

OK, I’ll admit it, it’s a tough sale.

On one hand you have the aforementioned all-singing, all-dancing robot-monkey vs. what appears at first glance to be a dead monkey.

Don’t be fooled. THAT MONKEY IS NOT DEAD.

You don’t see that in print very often. That makes me sad.

What’s So Great About Vim?

Let’s start with the obligatory Top-n List.

Top 5 Things I Like About Vim

  1. Runs anywhere
  2. Keep hands on the keyboard
  3. Macros become easy and wildly useful (not at first!)
  4. Lightweight
  5. Configurable

The first thing you hear about is the keyboard-centric nature of Vim. Vim, like it’s predecessor Vi can be used without ever touching the mouse.

This was why I decided to take a deeper look at Vim. I find the frequency with which I have to reach for the mouse in Visual Studio distracting. Downright annoying.

You may already know that you can move around using home-row keys instead of those distant arrow keys, but what you don’t know is that after a few days that won’t be moving one character at a time as often as you will be leaping around.

The richness of text navigation options in Vim is a great strength.

You can jump to:

  • Start/End of word
  • Start/End of line
  • Start/End of document
  • Start/End of tag (opening or closing curly-brace for instance)
  • Start to specific text
  • Start to text specified by regular expression
  • More and More and More

Why does this matter?

Remember the mention of macros?

Once you get in the flow of navigating your code in this manner, then creating macros becomes trivial. Literally 2 keys and you are recording a macro. Two more and you play it back.

So What Now?

First things first, do this:

  1. Install Vim
  2. Open it
  3. Shut it down
  4. Curse
  5. Laugh at me for suggesting you look at this crap!

Now that you have that out of your system, get ready to watch some screen-casts. You cannot learn what is good about Vim by just playing around with it.

Start With Derek Wyatt’s Screencasts

Derek Wyatt made a series of screencasts a few years back that are found on his blog.

Derek is very funny and full of energy and enthusiasm for Vim. Watch his Novice and Intermediate level videos to get an idea of why you might care about Vim.

Move On To VimCasts.Org

Drew Neil put together a great series of tutorials as well over at VimCasts.org. Drew’s videos are typically short and sharply focused.

Decide If Vim Is For You

Once you’ve watched some videos from Derek and Drew, you should have a good idea whether you want to pursue delving into Vim.

You might not. That’s OK.

Some of you might.

For me, it isn’t an either/or question. I use Vim with Visual Studio.

Options For Integrating With Visual Studio

  1. Keep them separate. Use Vim occasionally as needed.
  2. Install Visual Studio plug-in:
    1. VsVim (free)
    2. ViEmu (not free)
  3. Make Vim an External Tool

If you remember my Titanic analogies back in the days when you were young and had just started reading this ridiculously long post, you’ll probably agree that the last thing the Titanic needed was more cargo. Making that ship heavier would not have helped.

In much the same way, I try to avoid putting too many plug-ins into Visual Studio. Bare weight right now for me without a project loaded is around ~90 MB. Once I load a project, it will go way, way up.

For that reason, I have opted for the “Make Vim an External Tool” approach.

I have my F-1 key mapped to launch Vim (well GVim, actually) with the current document open at the current line I’m editing. I even have a Vim plug-in for working with Team Foundation Server.

For details on how to set this up (plus more), check out Integrate gvim with Visual Studio over at the Vim Wiki.

Summary

I can’t say if you will like Vim. I’m guessing 90% of you will not.

I also can’t say if a year from now I will be using Vim heavily.

I consider my current set up to be an experiment. For some things Visual Studio is perfect. For some things Vim is perfect. Neither is perfect for everything.

As long as I have to SSH into a server and edit files, I will use Vim or Vi to some extent. Now I will use it far more effectively.