What I don't like about E: Cygwin

Link. March 7, 2008. Comments [0]. Posted in: Tools

My good friend Sam Gentile blogged about his new dev environment for Ruby using the E Text Editor alongside cygwin and Console. I find E an interesting editor because of its TextMate-like functionality, and because pretty much everyone who has used TextMate raves about it (though I haven't used it myself).

As a side note, last time I tried E wasn't very successful. In their defense, I'll say that I've since reached the conclusion that it was probably my virtual machines acting up. VPC2007 sometimes has nasty issues when running on Vista.

However, the thing I don't really like much about E is its dependency on cygwin. I understand the reason for it, but frankly, I just don't like cygwin much. Don't get me wrong, cygwin fills a valuable niche [1], and I've used it in the past, but the truth is that it's much more less needed now than it used to be.

For example, a few years ago it was pretty hard to find native ports of many GNU command line utilities. Now they are widely available (and before that there was unxutils). There are differences of course, but they are very usable for the most part.

Cygwin itself feels pretty clunky. In fact, I don't want a "unix within windows" at all, as that forces to many compromises (many of which aren't really all that needed). If I wanted to, I could always go with something like andLinux, which seems like a better option to me.

Frankly, between PowerShell, the Windows port of GNU utilities and a few other things, I feel right at home on Windows and switch to unix when using my ubuntu machine without much fuzz at all.

Back to Sam's post: he's right on the money about Console; it's pretty sweet. Unlike Sam, however, I dumped my VS environment tab and just configured all the necessary paths in my PowerShell profile. I haven't had a need to switch to a regular CMD.EXE prompt in a few weeks!

[1] There are certainly some cases where cygwin is actually warranted because some specific tools, but, personally, I prefer to just switch to a real unix at that point. It's less painful.

PowerShell Editors and Other Not-So-Fascinating Stuff

Link. February 8, 2008. Comments [4]. Posted in: PowerShell | Tools

Scott Hanselman just mentioned using the PowerShellPlus editor as an IDE for PowerShell. You can always trust good old Scott to point out cool new tools!

