Animator vs. Animation II

Date July 20, 2009 by Isaac

Very cool sequel to the original.

Animator vs. Animation II by ~alanbecker on deviantART

Animator vs. Animation

Date July 20, 2009 by Isaac

This is awesome!

Animator vs. Animation by ~alanbecker on deviantART

Long Sleeps In Python

Date July 15, 2009 by Isaac

There is a portion of my test infrastructure that requires long sleep periods for stability soak testing purposes. So far the longest stability test run was 9 days. Originally, I simply used the time.sleep() method from the Python library. However, and I attribute this to VMware, I found that extremely inaccurate for long sleep durations. My test controller is running in a VM and although I have nothing to confirm this I suspect that VMware is doing funny stuff under the covers with the OS timer and that is throwing off the accuracy of time.sleep(). Anyway, here is my solution to the problem.

import time
from datetime import datetime, timedelta
 
def longsleep(minutes):
    """
    The normal time.sleep() method is not very accurate from inside
    VMware when sleeping for long periods of time.  This method is
    accurate to within +/- 5 seconds of the desired sleep time period.
    For long periods on the order of hours or days this small inaccuracy
    is acceptable.
    """
    sleepTimeSec = 60 * minutes
    now = datetime.utcnow()
    td = timedelta(seconds=sleepTimeSec)
    endTime = now + td
    while now <= endTime:
        time.sleep(5)
        now = datetime.utcnow()

The method is accurate to around +/- 5 seconds, but for really long sleep durations 5 seconds is no big deal.

Break Even Point for Fuel Efficiency Enhancements

Date July 1, 2009 by Isaac

On my way home from work yesterday I was pondering the question, "if I do modification foo to my car for a cost of bar dollars and it improves my fuel efficiency, then after how many miles is the break even point where that modification becomes cost effective?"  OK, I know that is a somewhat random question, but those are the types of questions my brain likes to solve.  So, I pulled out a pencil and some paper and after some thought derived the needed equation:

x = \frac{U_c E_1 E_2}{P (E_2 - E_1)}
Where:
x = Miles to break even
Uc = Upgrade cost in dollars
E1 = Fuel economy prior to upgrade (miles/gallon)
E2 = Fuel economy after upgrade (miles/gallon)
P = Price of fuel in dollars/gallon

So, for example, lets say that I put $75 into a modification to my car. Prior to the modification I got 18MPG and afterwards I get 20MPG. Let's also say that fuel costs an average of $2.99/gallon. The calculation would be:
x = \frac{75 \cdot 18 \cdot 20}{2.99 \cdot (20 - 18)}

Which works out to 4515 miles. So, if my car got 18MPG and I put $75 into a modification that brought the economy up to 20MPG it would take 4515 miles of driving to recover my costs. Anything after that would be saving me money.

There are a lot of scams out there for fuel saving devices. IF you can actually find something that works then you can use the above formula to calculate whether or not it would actually be worth the purchase.