You are viewing knowbody

Sat, Apr. 2nd, 2011, 01:02 pm
How I Lost 25 Pounds in a Month Without Exercising

How Things Got So Bad
Since joining Microsoft back in mid-2006, my weight skyrocketed about 15% or 30 pounds. A large part of this can be attributed to the abundance of unhealthy, free food at Microsoft, but that’s only half of the story. When I worked at University of Calgary, I had to walk at least a mile and a half each day to get to and from various transit points. Now, the parking lot is at best 50 meters away from my building. While I might have complained about walking around in -20 degree weather in Canada, I really had no idea how good it was for my health. Up until recently, I didn’t know just how bad Microsoft’s free perks such as unlimited soda and the constant supply of junk food outside co-workers' offiices were really harming me either. That said, my health is my own responsibility and I shouldn't have listened to the demons in my head that kept telling me to eat more.

The Scare
Flash forward to January 2011. An annual check-up revealed that my “fatty-liver” condition (human equivalent of foie gras) diagnosed in 2008 had progressed such that I now have either gallstones or possibly even a growth in my gallbladder. I was only 30 at the time! Any ways, this was exactly the ‘scare’ I needed for a major lifestyle change. My amazing wife letting me know that my snoring had gotten far worse since moving to Seattle wasn’t enough. Fear of cancer and Microsoft’s announcement that our 100% healthcare would disappear in two short years skyrocketed me into action.

Douglas Crockford
By chance, I came across a wonderful blog post, http://www.crockford.com/pwl/, by Douglas Crockford which explained our society’s current obesity epidemic and gave some awesome advice on losing weight. If you haven’t read this post before, I highly recommend it as it’s quite logical and well thought-out. 
 
Dr. Sandra Cabot  
Concurrently, I was also trying to abide by Dr. Sandra Cabot’s advice she gave in her book, the Liver Cleanse Diet. The basic premise of the book is that the liver is solely responsible for removing fat from the bloodstream, and an unhealthy liver implies you’ll pack on the pounds. Well, the way my “fatty-liver” was diagnosed was via blood tests looking for chemicals the liver releases when it’s under duress.
 
The Lifestyle Changes
What exactly did I do to lose the 25 pounds you ask? It was a combination of the Liver Cleanse Diet, Doug’s advice, and strong support from my wife:
  • No more sausage biscuits for breakfast. Instead, my wife or I typically juice apples/carrots/celery/kiwi/etc. or eat a bowl of oatmeal followed by a cup of black coffee
  • Replaced Indian food, pizza, and burgers for lunch with either a low-fat salad or a turkey (Subway) sub. The former set is incredibly high in fat
  • Take double the daily recommended amount of Milk Thistle, a herb purported to protect the liver
  • I used to eat 90% meat/cheese/dairy/flour for every meal, and perhaps 10% were fruits and vegetables. Now more than 50% of my food intake comes from fruits and vegetables
  • Portion control, portion control, portion control. My wife’s culture “loves you with food” which needed to change to “love you with less food”
  • Limited my intake of fats to those found in avocadoes, nuts, and lean poultry. It was hard to give up cheese and red meat, but it has paid off
  • Severely restricted my intake of alcohol. While it doesn’t necessarily add fat to my bloodstream, it does hurt one’s liver. Over the course of three months I’ve had a grand total of four beers
  • Severely restricted my intake of refined sugar. Had only one coke in three months and all the oatmeal cookies I’ve eaten have been low-sugar and low-fat. Have had a few peanut butter and honey sandwiches though
  • For two weeks I took a commercial (As Seen on TV) product called the “The Cleaner”. Basically just pop some pills every day and have weird looking bowel movements
  • This is perhaps the most difficult, yet also the most important facet of my diet – do a gallbladder cleanse. After finishing “The Cleaner”, one evening I downed 1.25 cups of the finest cold-pressed olive oil I could find chased by 1 cup of fresh lemon juice; all over the course of three hours. If you want to do this, be forewarned the next day will not be fun by any means. I didn’t *really* start shedding weight like crazy until after the gallbladder cleanse
  • I even jumped off the wagon for four days while on a business trip last month and have lost five pounds since then!
 