Anyway, I was already aware of PowerShell+ (and its closely related product, PowerShell Analyzer), and I find the idea appealing in general and a it's probably a very useful tool to have around. That said, I don't have plans to install PowerShell+ anytime, for a few reasons:

  1. I've had little need of such a tool until now. Granted, if I need to create a lot more complex scripts than what I've been doing until now, then having a something like the PowerShell+ debugger would sure be useful.
  2. From the screenshots, at least, it looks like a fairly busy UI, a mix of a console, office and Visual Studio strung together. I understand the technical reason for having the dual UI mode (console + editor), but it seems like forcing such disconnected experience between the two modes to be disconcerting as a user.
  3. It's currently in beta (at least that's what the web site says).
  4. Right now the site mentions it is "free for non-commercial use"; didn't find any obvious references to what the cost of a full version will be. I don't object to such deals (indeed, it's a good way to promote your products to enthusiasts), but I'm not quite sure I see how it can apply all that easily to a tool like PowerShell. What exactly constitutes a non-commercial use of an editor for a scripting language [aimed at systems administration]?

Related to (2), I've fallen back into working under more minimalist environments since a few months ago. I found that it helps a lot my concentration and productivity and leads to far better use of my screen real state.

Does this mean I dislike IDEs and other complex environments? not at all; it just means I don't want my editor to flaunt all its features in my face all the time demanding my attention. Like John Lam, I run my Visual Studio in an almost clean environment: All tools windows set in auto-hide, and almost no toolbars visible (unlike John I do keep one toolbar around, but not the standard one). I  works great for me.

For PowerShell, I'm pretty happy using Vim + Console; seems to do the trick, and actually has forced me to learn more about PowerShell than I had done previously. One of the things I love about PowerShell was that it includes commands for exploring itself right for the beginning (i.e. alias, get-command, get-help and so on).

PowerShell V2

While on the subject of PowerShell, I've been reading a bit about the features coming in PowerShell V2, and there are some pretty cool things there.

The "Graphical PowerShell" tool looks cool and I'm sure it will be very useful to a lot of people, but personally, I wish this would become a separate download and not part of the core PowerShell installation (might as well wish I would win the lottery; that probably has better changes of happening).

On a related note, out-gridview gives the the shivers.

Side Note: Is it just me that finds it ironic that PowerShell V2 brings several UI-related features when the big thing about V1 was creating a fantastic shell scripting language? Just food for thought.

(And yes, I'm aware of PowerShell's hosting API, and it's great. In fact, I've used it to embed PowerShell capabilities into three different projects, so I'm pretty well aware of how sweet it is.)

Formatting Source Code For Blog Posts

Link. February 7, 2008. Comments [4]. Posted in: Blogging | Tools

I've struggled quite a bit over the past few months trying to come up with a good way of including code snippets in my blog posts. The problem, of course, is making the code look good both when browsing the website as well as in the RSS feed. It's not the first time I've ran into this issue, either.

As I've mentioned in the past, one of the things making it hard is my blog engine, as the dasBlog build I'm currently running doesn't properly respect whitespace in the original HTML code. Because of this, posting code is a big pain in the neck, as you need to format the code in HTML manually since using good old <pre><code></code></pre> tags will render the code unreadable in the RSS feed.

Beyond just having the spacing and indentation right, there's also the matter of posting syntax highlighting. There are several options I've tried over the years:

  • CopySourceAsHtml: This is an OK tool, though I've had to build a custom build to make it work on my machine (which has some weird clipboard issues at times; not sure why). I'm not 100% satisfied with it, though. For one thing, it generates pretty ugly HTML. It's also not very useful for posting code in a language not supported by Visual Studio itself, which I occasionally do (example: PowerShell snippets).
  • CodeHTMLer: An online site for converting code snippets to HTML, supporting a bit more languages than CopySourceAsHtml. I've used this one extensively, and it usually does a good job, provided I explicitly check the "convert whitespace" option as well as "Inline Tags" for formatting. You don't get much choice in how the code is formatted, though. I believe there's a Windows Live Writer plugin based on this somewhere, but I always forget where so it's more convenient for me to just use the web application.
  • Syntaxhighlighter: A Javascript Library for formatting code snippets. Looks nifty, but only usable on the website and not RSS feeds, I think. It also seems to rely heavily
  • Iris: This is an interesting project, based on the VIM syntax highlighting. It actually does a pretty good job, though I haven't tried using it yet directly on my blog. The Ajax interface is slick, though there's also a version you can download to use on your own desktop. It only seems to support using CSS for the syntax highlighting, though.
  • TOhtml: I've also been experimenting lately with using Vim's :TOhtml command. This can actually provide very nice HTML if you set up the right options, and given the breath of syntaxes supported by Vim, you can pretty much use it to pretty print almost any code snippet you can think of.
    Another nicety of TOhtml is that it will use the colors in your selected Vim colorcheme, so the generated HTML looks exactly like it does in Vim. It can also generate the formatting using CSS or inline tags.
    As a sample, this is what I used in my last PowerShell post, with the options html_use_css, html_no_pre and use_xhtml. The color scheme I was was using was the black variant of the recently updated moria scheme, aided by Peter Provost's excellent PowerShell syntax files.

I'm sure there are many other options out there. I know there are some very nice plugins for other blogging platforms (like wordpress, from what I've been reading), but for obvious reasons that's not very useful.

Another issue that can be a bit bothersome with code formatting is the choice between using CSS rules or using inline tags.

In an ideal world, using CSS rules would be much more preferred, particularly if you can keep them in an external CSS file. One obvious benefit of this is that if you later decide to change your formatting preferences, your color scheme, or simply change your blog's layout and colors and want your code to match them, it becomes a whole lot easier (though this isn't all that possible for someone like me with 6 years of past blog posts with all kinds of code formatting used).

The downside of using CSS is that it's pretty much a website-only option, so it's not very useful for formatting code in your RSS feed. At least, my experience has been that most RSS generators and/or consumers will strip any inline CSS rules found in blog posts (this was, in fact, what happened to my last PowerShell post mentioned above).

I know of no way to easily reference an external CSS for this, but if anyone knows of a way, I'd sure appreciate knowing about it!

So that pretty much leaves, for now, the only option of not using <pre> tags and resorting to inline tags. Yuck! So, what's the secret sauce others are using for this?

Have Script, Will Backup

Link. February 6, 2008. Comments [2]. Posted in: PowerShell | Tools

A few days ago, I mentioned I did simple backups using the SyncToy powertool, and mentioned I might try replacing it with Robocopy. The end result is a simple PowerShell script that drives Robocopy. It simply backs up a specific set of directories and my VPC data virtual hard drive (.vhd) into a new folder with the current date, and leaves a log of the entire process.

The script also makes it easy to specify for each folder a set of file extensions to ignore. For example, I don't want to include object files when backing up my source code trees.

Anyway, it's not fancy, but it does the trick. Here's the script:

function script:filename([string] $path) {
   return [System.IO.Path]::GetFileName($path)
}
function stars {
   return (new-object string ('*', 80))
}

$BASE = 'g:\backups'
$today = [datetime]::Today.ToString("yyyyMMdd");

$dest = "$BASE\$today"
$log = "$dest\log.txt"

