There are certain things that I guess make me weird.. green.. hippie-ish? These few save money and resources so they’re green and money saving.

10. Wear an outfit twice before washing it.

.: Now I know this may sound gross, gnarly, grody. However, hear me out, if you work in an office and you haven’t managed to work up a sweat then your pants, shirt, and tie don’t need to go through the wash. You’ll save water which helps the planet and your wallet. Next you’ll save on detergent, fabric sheets and other cleaning products. Lastly you will save electricity and natural gas. I’m not saying wear you undies twice… That’s just nasty! But when was the last time you worked up a sweat in your day to day at the office?

9. Use mother natures coolant, and turn your air off before you leave.

.: This relates back to the fact that you can wake up pretty early, say six in the morning. This shouldn’t be strange if you’re a working stiff. On most nights/early mornings, it is pretty cool outside at 6:00am. Put several fans in your windows to pull the cool air in and vent the nights gases out. You won’t be living in a tight box of germs because you’re getting some air circulation and you just cooled off your whole house. Then once you are done grabbing all that fresh cool air, close the windows up and the blinds. This should keep the house cool at least until noon. By 5:00, depending on where you live the house won’t be too hot. Programmable thermostats may help, but those aren’t “easy” to install.

8. Re-use packaging in the kitchen.

.: You know those plastic bags that have the super awesome lock tight seal and are super expensive because of that? Well, are you throwing them out after just one use? Here is an idea, just save the bag, wash it out and re-use it. If you’re just storing fruits and veggies or a sandwich in them then just wash and re-use. If, however, you have stored meat in one of those bags, toss it. Cross contamination is not a fun night.

7. Turn lights off and use natural light.

.: I can’t tell you how many times I’ve been over to someones house in the middle of the afternoon. The shades were drawn and they had almost every light in the house on. Lights off, blinds open, money in pocket! If you are worried about the sun heating up the house open blinds to windows where the sun will not shine in.

6. Donate all but one TV.

.: I know… I know… it’s like I just swore at you and told you that your first born child is an ugly duckling. However TVs use lots of energy and typically you will have a light on in the room that you are watching TV. So you can save money and energy by powering only one TV and light. Your family will actually be stuck with you and have to be in the same room, or find hobbies and actual ways to entertain themselves. TVs do not belong in bedrooms. You wouldn’t put your bed in the family room would you? So, one TV, closer family, fatter wallet, and Captain Planet won’t attack you.

5. Turn off computers when you are not using them.

.: This one used to not be such a big problem, however with the up and coming generation it is starting to be. Here is a fine example. I had a computer that I kept on all the time. It broke, funny enough the power supply died. It wasn’t really a primary computer as I use my laptop most of the time. So I didn’t fix it for a month or two. My electric bill was about $15.00 cheaper for those 2 months. Sleep mode is fine for machines, although the one I had was never set to sleep. However computers still draw power even when they are “asleep” so just shut it down.

4. In the winter wear a sweatshirt to bed and turn the heat down to 65 to 68.

.: This will actually feel better in the long run and let’s face it… There is no reason to be sleeping in your boxers in the dead of winter. Use a warm blanket and wear a sweatshirt.

3. Move the family room to the basement and keep the air off.

.: This may not be as easy to implement and if you don’t have a basement, then it’s impossible. Also this is kind of an extreme measure. However, basements tend to be way cooler than the upstairs. So if you can just sit down there with the family you will all be cooler, saving money and enjoying some time together. Then if it’s still too humid or hot when you go to sleep kick the air back on. You won’t sleep well without it.

2. Let the grass get a little brown.

.: I know! More blasphemy! However grass is pretty resilient, it doesn’t just “die”. So don’t water your lawn every day. Do it only once or twice per week. Sure it won’t be the prettiest lawn out there, but you won’t have to mow as often, water it as much, you’ll save money, gas for the mower, etc. Lawns are actually REALLY expensive to maintain.

1. Use plastic on your windows, if you are living in an older home.

