Xcode: Sometimes a return is not a return (emacs brain damage)

December 23rd, 2012 (trackback)
ExpectedExpression
Indention and Insertion Prefs

Every now and then, I’ll be coding along merrily in Xcode and I’ll get an error much like the one at left. Or “expected identifier or ‘(‘” is another variant.

Huh? That code is fine. Maybe it is an invisible character? Nope. Nothing shown.

Took a bit, but I figured out the cause; 25 years of using emacs as my command line editor of choice, along with the folks at NeXT that implemented the AppKit’s text editor.

In emacs, you quite commonly navigate about by holding down the ctrl- key and banging on various keys to go to the beginning/end of lines, etc. Many of these control sequences are honored by Cocoa’s text editing system and quite a few more are supported in Xcode’s editor.

Seemingly unrelated, ctrl-return is mapped to Insert Line Break.

Thus, if you are an emacs head and you commonly hit ctrl-e<return> to start a new line of code and you happen to hold down the return key just a tad too long, it causes the error shown (or a variant depending on where the insert happens).

The easiest way to tell if this is the case is to go to the line of code after the line reporting the error and hit ctrl-a. If the cursor ends up at the beginning of the previous line, that line is ended by a line break and not a true newline. (ctrl-n – backspace – return to quickly fix).

While it is easy enough to fix once you know the ctrl-a trick, a better fix is one that makes it such that it’ll never happen again.

To do that, go to Xcode’s Key Bindings Preferences, click on “Text”, and scroll down to Insertions and Indetions. On Insert Line Break, delete the ctrl-return (hat + u-turn arrow) key sequence. For convenience add the same to Insert Newline.

Problem solved.


3D Printing: A Tour of Stuff

December 15th, 2012 (trackback)

Since picking up an Ultimaker nearly a year ago, I’ve printed many things (and wrote a very well received article for Make: Ultimate Guide to 3D Printing).

These are many of them and some lessons learned from each.

Printed Ornaments

Koch Snowflake Tree Ornament Baubles

This is Thingiverse Object #35561.

Every year, we have an annual ornament exchange in our neighborhood. Last year, I used EMSL’s Egg-Bot to create an Eichler themed ornament.

This year, I started down the path of custom designing an ornament for printing, but grabbed the Koch snowflake baubles from Thingiverse.

Lesson Learned: Design software is hard to use. 3D design software is harder. You’d think a simple circle with some stars and words extruded in 3-space would be easy to do. Still, people totally dig the unique texture and shapes of these. In hindsight, I probably should have used Inkscape (awful, but works and is what is used for the egg-bot) to do a 2D design and then extrude that.

Read the rest of this entry »


Roast Turkey

December 4th, 2012 (trackback)
Turkey

For Thanksgiving this year, I couldn’t decide between cooking a smoked turkey or a roasted turkey. So I did both. 38 lbs of turkey may have been excessive for 12 people, but the leftovers are grand (still have quit a bit frozen).

For the smoked turkey, I followed the guide at Amazing Ribs. Hands down, the best BBQ/Grilling site around.

For the roast turkey, I started with Martha Stewart’s Cheesecloth Method, derived inspiration from Amazing Ribs, and applied a bit of my whim. The end result was incredibly good and, bonus, also produced some of the best gravy I’ve ever had.

Details:

  • You’ll need a roasting pan that allows the turkey to be suspended at least an inch, preferably more, above the contents of the pan (which will be about 1″ deep). Looking closely at the (admittedly poor) picture, my turkey roaster’s rack has little notches that allow it to be suspended over the pan. If you have room, you could use a pan on the bottom rack of the oven with a rack immediately over to hold the turkey.
  • Shove some sage leaves and a lemon inside the bird’s body cavity. No stuffing, though, as that just dries out the meat (by requiring a longer cook) while not really improving stuffing quality.
  • Pre-heat oven to 450℉
  • In the roasting pan place all the turkey innards but the gizzard — neck, any fatty bits cut off, heart, liver, etc… Add to the pan:
    • One large onion, halved, skin on. The skin adds color.
    • Several peeled carrots, cut to finger length chunks.
    • Celery, finger length chunks.
    • 6+ whole peppercorns.
    • 60 / 40 mix of water / apple juice, enough to mostly cover the veggies.
  • In a deep sauce pan, melt 3/4 lbs of butter. Add 2 cups of Sake and ~1 Cup of Jack Daniels. Once thoroughly melted and stirred, soak a cheese cloth in it and layer on top of the turkey. There should be at least 4 layers of cloth on the top and down the sides of the turkey.
  • Shove the bird in the oven. After one hour, drop the temperature to 350℉ and baste the turkey with most of the remaining butter/sake/JD magic sauce. It’ll sizzle and pop. That’s OK. The cheesecloth will likely be near black and crispy. Also OK.
  • After another couple of hours, remove the cheesecloth carefully. Baste with any remaining awesomesauce and baste with a bit more of the drippings from the roasting pan below the turkey.
  • Cook for at least another hour. The bird will be done when the meat in the thickest part reaches ~155℉. Not 165℉ as the bird needs to rest for a good 15 to 20 minutes when pulled and carryover will cause the temperature to both continue to rise and continue to pasteurize (if you hold poultry at 131℉ for long enough, it’ll be fully pasteurized– the USDA’s quote of 165℉ for safety is based on holding at that temperature for only a few seconds!).
  • Strain the contents of the roasting pan into a pot. You could choose to serve it as is as a delicious and flavorful broth to be ladled over the meat. Or you can choose to cook it down — to thicken it up — as a more traditional gravy.



Printing the NASA 3D Models

October 23rd, 2012 (trackback)
Shuttle

Update: Thinking about it for just a moment, I realized the print quality would likely be higher if I printed in “launch position”. Doing so would greatly improve the wing quality while also, hopefully, improving tail quality in that there would be fewer really small layers (that cause the print head to slow way down, causing blobbing). The disadvantage would be a lot more support material, especially around the engines, and, thus, a potentially difficult, if not destructive, post print cleanup.

And it worked! I only lost one control jet off the back during cleanup, even!

There are more photos of the final printed piece and of the print in progress in my Flickr feed (link goes to a photo in the middle of the set).


I remember watching the first Shuttle launch way back in 1981. If you’d told me then that I’d be casually printing a small copy of the Shuttle on my own personal 3D printer 32 years later, I might have thought you were crazy. Or, at 11 years old, I probably would have have asked, “Why so long from now?”


3D Printed Shuttle

NASA has kindly dumped a treasure trove of 3D models available for free download.

Obviously, these beg to be printed. Doing so is a matter of jumping through a couple of file conversion hoops. The files start out as Autodesk 3DS files.

Meshlab can be used to import said files and then export them to STL. You might need to do some mixup after. Using netFabb, I found several errors in the model’s geometry and fixed it. I believe Meshlab can do the same, but I’m not familiar enough with the tool

Slicing for printing is tricky. The models give zero consideration, no surprise, for 3D printing. In fact, they are entirely sub-optimal for printing. For example, the shuttle’s cargo bay is empty, leading to a bit of a support mess, and it would print much better if the wings sat flat on the print bed. Thus, even the simple Space Shuttle model has a curved bottom. You’ll probably want to enable support when slicing. Some of the models, like the lunar landers, are unlikely to be able to be printed using an extruded plastic printer without support material that can be dissolved away afterwords (i.e print in PLA or ABS with PVA support material.

As a first print, I sliced using Cura with 20% infill, 0.2mm layer height, and support material turned on. It actually turned out better than expected!



75/47.5 Yogurt

September 9th, 2012 (trackback)
Yum!

When I became sous vide enabled (controlled water bath, anyway, a proper vacuum chamber is on the to-buy list), it immediately dawned on me that a tightly temperature controlled water bath would be perfect for purposefully growing microorganisms as much as for preventing the growth while achieving perfectly done foods.

Roger has long been a fan of yogurt and yogurt is nothing more than milk fermented by a lactose consuming bacteria of, most commonly, the Lactobacillus delbrueckii subsp. bulgaricus and Streptococcus salivarius subsp. thermophilus varieties.

And, yes, it has proven incredibly easy, cost effective, and exceptionally delicious to cultivate these bacteria in the milk of your choice using a sous vide rig. Note that you really don’t need a water bath; a cooler, some hot bottles and towels can work well enough.

However, you do need the precision of a water bath to achieve consistent results of the highest quality!

The Recipe

Milk Divided

1. Divide a gallon of milk amongst 5 1-quart Bell canning jars (which aren’t actually 1 quart in many cases — go figure — just divide the milk evenly between them). Lids on loosely!

We often use generic organic whole milk, but low-fat works, too. It cannot be ultra-pasteurized (as ultra-pasteurization breaks down the proteins to the point that the bacteria can’t survive. The implications on the healthiness of said milk are quite bad). Raw milk works beautifully, but is expensive. I’ve been meaning to try a mix of sheep and/or goat with the cow’s milk.

Lately, I’ve taken to using a gallon of 2% mixed with a quart of raw whole milk. The result is a bit richer in flavor and texture while not being the whole fat experience.

Making Yogurt; Scalding the Milk

2. Place in an 75C water bath for ~2 hours (long enough to heat the milk thoroughly to 75C for at least an hour).
3. Cool milk to 47.5C. I find it easiest to scoop out the hot water and replace with cold water to bring the temperature down rapidly.

I usually set the target temp of the water bath to 46C initially. By doing this, the residual heat from the milk will leach out into the water bath and you can tell when it is stable when it holds steady. You can inoculate and bring the temperature back to 47.5C simultaneously (Yogurt cultures will incubate fine up to just above 50C and, in fact, I used to do this at 50C. I’ve since found that 47.5C produces an even better result.). The key is to make sure the milk is solidly below 55C before inoculation, otherwise you’ll run the risk of killing off the live cultures!


Innoculate at 50C

4. Stir in one tablespoon of the plain flavor of your favorite brand of yogurt into each jar. Place lids back onto jar loosely.

You can use previous batches to inoculate new batches, but it is generally recommended that you refresh with new yogurt every few batches. Honestly, I’m not sure how much this matters. It’d seem that as long as you store your live culture yogurt properly, you shouldn’t have any more of an issue than one might with, say, a sour dough starter. Mostly, I end up “starting over” with store bought plain yogurt simply because we eat the previous batch so quickly and we forget to preserve enough to start the next batch!
5. Leave in the water bath for at least 12 hours and up to 24 hours (maybe even longer). The longer they are in the bath, the more greek-like sourness to the yogurt. I usually target 18 hours, maybe 22, and everyone in the family eats the stuff like crazy.

Done!

6. Tighten the lid and submerge in ice water to stop the bacteria from continuing reproduction as the temperature falls (more below). You should hear a “pop” as each jar seals itself.

7. Refrigerate. We’ve had jars sit in the fridge for 4+ weeks with no off flavors or nasty bits forming. Others have reported keeping the sealed jars in the fridge for 6+ weeks without issue.

You’ll get a bit of whey on some jars, some more than others, I typically collect the whey and use it in bread making.

Read the rest of this entry »


Whoah! Arduino goes ARM on the cheap & Arduino AVR Gets Really Tiny (on the cheap)!

September 5th, 2012 (trackback)
B47af8930ab8a169e37c95534ab9945e large

For the Teensy Blaster, I used a Teensy v2.0 board from PJRC. It is a tiny board containing a not-so-limited AVR chip (32K of flash, >2K RAM, 1K of EEPROM, and a slew of I/O pins) and a mini-USB port with the ability to be USB bus powered. Tiny. Versatile. And cheap at $16/board! $24 nearly gets you nearly 4x the memory and nearly doubles the I/O ports.

Today, I ran across Teensy v3.0 on Kickstarter. In pretty much the same sized package, the Teensy v3.0 features a 32bit ARM Cortex-M4 board with 128K of Flash(!!), 16K of RAM(!!), 2K of EEPROM, and a slew of I/O options. If that weren’t enough, it includes support for IR, a high quality audio interface, an optional real time clock, 4 DMA channels, and support for touch sensor inputs. And more. Much more. Holy cow! Truly, a nutty amount of computing power in a 1.4″ x 0.7″ package!

And it can be used from both Arduino and C.

So, yeah, funded. No brainer.

8170026945a0f0462acf148cc38b69f5 large

Then, at the thank you for funding this project page, there is a thing you might be interested link that leads to the Digispark.

Wait. What? A board barely bigger than a USB connector that features an Arduino compatible CPU with multiple I/O pins, 8K of flash, PWM on 3 pins, ADC on 4 pins and many many different shields?!

For $8-$10 / board?!

Sign me up! (And I did!)



Arduino on Mountain Lion

August 21st, 2012 (trackback)

In my “spare” time (hah!), I hack on Arduino a bit. Mostly because there are tons and tons of 3rd party libraries that make hacking up a hardware solution mostly a bit of soldering followed by gluing together some pre-made software bits. The Arduino IDE is Java based and… well… not terribly awesome (to be fair — it isn’t awful, just quite lacking beyond the basics).

With the release of Mountain Lion, most Arduino installations were broken. Fortunately, this can be fixed by grabbing the latest bits from here and there.

  • Grab the latest Arduino.app for Mac OS X
  • Run it and it’ll insist on installing the latest Java VM. Do so.
  • If you use Teensyduino, grab the latest installer and install it. If Mac OS X (rightly) complains that the software is from an unidentified source and can’t be opened, you can ctrl-click on the installer, select “open” and it will present the option to bypass the security check. Do so, but not without a bit of misgivings.
  • Install the latest FTDI driver.
  • If all went well, you should see the device show up in /dev/ as something like /dev/tty.usbmodem12341.


    Amazon: Playing with an iPad

    August 4th, 2012 (trackback)
    Playing with an iPad

    We spent a week at the end of June on the Amazon River in Peru with International Expeditions. Fantastic trip, more on that in a later post.

    One afternoon, we visited a village — Nueva York — along the Amazon. We spent some time with the children of the village, learning a bit of spanish and teaching them a bit of english (Head! Shoulders! Knees and Toes! Knees And Toes!).

    Fun with Photobooth

    One of our guides asked me to show the kids my iPad as they had never seen anything like it before. It took a moment, but they were enthralled. The big hits were Photo Booth and a simple finger painting app.

    It was quite gratifying to see the kids take to the iPad and start using the apps so naturally. They quite quickly learned how to change and control the effects in Photo Booth. Including taking their own pictures, as seen at the right.

    Of this wonderful experience — the kids were fantastically good natured and the adults were warm / welcoming — there were two standout events that I shall relay, one purely cultural and the other just flat out cute.

    When I first launched Photo Booth and showed it to one child, I was a bit surprised by the reaction. It was sort of, “Well, that’s neat.. but.. meh, weird pictures of a person isn’t that interesting”. When I turned the iPad so his friend could see, the second kid’s reaction was the same, but the first child completely lit up with laughter as soon as the second kid’s face was on screen! Then the same happened when I rotated back to the first child.

    As it turns out, there are pretty much no mirrors anywhere outside of, maybe, a hand mirror or two. Children really don’t see themselves on a regular basis save for on the back of a digital camera in the hands of a tourist (we were encouraged to always show them any pictures we took). Thus, seeing “self” just wasn’t very interesting at all.

    Once I suspected this was the case, I saw this same behavior with pretty much every child who saw Photo Booth for the first time!

    The really cute event happened when I was showing a little girl — maybe 6 or 7 years old — the finger painting application. It took her a second, but she got into it and had quite a bit of fun making a smily face. I showed her that the color could change and then left the color picker (a little grid of color swaths) on the screen for her to pick.

    She thought about it for a moment.

    Then carefully tapped light blue.

    Then looked at the tip of her finger to make sure the color was picked up.

    Disappointed that her finger wasn’t blue, she tried again with yellow. Same thing.

    Then I showed her that the color really did change and she was happily drawing away again. Still, every new color required a finger tip inspection…

    Neat folks. I hope to visit again.







    Aerogarden 2nd Run; With Custom Built Pieces

    May 14th, 2012 (trackback)

    After nearly 5 months, the first run of herbs in the Aerogarden were finally tired to the point of no longer useful (I started with AeroGarden Gourmet Herb Seed Kit (6-7-Pod) and it worked really well — way more than $18 worth of fresh, tasty, results).

    Pods Installed (Basil Sprouted!)

    One of my goals with the Aerogarden is to gradually replace all the pieces until I’ve effectively created a homebrew Aero-Hydro solution that will eventually integrate with our atrium’s pond (fish poo fertilizer FTW!), use LED lighting, and, hopefully, be an interesting conversation piece.

    The next obvious step was to replace the seed pods and baskets. The seed pods/baskets are the one piece that needs to be replaced with each planting. The baskets — white plastic things that fit in the holes on top of the Aerogarden — can be mostly reused, but the original design is obviously optimized for cost, not effectiveness (they don’t actually fit correctly in some of the holes!). The seed pods, themselves, are little bundles of seeds in growing medium; Aero’s are good quality, but relatively expensive and the seeds are of unknown variety (i.e. generic curly parsley and not some particular strain).

    At left is the current phase; seed pods and growing medium replaced with Basil sprouts showing some signs that it is working!

    Read the rest of this entry »


    3D Printing: Oh, The Tuning We Shall Do.

    March 25th, 2012 (trackback)

    After a while with the Ultimaker, a series of notes on the various things one can do to tune the 3D printing experience.

    Some of this is specific to the Ultimaker, but most of it is not. Much of this is personal preference and, frankly, there is probably some stuff in here that is wildly sub-optimal. But, hey, it has worked for me and it worked better than it did when I started.

    I.e. feedback and corrections are quite welcome!

    First, a note on consumables. I have stuck with PLA (polylactic acid) exclusively. It is a plant derived material that requires a lower temperature and is quite thoroughly non-toxic (there are lots of articles about fume-venting ABS… not so with PLA). As well, when I screw up — which is often — the resulting garbage is biodegradable (however, I’m donating my “pile of PLA” to someone who needs input into a PLA scrap-to-usable-filament project).

    PLA also doesn’t require — though it can benefit from — a heated print bed. ABS, the other common material, seemingly really does (though one can live without).

    Thus, these tips are optimized to PLA.

    These tips are also somewhat ordered in the steps that they should be done to maximize benefit. In some cases, that is because the earlier steps have a bigger ROI than later ones. In others, it is simply that the later steps really require the earlier steps first. Read the rest of this entry »