Example of Python Generator Function.

One of the great features of Python is Generator Functions.  Generator functions allow you to convert any function to a generator function by simply including the yield keyword somewhere in the function body.  When a generator function is called, the response is a generator object, which can be iterated over among other things.

To boil this down to basics, generator functions allow you the programmer to create a function which yields one value at a time (and pauses until the next value is requested) until you decide it is done.  This opens endless possibilities for converting sequences, creating sequences, filtering, and more.

The following example is a generator function which will take a simple list or iterator and return pairs of (element, previous_element).  This is a great use for generators and the yield statement.

Generator Function:

def lineandlast(listish, first=True, last=True):
    iterator = iter(listish)
    lastline = next(iterator)

    if first:
      yield lastline, None

    for line in iterator:
        yield line, lastline
        lastline = line

    if last:
        yield None, lastline

Example:

for line, last in lineandlast([1,2,3,4,5]):
    print(line, last)

Output:

1 None
2 1
3 2
4 3
5 4
None 5

Notes:
There are two keyword arguments, first and last, which can be used to control the output of the first and last items on the output example above.

Stain Dipper Parts

Here is a screenshot of some of the parts we’ve designed for the Stain Dipper.  All of the mechanical parts are in the design and correctly positioned and all the hardware has been ordered…

Here are several of the parts from Fusion 360

Fusion360_2018-07-05_02-41-05

Here is a servo motor mount and custom made pulley.

Frame v27

Here is a small piece of Nylon used to connect a 1/16″ cable with a aluminum tube.

Fusion360_2018-07-03_22-27-15

Stain Dipper

We’ve been doing some research into air knives and considering ways to make staining of thousands of small parts faster.  Dip it into the stain, and have a captive air knife blow the excess off (dripping back into the bucket) as the part is pulled out.

The PVC tube will be hinged so it can be opened for cleaning.  The air knife assembly will be near the top of the tube.

Did some checking on PVC compatibility with stain and it seems to be acceptable: https://www.berlinpackaging.com/insights/chemical-guidelines-for-plastic/

Here is a possible air knife kit. http://www.exair.com/index.php/products/air-wipes/super-air-wipe/saw-kit.html

Now just need to design the servo motor mounts, air knife mount, and misc. other structural components.

Fusion360_2018-06-18_00-14-56

Fudge Version 2

Fudge version 2.  (Version one wasn’t good enough to write about).

This is a cross between two recipes that I learned about.  I made use of some of the techniques but did not follow the recipe that Alton Brown explains so well in his episode “Fudge Factor” at https://www.foodnetwork.com/shows/good-eats/episodes/fudge-factor

Fudge V2

… start with …
2 3/4 cups sugar
1 cup cocoa
1/4 cup corn syrup
1/4 stick butter
1 cup milk

… and later …
1/2 stick softened butter
1 tbsp real vanilla extract

… and if you want…
Cocktail peanuts (or walnuts or whatever)

Put the “start with” ingredients in a saucepan over high heat and stir constantly with a wooden spoon until boiling.  I tried covering it as Alton Brown said, but it just tried to boil over, so maybe I did that wrong?

Turn heat down to medium low and DO NOT TOUCH IT.  As soon as the temp hits 232F, turn off heat and just let it set there.   Place a small amount of butter on the top to prevent it from drying out.  Let it sit undisturbed until it is 110F…. then…

Dump in the “and later” ingredients and stir it AS HARD AS YOU CAN with a wooden spoon.  When it starts feeling like it’s time, maybe losing it’s sheen, maybe starting to get stiff, it’s time to dump it into a parchment paper lined 8×8 pan before too late.

I then poured the peanuts on top and worked them down in with a spatula.   I though it was ruined, because it just wasn’t setting up.

But I got up the next day and sure enough it was perfect.

 

Grilling Chicken On Cast Iron

Lodge Cast Iron makes some nice products.  They are quality cast iron, made in the USA, and sold at incredibly good prices.  Here is a link http://shop.lodgemfg.com/

I was at Walmart the other day to restock up on Corelle dinnerware (which is also great – they just don’t play nicely with a tile floor – and my numbers were dwindling).  I noticed this Cast Iron Grill pan:

81leZN8NLkL._SL1500_.jpg

I never saw the point in these before, but then again, never used one…  But the price was less than $20, so I figured I’d get one…. well I liked it so much I ended up with two :)

So far I’ve cooked Pork Chops and Chicken Tenderloins.  Here is a picture of the chicken from lunch today.  I must say, some of the best chicken I’ve ever eaten.  Perfectly seared, drizzled in salt, pepper, lemon, and butter, it was cooked completely but soooo tender and juicy.

20180410_143336.jpg

This deserves a longer post, but I’ll put the rundown here for reference:

  • Rinse tenderloins in sink and shake off excess water
  • Liberal amount of kosher salt and pepper
  • Get grill pan(s) screaming hot (starting to smoke) and lay the chicken on it for about 3-4 minutes until the underside has nice grill marks.
  • Turn chicken over, turn burner to LOW, and let other side also get grill marks (another 3 minutes or so).
  • Turn over every 1-2 minutes brushing butter on the freshly turned up side and drizzling fresh lemon juice on each side.  Continue this until internal temp reaches 165+ in the thickest part.
  • Let rest for 5 min in a pile on a plate.

Enjoy!

Southwestern Smoked Chicken And Corn

Another “experiment”…  Thanks again to Ezra, I had some fresh KC BBQ Rubbed Smoked Chicken Breast in the fridge.

Frozen, sweet white corn, in seasoned cast iron on high heat until perfectly done (stirring constantly).  Chopped up smoked chicken breast in.  A little Adobo (which is made from salt, pepper, garlic, spices) for seasoning and a few tablespoons of heavy whipping cream to meld it all together.

Served with On The Border corn chips and fresh salsa.  Mmmm.  It was outstanding.

20180326_232902.jpg

Smoked Chicken And Cheese Wrap

Being in the possession of some freshly smoked chicken breast (Thanks Ezra!), I made a smoked chicken and cheese wrap.   Chunks of smoked chicken and chunks of Boar’s Head Munster cheese into a cast iron skillet until sizzling.  Flour tortilla into another skillet with a dollop of butter until browned on both sides.  A little bit of mustard and mayonnaise wrapped up with the sizzling chicken and cheese mix…. it was divine.

20180319_232019.jpg