.: Most hardware stores sell plastic that you can use to line your windows. It goes on the inside frame of the window and should help trap that cool or warm air, depending on the season. If you’re worried about how this may look you can just use it on windows that company won’t see. It’s actually a great trick if you don’t have the cash to get a house worth of new windows. Here is a link to what I am talking about 3M 2141W Indoor 5-Window Insulator Kit

The End
That’s all. 10 easy tips in no particular order. Some you are going to find helpful, some are going to make you scratch your head, some will make you think I’m a hippie. However, if you find one or two helpful then I have succeeded. So try one or two out, see how they work for you.

I recently had this problem where I needed to do something to all the items of a certain type in a collection, remove them and continue through what was left.

This error was the result of my endeavors:
System.InvalidOperationException: Collection was modified; enumeration operation might not execute.

I wasn’t looking for lengthy writeups so here’s the code:

Before With For Loop:

   1:  Dim curLst As List(Of String)
   2:   
   3:  For Each item As String In BigStringLst
   4:   
   5:      curLst = BigStringLst.FindAll(AddressOf FindResult)
   6:   
   7:      ' DO SOMETHING WITH YOUR LIST OF STRINGS
   8:      ' AND THE CURRENT ITEM
   9:   
  10:      BigStringLst.RemoveAll(AddressOf FindResult)
  11:   Next

What you’re actually looking to do is use a While loop and remove the items. So while you still have items you want to keep processing. The “Next” item is simply the first item in the collection since the collection is shrinking.

After with While Loop:

   1:  Dim curLst as List(Of String)
   2:   
   3:  While BigStringLst.Count > 0
   4:     Dim item As String = upcLst(0)
   5:   
   6:     curLst = BigStringLst.FindAll(AddressOf FindResult)
   7:   
   8:     ' DO SOMETHING WITH YOUR LIST OF STRINGS
   9:   
  10:     BigStringLst.RemoveAll(AddressOf FindResult)
  11:   
  12:  End While
  13:   

Here is the code for the predicate function used in FindAll and RemoveAll for the List(Of String):

  1:  Private Function FindResult(ByVal item As String) As Boolean
  2:     Return (item = "virtualadrian.com")
  3:  End Function

This code was done for folks that want VB.NET so if you want to get this in C# just use a converter. I prefer this one :

http://www.developerfusion.com/tools/convert/vb-to-csharp/

PS: Obviously I wasn’t searching for strings or doing the simple stuff the example shows. However you should get the idea. Also I wrote this up in Notepad so.. watch for syntax errors :0)

Good Luck !

For some reason I cannot sleep… I got a great chest workout in the other day and last night I got a little too crazy at Kung Fu and did a bunch of pushups. So now my chest hurts like crazy and I’m fully awake for reasons unknown. That said…. I have been messing around with the Phidget servos I received and I must say that going from a realm where the coolest thing I ever do is retrieve a few million rows really fast. Or, make a grid look REALLY cool and apply a filter… or do a pretty picture graph…

Writing stuff that has impact in the physical realm is really cool. The most recent problem I am tackling is my inability to read… My servos turn only 180* and I need 360, fine print, regular print… No match for an excited nerds eyes when he wants to spend money on cool electronic gadgets. So what I’ve done is played with some gearing to turn the 180 to 360. I will post a few pictures once I have things all tidied up and working.

The other thing that I’ve done is I have build a little enclosure for my control board. Now the only task is attaching that to the contraption I am building and maybe looking into hooking up bluetooth communication. Although this is just a prototype so I don’t know how useful that will be.

So between that, this whole Directshow .NET thing I’ve been diving into, and work I’ve been pretty busy. I need to find our Microsoft rep tomorrow and ask him about the direction of Directshow because there seem to be a lot of under-served people out there all trying to code against Directshow for one reason or another. However, the documentation is … meh .. at best and the one book on Directshow is hundreds of dollars and out of print. So if I figure out how to freeze time and read through the Directshow book, I may do a little “follow along with me through my misery series and hopefully we’ll both have a better understanding.” Maybe the Flux Capacitor would help with that time thing? Or… Continuum Transfunctionor?

