Monthly Archives: May 2014

iOS Map Comparison

We experiment with a lot of things at work.  Tools.  Technologies.  Workflows.  Recently we were discussing an effective way to do native iOS development with the team.  I love RubyMotion.  I think it makes it faster and easier to create a native iOS app.  There is a learning curve, though.

We are considering doing a project where the app is native, and written is XCode, but the guts of the app are just web views fed by a Rails app.  But before we could really consider that as an option, we needed to know how it would handle mapping.

So I whipped up a quick and dirty RubyMotion app to see.  I used Leaflet for the HTML version, and had the webpage be served from as a resource in the app.

Choose your adventure
Choose your adventure
« 1 of 3 »

I didn’t see anything that scared me off.  You lose the native feel, but I’m not crazy about the MMMapView and it’s annotations.  I’d much rather work with Leaflet and use markers.

So it looks promising.

Here’s a link to the project: https://github.com/barrettclark/MapCompare

Leave a Comment

Filed under iOS, programming, ruby

Android vs Google Glass LocationManager

I’ve played around with location a lot in the past year at Sabre Labs, and also in my previous job at Geoforce.  I find it very interesting and fun to work with.  Recently in The Lab we took on a Google Glass project.  The Glass is an interesting animal.  It runs Android, but it’s ever so slightly different.   One area that tripped me up was location.

So, here is a comparison of LocationManager in Android vs LocationManager in Google Glass.

Android:


// Android-flavored location
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 35000, 10, this);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 35000, 10, this);
Criteria criteria = new Criteria();
provider = locationManager.getBestProvider(criteria, false);

Google Glass:


// Google Glass-flavored location
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
List<String> providers = locationManager.getProviders(criteria, true);
for (String provider : providers) {
    Log.d(TAG, provider);
    location = locationManager.getLastKnownLocation(provider);
    if (location != null) {
        this.onLocationChanged(location);
        // one location is probably sufficient
        break;
    } else {
        // probably don't need regular updates, but if we miss a last known location we might
        locationManager.requestLocationUpdates(provider, 35000, 10, this);
    }
}

You’ll note that there is an extra context. before the getSystemService call in the Glass example. That’s because I put the LocationManager in a separate singleton class, so I get the app’s context first.

I wanted to have a lot of utility classes off the main UI thread, and I only needed location to support a subset of API calls that I fire off to our service. HTTP requests have to be done asynchronously, so I had a good clean line of delineation between the view layer and object models.

Leave a Comment

Filed under Android, programming

Beer Can Chicken

Today, in the rain, I smoked some chickens.  I followed a beer can chicken recipe that I found in the Weber On The Grill app:

Beer Can Chicken
Easy, delicious, and moist smoked chicken
Write a review
Print
Cook Time
1 hr 30 min
Cook Time
1 hr 30 min
For the rub
  1. 1 ts kosher salt
  2. 1 ts paprike
  3. 1 ts finely chopped rosemary
  4. 1 ts dried thyme
  5. 1/2 ts lemon zest
  6. 1/2 ts fresh ground pepper
For the chicken
  1. 1 whole chicken
  2. 2 ts EVOO
  3. 1 can beer (Shiner) at room temperature
  4. 1-2 sprigs of fresh rosemary
  5. 1 clove garlic (or some garlic powder)
  6. juice of 1 lemon
  7. 1 ts dried thyme
  8. 1/2 ts (or less) crushed red pepper flakes
Instructions
  1. Mix up the rub ingredients.
  2. Clean up the chicken such that you have just the chicken and not all the gross stuff inside it. Pat it dry. Brush the EVOO onto the chicken, then apply your rub.
  3. Big Green Egg set to 350 indirect. I used 1 pecan wood chip, soaked, that I put in at the last minute before the chicken went on.
  4. Open the beer can and drink (or reserve) half the can. Mix up all the stuff in the "for the chicken" ingredient list. Open a few more holes in the can with a can opener. Slowly pour the lemon-seasoning mixture into the can. Rosemary sprig(s) go in the chicken cavity. Stick the chicken on the can.
  5. Carefully put the chicken(s) on the egg.
  6. Cook until the chickens read about 165-170 in the thickest part of the thigh. Rest at least 10 minutes.
