Archive

Archive for the ‘Life’ Category

Windows command-line regular expression renaming tool: RenameRegex

January 30th, 2012

Every once in a while, I need to rename a bunch of files.  Instead of hand-typing all of the new names, sometimes a nice regular expression would get the job done a lot faster.  While there are a couple Windows GUI regular expression file renamers, I enjoy doing as much as I can from the command-line.

Since .NET exposes an easy to use library for regular expressions, I created a small C# command-line app that can rename files via any regular expression.

Usage:

RR.exe file-match search replace [/p]
  /p: pretend (show what will be renamed)

You can use .NET regular expressions for the search and replacement strings, including substitutions (for example, “$1″ is the 1st capture group in the search term).

Examples:

Simple rename without a regular expression:

RR.exe * .ext1 .ext2

Renaming with a replacement of all “-” characters to “_”:

RR.exe * "-" "_"

Remove all numbers from the file names:

RR.exe * "[0-9]+" ""

Rename files in the pattern of “123_xyz.txt” to “xyz_123.txt”:

RR.exe *.txt "([0-9]+)_([a-z]+)" "$2_$1"

Download

You can download RenameRegex (RR.exe) from here.  The full source of RenameRegex is also available at GitHub if you want to fork or modify it. If you make changes, let me know!

New Adventures: Why I’m Leaving Microsoft and What’s Next

September 14th, 2011

Six years ago, fresh out of college, I packed up my life into a couple of moving boxes and headed out to the Pacific Northwest to take a job at Microsoft.  Since then, I’ve been lucky enough to work on some amazing projects – a large scale performance validation infrastructure for Windows 7, a world-class browser, and have helped shape the future of the web by collaborating in the W3C webperf working group.  It’s been a great place to work – I’ve made some amazing friends, learned more than I ever would have imagined, and have been often humbled by how amazing my coworkers are.

This Friday will be my last day at Microsoft.  It was a tough decision to leave, and there are many things I will miss about the company, my work, and my coworkers.  Microsoft is a great company, the benefits are amazing, and you get to work with a ton of awesome people.  I’ve grown in so many ways by just being able to interact with and learn from my coworkers.  I’ll miss those interactions.

On the other hand, for the past fifteen years, I have been building software, websites, and now mobile apps in my spare time.  I’ve always used these side projects to satisfy a need to be creative, to learn and explore new technologies, and to have fun.  Some of these projects have grown beyond what I would have ever expected them to be.  It’s been tough finding time to work on them – after a long day of mind-bending work, staring at a monitor for another couple hours isn’t always at the top of my list of things to do.  But I get a lot of pleasure out of being creative, so I’ll often stay up late working on this or that.

And so, I’ve always wondered what I could accomplish if those projects were my only job?

Starting Monday, I am taking the big, scary step of becoming my own boss.  I’m still not 100% sure what that means, and I’ll let you know a year from now how it has worked out.  I’m excited to build, to be creative, to learn, and to share.  It’s time for me to get serious about some of the projects I’ve already put hundreds of hours into and to take them to the next level.

In addition to those projects, one of my passions is performance, on both the desktop and the web.  My focus at Microsoft was on perf features and analysis, where I developed a massive performance regression testing system for Windows 7.  I built performance features for Internet Explorer 9, and collaborated in the W3C webperf working group.  I hope to continue learning, exploring and even teaching others about performance in the future, through research and experimentation with my own projects.

There are a ton of things I want to accomplish, and I know I’ll have to work hard to provide for my family.  It’s not easy walking away from a comfy salary and great benefits, with the knowledge that you have to make up for all of it on your own.  Thankfully I have a head start with some successful websites and apps, but I know I’m going to have to put a lot of hard work into taking them to the next level.

Wish me luck.

My attempt at being environmentally friendly, day 2

January 3rd, 2007

So after being inspired to reduce my energy usage, I took a look at buying Compact Fluorescent Light bulbs (CFLs) for my apartment.

CFL

CFLs are recently becoming popular in home lighting, and can provide substantial energy savings over their lifetime. They can replace almost all of your existing light bulbs in your house.

CFLs:

  • Use 2/3 the energy of normal bulbs
  • Last up to 10 times longer
  • Generate up to 70% less heat