I know Media Foundation (MF) is supposed to replace Directshow, but it’s missed it’s deadline and feature set from what I’ve been reading so it looks like if you want to write a decent multimedia application then Directshow is still your friend. It would also be really nice if Microsoft provided a library for writing this stuff in C#. It can still be against all the COM components and fast. I’m willing to do some thinking when I write code…

That’s all for now… just randomly ranting.

Adrian.BrainStream.Close();

So the application that I am writing needs to stream from multiple cameras to one screen. I need to do this live, so no need to record the stream. I started doing this with Directshow .NET.

When you download the Directshow .NET library you get a Samples folder as part of the download. Within samples there is a sample called PlayCap. This sample will simply find the first webcam attached to your computer and stream from said webcam. It puts the video out to the whole window. We don’t want that though. So to change where the feed goes we are going to have to understand the code. Warning: We are about to take the scenic route to streaming from two webcams if you don’t care about the code explanation or know enough skip to Part Two ( still typing that part up as of now ) of this little series.

So let’s pop open the code… Also if you haven’t done so, get the sample to just run. That will give you an idea of what I’m talking about. You should only need to have a camera attached to your computer.

Moving on, the first thing we see in the PlayCap code is this :

        // a small enum to record the graph state
        enum PlayState
        {
          Stopped,
          Paused,
          Running,
          Init
        };

This is pretty self explanatory. It is a small enum for maintaining the status of the video, we’ll get into the “difference” between a “graph” and video in a later post and probably another series. Moving on:

        // Application-defined message to notify app of filtergraph events
        public const int WM_GRAPHNOTIFY = 0x8000 + 1;

        IVideoWindow  videoWindow = null;
        IMediaControl mediaControl = null;
        IMediaEventEx mediaEventEx = null;
        IGraphBuilder graphBuilder = null;
        ICaptureGraphBuilder2 captureGraphBuilder = null;
        PlayState currentState = PlayState.Stopped;

This section is fairly simple too. The first line is a constant declaration for the graph notify event that windows will be firing for our WndProc method, we will be overriding that. The next piece again is a series of interface declarations. Their implementation can be anything, although the library provides that.

  • The videoWindow member is our video display.
  • The mediaControl will be maintaining/controlling the status of the video, although in this example it is playing as long as the app is running.
  • The mediaEventEx member is used to capture the graph notify.
  • The graphBuilder member will be putting things together for us, and provide the implementation of some the interfaces.
  • The captureGraphBuilder will be used to help with capture. It may help quite a bit if I explained the different … nomenclature… maybe that will be another post… or maybe I’ll wait to post this until I explain that.
  • Last but not least we declare a PlayState, and by default it is stopped. Don’t worry that will change.

Onward we go:

public Form1()
{
    InitializeComponent();
    CaptureVideo();
}

The form constructor calls the CaptureVideo() method to start the stream. That method is where the magic happens.

protected override void Dispose( bool disposing )
{
            if( disposing )
            {
                // Stop capturing and release interfaces
               CloseInterfaces();
            }

            base.Dispose( disposing );
}

This is the Form disposing method. When the form is being disposed of, we need to clean up so we don’t get any memory leaks. Now! Onto the fun part! You ready ?

    public void CaptureVideo()
    {
      int hr = 0;
      IBaseFilter sourceFilter = null;

      try
      {
        // Get DirectShow interfaces
        GetInterfaces();

        // Attach the filter graph to the capture graph
        hr = this.captureGraphBuilder.SetFiltergraph(this.graphBuilder);
        DsError.ThrowExceptionForHR(hr);

        // Use the system device enumerator and class enumerator to find
        // a video capture/preview device, such as a desktop USB video camera.
        sourceFilter = FindCaptureDevice();

        // Add Capture filter to our graph.
        hr = this.graphBuilder.AddFilter(sourceFilter, "Video Capture");
        DsError.ThrowExceptionForHR(hr);

        // Render the preview pin on the video capture filter
        // Use this instead of this.graphBuilder.RenderFile
        hr = this.captureGraphBuilder.RenderStream(PinCategory.Preview,
                                         MediaType.Video, sourceFilter,
                                         null,
                                         null);
        DsError.ThrowExceptionForHR(hr);

        // Now that the filter has been added to the graph and we have
        // rendered its stream, we can release this reference to the filter.
        Marshal.ReleaseComObject(sourceFilter);

        // Set video window style and position
        SetupVideoWindow();

        // Add our graph to the running object table, which will allow
        // the GraphEdit application to "spy" on our graph
        rot = new DsROTEntry(this.graphBuilder);

        // Start previewing video data
        hr = this.mediaControl.Run();
        DsError.ThrowExceptionForHR(hr);

        // Remember current state
        this.currentState = PlayState.Running;
      }
      catch
      {
        MessageBox.Show("An unrecoverable error has occurred.");
      }
    }