The Benefits
Now onto the benefits I’ve seen thus far:
  • the look of shock from people who haven’t seen me in a while
  • a recent blood test indicates my liver function is back to normal
  • a sleep study performed after I’d lost about 15 pounds showed I was no longer snoring excessively nor breathing incorrectly
  • my brain is operating at a frequency I quite honestly haven’t experienced since 2004
  • far less tired yet I’ve also been getting less sleep (i.e., maybe six hours a night)
  • lost 31 pounds to date. After another five I plan on relaxing the diet just a bit

Tue, Aug. 24th, 2010, 03:01 pm
JavaScript Fail


The following snippet:

<html>
<body>

<script type="text/javascript">
document.write(typeof NaN);
</script>

</body>
</html>


produces:

        number 


The type of not a number is number...  Seriously, what were they thinking!?!

*edit*
Far worse is the result of 'parseInt("number")'.  This produces NaN!

Tue, Aug. 10th, 2010, 01:39 pm
Code Coverage Report for IronPython 1.0(ish)

Digging through some old emails when I found this=)


Today's Statistics (2006-08-30)

 

 

Blocks

Source Files

Namespaces

Classes

Functions

Block Delta

[ipy.exe]

Total

1239

2

1

10

90

0

 

Hit

1043

2

1

10

82

0

 

Percentage Hit

84.18 %

100.00 %

100.00 %

100.00 %

91.11 %

0

[IronMath.dll]

Total

1520

3

1

3

173

0

 

Hit

1322

3

1

3

158

0

 

Percentage Hit

86.97 %

100.00 %

100.00 %

100.00 %

91.33 %

0

[IronPython.dll]

Total

84661

185

11

579

8029

0

 

Hit

70176

185

11

534

6311

+7

 

Percentage Hit

82.89 %

100.00 %

100.00 %

92.23 %

78.60 %

+0.01%

[All Components]

Total

87420

190

13

592

8292

0

 

Hit

72541

190

13

547

6551

+7

 

Percentage Hit

82.98 %

100.00 %

100.00 %

92.40 %

79.00 %

+0.01%




Wed, May. 26th, 2010, 03:24 pm
Another Reason I Love PowerShell and Python...

I've been refactoring a ton of scripts lately and today I was doing a simple rename of an environment variable that we'll call "ABC" to "DEFG".  Well in some random batch file there was a snippet similar to:
IF "%ABC%" == "" ( 
    REM Do something
)

REM ...
REM a bunch more cruft
REM ...

IF "%SOME_CONDITION%" == ""

    REM Do something else
)

 
Astute observers will notice the "Do something else" piece is incorrect as the left parenthesis needs to be on the same line as the IF statement for this to work.  For some reason I cannot fathom though, Windows allowed this mistake to run correctly.  Well as soon as I did a global search/replace on "ABC" to "DEFG", lo and behold Windows decided this was in fact a grammar mistake.  Spent an hour or so digging through "a bunch more cruft" (quite more significant than the three lines I've abstracted it to be) to figure out what the underlying issue was.

Writing new scripts for MS Windows?  Please do yourself a favor and use PowerShell, IronPython, or even Perl to save yourself and maintainers of your code future troubles:)

Mon, Apr. 12th, 2010, 11:26 am
Top Three Reasons to Upgrade to .NET 4.0 Today

Startup Time for IronPython 2.6.1 for .NET 4.0 is 30% Faster




Where exactly is this improvement coming from?  Well we don't know quite yet.  Our first bona fide .NET 2.0 SP1 versus .NET 4.0 IronPython perf suite run occurred less than two weeks ago!  An educated guess is that at least a small portion of this improvement stems from the fact that Microsoft.Scripting.Core.dll is actually part of the .NET 4.0 framework.  Any ways, you can see more of the performance characteristics of IronPython running under both these .NET releases here


Beautiful is better than Ugly and Simple is Better than Complex