if ( -not (test-path $dest) ) {
   mkdir $dest
}

#
# write header
#
write (stars) >> $log
write "Backup procedure starting at " `
      ([datetime]::Now.ToString()) >> $log
write (stars) "`r`n`r`n" >> $log

#
# stop CVS services
#
net stop cvsnt >> $log
net stop cvslock >> $log

#
# backup our set of folders
#
$folders = (
   ('e:\CVS', ''),
   ('e:\devdeo', ''),
   ('e:\home', '*.swp'),
   ('e:\projects', '*.swp *.obj *.exe *.dll *.pdb *.pch *.idb'),
   ('e:\opensource', '*.swp *.obj *.exe *.dll *.pdb *.pch *.idb'),
   ('e:\tools', '')
)

$folders | %{
   $name = filename($_[0])
   $excludes = $_[1].Split(' ')
   robocopy $_ "$dest\$name" *.* /E /ZB /NP /XF $excludes >> $log
}

#
# backup our VPC data file
#
robocopy 'E:\vpc\' $dest 'datos.vhd' /NP >> $log

#
# restart CVS services
#
net start cvsnt >> $log
net start cvslock >> $log

#
# write footer
#
write "`r`n`r`n" (stars) >> $log
write "Backup procedure finished at " `
      ([datetime]::Now.ToString()) >> $log
write (stars) >> $log

write "Backup done. Check log file for details."
write $log

Here's the source as well.

Backing Stuff Up

Link. February 1, 2008. Comments [0]. Posted in: Personal | Tools

Jeff Atwood's post on backup strategies made me reflect on what I was doing myself to keep my data safe. I don't really have a "backup strategy", though I do try to keep a good backup around (and I'm always careful to, for example, backup my laptop when I'm traveling with it).

But definitely, I have some major holes in my current backup management. Currently, I have a very simplistic backup procedure:

  1. Every once in a while I back all my really important files (mail, pictures, documents and so on) over to an external drive that I usually keep connected to my laptop. My backups aren't really huge, so I can easily keep two versions around.
  2. Every once in a while (less often) I do a second backup into a 20GB small external drive (what used to be an Archos Gmini 120 MP3 player, now formatted using NTFS). This is small enough that I can easily put this somewhere else as a good second level backup.
  3. Regularly I do a third copy of my data into a DVD (yes, the backup of my core stuff still fits in a DVD with a bit of compression).

For (1) and (2) I've been using Microsoft's SyncToy for a number of years, and for the most part it usually works OK (as long as you don't have too many read-only files and make sure no files are in use). It's not perfect, but it does the trick, though I guess I could easily replace it with a batch file and robocopy.

There's one thing I haven't covered yet in my backups: Source Code. Actually, this is for the most part easy because most of it is in source control already, so I don't have too much of a need to back it up explicitly (and most of it is my client's servers, so I don't have to take care of it). I do keep a local CVS repository (yes, one day I'll migrate it off that, I promise!), which I do backup regularly as part of my backup sets.

Though these simple mechanisms have worked for me so far, there are a few significant things I'd definitely like to improve:

  1. I'd definitely like to start keeping more offsite backups, and more often.
  2. I don't currently backup a number of things, particularly my music collection (ranging around 40GB now). If I lost it, I could rebuild it from a number of sources (CDs, emusic catalog and so on) but I would still lose some of it. Still, backing up that much data is a hassle. I'll probably end up getting a second large external drive for this once I finally get a desktop machine.

A while ago I had given Mozy a quick try, and rather liked the idea. The problem at that time was that our internet access here in Colombia still isn't all that very good (unless you're willing to pay very large sums of money for it). Specifically, we have very crappy upload speeds, which pretty much made a service like Mozy impossible to use effectively.

Recently, after our local phone company started getting some competition this has changed a bit, and now they have doubled our upload speeds to a whooping 256Kbps (on good days!), so I decided to give Mozy a try again. It took all day, but I was able to create and upload a new 850MB backup of some of the most important stuff (mostly documents and such), so at least this gives me hope that I can start using this more effectively now. We'll see.

About

Tomas Restrepo is co-founder of devdeo. His interests include .NET, Connected Systems, PowerShell and, lately, dynamic programming languages. More...

email: tomas@winterdom.com
msn: tomasr@passport.com
twitter: tomas_restrepo

Technorati Profile

devdeo logo

View my profile on LinkedIn

MVP logo

Syndicate

Ads


Links

Categories

Statistics

Total Posts: 1006
This Year: 76
This Month: 7
This Week: 0
Comments: 771

Blogroll

Post Archive

Other

Copyright © 2002-2008, Tomas Restrepo.

Powered by: newtelligence dasBlog 1.9.7174.0

Sign In