So since this is where all the magic happens I am going to go line by line and then post the corresponding method if needed. That being said the first call we see is to a method called GetInterfaces(). This method just sets up your interfaces you declared above, instantiating them. The method looks as such:

    public void GetInterfaces()
    {
      int hr = 0;

      // An exception is thrown if cast fail
      this.graphBuilder = (IGraphBuilder) new FilterGraph();
      this.captureGraphBuilder = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();
      this.mediaControl = (IMediaControl) this.graphBuilder;
      this.videoWindow = (IVideoWindow) this.graphBuilder;
      this.mediaEventEx = (IMediaEventEx) this.graphBuilder;

      hr = this.mediaEventEx.SetNotifyWindow(this.Handle, WM_GRAPHNOTIFY, IntPtr.Zero);
      DsError.ThrowExceptionForHR(hr);
    }

The first thing declared is the hr variable. That is an integer indicating a response being fed back from a call to a COM component. If you look toward the end of the method there is a call to DsError.ThrowExceptionForHR if your response is not zero then there was an error and the hr variable has the error code. DsError just throws an exception based on the error code. Meanwhile… back at the batcave the CaptureVideo() is still running…. The next call that is of interest is this:

        // Use the system device enumerator and class enumerator to find
        // a video capture/preview device, such as a desktop USB video camera.
        sourceFilter = FindCaptureDevice();

This source filter is where the stream originates. That stream originates with the WebCam so we need to tie this source to our graph. The FindCaptureDevice() has two versions, one is the active one, and then there is a commented out version that uses the DsDevice helper class. I uncommented that method and decided to use it since it is easier in the long run. That method looks like this:

    // Uncomment this version of FindCaptureDevice to use the DsDevice helper class
    // (and comment the first version of course)
    public IBaseFilter FindCaptureDevice()
    {
      System.Collections.ArrayList devices;
      object source;

      // Get all video input devices
      devices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);

      // Take the first device
      DsDevice device = (DsDevice)devices[0];

      // Bind Moniker to a filter object
      Guid iid = typeof(IBaseFilter).GUID;
      device.Mon.BindToObject(null, null, ref iid, out source);

      // An exception is thrown if cast fail
      return (IBaseFilter) source;
    }

The first thing here is an ArrayList of devices being declared and a source of IBaseFilter. The devices ArrayList then is populated by making a call to DsDevice.GetDevicesofCat(FilterCategory.VideoInputDevice). This method returns devices of type VideoInputDevice. Next we grab the first device found, you could modify this method and pass in a device index if you have more than one web-cam ( hint ! ). Lastly the device is bound to our IBaseFilter source and returned.

The next part of CaptureVideo() is this:

        // Add Capture filter to our graph.
        hr = this.graphBuilder.AddFilter(sourceFilter, "Video Capture");
        DsError.ThrowExceptionForHR(hr);

        // Render the preview pin on the video capture filter
        // Use this instead of this.graphBuilder.RenderFile
        hr = this.captureGraphBuilder.RenderStream(PinCategory.Preview,
                                                MediaType.Video, sourceFilter,
                                                null,
                                                null);
        DsError.ThrowExceptionForHR(hr);

        // Now that the filter has been added to the graph and we have
        // rendered its stream, we can release this reference to the filter.
        Marshal.ReleaseComObject(sourceFilter);

This little blob simply adds the source filter to our graph, checking for an exception code afterward. Then it asks our captureGraphBuilder to render the stream as Preview, using our sourceFilter that we built up top by calling the FindCaptureDevice() method. Finally once the stream is built the sourceFilter is released… whole memory leak thing again.