.NET 2.0 SP1 versus .NET 4.0 DLR Hosting APIs
 
The screenshot above shows a small C# snippet of code utilizing a Python module both as a .NET 3.5 application (top) and as a .NET 4.0 application (bottom).  Both of these snippets have been diffed to highlight differences in red. 

It should be blindingly obvious that the bottom snippet is far more readable due to the use of C# 4.0’s new dynamic type.  What the hell’s an “IDynamicMetaObjectProvider” supposed to be any ways?  In any event, our DLR and IronPython hosting APIs are adhering more to the Zen of Python with each release.


Python and Ruby Play Nice Together

Command Prompt
 
In the Command Prompt session above, I’ve created a trivial Ruby class, RubyPC, which provides a factorial method, fact, in rbfactorial.rb.  From there, I started an IronPython interactive session and directly called into the rbfactorial Ruby script via our clr builtin Python module.  Let’s see you do that from other implementations of Python:-)

IronPython 2.6.1 for .NET 4.0 and IronRuby 1.0v4 are the first two major releases of these dynamic languages that share the same Dynamic Language Runtime pedigree.  The end result of this is that they interop together quite nicely out of the box with one small caveat:  you just need to copy “IronPython-2.6.1-Src\IronPython-2.6.1\Config\Signed\App.config” from the source or binary zip file releases to “%ProgramFiles%\IronPython 2.6 for .NET 4.0\ipy.exe.config” and/or “%ProgramFiles%\IronPython 2.6 for .NET 4.0\ipy64.exe.config”.  This configuration file tells IronPython which version of IronRuby it needs to load, and we simply forgot to include this file in the IronPython MSI installer. 


NOTES

Thu, Feb. 4th, 2010, 12:11 pm
Poor Man's PowerShell Linecount Tool

This obviously doesn't account for empty lines, comments, etc., but it works:)

function get-numlines($filter) {
    $num_lines = 0
    ls -recurse -filter $filter |% {gc $_.FullName | measure-object} | % {$num_lines+=$_.Count}
    return $num_lines
}

get-numlines *.py


Sat, Dec. 26th, 2009, 04:53 pm
Mom's Chicken-fried Steak Recipe

  • Cube Steak or beef steak that you tenderize
  • Salt and Pepper
  • Buttermilk
  • Egg
  • Flour
  • Oil

Begin heating oil as soon as the meat is tenderized. Take tenderized steak (cube steak) and salt and pepper both sides to taste. Dip meat in flour to cover on both sides. Shake off excess. Beat egg into buttermilk. Dip flour covered meat in egg mixture covering well. Dip meat back into flour. Test oil by dropping a small drop of water in it. If it splatters, it is hot enough. Place meat into hot oil and fry on one side until brown. Turn meat and cook on other side until brown. Check for doneness. Turn and fry some more if needed. Sometimes a salt and pepper the flour too. I use bacon fat for deer steak or any wild meat. I like it for beef too, but it is not always available.

Fri, Nov. 20th, 2009, 10:16 am
IronPython 2.6 RC 3

http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=36150

This release contains a few small Silverlight fixes, with basically zero changes to the Desktop version of IronPython. Hopefully third time's a charm.

Tue, Oct. 27th, 2009, 02:10 pm
IronPython 2.6 Part Deux Released


http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=34451

Well assuming no major problems are found this release, I should in theory have some time for more IronPython blog entries in about a month.  Let's see what happens...

Thu, Oct. 22nd, 2009, 01:11 pm
Uninstalling "IronPython 2.6 CTP for .NET 4.0 Beta 1" without .NET 4.0 Beta 1 Installed

We've heard from a few people in the last week that they're having trouble uninstalling our community technology preview of IronPython running under .NET 4.0 Beta 1 if the installation of .NET 4.0 Beta 1 has been removed or replaced in some fashion.  Basically what's going on is that a prerequisite for running IronPython.msi (whether you intend on installing/repairing/removing it) is the presence of a very specific version of .NET - namely v4.0.20506.  The tie in to this .NET 4.0 release means that even with an install of .NET 4.0 Beta 2, you'll be unable to remove the IronPython CTP for Beta 1 cleanly unless you also have .NET 4.0 Beta 1 installed concurrently (is this even possible I wonder...).

