Generics, Protocols and Associated Types

My desire to revisit priority queues was driven by "Classic Computer Science Problems in Swift: Essential techniques for practicing programmers". This book is a fun read. It's almost like reliving my sophomore year in college. It makes me feel young again ;)

I haven't written much Swift code that defined generics and protocols with associated types. These concepts aren't hard to understand, but as a long-time Python developer, I find Swift's boilerplate distracting and sometimes hard to read. When I get it wrong, the compiler error messages usually leave me scratching my head.

Read more…

A Stark Beauty

Taos Junction"It has a stark beauty all its own. It's like much of the high desert of the United States."
— Neil Armstrong

When I first looked down on the Taos Junction bridge from the top of the Picuris trail, I thought of Neil Armstrong's description of the lunar landscape. Little did I know that Apollo astronauts had trained just a few feet away.

Read more…

Adding Swift to an Obj-C Project

You have an Objective-C Xcode project, and you want to add Swift code to it for the first time.

  • What do you need to do so it doesn't segfault when you launch?
  • What do you need to do so your Objective-C code can call your Swift code, and vice versa?

These notes apply to Xcode 8, and they assume an Xcode project named Project Foo. Names of build settings, etc., may change from one Xcode release to the next.

Read more…

Not Just Clogged Pipes

Coronary Artery Disease as Clogged Pipes


Although the image of coronary arteries as kitchen pipes clogged with fat is simple, familiar, and evocative, it is also wrong.

most cardiac events occur at lesions that appeared mild on previous angiography

These plaques contain a lipid-rich core covered by a thin fibromatous cap. Inflammatory cells (eg, macrophages and mast cells) within the plaque may become activated by microbes, autoantigens, or inflammatory molecules (activated plaque model). The activated cells secrete cytokines and proteases that weaken the fibrous cap, causing it to erode or rupture.

Before rupture, these plaques often do not limit flow and may be invisible to angiography and stress tests.

Anecdote: My dad had ​a stress test and angiography in early 2003. It showed him to have low risk for heart attack. Less than 8 months later Dad had a heart attack, with a subsequent quintuple bypass and a stent.

in the setting of myocardial infarction, the model of an obstructed pipe is accurate, and interventions aimed at eliminating the thrombus, either thrombolytics or angioplasty, can be lifesaving. But for patients with stable disease, local interventions can only relieve symptoms; they cannot prevent future myocardial infarctions.

Although atheromatous plaques contain lipids, they are not composed of fat directly from the diet. Low-density lipoprotein is produced primarily in the liver...

growth within the vessel walls is accommodated by outward enlargement of the vessel. In that case, large plaques may not encroach on the lumen and are therefore hidden from angiography.

High-density lipoprotein removes low-density lipoprotein from peripheral tissues through reverse cholesterol transport to the liver and may have antiinflammatory properties

Although saturated fat increases low-density lipoprotein cholesterol, it also increases high-density lipoprotein, so the net effect on cardiac risk is neutral.

More recent observational studies do not support the use of low-fat diets. ​ low-fat diets had adverse effects on high-density lipoprotein cholesterol. But for patients with elevated low-density lipoprotein, they have tightened restrictions on saturated fats and now recommend that consumption not exceed 7% of total calories.

in many products, fat is simply replaced by sugar. More recently, the AHA recommended that people limit their intake of sugar, which now appears to contribute to obesity, hypertension, and subsequently coronary heart disease.

Useful Python Modules

My top 5 ‘new’ Python modules of 2015 « Robin's Blog


This module is so simple but so useful – it makes it stupidly easy to display progress bars for loops in your code.


[...] to use it within the Jupyter Notebook just make sure that the map object (map_1 in the example above) is by itself on the final line in a cell, and the notebook will work its magic and display it inline…perfect!

​ Many thanks to Robin Wilson for the summaries. It will be fun to try folium, especially.