The last blob of code that is interesting is this the call to SetupVideoWindow() and SetupVideoWindow() itself of course. Here is that code:

public void SetupVideoWindow()
{
  int hr = 0;

  // Set the video window to be a child of the main window
      hr = this.videoWindow.put_Owner(panel1.Handle);

  this.videoWindow.put_MessageDrain(panel1.Handle);

  DsError.ThrowExceptionForHR(hr);

  hr = this.videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipChildren);
  DsError.ThrowExceptionForHR(hr);

  // Use helper function to position video window in client rect 
  // of main application window
  ResizeVideoWindow();

  // Make the video window visible, now that it is properly positioned
  hr = this.videoWindow.put_Visible(OABool.True);
  DsError.ThrowExceptionForHR(hr);
}

The first call to put_Owner() is the most interesting here, followed by a call to put_MessageDrain(). The put_Owner() call puts the video inside the container that you pass to the method. So by default the example said this.Handle, I changed it to panel1, which is my smaller panel inside the window. I have also put a message drain to the panel1 object. Which means that when you click on the video window the panels events will fire. The call to put_MessageDrain(panel1.Handle) means that events from the video window will drain to panel1. So, for example, when the WM_LBUTTONUP ( left mouse button up ) is fired by windows the panel1.MouseUp event will fire. Handled as such:

private void panel1_MouseUp(object sender, MouseEventArgs e)
{
            this.textBox1.Text = e.X.ToString() + "," + e.Y.ToString() + "\r\n";
}

The next method that is noteworthy since we are after all placing our video inside of a panel is the ResizeVideoWindow() method. Now… I have my panel inside of a splitter so my method looks like this:

public void ResizeVideoWindow()
{
   // Resize the video preview window to match owner window size
   if (this.videoWindow != null)
   {
          this.videoWindow.SetWindowPosition(0, 0,
                                 this.splitContainer1.Panel1.ClientSize.Width,
                                 this.splitContainer1.Panel1.ClientSize.Height);
   }
}

So what I am saying here is that I want the video to start at 0,0 ( top , left ) and go the whole width and height of the panel that it is sitting in.

Next the ChangePreviewState method is somewhat interesting. It is called when the video is minimized or restored. If you minimize this method will stop the feed.

    public void ChangePreviewState(bool showVideo)
    {
      int hr = 0;

      // If the media control interface isn't ready, don't call it
      if (this.mediaControl == null)
        return;

      if (showVideo)
      {
        if (this.currentState != PlayState.Running)
        {
          // Start previewing video data
          hr = this.mediaControl.Run();
          this.currentState = PlayState.Running;
        }
      }
      else
      {
        // Stop previewing video data
        hr = this.mediaControl.StopWhenReady();
        this.currentState = PlayState.Stopped;
      }
    }

This method is called by the Form1_Resize() event. Which resizes if needed but if it’s been minimized stops the feed by calling ChangePreviewState(false)

That’s really all I found interesting / worth explaining. The only caveat here is that I am a DirectShow newbie so … read with caution… contents may be volatile. Save often as memory leaks may happen.

In Part Two I will look at how to make our little application stream from two cameras. Also I am going to encapsulate all this stuff into a class so that we can just instantiate Camera objects and not worry about all the unmanaged code. I will post these as they are done along with the sample projects. Comments, questions, post them below.

Good luck!

Lately I have tried to be very positive on my blog as positive posts seem to generate more traffic. However… I saw this while tweaking my days meals and had to post about it.

Hollywood Cookie Diet®

IT’S THE COOKIE DIET! YAY! We’re saved! No more not eating cookies on our diet. So, either they taste terrible or there is a catch. That said I went on a hunt for the nutrition information. Here is what I found:


Hollywood Cookie Diet Nutrition Information
.: Click Picture For Full-Size :.

Now, if you don’t know how to read one of those tags, and a large portion of the population does not, you may think: “Oooh! Shiny! They have testimonials and the box of cookies is $19.99!! So it must work!” That’s where you’d be wrong.