They do come at a higher initial cost. However, as I was shopping for CFLs at Home Depot, I noticed coupons from Puget Sound Energy for $2 off (small) and $3 off (large) per bulb, limit of 8 of each size. That saved me (8 * $2 + 8 * $3) = $40 in bulbs, so I retrofitted my entire apartment, 16 bulbs for $32!

After replacing all of the bulbs in my apartment, I am quite happy. Their lighting output is the same (to the naked eye) as the old bulbs. The energy savings are substantial. Before and after wattages (verified with the Kill-A-Watt):

  • 1x floor lamp – 140W before, 21W with CFLs
  • 1x night stand lamp – 90W before, 14W with CFLs (60W equivalent)
  • 3x bathroom mirror lights – 60W before, 14W with CFLs
  • 4x dome lights – 60W before, 14W with CFLs
  • 6x track lights – 60W before, 14W with CFLs
  • Total: 1010W before, 217W with CFLs

PSE charges me about $0.06841 per kWh. (not that I do), but if I ran all of these lights 24/7, I would be spending (1010W * 24 h * 30 days * 0.06841) = $49.73 / mo. With CFLs, this is reduced to (216 W * 24 h * 30 days * 0.06841) = $10.63 / mo. So while that isn’t realistic, as I don’t have all my lights on all of the time, I’m probably saving a few dollars a month.

Cool stuff!

My attempt at being environmentally friendly, day 1

January 3rd, 2007

An Inconvenient Truth

I had been meaning to check it out for a while, so I finally watched An Inconvenient Truth (on my Zune! great for a coast to coast flight) on the way back to Michigan before Christmas. I would definitely recommend watching it, then doing some research on your own afterwards. There is a Wikipedia article with some good references for further information as well.

ClimateCrisis.net has an interesting calculator to determine how much CO2 emissions you produce annually (I’m estimated at about 10.2 tons of CO2 per year, mostly due to flying every month). In an attempt to lower my impact on the environment, I’ve dug out my P3 Kill-A-Watt I bought last year after reading about it on Coding Horror.

P3 Kill-a-Watt
The $25 Kill A Watt is a sweet little device that you can use to measure the energy consumption of various things in your house. You just plug this into your wall first, then your appliance into it. It shows current volts, amps, watts, kWh, etc.

I went on an energy census of my various electrical devices, and found some interesting things:

Appliances
* Mini refrigerator (average): 20W
* Coffee grinder: 67W
* Toaster oven: 1470W

Fans
* Bedroom tower fan: 25W low, 38W high
* Living room tower fan: 30W low, 37W high, 37W high+oscillation

Lighting
* Bedroom tower light: 140W, 21W w/ CFL
* Bedroom desk lamp: 90W, 13W w/ CFL
* CPU desk lamp: 20W
* Living room tower light: 165W low, 300W high
* Bathroom mirror (3x): 60W, 14W w/ CFL
* Dome lights (4x): 60W, 14W w/ CFL
* Kitchen, living room track lights (6x): 60W, 14W w/ CFL

Misc
* Zune charging w/ iPod adapter: 2W
* Jabra (headset) charging: 0W
* MotoQ (cellphone) charging: 2W
* Alarm clock: 0W

Electronics
* Main computer: 190W
* Shuttle (Media Center) computer: 140W
* 17″ LCD: 45W
* 21″ LCD: 40W

* Comcast DVR: 43W off, recording, or playing
* Xbox 360: 275W @ dashboard, +4W if a 1-4 wireless controllers active
* TV: 87W
* Amp: 72W idle or playing content
* Playstation 2: 29W

Interesting stuff! I was surprised that my 21″ LCD took less energy than the 17″ LCD. The 17″ LCD is older (a year or two), and is also running VGA (instead of DVI on the 21″). Would that be why?

There are other devices that I didn’t quite measure that I’m sure account for a good percentage lot of my electrical usage (refrigerators, microwave, washer, dryer, dish washer) as well. Here‘s a good estimator for those appliances.

Tomorrow’s adventure is converting my apartment to Compact Fluorescent Lights (CFLs).

Performance Optimization WordPress Plugins by W3 EDGE