Scott Hanselman

Coding4Fun Hardware Webcast

May 1, '06 Comments [4] Posted in Coding4Fun
Sponsored By

SmallwebcastUPDATE: The time is Friday at 10AM PST. Blog Readers note, this is a 100 level cast, not a 300 level cast, so set your expectations accordingly.

I'm giving a webcast based on the Coding4Fun Some Assembly Required articles this Friday 10AM PST. You can register for this Live Webcast now.

I'll be talking about how to use the System.IO.Ports namespace in the Microsoft .NET Framework 2.0 as an interface with most devices such as global positioning system (GPS) receivers and LCD screens. Stop by as we discuss the challenges of writing applications that interface with USB devices, the power of Windows Image Acquisition (WIA), and the joys of HTTP.

Should be a nice way to spend lunch. Of course the demos will likely be less impressive since you won't be able to see the hardware, but maybe I'll try to make up for it with photos.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Making Negative Numbers turn Red using CSS and Javascript

May 1, '06 Comments [9] Posted in ASP.NET | Javascript
Sponsored By

A common thing one wants to do in a table of financial figures is to turn negative numbers red. Given that folks would rather use CSS than <font>, there's some conflicting thinking around the right way to do it.

Some propose adding "negative" a css class like:

<TD CLASS="financial negative">-190</TD>

but others find that distasteful and say:

  • number is a data type.
  • currency is both a presentational instruction and a sub-type of the number data type.
  • negative is neither type nor presentational — it’s dependent on the data value, not the type or the author’s formatting preference. It doesn’t belong there. [Xaprb]

and go on to provide a clever CSS-only technique that works everywhere but IE6 (demo here).

In the specific situation I've got, I'd like to make the change without changing any server-side code (which precludes adding a "negative" css class) and I need it to work everywhere (which nixes clever css).

So, here's my not-so-clever Javascript solution (Warning, I'm not a Javascript guy so give Phil a few minutes and he'll no doubt include color commentary).

<html>
<head>
    <style type="text/css">
     td.negative { color : red; }
    </style>
    <script language="JavaScript" type="text/javascript">
    <!--
    function MakeNegative() {
        TDs = document.getElementsByTagName('td');
        for (var i=0; i<TDs.length; i++) {
                var temp = TDs[i];
                if (temp.firstChild.nodeValue.indexOf('-') == 0) temp.className = "negative";
            }
    }
    //-->
    </script>
</head>
<body>
 <table id="mytable">
  <caption>Some Financial Stuff</caption>
  <thead>
    <tr><th scope="col">Date</th><th scope="col">Money is good</th></tr>
  </thead>
  <tbody>
  <tr><td>2006-05-01</td><td>19.95</td></tr>
  <tr><td>2006-05-02</td><td>-54.54</td></tr>
  <tr><td>2006-05-03</td><td>34.45</td></tr>
  <tr><td>2006-05-04</td><td>88.00</td></tr>
  <tr><td>2006-05-05</td><td>22.43</td></tr>
  </tbody>
 </table>
    <script language="JavaScript" type="text/javascript">
  <!--
   MakeNegative();
  //-->
    </script>
</body>

May not be Web 2.0, and it likely doesn't please the standards wonks, but it works.

UPDATE: Similar attempt seen here.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

ASP.NET MVP Hacks

April 30, '06 Comments [5] Posted in ASP.NET | TechEd | ViewState | HttpHandler | HttpModule
Sponsored By

0764597663.01._SCLZZZZZZZ_V52483501_David Yack got a bunch of folks together and assembled ASP.NET 2.0 MVP Hacks from Wrox. Take a look at the picture on the right, totally looks like we're all in the same room with our twelve-sided dice, no? ;)

Seriously though, it's a good collection of "messing with ASP" hacks. I did the sections on HttpHandlers/HttpModules and the ViewState hacks. Some of the content came from my blog. I also pulled in content, with permission and attribution from a number of other smart ASP.NET blogs. Most hacks work on both ASP.NET 1.x and 2.0 as well.

A book with a Brady Bunch cover full of nerds, yes.

A book with a lot of slick hacks, totally.

Big ups and congrats to David for pulling it all together, he's really been working hard on this book and I'm happy to have been involved along with the other (very seasoned) authors David Yack, Joe Mayo, Fredrik Normén, Dan Wahlin, J. Ambrose Little, and Jonathan Goodyear.