These cookies have roughly the same nutrition information as a Nabisco Cookies which… by the way are lots cheaper! I mean you’re talking like $3.99 per package versus $19.99. Just so you don’t think I’m lying to you, here is the nutrition info for a Nabisco cookie:


Nabisco Chocolate Oatmeal Chip Cookie
.: Click Picture For Full-Size :.

So, some things to note here. The cookies are comparable, however there are some differences.

  • The Nabisco cookie is a smaller serving, so if you were to eat 40 grams you’re looking at 28 more calories.
  • The Hollywood Diet Cookies have 4.4 grams fewer fat, and only 1g of Saturated Fat compared to the 4.45g in the Nabisco cookie.
  • The Nabisco Cookie has more carbohydrates ( carbs ). 26 grams compared to the 24 grams in the Hollywood Diet Cookies.
  • The Hollywood Diet Cookies has 5 grams of protein compared to the 1.48 gram in the Nabisco Cookie.
  • The Hollywood Diet Cookies have more Vitamin A, C, Calcium, Iron and fiber ( you shouldn’t get your fiber from a cookie anyway ) than the Nabisco Cookie.

I am sure that there other differences, however those are what I would consider “primary”. Considering the price point of the Hollywood Diet cookies those differences are not vast enough to go with their product.

So what does all that mean? What are carbs, fat, and protein? Well… carbs, fat, and protein are also known as Macro-nutrients. They are the building blocks of food, so when you put them all together you get the calories in a food. The way this works is this:

What does it all mean?

1 Gram of Protein = 4 Calories
1 Gram of Carbohydrates = 4 Calories
1 Gram of Fat = 9 Calories

Protein rebuilds muscle, replaces tissue, etc. It is broken down by the body and used to build whatever tissue is needed to repair, grow… to live. It can also provide energy, long explanation there.

Carbohydrates provide energy. They are what your muscles will eventually use as fuel. Carbs are broken down into Glycogen and consumed by muscles. If you eat too many and your body cannot use them the liver turns those carbs into fat and stores them in your as… body.

Fat is very high in energy and thus packs a whoping 9 calories per gram. That is why it is often seen as “bad”. There are many types of fat, some are good, some are bad, some can be bad if they are acquired the wrong way. We won’t get into that. Saturated fat is the stuff that clogs your veins… well if you have too much. It’s actually also used for hormone generation, but that’s beside the point. /mini_rant

Some Simple Math

The Hollywood Diet Cookies have 4.5 grams of fat, 24 grams of carbs and 5 grams of protein. So let’s do the math:

4.5 x 9 = 40.5 calories
24 x 4 = 96.0 calories
5 x 4 = 20.0 calories
———————–
Total = 156.5 calories ( looks like they rounded down lawl )

So the macro-nutrient split is roughly similar between the two cookies and the Nabisco cookie is WAY cheaper. So why do these folks claim that their diet works? Well… I went on to read this little tidbit:

“We all know that to lose weight we have to restrict calories, but that is easier said than done. When hunger strikes, diets fail. The Hollywood Cookie Diet works by satisfying your hunger and your sweet tooth. Simply eat up to four cookies a day, replacing breakfast and lunch, and eat a sensible dinner. Eat a cookie for breakfast, mid-morning snack, lunch and mid-afternoon snack. The Hollywood Cookie Diet works because it is a low calorie diet based on caloric restriction by meal replacement and portion control.”

So what you are supposed to do is:

  1. Eat a cookie for breakfast, starve and be dangerously under nourished until lunch.
  2. Eat another cookie for lunch and continue to be miserable.
  3. When 3:00 strikes and you’re about to pass out because you haven’t eaten yet… HAVE ANOTHER COOKIE !!! Whee! Guess what!? You still have not eaten.
  4. Finally when you get home… “eat a sensible dinner”. Let’s be realistic… if you have not eaten anything and it’s 6:00 in the afternoon you are going to devour a pizza, or slay a box of doughnuts. ( I wonder if there is a doughnut diet!? )