Cooking. Code. http://cookingco.de/
 I actually took the chicken a little higher — 180 or so.  It went pretty quickly towards the end.  It was still plenty moist.

Leave a Comment

Filed under Big Green Egg, cooking

Generally Foolproof Awesome Brisket

Let me start by saying that this is more of a guide than a hard and fast recipe. This is not baking, so precision is not required, and you can (should) safely explore and experiment.

I’ve taken a handful of recipes and “averaged” them together to come up with a process that has consistently produced a delicious (and easy) brisket. The recipes that I drew inspiration from are:

  • http://www.biggreenegg.com/recipes/beef-brisket/
  • http://grillgrrrl.com/2013/01/better-than-sex-brisket-recipe/
  • http://www.nibblemethis.com/2013/03/how-i-smoke-brisket.html

tl;dr

Here is my short and sweet version of all the stuff below:

  • Score brisket
  • Rub up to 2 days before
  • Smoker set to 225º, soaked pecan chips, indirect
  • Wrap in double foil at ~160º with the wrap sauce
  • Wrap in towels and put in cooler at 205º
  • Rest for hours
Brisket and Sauce

Brisket through the stages of cooking, and my homemade sauce

The Meat

Get a brisket. Trimmed, portioned, whatever. If you get a whole brisket it’ll have a lot of fat on it. A lot. Trim that up a bit, or ask the butcher to. Score the meat while you have the knife out. Both sides. This gives even more surface area to absorb the rub and smoke.

The Rub

Liberally apply your favorite rub somewhere between the night before and 2 days before the smoke. I don’t just sprinkle it daintily on mine. I coat it. Wrap it up and let it sit in the fridge If you don’t have a favorite rub, you can try the one that I use:

Texas Dry Rub (from Weber’s On The Grill app)

  • 2 tb paprika
  • 2 tb light brown sugar
  • 1 tb pure chile powder
  • 1 tb cracked black pepper
  • 1 tb kosher salt
  • 2 ts granulated garlic (garlic powder)
  • 2 ts granulated onion (onion powder)
  • 1 ts ground cumin

I don’t inject (or brine) my brisket. I actually don’t inject anything.

Equipment

My equipment is a Big Green Egg, large in this case. I use indirect heat, lump charcoal, and a couple of big chunks of pecan (soaked). I like to try to maintain a 225º heat throughout the smoke. You probably don’t want to go above 250º for an extended period of time. Slow and low is the key.

Go Time

Start in the morning. You don’t have to get up crazy early, though. It seems like it takes my Egg about 45 minutes to get settled in where I really like it when I’m going to do a long smoke. Take the meat out of the fridge and let it sit on the counter while the grill gets going. This is also when I soak the wood chunks.

Stick your meat thermometer in the meat – making sure it’s in the middle of the fattest part of your hunk of brisket. It’s also a good idea to monitor the temperature of the grill, and some thermometers have inputs for both.

Once you’ve got the grill stabilized and smoking, put the meat on. Fat side up or down. It doesn’t matter. Really.

The Meat Stalls

You’ll notice the meat temperature climbs pretty steadily and then stalls around 160º. There’s science going on that you should go read about, but the short of it is that you can cheat and win. I’ve seen this called the Texas Crutch, and I’m not too proud to use it. As someone online said, if you want to be a “purist” then go dig a pit.

Crutch Sauce

  • 2 tb (or so) brown sugar
  • 2 tb (or so) chopped shallots
  • 2 tb (or so) apple juice

I let my meat get to 170º, but somewhere in the 160º-170º range you can wrap the meat in heavy duty foil. A double layer is even better. Pour the crutch sauce in there. Make it as air tight as you can, while still letting the thermometer wire come out.

More Cooking