There's at least one alternative to removing "IronPython 2.6 CTP for .NET 4.0 Beta 1" if you no longer have access to .NET 4.0 Beta 1 on your machine.  Basically you'll just need to remove the related installation directory and shortcut menus by hand.  Also, there's those pesky registry entries that don't have to be removed, but can be if you prefer. 

Disclaimer
While the info presented below on removing "IronPython 2.6 CTP for .NET 4.0 Beta 1" without using the uninstaller from the Control Panel should work on just about anybody's machine, the steps were tested on a single 32-bit Windows 7 machine.  There's at least a trillion ways your machine(s) may vary from the test box, and not only may some steps not work...they could even hurt your machine!  Proceed with caution...

Step 1 - Remove the Installation Directory
Assuming you accepted the default installation directory for the CTP, you'll have either "%ProgramFiles%\IronPython 2.6 CTP for .NET 4.0 Beta 1" or "%ProgramFiles% (x86)\IronPython 2.6 CTP for .NET 4.0 Beta 1".  Simply open a command prompt as an Administrator and remove this directory:
    rmdir /s /q "%ProgramFiles%\IronPython 2.6 CTP for .NET 4.0 Beta 1"

Step 2 - Remove the Shortcut Menu
The shortcuts to the CTP's ipy.exe should be in "%ProgramData%\Microsoft\Windows\Start Menu\Programs\IronPython 2.6 CTP for .NET 4.0 Beta 1".  Verify the presence of this directory, open a command prompt as an Administrator again, and remove the directory:
    rmdir /s /q "%ProgramData%\Microsoft\Windows\Start Menu\Programs\IronPython 2.6 CTP for .NET 4.0 Beta 1"

Step 3 - "Fix" the registry
Background: as of today no IronPython release uses *any* information found in the registry.  There's .NET key/value pairs that could affect the runtime behavior of IronPython (e.g., NGen'ing), but these are not directly utilized by IronPython.  In effect, the only reason to follow this step is to remove "IronPython 2.6 CTP for .NET 4.0 Beta 1" as an option from the "Add/Remove Programs" portion of the Control Panel.  While the previous steps have very little chance of screwing up your machine, most people know that messing with the registry can cripple your box if you're not careful.  If I haven't scared you off yet...

  1. Run "regedit" from an elevated command prompt
  2. Press Ctrl-F and do a search on "IronPython 2.6 CTP for .NET 4.0 Beta 1". Keep searching (via the F3 key) until you find something like Computer\HKEY_CLASSES_ROOT\Installer\Products\70089FC31E5E8B340817C3CA5F82E45D containing keys such as ProductName, Version, etc.  Remove the directory which contains these keys and "IronPython 2.6 CTP for .NET 4.0 Beta 1" will be uninstalled as far as the Control Panel is concerned
  3. There are other keys in the registry with respect to the CTP Beta 1 release.  My guess is that these are perfectly harmless to remove, but I wouldn't advise removing them

Thu, Aug. 27th, 2009, 04:16 pm
What do you want to know about IronPython?

While I've been waiting for a huge build to finish unzipping on a shiny new Windows 7 test machine, I've been looking over my own and other IronPython team members' blogs.  I've come to the conclusion that there are far more comments for posts not dealing with Python, and in many cases the IronPython posts aren't getting any comments at all.  The missing interaction isn't necessarily limited to technical posts either from what I've seen.

Is this because we're doing a great job at covering IronPython topic xyz or because xyz just isn't that interesting?  If it's the latter, what would you like to see more of and less of?

Wed, Aug. 26th, 2009, 03:53 pm
Cited in a dissertation?

Looks like a talk/paper I gave on distributed object simulation frameworks at the ICALEPCS (The International Conference on Accelerator and Large Experimental Physics Control Systems) conference back in 2005 was cited in what appears to be a computer science dissertation.  Sweet

12 most recent