So I’m being a negative ninny! Sure, but this is absolute non-sense… If you want to achieve the same results as this diet buy the Nabisco cookies and give it a shot. If you can eat just 4 cookies and a “sensible” dinner for more than 3 days ( if you try this I am not to be held liable for any consequences! IT IS A BAD IDEA !! ) and not scarf down a pizza or some huge meal or faint… My hat is off to you!

The other choice you have is to throw 2 scoops of Vanilla Whey Protein Powder into home made cookie bater. It will raise the protein content considerably and the home made recipe is probably healthier.

Moral of the story?

There is no way around it. Good old fashioned healthy eating every few hours, 5 or 6 meals per day, with a good macro split and portion control with a nice helping of exercise is the only thing that works. It is way easier to eat 5 or 6 times per day and eat healthy meals. If done right you won’t be hungry at all. I usually eat at my BMR and exercise vigorously to lose weight. Then when I want to gain I eat at about 1.5 times the BMR , lift more and reduce the cardio ( not cut it out… reduce it ). By the way… that’s cheaper too!

Here are some good resources for learning more about macro nutrients, nutrition and exercise:

  • This is where I started out. John Stone Fitness
    Poke around the forum you’ll find explanations of all the macronutrients, BMR, exercise routines, etc.
  • This Thread has some great links: BEGINNERS/NEW MEMBERS
    These two guides on that thread are exactly where I started:

    • Gravityhomer’s fat loss guide (by gravityhomer)
    • My guide to nutrition for weight loss (by marcus)
  • I blogged about a site I found that had great full body workouts that are about 15 minutes long. Check it out.

Update:
Noticed that the serving size was actually part of the 1 cookie and the 27 vs. 40g makes a difference so I updated the differences section.

Good luck!

I got my Phidgets Control Board and servos yesterday and I immediately started messing around with them. It was easy to hook up and install all the stuff you need to program against them. Very… plug-and-play-ish. So I did what the quick start said and I fired up their Control Panel and tested out the servos I had hooked up just to test make sure all was ok. Everything went fine there, so onto my next adventure, their code samples. I opened up just the simple servo example to test that out. That’s when I ran into my little problem. The code stopped at the waitForAttachment() call:


//Get the program to wait for a Servo to be attached
Console.WriteLine("Waiting for Servo to be attached...");
servo.waitForAttachment();

So after being late for the other things I had going on last night, I still did not know what to do. I poked around, my friend Ryan suggested I try a different version of the .NET framework, I hooked up different servos, the list goes on…

I finally stumbled upon a forum post which doesn’t really relate to what I was experiencing. However … In the reply that was posted I noticed that the Servo was declared as AdvancedServo not Servo like in the example that is provided in the download. Here’s what I mean:

The sample code looks like this:


//Declare a Servo object
Servo servo = new Servo();

The post has the declaration looking something like this:


//Declare a Servo object
AdvancedServo servo = new AdvancedServo();

So I changed the declaration in the code sample to be AdvancedServo and everything worked fine. The code got past the call to waitForAttachment() and the servo started moving. Yay! I’m still reading up on the programming concepts/etc. with Phidgets but I would assume that the difference is that AdvancedServo services either a new model or… Advanced one and Servo was the first revision. So if I had a plain Jane Servo and not an Advanced one ( didn’t know I was that special ) the code would have probably worked.

Strange behavior though, the Phidgets Control Panel was able to move the servo but the demo-apps and Code Samples were not able to due to this little snafu. The control panel probably detects the type and then goes on…

Anyway, that’s all.

So I bought a Phidgets Servo Kit a few days ago for my new project I’m working on at home and they’re supposed to be delivered today! Exciting!! I don’t really need to sense anything since I’m using optics to detect objects… so that was the most cost effective kit for me. Still… $150.00.

On another note… I found this attempt at comment spam kind of funny!

Funny Comment Spam

Funny Comment Spam

The funny part is the URL that they wanted to spam with … vagina-lend.co.tv …. REALLY !?!?! If I ever find myself needing anything from vagina-lend.co.tv .. I might just jump off a cliff because life is not worth living.

So I was poking around on YouTube.com the other day and was looking for a full body workout that only took about 15 to 20 minutes. I actually stumbled upon a pretty decent site in the process. I found this video:

