Okay, so now that the basics are out of the way, here is a code snippet I use frequently. It provides a moving window over a stream of data.