With the meat wrapped in a cozy foil cocoon it will go through the meat stalls much quicker, and also not dry out. You’ll also get a lot of really tasty juice, seasoned by the drippings from the brisket and the rub that you liberally applied.

I like to take my brisket up to 205º (or even a little higher at 207º). It may only take an hour or two to get there once you’ve wrapped it up. You can probably take it off anytime after 190º, but it will be ridiculously tender when you take it up to 205º.

Rest

Do Not Unwrap The Meat. Leave it in it’s double heavy duty foil wrap cocoon, and wrap it in a couple of layers of old towels. Stick it in a cooler, with the thermometer wire accessible. You’ll want to keep an eye on the temperature, and you’ll be surprised how warm it stays.

Let it rest for as long as you can possibly stand it. Hours. The meat will stay warm for a very long time. To put your mind at ease, you’ve got the thermometer still going. The USDA says the safe limit for raw or cooked food is 2 hours in the danger zone (40-140°). My briskets have stayed above 150º for up to 8 hours sitting wrapped up in a cooler. YMMV. You can always turn the oven on to it’s lowest setting (170º) and let it hang out in there.

Sauce

You don’t use that high fructose corn syrup junk that you buy at the grocery store, do you? No. You’ve worked too hard to perfect your brisket to ruin it with crap BBQ sauce.

Here is a super easy sauce that you can make in a few minutes. I got this from a tri tip recipe in the Weber’s On The Grill app.

  • 1/2 cup ketchup (you can get it with real sugar instead of HFCS)
  • 2 tb white wine vinegar
  • 2 tb water
  • 1 tb Worcestershire sauce
  • 1 ts molasses
  • 1 ts soy sauce
  • 1/2 ts chili powder
  • 1/2 ts granulated garlic (garlic powder)
  • 1/4 ts celery salt

Mix it all up in a small pot and let it simmer for a few minutes. The longer it simmers the more it’ll thicken up. I got a small squirt bottle on Amazon, and I always keep some sauce in my fridge.

Enjoy

Slice the brisket up. You can reserve the juice that it’s been sitting in as an additional sauce, or to put over the brisket in storage.

What did you think? What did you like, and what would you do different?

4 Comments

Filed under Big Green Egg, cooking

Ruby Attr Antipattern

Recently I’ve seen a good handful of something that I’ve never seen before in the Ruby world, and it mystifies me. I’ve been going through exercises on Exercism (http://exercism.io), and in the Ruby exercises I’ve seen several people using private attr_accessor. What?

The argument, so far, has been that it’s the same as doing it the long way so why not?

It’s weird. That’s why not. It’s not expressive. That’s why not. It’s a lazy shortcut that still didn’t buy you anything. That’s why not.

An example:

class Demo
  def initialize(something)
    @something = something
  end

  def based_on_something
    something * 2
  end

  private
  attr_reader :something
end

So, I am all for the use of attr accessors, and I am all for tucking implementation details away in private methods. The use of a private attr does nothing for the latter. You’ve simply added more obscure code that doesn’t tell future you or future maintainers anything about what you intended or thought might happen. If you think the implementation might change or evolve, then go ahead and write the extra 2 lines to define the method explicitly. Otherwise just use the ivar.

Now, it’s entirely possible that I’m just being grumpy old man and shaking my cane. If there is a good reason that’s come along that I haven’t picked up on yet I would love to understand it. For now, though, I’m maintaining that this is a weird antipattern.

2 Comments

Filed under programming, ruby

IRB Benchmark Helper Method

Quick and dirty ruby benchmarking helper that you can stick in your .irbrc:

require 'benchmark'
def benchmark(n, &block)
  Benchmark.bm do |x|
    x.report do
      n.times { block.call }
    end
  end
end

Then call it like so:

str = "2013-01-21"
benchmark(10) do
  Date.parse(str)
end
benchmark(10) { Date.strptime(str, "%Y-%m-%d") }

Simples!

Leave a Comment

Filed under programming, ruby