Seemed kinda cheesy at first. I was looking for a workout not … Well… I don’t know how to put it nicely, but let’s just say that a decent workout and site to go with it was not what I expected when I clicked that link. Check out the actual site http://www.bodyrock.tv/

Anywho, I watched a few of the workout vids and they’re all good, least what I watched. The nice thing is that the site has recipes too and a breakdown of the workout. Which is really nice since 85% of any type of weight-gain / weight-loss goal is your intake. As far as the exercises on there I adapted some of them into my Wing Chun warmup. The different kind of push-ups, mountain climbers where the leg next to the chest remains off the ground( there’s probably a name for that ), etc.

I also bought a Gymboss timer which I used today for the first time and I like. It’s going to come in handy for getting the Mok Jong under a minute. My first use of the timer was to run 3.8 miles. 1 minute on, 1 minute off. Earlier this summer I was up to 3.65 miles continuous. I got the flu for some reason… and it seriously destroyed me. I quit running for 2 months straight, and to add insult to injury I skipped a month of Wing Chun during that time as well… end result… Gained 10lbs, and it wasn’t muscle.

So, the goal is to pop back down to 165lbs, I’m about 190 right now. I added a Food Journal section to this site, top right of the page. So for the next two months I suspect I’ll be updating it. If you don’t track what you eat you fall off the wagon. That’s all I got for today.

Questions, comments, leave ‘em below.

So I started playing around with streaming video from a webcam in my .NET application at home and I found a library that encapsulates the functionality that DirectShow provides within a .NET library. Coding with un-managed assemblies is certainly interesting, there are a ton of things that don’t come naturally and in large there don’t seem to be any books out there. Which would make sense since there aren’t a whole lot of people who do this kind of stuff anymore. Most development these days is: Grab user input, Store user input, Retrieve user input, Show user input.

At any rate I found one book on DirectShow that explains the thought patterns behind the design of the framework but it is out of print and roughly $200.00 on Amazon:

Programming Microsoft DirectShow for Digital Video and Television (Pro-Developer)

There are other places that you can find the book that are cheaper, but it is a shame that a book that is obviously needed by some and abused by others, price, is out of print. Sure would be nifty if they had a digital download or something.

Anyway, back to the DirectShow .NET library… The traditional “documentation” isn’t really that full, but they provide a ton of code samples with the download. The only thing that would be nice is something that explained filters, graphs, etc. for noobs like me. That book mentioned above does, and if you pair that up with the library mentioned here you can cut your way through the muck.

I took a sample the good folks at DirectShow .NET had and put the meat into it’s own class / project, even figured out how to capture mouse events in the video window and flush them to my panel that I have the thing sitting in. I’ll put up the code samples in a day or two when I get a chance, I’m still learning myself. If you’re reading this and really can’t wait….

IVideoWindow has a method called put_MessageDrain, if your video is sitting inside of panel1 for example you’d set this up as such:


this.myVideoWindow.put_MessageDrain(panel1.Handle);

Then you just need to handle the events it “drains” to you, for example:

private void panel1_MouseUp(object sender, MouseEventArgs e)
{
this.textBox1.Text = "CAM 1: " + e.X.ToString() + "," + e.Y.ToString() + "\r\n";
}

There are other events you can capture but that’s a simple example of how you would capture mouse clicks on your video window. You can find all this stuff online somewhere … I’m sure… however I had a beast of a time doing so, thus I decided to start blogging about my experiences with these libraries.

That’s all for now…

Look no further people. I have found it!

Recipe For a Show On FOX:
1. Female of roughly 110 to 125lbs.
2. C or D cup on said female
3. Daddy issues or some kind of problem
4. Mean guy / organization
5. Guns and Explosions
6. Possibly Martial Arts
7. Fast camera angles and bad fight scenes
8. Intimacy between said female and square jawed male counterpart with no more than 8% body fat and 6 pack abs… somehow his shirt came off… possibly blown off by one of the explosions in ingredient 5
9. Some sort of morally incorrect controversial conflict

Stir slowly so these ingredients don’t explode! There’s quite the powder keg in here and if we’re not careful we could get FOX all over the place!