ASP.NET 2.0 MVP HacksProfessional ASP.NET 2.0
Total List Price: $89.98
Buy Together Today: $57.88

If you're looking to get this and Pro ASP.NET 2.0, the total price is only $57.88 on Amazon right now as a bundle. To be clear, the content in these two books doesn't overlap. The Hacks book is focused on specific and finite tips, tricks, and undocumented features and manipulations of ASP.NET Features, while the Pro ASP.NET book starts with fundamentals and builds feature by feature to advanced topics advanced to Professional ASP.NET 2.0 developers.

 

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Replacing Explorer.exe - The Return of Norton Commander with xplorer2 and FAR

April 30, '06 Comments [19] Posted in Reviews | PowerShell | Tools
Sponsored By

Far1"The Norton Commander is the most useful DOS program ever written" says the Commander Homepage, a site dedicated to Norton Commander. And true it is. NC was flippin' fabulous. I used the crap out of that program. You think I'm fast now, back in day™ I was fast as lightning on a stac'ered 386sx. Those were the days.

Misha Bergal emailed me recently reminding me of FAR, a text-mode Norton Commander clone with Windows long filename support. Wow, takes me back.

Sure, PowerShell is a better shell. The best ever, even, there's no question of that (Seriously, get on board, the PowerShell is poised to take over the planet, but I digress...) but if you really want to stop dragging files around in Explorer and start doing some serious damage, take a look at these potential additions to your tools list.

The first is FAR and the real story is it's plugin support. Some of my favorite features? Start it up and press Ctrl-UpArrow for a while, then Ctrl-DownArrow. Now try Alt-F9. Try Ctrl-W. It'll take a while to get used to, but wow, you can fly once you've taken off.

Xplorer1

My other favorite Explorer Replacement is xplorer2 from Zabkat. There's so much goodness in xplorer2 I will have to blog about it separately. It's got the same familiar Norton Command dual-pane view with the quick switching with "Tab" feature. It has integrated file preview and all the things you'd expect, but also throws in a great folder synchronizer, an amazing "mass file rename" token language for those large tricking bulk renames, rule-based file section, a macro language and it starts up faster than a new explorer window.

Both of these great tools are bound to hotkeys on my systems and make my life easier.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Mourning Monad - This whole Monad, MSH, Microsoft Command Shell, PowerShell thing is tearing me up inside

April 28, '06 Comments [7] Posted in PowerShell
Sponsored By

PowerShellThis whole name change thing is tearing me up.

Note the screenshot at the right while searching Microsoft.com for "Powershell." Even Microsoft.com isn't comfortable with the name change.

If you're having trouble getting the downloads as no search engine, even Google, is willing to give up the goods when searching for "PowerShell" or "John Smith" or other fantastically descriptive names, here they are:

I did set up a SlickRun shortcut to PowerShell as well as a msh.bat file in my Windows Folder so I could "moosh" my way to denial.

Here's what I'm going through as Monad becomes Powershell. Or, is it PowerShell? PowerShell! POWerSHELL!

1 - Denial - "this can't be happening to me", looking for former shortcuts or files in familiar places. Setting the table for Monad or acting as if he is still living here. Not crying. Not accepting or even acknowledging the loss.

2 - Anger - "why me?", feelings of wanting to fight back or get even with Monad, for death, anger at the deceased, blaming them for leaving.

3 - Bargaining - bargaining often takes place before the loss. Attempting to make deals with the shell who is leaving, or attempting to make deals with God to stop or change the loss. Begging, wishing, praying for them to come back.

4 - Depression-overwhelming feelings of hopelessness, frustration, bitterness, self pity, mourning loss of Monad as well as the hopes, dreams and plans for the future. Feeling lack of control, feeling numb.

5 - Acceptance - there is a difference between resignation and acceptance. You have to accept the loss of Monad, not just try to bear it quietly. Realization that it takes two to rename a command shell. Realization that Monad is gone (as in death) that it is not Monad's fault, they didn't leave you on purpose. Finding the good that can come out of the pain of loss, finding comfort and healing. Our goals turn toward personal growth. Stay with fond memories of Monad.

Sigh. Come here, PowerShell, gimme an uncomfortable heterosexual hug.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.