Monthly Archives: March 2015

Myth of High-Protein Diets

This is a GREAT read! Many research papers sited. I highly suggest you read the entire article but here’s the key excerpt:

What that means in practice is little or no red meat; mostly vegetables, fruits, whole grains, legumes and soy products in their natural forms; very few simple and refined carbohydrates such as sugar and white flour; and sufficient “good fats” such as fish oil or flax oil, seeds and nuts. A healthful diet should be low in “bad fats,” meaning trans fats, saturated fats and hydrogenated fats. Finally, we need more quality and less quantity.

23ornish-blog427

Kaley McKean

 

Original article by DEAN ORNISH, MARCH 23, 2015 NYT.

March Madness

While I managed to get onto the Yahoo! website just under the wire and created this before the first games were played, I’ve been working on a project and so am only now posting my bracket. Of course, Baylor lost yesterday in one of the first upsets, so it’s already “blown up”. As I stated last year, I don’t follow NCAA Basketball, so this is more of an exercise in statistics than anything else. Good luck to all the teams competing this year!

Pi Day!!!

As you probably have seen, tomorrow, March 14, 2015, when written using the standard US (short) notation 3/14/15, spells out the first 5 digits of Pi. As it turns out, you can go even further down the Pi “number” hole. Here are a couple of good references:

Vox has a good (layperson) explanation of Pi Day
http://www.vox.com/2015/3/13/8205807/pi-day

Jeff Rosenthal has a detailed explanation of the Pi Instant
http://probability.ca/jeff/writing/PiInstant.html

You can also find your birthday “spelled out” WITHIN the digits of Pi using this cool Wolfram site!  Here is mine:

Vernal Equinox – March 20, 2015

The 2015 Vernal Equinox, which marks the first day of Spring for Northern Hemisphere dwellers, is almost upon us. This is the (one of 2) point(s) in the Earth’s orbit when the tilt of its axis (e.g. the North Pole) is neither pointing toward nor away from the Sun. In this situation, virtually all parts of the Earth receive (approximately) equal amounts of day and night (12 hours each). It’s also the point at which the increasing amount daylight (or night-time in the case of the Autumn Equinox) is at a maximum! Here are a few links if you’d like to learn more about equinoxes:

Wikipedia

Time and Date

The Old Farmer’s Almanac

McLaren 675LT vs Tesla P85D

I’m an F1 fan and can’t wait for the 2015 season to start at Melbourne in a couple of weeks. However, I don’t consider myself a “car guy”. I don’t fantasize about cool/fast cars, etc. but I did find this announcement by McLaren interesting.

The McLaren 675LT Takes Off at Geneva Motor Show, Fast and Street-Legal

Specifically, this section:

It has a 666bhp V8 engine with a 0 to 62-mile-per-hour sprint time of 2.9 seconds. Top speed is 205 mph. You’ll be hard-pressed to find anything street-legal that can beat that time, apart from a Bugatti. (Pricing has yet to be announced on this, but Car+Driver estimates it’ll be $345,000. I agree it’ll likely be a heck of a lot less than the $2-million-plus Bugatti Veyron.)

I found that comment interesting, given this article from November 3, 2014 (the fact of which has been widely publicized since) about Tesla’s “Insane” mode on the new P85D. There have been recent rumors that suggest the P85D’s 0-60 time could drop to 2.9s after an upcoming firmware update. Don’t get me wrong, the $120,000 price tag of the Tesla P85D seems ridiculous to me but pales in comparison to $345,000 for the P1. I know, comparing apples to oranges but if you are looking purely at acceleration…

Since I’m trying to write about science, here are a few graphs for you. This first one comes from a reddit.com posting and the second comes from dragtimes.com. The second graph is a V-T graph, so the slopes are acceleration, which you can see are pretty much linear (which is remarkable for a car). Insane mode provides a horizontal acceleration (also shown on the graph) in the neighborhood of 1g! Wow!

Tesla Model S Power and Torque

 

Tesla-P85D-Insane-vs-Sport-Mode-Graph

Creating a Transparent Modal UIViewController in iOS 8

I’ve just started to scratch the surface of all the cool things iOS 8 can do, so much to learn! One of my apps presents a modal view controller that asks the user to select a date from a custom calendar view I built. The app displays photos and this modal vc is presented over an image, so I wanted the modal vc to be (semi) transparent, so the image could be seen behind it. I scoured the web but there seemed to be a lot of conflicting ideas out there and none of them worked for me. I happened to stumble upon a/the solution on my own, while poking around Attributes Inspector.

Select the (modal’s – i.e. the one you want to be transparent) view controller from your storyboard and then click on the Attributes Inspector. As you can see in the screen shot below, there are Transition Style and Presentation options now available. The Transition Style is just what you expect it is and for Presentation, you want to select Over Current Context. Viola! Crazy simple.

Attributes Inspector

I’d be interested to hear what has worked for you in iOS 7, although backward compatibility is quickly becoming less interesting to me.

How To Convert HTML to NSAttributedString

I’m not sure what the best practice is these days when displaying HTML content in your app. It seems you can either put it into a UIWebView or you can, as of iOS 7, convert it to an NSAttributedString and put it into a UILabel, UITextField, etc. I have been leaning toward the latter recently and thought I’d post the 2 lines of code required to make that happen.

NSAttributedString *stringWithHTMLAttributes = [[NSAttributedString alloc] initWithData:[self.htmlText dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute:@(NSUTF8StringEncoding)} documentAttributes:nil error:nil];

self.htmlLabel.attributedText = stringWithHTMLAttributes;

The above code assumes you have HTML stored in an NSString variable called “self.htmlText” and a UILabel called htmlLabel and that your encoding is UTF8.

Let me know if you have any questions or if there is a better practice I’m not aware of.

How to Convert an ISO8601 Date in iOS

I still find working with dates in iOS a little tricky. There is always a new format to deal with and it’s all about getting the identifiers for the format just right! I recently ran into ISO8601 and hope the bit of code below is of some use.

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZZZZ"];
NSDate *date = [dateFormatter dateFromString:self.releaseDate];
[dateFormatter setDateStyle:NSDateFormatterLongStyle];
self.dateString = [dateFormatter stringFromDate:date];

You can, of course, pick any other date format style (instead of Long) as the output. As always, let me know if you have any questions.