<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>Ted Pak</title>
 <link href="https://tedpak.com/atom.xml" rel="self"/>
 <link href="https://tedpak.com"/>
 <updated>2025-10-15T15:32:24-04:00</updated>
 <id>https://tedpak.com</id>
 <author>
   <name>Theodore Pak</name>
   <email>theodore.r.pak@gmail.com</email>
 </author>

 
 <entry>
   <title>Pitfalls of Using ChatGPT and GPT-4 for Data Science</title>
   <link href="https://tedpak.com/2023/11/30/pitfalls-of-gpt4-for-data-science.html"/>
   <updated>2023-11-30T00:00:00-05:00</updated>
   <id>https://tedpak.com/2023/11/30/pitfalls-of-gpt4-for-data-science</id>
   <content type="html">
&lt;p&gt;If you are reading any scientific journal right now, there’s no question that artificial intelligence (AI) is a &lt;em&gt;hot topic&lt;/em&gt; once more. Just about every issue you pick up will be peppered with updates on how AI is changing any given subfield of science. &lt;em&gt;Clinical Infectious Diseases&lt;/em&gt; (CID) recently published a Viewpoint on how large language models will change microbiology,&lt;sup id=&quot;fnref-318ad3:1&quot;&gt;&lt;a href=&quot;#fn-318ad3:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; which caught my eye.&lt;/p&gt;

&lt;p&gt;In general, I think these articles are important and helpful! As my colleague Sanjat Kanjilal pointed out in another CID editorial,&lt;sup id=&quot;fnref-318ad3:2&quot;&gt;&lt;a href=&quot;#fn-318ad3:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; there is no question these technologies are fundamentally shifting the boundary of the tasks we imagine delegating to machines. And given that anybody can access large language models (LLMs) for very little cost,&lt;sup id=&quot;fnref-318ad3:3&quot;&gt;&lt;a href=&quot;#fn-318ad3:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;3&lt;/a&gt;&lt;/sup&gt; they will absolutely have far-reaching impact on both medicine and science. It’s helpful to discuss what those impacts could be, even if this train of thought occassionally veers into the hypothetical and fantastic. I am certainly no stranger to making optimistic claims about how certain technologies, e.g. next-generation sequencing, will revolutionize various aspects of infectious diseases,&lt;sup id=&quot;fnref-318ad3:4&quot;&gt;&lt;a href=&quot;#fn-318ad3:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;4&lt;/a&gt;&lt;/sup&gt; and  finding some of these claims may be &lt;em&gt;slightly&lt;/em&gt; delayed in the event of a global pandemic.&lt;/p&gt;

&lt;p&gt;On the other hand, I’m a programmer and data scientist, so I will be a stickler over claims that AI is changing specific aspects of those disciplines, particularly as a means toward some larger goal like the improvement of clinical microbiology. On this front, I often find that the truth is much, much more nuanced than the way it’s presented in these articles.&lt;/p&gt;

&lt;p&gt;For instance, the following examples were included in the aforementioned Viewpoint&lt;sup id=&quot;fnref:1:1&quot;&gt;&lt;a href=&quot;#fn-318ad3:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; to support the assertion that “GPT-4 is used to analyze data by providing SQL and R scripts,” which I take to mean that GPT-4 can help write SQL and R code for such tasks. But truthfully, the examples show quite the opposite! Can you spot the problems? Here’s the first one:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;Human&lt;/strong&gt;: Please provide a SQL code to access a microbiology database. The code should look for Staphylococcus spp. (but exclude Staphylococcus aureus) and include strain information on oxacillin resistance and age. An additional criteria is that the original sample material must only include biopsies and implants from the University Hospital Zurich. Please comment the code and explain it.&lt;/p&gt;

  &lt;p&gt;&lt;strong&gt;GPT-4&lt;/strong&gt;: Sure, here is an example of SQL code that can be used to access a microbiology database and retrieve information about strains that meet the specified criteria:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class=&quot;language-sql highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;-- This code selects specific columns from the table&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;-- &apos;microbiology_samples&apos; where the bacteria is &quot;Staphylococcus spp.&quot;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;-- (excluding &quot;Staphylococcus aureus&quot;), the resistance to &quot;oxacillin&quot; is&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;-- true, the age of patient is greater than 65 years old and the original&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;-- sample material only includes biopsies from the University Hospital&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;-- Zurich.&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;patient_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;patient_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hospital&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bacteria&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
       &lt;span class=&quot;n&quot;&gt;sample_material&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;microbiology_samples&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;WHERE&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;age&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;65&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;AND&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;hospital&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;University Hospital Zurich&apos;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;AND&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;sample_material&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;biopsy&apos;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;AND&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;bacteria&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;LIKE&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;Staphylococcus %&apos;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;AND&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;bacteria&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;LIKE&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;Staphylococcus aureus&apos;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;AND&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;oxacillin&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;GPT-4&lt;/strong&gt;: This code selects specific columns (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;patient_id&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;patient_name&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;age&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hospital&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bacteria&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;resistance&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sample_material&lt;/code&gt;) from the table &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;microbiology_samples&lt;/code&gt; where the age of patient is greater than 65, the original sample material only includes biopsies from the University Hospital Zurich, the bacteria is like ‘Staphylococcus %’ (all Staphylococcus species) and not like ‘Staphylococcus aureus’ and the resistance is equal to ‘oxacillin’.&lt;/p&gt;

  &lt;p&gt;It is important to note that this is a sample code and it may not run on your specific database without modification. The table and column names, as well as the database structure, may be different depending on the system you are using. Additionally, you may need to adjust the logic and syntax to match the specific requirements of your database management system.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;See anything unusual? Setting aside the vagueness of the human’s prompt, which omits some pertinent details like, what’s the structure of this database? Which dialect of SQL? and so on… a bit like asking “How do I upgrade my car’s brakes” without specifying the make/model of the car… The response has major problems, even if GPT-4 cautions that it is pseudocode and not runnable as-is.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;GPT-4 interprets “age” as the patient’s age, but the prompt suggested it’s a property of the strain.&lt;/li&gt;
  &lt;li&gt;OK, even if it’s the patient’s age: why filter to &amp;gt;65? That’s not what the user asked.&lt;/li&gt;
  &lt;li&gt;Why filter to biopsies but omit implants? Also not what the user asked.&lt;/li&gt;
  &lt;li&gt;The user asked for information on oxacillin resistance, not to filter to oxacillin-resistant isolates.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And I could go on. But even for pseudocode this is … pretty off base. Let’s look at the example given for writing R code, for which GPT-4 sounds more confident and doesn’t include any disclaimers about its output.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;Human&lt;/strong&gt;: Now please write a code in R based on this SQL output. The code should allow to visualize the output data with a boxplot (with median and IQR and min/max) of age distribution of people with a oxacillin resistant and sensitive strain. The graph with resistance should be red, the one for sensitive strains should be green. Please comment and explain the code.&lt;/p&gt;

  &lt;p&gt;&lt;strong&gt;GPT-4&lt;/strong&gt;: Sure, here is an example of R code that can be used to visualize the output data from the SQL query in the form of a boxplot:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class=&quot;language-R highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;library&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dplyr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;library&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ggplot2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# Connect to the database and retrieve the data using the SQL query&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;db_con&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dbConnect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# specify the connection details to your&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                         &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# database&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dbGetQuery&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;db_con&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;SELECT patient_id, patient_name, age,
                            resistance FROM microbiology_samples WHERE...&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dbDisconnect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;db_con&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# Use dplyr to group the data by resistance and calculate the age&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# statistics&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_grouped&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&amp;gt;%&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;group_by&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&amp;gt;%&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;summarize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IQR&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IQR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# Plot the data using ggplot&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ggplot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;aes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;geom_boxplot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;outlier.shape&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;NA&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;geom_point&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_grouped&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;aes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;geom_errorbar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_grouped&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;aes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ymin&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IQR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ymax&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IQR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;0.2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;scale_color_manual&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;red&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;green&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ggtitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Age distribution of oxacillin resistant and sensitive
          strains&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xlab&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Resistance&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;GPT-4&lt;/strong&gt;: Would you like me to explain or break down this code?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There’s plenty of problems here as well.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Assuming you fill in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dbConnect&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dbGetQuery&lt;/code&gt; arguments correctly … this code won’t run, because those functions come from the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DBI&lt;/code&gt; package, which was never loaded.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Let’s say you knew to add &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;library(DBI)&lt;/code&gt; yourself, or created fake data, like I’ve done in this rewritten version. It still won’t run. The code GPT-4 wrote was cut off prematurely after the final “y”!&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-R highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;library&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dplyr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;library&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ggplot2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data.frame&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rnorm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mean&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;65&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sd&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;rep&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;oxacillin&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;none&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_grouped&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&amp;gt;%&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;group_by&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&amp;gt;%&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;summarize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IQR&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IQR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# Plot the data using ggplot&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ggplot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;aes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;geom_boxplot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;outlier.shape&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;NA&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;geom_point&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_grouped&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;aes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;geom_errorbar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_grouped&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;aes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ymin&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IQR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ymax&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IQR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;0.2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;scale_color_manual&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;red&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;green&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ggtitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Age distribution of oxacillin resistant and sensitive strains&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xlab&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Resistance&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Error in eval(expr, envir, enclos): object &apos;y&apos; not found.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol start=&quot;3&quot;&gt;
  &lt;li&gt;OK, maybe GPT-4 meant to add a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ylab()&lt;/code&gt; but ran out of tokens, or something. Even after fixing that, still won’t run!&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-R highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;library&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dplyr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;library&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ggplot2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data.frame&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rnorm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mean&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;65&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sd&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;rep&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;oxacillin&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;none&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_grouped&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&amp;gt;%&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;group_by&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&amp;gt;%&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;summarize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IQR&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IQR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# Plot the data using ggplot&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ggplot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;aes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;geom_boxplot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;outlier.shape&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;NA&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;geom_point&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_grouped&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;aes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;geom_errorbar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_grouped&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;aes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ymin&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IQR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ymax&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IQR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;0.2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;scale_color_manual&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;red&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;green&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ggtitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Age distribution of oxacillin resistant and sensitive strains&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xlab&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Resistance&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ylab&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Age&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ERROR while rich displaying an object: Error in `geom_errorbar()`:
! Problem while computing aesthetics.
i Error occurred in the 3rd layer.
Caused by error in `FUN()`:
! object &apos;age&apos; not found
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The aesthetics are mapped wrong, for a data frame that GPT-4 defined every part of, by writing the code to create &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data_grouped&lt;/code&gt;. So, no excuses GPT-4, that bug is all on you.&lt;/p&gt;

&lt;p&gt;The fix is quite subtle, actually. You have to move the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;aes(y=age)&lt;/code&gt; mapping from the entire &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ggplot()&lt;/code&gt; to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;geom_boxplot()&lt;/code&gt;, so it doesn’t get applied to every geom.&lt;sup id=&quot;fnref-318ad3:5&quot;&gt;&lt;a href=&quot;#fn-318ad3:5&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;5&lt;/a&gt;&lt;/sup&gt; Once we do this, we’ve finally fixed this up enough to get a plot as output! 🎉&lt;/p&gt;

&lt;div class=&quot;language-R highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;library&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dplyr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;library&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ggplot2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data.frame&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rnorm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mean&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;65&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sd&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;rep&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;oxacillin&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;none&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_grouped&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&amp;gt;%&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;group_by&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&amp;gt;%&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;summarize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IQR&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IQR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# Plot the data using ggplot&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ggplot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;aes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;geom_boxplot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;aes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;outlier.shape&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;NA&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;geom_point&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_grouped&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;aes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;geom_errorbar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_grouped&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;aes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resistance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ymin&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IQR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ymax&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IQR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;0.2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;scale_color_manual&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;red&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;green&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ggtitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Age distribution of oxacillin resistant and sensitive strains&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xlab&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Resistance&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ylab&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Age&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p class=&quot;figure shadow&quot;&gt;&lt;img src=&quot;/images/oxa-plot.png&quot; alt=&quot;Plot output&quot; /&gt;&lt;/p&gt;

&lt;p&gt;But there’s yet more weirdness to fix. Why are the error bars drawn as 2 × IQR, when the human originally asked for max and min? Why do we have a redundant &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;geom_point()&lt;/code&gt;? How do we fix the colors, which are backwards from what was asked for? And it goes on. Could we goad GPT-4 into getting the right answer eventually? Maybe 🥴&lt;/p&gt;

&lt;p&gt;To be fair, the CID Viewpoint does later mention the limitation that LLMs sometimes produce “coherent but incorrect” output.&lt;sup id=&quot;fnref:1:2&quot;&gt;&lt;a href=&quot;#fn-318ad3:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; These examples portray that limitation much better than the assertion that GPT-4 can write code to do data analysis.&lt;/p&gt;

&lt;p&gt;Some have gone as far as to call GPTs &lt;a href=&quot;https://www.cst.cam.ac.uk/blog/afb21/oops-we-automated-bullshit&quot;&gt;bullshit generators&lt;/a&gt;. I think that’s a bit over the top. A better framing is that they produce output that is probabilistically correct, and for some tasks that could be useful, while for others it’s wholly inappropriate. Just like all machine learning methods, that uncertainty (is it correct 95% of the time? 23%? etc.) should be estimated, ideally using large samples, and then considered before using any of the output further.&lt;/p&gt;

&lt;p&gt;By contrast, if you’re planning to say “Hey GPT-4, write me some R code” and plug that blindly into your analytical pipeline for bioinformatics, diagnostics, etc.? Since that requires a 100% correct answer, it would be a bad idea, without some reliable way of validating the code (e.g., human expert or test suite) and then fixing it, just as we had to do above.&lt;/p&gt;

&lt;p&gt;So my final verdict? No, I would not yet say GPT-4 can replace a data analyst, or that it can write &lt;em&gt;any&lt;/em&gt; code that I’d trust blindly. But can it speed up certain sub-tasks within data science? Absolutely! Information extraction from unstructured text, drafting small bits of code like regular expressions, first-pass conversion from one format/language to another… LLMs shine when you know how to use them. There are so many bits of tedium in programming that coders would happily delegate, as long as the process remains supervised.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/features/copilot&quot;&gt;Copilot&lt;/a&gt; is a great example of an LLM product that already helps many coders write documentation, generate unit tests, and review pull requests faster—with a human still very much in the loop. This pattern can be imitated in future AI products for clinicians and microbiology laboratories. The AI tool is invited in by the user as an augmentative assistant with access to current working data, but its output is reviewed and scrutinized before it is implemented or added to the record. This pattern is already central to successful medical voice transcription products like Dragon, and given the dozens of AI-powered scribes entering the market now,&lt;sup id=&quot;fnref-318ad3:6&quot;&gt;&lt;a href=&quot;#fn-318ad3:6&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;6&lt;/a&gt;&lt;/sup&gt; it’s clearly seen as a pattern that works.&lt;/p&gt;

&lt;p&gt;That’s my hope for the general framework in which AI tools enter medicine, clinical research, microbiology, and infectious diseases. It is incumbent on domain experts in these fields to actively identify and adapt AI technologies to the use cases in which they make sense, while preserving our profession’s core values, including equitable outcomes, patient privacy, and the patient-provider relationship. Otherwise, much like how electronic medical records often feel like they were designed with front-line clinicians as an afterthought, we risk becoming the passengers—rather than the pilots—of the next generation of healthcare technology.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn-318ad3:1&quot;&gt;
      &lt;p&gt;Egli A. ChatGPT, GPT-4, and Other Large Language Models: The Next Revolution for Clinical Microbiology? &lt;em&gt;Clin Infect Dis.&lt;/em&gt; 2023 Nov 11;77(9):1322-1328. &lt;a href=&quot;https://doi.org/10.1093/cid/ciad407&quot;&gt;doi:10.1093/cid/ciad407&lt;/a&gt;. &lt;a href=&quot;#fnref-318ad3:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt; &lt;a href=&quot;#fnref:1:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt; &lt;a href=&quot;#fnref:1:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-318ad3:2&quot;&gt;
      &lt;p&gt;Kanjilal S. Flying Into the Future With Large Language Models. &lt;em&gt;Clin Infect Dis.&lt;/em&gt; 2024 Apr 10;78(4):867-869. &lt;a href=&quot;https://doi.org/10.1093/cid/ciad635&quot;&gt;doi:10.1093/cid/ciad635&lt;/a&gt;. &lt;a href=&quot;#fnref-318ad3:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-318ad3:3&quot;&gt;
      &lt;p&gt;ChatGPT, Claude, Bard, and Gemini, among a growing field of competitors, all have options for free access. There’s also the option of free downloadable models (LLaMA, Gemma, Mixtral, etc.) that you run on your own computer. &lt;a href=&quot;#fnref-318ad3:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-318ad3:4&quot;&gt;
      &lt;p&gt;Pak TR, Kasarskis A. How next-generation sequencing and multiscale data analysis will transform infectious disease management. &lt;em&gt;Clin Infect Dis.&lt;/em&gt; 2015 Dec 1;61(11):1695-702. &lt;a href=&quot;https://doi.org/10.1093/cid/civ670&quot;&gt;doi:10.1093/cid/civ670&lt;/a&gt;. &lt;a href=&quot;#fnref-318ad3:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-318ad3:5&quot;&gt;
      &lt;p&gt;I actually tried to guide GPT-4 into fixing this bug itself, but it repeatedly failed, even when giving it the full error message. &lt;a href=&quot;#fnref-318ad3:5&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-318ad3:6&quot;&gt;
      &lt;p&gt;These are products that passively listen to a doctor-patient conversation and try to draft a clinical note, similar to a human medical scribe. Some of the many entrants include: &lt;a href=&quot;https://turboscribe.ai/l/ai-medical-transcription&quot;&gt;Turboscribe.ai&lt;/a&gt;, &lt;a href=&quot;https://www.carepatron.com/feature/ai-medical-transcription&quot;&gt;CarePatron&lt;/a&gt;, &lt;a href=&quot;https://aws.amazon.com/transcribe/medical/&quot;&gt;Amazon&lt;/a&gt;, &lt;a href=&quot;https://www.heidihealth.com/&quot;&gt;Heidi&lt;/a&gt;, &lt;a href=&quot;https://get.otter.ai/interview-transcription/?keywordgroup=medical%20transcription&quot;&gt;Otter&lt;/a&gt;, &lt;a href=&quot;https://tali.ai/&quot;&gt;Tali&lt;/a&gt;, &lt;a href=&quot;https://www.ambiencehealthcare.com/product&quot;&gt;Ambience&lt;/a&gt;… &lt;a href=&quot;#fnref-318ad3:6&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</content>
 </entry>
 
 <entry>
   <title>Nuances of Observational Studies of Time-to-Antibiotics and Sepsis Mortality</title>
   <link href="https://tedpak.com/2023/08/02/risks-of-observational-studies-of-time-to-antibiotics.html"/>
   <updated>2023-08-02T00:00:00-04:00</updated>
   <id>https://tedpak.com/2023/08/02/risks-of-observational-studies-of-time-to-antibiotics</id>
   <content type="html">
&lt;p&gt;I’m happy to announce a research article I published in &lt;em&gt;Clinical Infectious Diseases&lt;/em&gt; with my mentors Mike Klompas and Chanu Rhee, entitled “Risk of Misleading Conclusions in Observational Studies of Time-to-Antibiotics and Mortality in Suspected Sepsis.” The &lt;a href=&quot;https://academic.oup.com/cid/advance-article/doi/10.1093/cid/ciad450/7235902?utm_source=authortollfreelink&amp;amp;utm_campaign=cid&amp;amp;utm_medium=email&amp;amp;guestAccessKey=d8f3a4a4-5c6c-4419-8650-369beeb63117&quot;&gt;full text is freely available using this link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We were motivated to perform this study after we reviewed the state of evidence used to support clinical guidelines on timing of antibiotics for sepsis. The typical maxim given on rounds is that the risk of death increases by 8% per hour of delay in treatment, and this has been sloganized into phrases like &lt;a href=&quot;https://www.google.com/imgres?imgurl=https://www.sepsis.org/wp-content/uploads/2019/06/Its-About-TIME-social-media-graphic-1.jpg&amp;amp;tbnid=1ts-z0Ociw4hhM&amp;amp;vet=1&amp;amp;imgrefurl=https://www.sepsis.org/wp-content/uploads/2019/08/Healthcare-and-local-government-SAM-toolkit-FINAL-08-15-19.pdf&amp;amp;docid=jk6WD3sxFoB08M&amp;amp;w=4500&amp;amp;h=4500&amp;amp;source=sh/x/im/m1/1&amp;amp;kgs=d74094378d868a9d&amp;amp;shem=abme,trie&quot;&gt;It’s About TIME&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Essentially all evidence for this derives from observational cohorts. A close reading of these studies shows four potential areas of concern, including:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;limited adjustment for potential confounders,&lt;/li&gt;
  &lt;li&gt;inclusion of outlier patients with very long delays until antibiotics,&lt;/li&gt;
  &lt;li&gt;failure to differentiate between sepsis with and without shock, and&lt;/li&gt;
  &lt;li&gt;use of linear models that assume that each additional hour until antibiotics has an equal effect.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We created our own cohort that compares favorably to prior studies (largest &lt;em&gt;N&lt;/em&gt;, five hospitals, detailed patient-level clinical data) and tested each of these analytical concerns in turn. (In essence, this was a series of four sensitivity analyses.) We used the same basic method as the most prominent studies in this field (multivariable logistic regression), varied the assumption corresponding with each analytical concern, and checked if the results changed. For all four, they did.&lt;/p&gt;

&lt;p class=&quot;figure shadow&quot;&gt;&lt;img src=&quot;/images/cid-graphical-abstract-table.png&quot; alt=&quot;Graphical abstract table&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We conclude that this type of study is highly sensitive to analytic choices regarding confounding, outliers, inclusion criteria, and non-linearity, and it’s likely that most of the prior studies were afflicted by at least one of these problems.&lt;sup id=&quot;fnref-8abe16:1&quot;&gt;&lt;a href=&quot;#fn-8abe16:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; If we keep only the most conservative assumptions (shorten the study time to 6h and adjust for all possible confounders) we are able to find a significant hourly relationship in patients with shock, but not in the cohorts without shock.&lt;/p&gt;

&lt;p&gt;Many thanks to the entire Sepsis Time Zero team, &lt;a href=&quot;https://www.populationmedicine.org/research/therapeutics-research-infectious-disease/home&quot;&gt;TIDE&lt;/a&gt;, and the &lt;a href=&quot;https://reporter.nih.gov/search/PmWJOBW3N0-TKGCcV3VXVA/project-details/10942098&quot;&gt;Harvard ID T32&lt;/a&gt; for supporting this work, as well as the American Thoracic Society for inviting me to speak about it at the 2023 meeting.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn-8abe16:1&quot;&gt;
      &lt;p&gt;The many, many pitfalls of time-to-intervention studies are summarized in this &lt;a href=&quot;https://emcrit.org/pulmcrit/the-fallacy-of-time-to-intervention-studies/&quot;&gt;evergreen EMCrit post by Josh Farkas&lt;/a&gt;. &lt;a href=&quot;#fnref-8abe16:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</content>
 </entry>
 
 <entry>
   <title>Asymptomatic COVID-19 Screening At Hospitals</title>
   <link href="https://tedpak.com/2023/04/30/the-value-of-covid-screening-at-hospitals.html"/>
   <updated>2023-04-30T00:00:00-04:00</updated>
   <id>https://tedpak.com/2023/04/30/the-value-of-covid-screening-at-hospitals</id>
   <content type="html">
&lt;p&gt;Many US hospitals have already or will soon stop testing all admitted patients for COVID-19. To support this decision, policymakers will likely cite new recommendations released by the Society for Healthcare Epidemiology of America (SHEA), the professional society that encompasses most hospital epidemiologists in the US.&lt;/p&gt;

&lt;p&gt;Interestingly, &lt;a href=&quot;https://www.cambridge.org/core/journals/infection-control-and-hospital-epidemiology/article/asymptomatic-screening-for-severe-acute-respiratory-coronavirus-virus-2-sarscov2-as-an-infection-prevention-measure-in-healthcare-facilities-challenges-and-considerations/5D9FF2904AD88CDBDA5CAFD29A965A69&quot;&gt;SHEA’s position paper in &lt;em&gt;ICHE&lt;/em&gt;&lt;/a&gt; was guarded in its conclusions, stating “the use of asymptomatic screening is a unique yet resource-intensive tool that arguably has been overused” and that “support and funding are needed for high-quality studies to examine the use of asymptomatic screening”—in essence, that we don’t have enough data to fully know the costs and benefits of the practice. On the other hand, the corresponding &lt;a href=&quot;https://shea-online.org/pre-procedure-and-pre-admission-covid-19-testing-no-longer-recommended-for-asymptomatic-patients/&quot;&gt;press release&lt;/a&gt; took it a step farther, leading off with, “Healthcare facilities should no longer routinely screen symptom-free patients for COVID-19 upon admission or before procedures.” So, this is likely to be the takeaway for hospitals: that they can and should stop all asymptomatic testing for COVID-19.&lt;/p&gt;

&lt;p&gt;In a &lt;a href=&quot;https://academic.oup.com/cid/article/78/2/439/7226132&quot;&gt;countering Viewpoint&lt;/a&gt; that my research mentors Mike Klompas and Chanu Rhee, Julia Köhler at Boston Children’s, and I wrote for &lt;em&gt;Clinical Infectious Diseases&lt;/em&gt;, we offer seven reasons why testing should continue,&lt;sup id=&quot;fnref-c9dcbf:1&quot;&gt;&lt;a href=&quot;#fn-c9dcbf:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; particularly during times of increased community transmission.&lt;/p&gt;

&lt;p class=&quot;figure shadow&quot;&gt;&lt;img src=&quot;/images/cid-viewpoint.png&quot; alt=&quot;CID viewpoint&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Here’s the top-line points:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Hospital-acquired COVID-19 remains common but under-reported and under-appreciated.  Earlier studies found that &lt;a href=&quot;https://www.theguardian.com/society/2021/mar/26/40600-people-likely-caught-covid-while-hospital-inpatients-in-england&quot;&gt;~15% of admitted patients with COVID-19 acquired it in hospitals&lt;/a&gt;.  Omicron associated with another uptrend in hospital-onset cases, as could be seen in &lt;a href=&quot;https://jamanetwork.com/journals/jama/fullarticle/2793582&quot;&gt;our healthcare system in Massachusetts&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Presymptomatic and asymptomatic patients pose the highest risk. Viral loads are highest just before symptoms (if any) start. So, &lt;a href=&quot;https://jamanetwork.com/journals/jamanetworkopen/fullarticle/2774707&quot;&gt;most transmissions are from people without symptoms&lt;/a&gt;. If you don’t screen all admissions, you’ll never catch it in time.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Transmission risk in shared patient rooms is high. The transmission rate from a patient with undiagnosed COVID-19 to an uninfected patient in the same room is 20-40%; in one Boston academic center early in the pandemic, with &lt;em&gt;both&lt;/em&gt; universal testing and masking in place, &lt;a href=&quot;https://academic.oup.com/cid/article/74/6/1097/6305137&quot;&gt;it was 39%&lt;/a&gt;. Most US hospitals have lots of shared rooms. And patients don’t get to pick their roommates.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Hospital-acquired COVID-19 still causes substantial morbidity and mortality. In vulnerable inpatients, Omicron is far from “mild” (the infamous epithet it was given by &lt;a href=&quot;https://web.archive.org/web/20240624081236/www.nytimes.com/2022/01/05/briefing/omicron-risk-milder-pandemic.html&quot;&gt;talking heads in the media&lt;/a&gt; shortly before it &lt;a href=&quot;https://web.archive.org/web/20240628093706/https://www.nytimes.com/interactive/2022/02/01/science/covid-deaths-united-states.html#:~:text=the%20new%20variant%20was%20most%20likely%20responsible%20for%20a%20majority%20of%20Covid%20deaths%20in%20the%20U.S.%20today.&quot;&gt;killed more Americans than any prior variant&lt;/a&gt;). Crude mortality rates for hospital-onset Omicron are as high as &lt;a href=&quot;https://phw.nhs.wales/services-and-teams/harp/nosocomial-covid-briefing-reports/all-cause-mortality-in-nosocomial-covid-19-cases-in-wales-version-12/&quot;&gt;13% in other countries’ national health system data&lt;/a&gt;. In a propensity-matched study of 1,095 hospital-onset COVID patients that we published in &lt;a href=&quot;https://doi.org/10.7326/M24-0199&quot;&gt;Annals of Internal Medicine&lt;/a&gt;, we found that patients infected with hospital-onset Omicron experienced 64% higher mortality than matched uninfected controls. We already undertake enormously expensive measures to stop nosocomial infections like MRSA, VRE, and &lt;em&gt;Clostridium difficile&lt;/em&gt;, all of which have arguably lower attributable risks to hospital inpatients than COVID-19. For example, some hospitals (including MGH and BWH) perform asymptomatic screening of all ICU patients for MRSA and VRE using periodic swab testing.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;More testing is associated with fewer nosocomial cases and better outcomes. When England and Scotland stopped universal admission testing in Aug-Sep 2022, &lt;a href=&quot;https://jamanetwork.com/journals/jamainternalmedicine/fullarticle/2805585&quot;&gt;hospital-onset cases rose by 26-41% compared to community-onset infections&lt;/a&gt;.&lt;sup id=&quot;fnref-c9dcbf:2&quot;&gt;&lt;a href=&quot;#fn-c9dcbf:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Potential downsides of asymptomatic testing are real, but can be mitigated. The cost (&lt;a href=&quot;https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8327298/#:~:text=The%20estimated%20excess%20testing%20cost%20based%20on%20our%20strategy%20was%20$54.5%20per%20admission&quot;&gt;$55/patient in 1 study&lt;/a&gt;) is minimal compared to 1 inpatient-day ($3-10k). False positives occur, but retesting and discontinuing precautions can be automated, as many US healthcare systems figured out during the pandemic. Mass General Brigham automated this process using an Epic SmartForm called &lt;a href=&quot;https://academic.oup.com/cid/article/73/12/2248/6132091&quot;&gt;CORAL&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Hospitals have an ethical responsibility to protect patients from COVID-19. Forcing all patients to accept increased risk of COVID-19 when they enter hospitals in exchange for minimal benefit (saving $55, avoiding unnecessary airborne isolation, small differences in care timeliness) violates non-maleficence and beneficence. As COVID-19 has disproportionately harmed Black, Latinx, and Native American populations in the US, and continues to pose the highest risk to elderly, immunocompromised, and disabled people, the removal of various layers of COVID-19 precautions in hospitals will worsen systematic healthcare inequity in the US.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As an aside: Universal masking in hospitals &lt;a href=&quot;https://www.acpjournals.org/doi/10.7326/M23-0793&quot;&gt;is also under fire&lt;/a&gt;, so when “existing layers of protection” are offered &lt;a href=&quot;https://www.cambridge.org/core/journals/infection-control-and-hospital-epidemiology/article/asymptomatic-screening-for-severe-acute-respiratory-coronavirus-virus-2-sarscov2-as-an-infection-prevention-measure-in-healthcare-facilities-challenges-and-considerations/5D9FF2904AD88CDBDA5CAFD29A965A69#:~:text=strengthening%20existing%20layers&quot;&gt;as the compensatory mechanism&lt;/a&gt; that justifies ending asymptomatic respiratory viral testing, it is hard to accept such arguments in good faith.&lt;/p&gt;

&lt;p&gt;In conclusion, we believe that more evidence and a serious plan for monitoring potential harms is needed before hospitals end universal admission testing.  For more, read &lt;a href=&quot;https://academic.oup.com/cid/article/78/2/439/7226132&quot;&gt;our full editorial in &lt;em&gt;CID&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn-c9dcbf:1&quot;&gt;
      &lt;p&gt;First released as a &lt;a href=&quot;https://osf.io/unfz7/&quot;&gt;preprint&lt;/a&gt; and also as a &lt;a href=&quot;https://x.com/theodorepak/status/1652787687835811841&quot;&gt;Twitter thread&lt;/a&gt;. &lt;a href=&quot;#fnref-c9dcbf:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-c9dcbf:2&quot;&gt;
      &lt;p&gt;When we published these results, the most common &lt;a href=&quot;https://academic.oup.com/cid/article/78/2/356/7226131#:~:text=More%20recently,%20Pak%20and%20colleagues&quot;&gt;concern raised&lt;/a&gt; was that this increase was biased by misclassification of asymptomatic shedding cases as hospital-onset cases after the policy change. We’ve now replicated an &lt;a href=&quot;https://www.healio.com/news/infectious-disease/20240423/hospitalonset-covid19-surged-after-end-of-universal-screening-masking&quot;&gt;even larger increase across a regional US healthcare system&lt;/a&gt; that ended both universal admission testing and masking simultaneously in May 2023, and we used chart reviews to find that there is a neglible proportion of misclassified hospital-onset cases after the policy change. &lt;a href=&quot;#fnref-c9dcbf:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</content>
 </entry>
 
 <entry>
   <title>My PhD Thesis</title>
   <link href="https://tedpak.com/2018/09/03/phd-thesis-is-online.html"/>
   <updated>2018-09-03T00:00:00-04:00</updated>
   <id>https://tedpak.com/2018/09/03/phd-thesis-is-online</id>
   <content type="html">
&lt;p&gt;With the publication of the last major chapter of my thesis in &lt;a href=&quot;https://doi.org/10.15252/msb.20177862&quot;&gt;&lt;em&gt;Molecular Systems Biology&lt;/em&gt;&lt;/a&gt;, I’m happy to finally be able to put the full text of my thesis on this website.&lt;sup id=&quot;fnref-017763:1&quot;&gt;&lt;a href=&quot;#fn-017763:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;tl;dr: &lt;a href=&quot;https://drive.google.com/open?id=1Rz19CdlJqs5OAtP2ZpJSiM28UfBmazF3&quot;&gt;here’s the PDF&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;My PhD thesis was called &lt;strong&gt;“Multiscale analysis of infectious diseases: integrating omics and clinical informatics data into patient care”&lt;/strong&gt; and I wrote it under the dedicated guidance of &lt;a href=&quot;https://icahn.mssm.edu/profiles/andrew-kasarskis&quot;&gt;Andrew Kasarskis, PhD&lt;/a&gt;, my thesis advisor. It was a dissertation comprising exclusively computational work. The motivating premise is that “big data” on infectious diseases are becoming more prevalent, and we should attempt new and ambitious methods to combine these data to solve urgent problems affecting our patients. Some examples of these new data sources are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Next-generation sequencing of pathogen genomes&lt;/li&gt;
  &lt;li&gt;Electronic medical records&lt;/li&gt;
  &lt;li&gt;Mass cytometry of immune cell subpopulations during infection&lt;/li&gt;
  &lt;li&gt;RNA-seq of host gene expression changes during infection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some of the problems that I tackled in this thesis were:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Using bacterial genome sequencing to explain the development of antibiotic resistance in patients undergoing treatment in the hospital&lt;/li&gt;
  &lt;li&gt;Tracking the patient-to-patient spread of hospital-acquired infections with nearly real-time analysis of genomic surveillance data&lt;/li&gt;
  &lt;li&gt;Estimating the cost of a hospital-acquired infection from electronic medical record data&lt;/li&gt;
  &lt;li&gt;Dissecting the human immune response to a recently emerging viral infection in the Americas (Chikungunya) in unprecedented depth&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;To read the thesis,&lt;/strong&gt; you can:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://drive.google.com/open?id=1Rz19CdlJqs5OAtP2ZpJSiM28UfBmazF3&quot;&gt;download the PDF&lt;/a&gt;, or…&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/thesis.html&quot;&gt;read a little more&lt;/a&gt; about the details of the thesis, its abstract, and links to the publications derived from its chapters.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’ve also put the source code for typesetting the thesis &lt;a href=&quot;https://github.com/powerpak/thesis&quot;&gt;on my GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn-017763:1&quot;&gt;
      &lt;p&gt;Although &lt;em&gt;Molecular Systems Biology&lt;/em&gt; is an open access journal and is fairly liberal about accepting work already posted online, even encouraging posts to preprint servers and &lt;a href=&quot;http://msb.embopress.org/authorguide#originalityplagiarism&quot;&gt;explicitly exempting theses&lt;/a&gt; as prior publication, many journals reserve the right to reject manuscripts that were disseminated in any way prior to submission. And until an article is published, you never know what other journals you might submit it to. Therefore, at least in the life sciences, I’d still recommend caution on putting thesis chapters online until they are accepted somewhere, or unless you’ve reviewed the editorial policies of every possible target journal. &lt;a href=&quot;#fnref-017763:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</content>
 </entry>
 
 <entry>
   <title>Anki-Slideshow: Publish Anki flashcards to the web</title>
   <link href="https://tedpak.com/2013/10/30/exporting-anki-flashcards-to-the-web.html"/>
   <updated>2013-10-30T00:00:00-04:00</updated>
   <id>https://tedpak.com/2013/10/30/exporting-anki-flashcards-to-the-web</id>
   <content type="html">
&lt;p&gt;&lt;em&gt;I’ve started putting all my medical school flashcards &lt;a href=&quot;/learn.html&quot;&gt;on this website&lt;/a&gt; using some Python and Ruby.  Read how I did it below, or &lt;a href=&quot;https://github.com/powerpak/anki-slideshow&quot;&gt;get the source code&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p class=&quot;figure shadow&quot;&gt;&lt;img src=&quot;/images/anki-slideshow.png&quot; alt=&quot;screenshot&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I’ve been using &lt;a href=&quot;http://ankisrs.net&quot;&gt;Anki&lt;/a&gt; to generate flashcards for just about every class in medical school since the second semester, and it’s been clutch for trying to memorize the insane amounts of material that we’re given.  I’d say that Anki is almost perfect for medical students and the reasons why deserve a post all to themselves.  This post, rather, is about something that I thought was missing from Anki—namely, publishing the content to the web—and how I wrote some code to fix it, all thanks to Anki being &lt;a href=&quot;https://github.com/dae/anki&quot;&gt;open source and extensible&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Most people think using open source software is an ideological consideration, but as a student, it can be just as much a practical benefit.  Students are already reliant on so much software, from &lt;a href=&quot;http://office.microsoft.com&quot;&gt;office programs&lt;/a&gt; to &lt;a href=&quot;http://www.blackboard.com/&quot;&gt;course management systems&lt;/a&gt;, much of it proprietary.  It can be disastrous when those apps become unsupported, stop working on your new device, or worse, lose data.  Imagine taking a semester’s worth of notes on a shiny new website or app that you tried because it was free or had some killer feature that you couldn’t resist.  Then the company goes out of business, and the website shuts down.  Or, your computer breaks, and the app doesn’t work on your new one.  Maybe the company decides to disable support for exporting content unless you pay a huge fee.  These situations are terrifying—especially if you have a test, much less a &lt;a href=&quot;http://www.usmle.org/step-1/&quot;&gt;career licensing exam&lt;/a&gt;, right around the corner.&lt;/p&gt;

&lt;p&gt;With Anki, not only is the desktop program free, but all notes are stored permanently on your own computer.  Also, because it is open source, your data will &lt;em&gt;always&lt;/em&gt; be retrievable, even if that means some tooling around with &lt;a href=&quot;https://github.com/dae/anki/tree/master/anki&quot;&gt;some Python libraries&lt;/a&gt; or firing up an SQLite console.  It’s literally impossible for the developers to shut you out, and even if they tried, somebody could fork Anki and fix it.  For these reasons, data in open source software is inherently much more future-proof than something like Microsoft Office.  In case you didn’t know, Office still has no complete specifications for its legacy file formats, &lt;a href=&quot;http://www.joelonsoftware.com/items/2008/02/19.html&quot;&gt;and probably never will&lt;/a&gt;. (And now it’s moving to the cloud with Office 365, where you will have even less control over preserving your content.)&lt;/p&gt;

&lt;p&gt;As it turns out, Anki is exceptionally customizable.  Since the desktop app is written in Python with &lt;a href=&quot;http://www.riverbankcomputing.com/software/pyqt/intro&quot;&gt;bindings to Qt for the GUI&lt;/a&gt;, not only is it cross-platform, but it &lt;a href=&quot;http://ankisrs.net/docs/addons.html&quot;&gt;supports writing plugins as Python scripts&lt;/a&gt;, called “addons”.  That means: no compiling, everything lives in one text file, and live objects can be debugged in a console.  Sweet!  You can do everything from GUI alterations to enhancing internal data structures or the scheduling algorithm.  There are &lt;a href=&quot;https://ankiweb.net/shared/addons/&quot;&gt;quite a few addons&lt;/a&gt; already available online.&lt;/p&gt;

&lt;p&gt;That brings us to my problem: most kinds of content have a “natural” online destination for sharing: Flickr and Instagram for photos, YouTube for video, Slideshare for slide decks, and Scribd for office documents.  Anki doesn’t really have anything in the same league.  &lt;a href=&quot;https://ankiweb.net/&quot;&gt;Yes, there’s AnkiWeb&lt;/a&gt;, but it’s designed to be used primarily as a sync backend.  An account is required to do anything, it has less features than the desktop app, and the &lt;a href=&quot;https://ankiweb.net/shared/decks/&quot;&gt;sharing functions&lt;/a&gt; are pretty limited.  There are a &lt;a href=&quot;https://ankiweb.net/shared/info/2374623780&quot;&gt;few&lt;/a&gt; &lt;a href=&quot;https://ankiweb.net/shared/info/3641619405&quot;&gt;gems&lt;/a&gt; hidden in there for medical students, but in general it’s hard to find, share, and show off good Anki material.&lt;/p&gt;

&lt;p&gt;And so, I was struck with the idea of creating a way to do exactly this.  I spend most of my time in lecture writing flashcards, and I don’t want them locked up on my computer forever.  It would be nice to have them right here on this blog, not only for me so I can watch them when I’m bored, but so that others might do the same.  Sometimes it’s nice to passively browse through content.  Why watch cat videos when you can watch Pathology flashcards?  (Har har.)&lt;/p&gt;

&lt;p&gt;The vision was to create a menu item within Anki that you click, and then everything gets synced to the web server, which plays the cards like a slideshow.  The Anki component fits entirely in &lt;a href=&quot;https://github.com/powerpak/anki-slideshow/blob/master/anki-plugin/anki-slideshow.py&quot;&gt;one short Python script&lt;/a&gt;.  There are only 5 functions, the key one being &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exportCardsToWeb()&lt;/code&gt;.  In short, the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mw.col&lt;/code&gt; object, which represents the current collection of Anki notes, is dumped into a JSON file holding the decks and the cards within them, rendered to HTML by the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;renderQA()&lt;/code&gt; method.   Then, the whole mess is copied using &lt;a href=&quot;http://www.samba.org/rsync&quot;&gt;rsync&lt;/a&gt; to a destination of your choice.  Adding these functions into the Anki GUI is as easy as the following lines at the end of the script:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;n&quot;&gt;mw&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;form&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;menuTools&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;addSeparator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;action&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;QAction&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Export Cards to Anki-Slideshow&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mw&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;mw&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;connect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;action&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SIGNAL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;triggered()&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;exportCardsToWeb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;mw&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;form&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;menuTools&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;addAction&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;action&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;action&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;QAction&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Change Sync Destination for Anki-Slideshow&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mw&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;mw&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;connect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;action&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SIGNAL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;triggered()&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getSyncTarget&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;mw&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;form&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;menuTools&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;addAction&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;action&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This throws an extra section with two items onto the end of the Tools menu of the main window.  Clicking on these items runs the functions written at the beginning of the script.&lt;/p&gt;

&lt;p&gt;It’s not that hard to serve data from a big JSON file with a web app.  It’s a perfect use case for the lightweight &lt;a href=&quot;http://sinatrarb.com&quot;&gt;Sinatra web framework&lt;/a&gt;.  The entirety of the Ruby code written for this is &lt;a href=&quot;https://github.com/powerpak/anki-slideshow/blob/master/anki-slideshow.rb&quot;&gt;72 lines&lt;/a&gt;, with around &lt;a href=&quot;https://github.com/powerpak/anki-slideshow/tree/master/views&quot;&gt;75 lines of HTML templating in ERB&lt;/a&gt;.  There are more lines of Javascript (~150 + a few jQuery plugins) than server-side code.  I wanted to serve this from a subdomain of this server (&lt;a href=&quot;https://learn.tedpak.com&quot;&gt;https://learn.tedpak.com&lt;/a&gt;) and have it look decent both on its own and as an embeddable widget.  There are only three routes defined:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;/&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;redirect&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;/&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;AnkiSlideshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;decks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;keys&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sample&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;/:image.jpg&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;content_type&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;image/jpeg&quot;&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;send_file&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;File&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;AnkiSlideshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;media_dir&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;params&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;.jpg&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;/:deck&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;vi&quot;&gt;@title&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;vi&quot;&gt;@deck_name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;params&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:deck&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;deck&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;AnkiSlideshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;decks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;params&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:deck&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;pass&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;unless&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;deck&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;random_card_id&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;deck&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sample&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;deck&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sample&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_s&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_card_id&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;vi&quot;&gt;@card&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;AnkiSlideshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;cards&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random_card_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;vi&quot;&gt;@card&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;q&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;NO_CARDS_MESSAGE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;a&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;NO_CARDS_MESSAGE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;erb&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:card&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;In short, this means that if you go to the bare domain, you’re redirected to a random deck; if you fetch a URL ending in “.jpg”, it grabs the picture (if there is one) and serves it.  If the URL is anything else, it looks for a deck with that name and serves a random card from it.&lt;/p&gt;

&lt;p&gt;The rest of the hard work is done by some jQuery in the interface.  Once it is time to fetch a new card, a request is sent via AJAX to the same &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/:deck&lt;/code&gt; URL route, which provides the full HTML for a new random card.  To avoid a distracting transition, the new card is parsed out of the HTML and inserted in the current page.  If the user changed the deck they want to view, we can even gracefully update the URL in the address bar using the &lt;a href=&quot;http://diveintohtml5.info/history.html&quot;&gt;HTML5 History API&lt;/a&gt;.  A lot of this is made straightforward by the &lt;a href=&quot;http://api.jquery.com/load/&quot;&gt;jQuery .load() method&lt;/a&gt;, as can be seen in the excerpt below:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;nf&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;#next-card&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;href&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; #card &amp;gt; *&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nf&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;#card&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;fadeOut&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;fadeTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;history&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;history&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;pushState&lt;/span&gt; 
        &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;location&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;href&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;nb&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;history&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;pushState&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;#card&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;empty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;#next-card &amp;gt; *&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;#next&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Turn over&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;unbind&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;click&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;click&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;flipCard&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;#timer&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;trigger&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;flipCard&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;#timer&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;trigger&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;changeTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;removeClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;transition&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;#card .front&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;addClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;solid&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;fadeIn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;scrollTo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;#card .front&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;fadeTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;axis&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; 
        &lt;span class=&quot;na&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;switcherHeight&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}});&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;is&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;.hover&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;#timer&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;trigger&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;stop&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;That &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$.scrollTo()&lt;/code&gt; call provides a nice animated transition to the reverse side of the card in case it is off the edge of the screen, using the very nice &lt;a href=&quot;http://flesler.blogspot.com/2007/10/jqueryscrollto.html&quot;&gt;scrollTo jQuery plugin&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Since I preferred the web app to run more like a passive slideshow than an active learning tool like the Anki apps (requiring you to click through the cards according to right or wrong answers), the bulk of the remaining JavaScript is dedicated to making the little timer widget in the upper right corner, which automatically flips cards unless you turn it off or pause it by hovering over the card.  You can see how other code has to interact with the widget via those events triggered on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$(&apos;#timer&apos;)&lt;/code&gt; in the previous excerpt.  The spinning wheel is drawn via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; but it would probably look even better as SVG.&lt;/p&gt;

&lt;p&gt;To embed the web app into another page, an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;iframe/&amp;gt;&lt;/code&gt; element with a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src&lt;/code&gt; attribute pointing to one of the decks can be used.  For example, this is how I can embed my Cardiovascular deck.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-html&quot; data-lang=&quot;html&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;iframe&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;src=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;//learn.tedpak.com/Cardiovascular&quot;&lt;/span&gt; 
    &lt;span class=&quot;na&quot;&gt;width=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;480&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;height=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;400&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;frameborder=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;2&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;It produces the following, which I’ve highlighted with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;frameborder=&quot;2&quot;&lt;/code&gt; attribute so you can see where its edges are.  But those can be turned off by setting &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;frameborder=&quot;0&quot;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe src=&quot;//learn.tedpak.com/Cardiovascular&quot; width=&quot;480&quot; height=&quot;400&quot; frameborder=&quot;2&quot;&gt;&lt;/iframe&gt;&lt;/p&gt;

&lt;p&gt;And there you have it.  Hopefully this inspires other projects that try to use Anki content in larger web apps, since it is a powerful tool that deserves more integration into so many other things.  The code is &lt;a href=&quot;https://github.com/powerpak/anki-slideshow&quot;&gt;on Github&lt;/a&gt;, and you can see the slideshow in action with my medical school decks on &lt;a href=&quot;/learn.html&quot;&gt;this site&lt;/a&gt; or as a &lt;a href=&quot;//learn.tedpak.com/&quot;&gt;standalone website&lt;/a&gt;.  Some ideas I currently have for improving it are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A better front page for it that explains the UI and deck content before jumping into a deck&lt;/li&gt;
  &lt;li&gt;Upgrading the timer drawing to SVG so it looks better on high-res screens&lt;/li&gt;
  &lt;li&gt;Adding tag support, so you can filter by subtopic and by lecture (I tag in Anki by lecture number)&lt;/li&gt;
  &lt;li&gt;Having the server remember your recent cards, so it tries not to repick them&lt;/li&gt;
&lt;/ul&gt;

</content>
 </entry>
 
 <entry>
   <title>The First Year At Icahn School of Medicine at Mount Sinai</title>
   <link href="https://tedpak.com/2013/07/17/first-year-as-a-medical-student-ismms.html"/>
   <updated>2013-07-17T00:00:00-04:00</updated>
   <id>https://tedpak.com/2013/07/17/first-year-as-a-medical-student-ismms</id>
   <content type="html">
&lt;p&gt;I was happy to be featured in a video produced by my medical school about life as a first year student here.&lt;/p&gt;

&lt;iframe width=&quot;480&quot; height=&quot;300&quot; src=&quot;//www.youtube.com/embed/_AWbc1wUadE&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;

&lt;p&gt;Since it was filmed throughout the entirety of first year starting from the white coat ceremony, and now I’m knee-deep in the second, it’s interesting to look back and remember snippets of how it all went down.  It was shot in a hands-off style: besides coordinating when the crew would be where, and the “debriefing” interviews, we as students pretty much did our thing and the cameras rolled.&lt;/p&gt;

&lt;p&gt;The video is sincere about the culture and mission of the school, with the essence of our experience as first-years conveyed quite honestly.  There are a lot of special things about Mount Sinai that I’ve already discovered in the short time that I’ve been here.  Most of all, what makes Sinai especially great are the students and faculty here, and I was happy to see the video let the students’ thoughts and personalities speak for themselves.  Ultimately medical education is about the people around you, so you should never underestimate the impact of a happy and well-rounded student body.&lt;/p&gt;

&lt;p&gt;Hopefully applicants see the video and get a more personal sense of what Sinai is like.  If you’re applying to Sinai and are interested in anything that you saw or heard about, feel free to &lt;a href=&quot;ma&amp;#105;lt&amp;#111;&amp;#58;%&amp;#55;&amp;#52;%68e&amp;#37;&amp;#54;F%64or%65&amp;#46;&amp;#114;&amp;#46;&amp;#37;70a%6B&amp;#37;&amp;#52;0g%&amp;#54;&amp;#68;a&amp;#105;%6C%2Ec%6&amp;#70;%6D&quot;&gt;email me&lt;/a&gt;!&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Predicting Influenza Virulence with Machine Learning</title>
   <link href="https://tedpak.com/2013/06/18/predicting-influenza-virulence-with-machine-learning.html"/>
   <updated>2013-06-18T00:00:00-04:00</updated>
   <id>https://tedpak.com/2013/06/18/predicting-influenza-virulence-with-machine-learning</id>
   <content type="html">&lt;h1 id=&quot;proposal&quot;&gt;Proposal&lt;/h1&gt;

&lt;p&gt;Machine learning (ML) excels at creating models of the interactions between many weak correlations that may elude lower-dimensional statistical analysis. An example of a network of such interactions is the multifactorial sequence properties that determine the phenotype of a virus, such as influenza, in a given host. Although ML on viral sequence features has been used to predict more effective antiretroviral combinations for HIV &lt;sup id=&quot;fnref-07fc06:1&quot;&gt;&lt;a href=&quot;#fn-07fc06:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;, identify genetic markers for host selectivity within families of viruses &lt;sup id=&quot;fnref-07fc06:2&quot;&gt;&lt;a href=&quot;#fn-07fc06:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;, and refine genotyping strategies for Hepatitis C virus &lt;sup id=&quot;fnref-07fc06:3&quot;&gt;&lt;a href=&quot;#fn-07fc06:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;, the use of ML algorithms to predict the pathogenicity, infectivity, transmissibility, and vaccination response of an uncharacterized influenza strain from viral genomic sequence is still in its infancy &lt;sup id=&quot;fnref-07fc06:4&quot;&gt;&lt;a href=&quot;#fn-07fc06:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;&lt;sup&gt;,&lt;/sup&gt;&lt;sup id=&quot;fnref-07fc06:5&quot;&gt;&lt;a href=&quot;#fn-07fc06:5&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;&lt;sup&gt;,&lt;/sup&gt;&lt;sup id=&quot;fnref-07fc06:6&quot;&gt;&lt;a href=&quot;#fn-07fc06:6&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;6&lt;/a&gt;&lt;/sup&gt;. It is widely understood that these properties of influenza virus as they manifest within a specific host are complex polygenic traits, currently characterized as a collection of genetic mutations &lt;sup id=&quot;fnref-07fc06:7&quot;&gt;&lt;a href=&quot;#fn-07fc06:7&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;7&lt;/a&gt;&lt;/sup&gt; isolated from wild strains whose singular effect on virulence are further characterized in animal studies, e.g., the N66S mutation in the proapoptotic PB1-F2 viral protein that increased the virulence of the 1918 Spanish Flu virus &lt;sup id=&quot;fnref-07fc06:8&quot;&gt;&lt;a href=&quot;#fn-07fc06:8&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;8&lt;/a&gt;&lt;/sup&gt;. Multivariate analyses of the &lt;em&gt;interactions&lt;/em&gt; between observed mutations are not commonly published, however. One such meta-analysis in 2009 used 69 genomic sequences of H5N1 avian influenza to create a Bayesian graphical model inferring their virulence in mammals and confirmed that virulence is directly influenced by mutations in at least four genes, with at least two mechanisms requiring particular mutation combinations &lt;sup id=&quot;fnref-07fc06:9&quot;&gt;&lt;a href=&quot;#fn-07fc06:9&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;9&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;p&gt;The ability to predict changes in virulence properties in animal reservoirs of influenza and likely mutations that would cause transmission to humans would have a profound effect on our ability to take preventative measures against the outbreak of hypervirulent influenza like the strains causing pandemics in 1918-1919 and 1957-1958 with tens of millions of casualties, and more recently tens of thousands of deaths resulting from reemergence of an older strain in 1977 and triple reassortment in 2009 &lt;sup id=&quot;fnref-07fc06:7&quot;&gt;&lt;a href=&quot;#fn-07fc06:7&quot; class=&quot;footnote&quot;&gt;7&lt;/a&gt;&lt;/sup&gt;. For example, the current vaccination strategy could be enhanced for generation of immunity against not only previously known strains on the rise, but predicted future pandemic strains. The novel triple-reassortment strain that produced the 2009 H1N1 pandemic was identified too late to be included in that season’s trivalent vaccine &lt;sup id=&quot;fnref-07fc06:10&quot;&gt;&lt;a href=&quot;#fn-07fc06:10&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;10&lt;/a&gt;&lt;/sup&gt;, requiring rapid development of a second vaccine at an additional cost of $2 billion &lt;sup id=&quot;fnref-07fc06:11&quot;&gt;&lt;a href=&quot;#fn-07fc06:11&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;11&lt;/a&gt;&lt;/sup&gt;. While some computational models of influenza virulence &lt;sup id=&quot;fnref-07fc06:12&quot;&gt;&lt;a href=&quot;#fn-07fc06:12&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;12&lt;/a&gt;&lt;/sup&gt; and mutation &lt;sup id=&quot;fnref-07fc06:6&quot;&gt;&lt;a href=&quot;#fn-07fc06:6&quot; class=&quot;footnote&quot;&gt;6&lt;/a&gt;&lt;/sup&gt; take a highly structural approach (e.g., based on antigen-receptor binding affinity), we propose that an ML algorithm modeling these phenomena should be constructed on phenotype-genotype correlation data for three reasons. Firstly, many mutations that are known to affect influenza virulence occur in the viral polymerase complex (PB1 and PB2) or the IFN antagonist (NS1) &lt;sup id=&quot;fnref-07fc06:7&quot;&gt;&lt;a href=&quot;#fn-07fc06:7&quot; class=&quot;footnote&quot;&gt;7&lt;/a&gt;&lt;/sup&gt;&lt;sup&gt;,&lt;/sup&gt;&lt;sup id=&quot;fnref-07fc06:9&quot;&gt;&lt;a href=&quot;#fn-07fc06:9&quot; class=&quot;footnote&quot;&gt;9&lt;/a&gt;&lt;/sup&gt;, and these are not captured by the cited models which focus on the hemagluttinin protein (HA). Secondly, genotypic and phenotypic data on influenza isolates are being actively concentrated into several online public databases: the &lt;a href=&quot;http://platform.gisaid.org/epi3/frontend&quot;&gt;GISAID&lt;/a&gt;, the &lt;a href=&quot;http://www.ncbi.nlm.nih.gov/genomes/FLU/FLU.html&quot;&gt;Influenza Virus Resource&lt;/a&gt;, and the &lt;a href=&quot;http://www.fludb.org/brc/home.do?decorator=influenza&quot;&gt;Influenza Research Database&lt;/a&gt; (IRD), from which data should be pipelined to continually inform any systematic model of influenza so that it may remain up to date. Thirdly, depending on the selection of the ML technique, a human-interpretable model created by the training process could facilitate biological interpretation of the results, e.g., an ML analysis of host selectivity in &lt;em&gt;Picornaviridae&lt;/em&gt; showed by mapping the most predictive AA &lt;em&gt;k&lt;/em&gt;-mers back to annotated domains that replicase motifs in the polymerases were most discriminative &lt;sup id=&quot;fnref-07fc06:2&quot;&gt;&lt;a href=&quot;#fn-07fc06:2&quot; class=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;p&gt;We propose that a decision-tree-based ML algorithm trained on &lt;a href=&quot;http://www.fludb.org/brc/influenza_virus_characteristic_search.do?method=SubmitForm&amp;amp;decorator=influenza&amp;amp;navRoot=true&quot;&gt;phenotypic data from the IRD&lt;/a&gt; will be able to distinguish significant interactions between virulence factors and predict virulence caused by combinations of variants and segments that are currently uncharacterized. Firstly, the associated publication for each of the the phenotype records will be filtered for articles that report pathogenicity data, and for each strain, we will extract data on lethality in the experimental animal cohort, severity of the disease, associated symptoms, and a timecourse of viral titers in various tissues. For example, Govorkova et al. report such data for four human isolates and nine avian isolates in ferrets &lt;sup id=&quot;fnref-07fc06:13&quot;&gt;&lt;a href=&quot;#fn-07fc06:13&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;13&lt;/a&gt;&lt;/sup&gt;, and other papers in the IRD report analogous results for other strains.&lt;/p&gt;

&lt;p class=&quot;figure&quot;&gt;&lt;img src=&quot;/images/govorkova-table-1.png&quot; alt=&quot;Table 1 from Govorkova et al., illustrating phenotypic data from animal experiments that will be used to train the ML algorithm.&quot; /&gt;
Table 1 from Govorkova et al., illustrating phenotypic data from animal experiments that will be used to train the ML algorithm.&lt;/p&gt;

&lt;p&gt;Having loaded this data into a relational database similar to the design seen in Figure 2, we will relate it to sequence data downloaded from &lt;a href=&quot;http://www.fludb.org/brc/home.do?decorator=influenza&quot;&gt;IRD&lt;/a&gt; or &lt;a href=&quot;http://www.ncbi.nlm.nih.gov/genbank/&quot;&gt;GenBank&lt;/a&gt;. Sequence data must be processed to extract genotypic features that will be used by the model. We may do this by simply using the sequencing derived phenotype markers already annotated by IRD (typically AA substitutions), but we may also choose to use &lt;a href=&quot;http://www.ncbi.nlm.nih.gov/genomes/FLU/help.html#annotation&quot;&gt;FLAN from the Influenza Virus Resource&lt;/a&gt; to generate a feature table, or align the sequences to a generalized reference assembly or Hidden Markov Model &lt;sup id=&quot;fnref-07fc06:14&quot;&gt;&lt;a href=&quot;#fn-07fc06:14&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;14&lt;/a&gt;&lt;/sup&gt;&lt;sup&gt;,&lt;/sup&gt;&lt;sup id=&quot;fnref-07fc06:15&quot;&gt;&lt;a href=&quot;#fn-07fc06:15&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;15&lt;/a&gt;&lt;/sup&gt; and extract features according to our own criteria. This could include raw &lt;em&gt;k&lt;/em&gt;-mers of AAs or nucleotides, SNPs from the nucleic acid sequence, deleteriousness of these SNPs as predicted by PolyPhen &lt;sup id=&quot;fnref-07fc06:16&quot;&gt;&lt;a href=&quot;#fn-07fc06:16&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;16&lt;/a&gt;&lt;/sup&gt; or similar, functional domains predicted within ORFs, codon usage bias within these domains, and more complex measures that attempt to capture the proximity of pairs of features.&lt;/p&gt;

&lt;p class=&quot;figure&quot;&gt;&lt;img src=&quot;/images/virus-data-model.png&quot; alt=&quot;A relational data model for capturing pathogenic genotype-phenotype associations (apologies for cameraphone quality)&quot; /&gt;
A relational data model for capturing pathogenic genotype-phenotype associations (apologies for cameraphone quality)&lt;/p&gt;

&lt;p&gt;We will then extract (in a process analagous to denormalization of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sequence&lt;/code&gt; table in Figure 2) vectors of sequence features and phenotype features with which we can train a machine-learning algorithm. A decision-tree based algorithm, such as probabilistic decision trees, random forest or alternating decision trees, will be trained on these vectors to produce a model. The model can be tested by taking sequence data for an unknown strain, processing it via the same feature extraction pipeline used for the training set, and running the model on this vector of features. We can validate this model internally via ten-fold cross-validation and externally via analysis of strains that are not yet in the IRD’s phenotype database but for which experimental or epidemiological data in the literature strongly suggests a correct phenotype.&lt;/p&gt;

&lt;p&gt;Assuming our model holds up to internal and external validation, the decision tree or ensemble of decision trees produced by ML can be examined to determine interesting combinations of features that we predict will produce significant changes in virulence. The biological significance of these combinations can potentially be experimentally verified in animal models. Furthermore, by starting with the phenotypic prediction for a particular virus sequence and varying small combinations of features at a time, we can predict the changes that would cause the greatest change in virulence &lt;em&gt;for that virus&lt;/em&gt;. This can be performed on &lt;a href=&quot;ftp://ftp.ncbi.nih.gov/genomes/INFLUENZA/&quot;&gt;the entire GenBank influenza library&lt;/a&gt; to predict which sequenced strains are predicted to already be the &lt;em&gt;most&lt;/em&gt; virulent in humans, and which will increase most in virulence after a small number of genetic alterations.&lt;/p&gt;

&lt;p&gt;We can then present our model to the internet via a web interface, allowing analysis of arbitrary influenza sequences using our pipeline, submission of new phenotypic data, and visualization of predictions for the GenBank influenza library. Sequence data is frequently the first informative data available for an emerging pathogen. Here, we hope to produce a model for influenza virulence based exclusively on sequence data that will produce for any given viral sequence, based on the most up-to-date experimental evidence curated in the IRD, 1) a likelihood of the unknown strain’s danger to humans and 2) the number and location of mutations that would most likely increase its virulence, allowing an assessment of whether it will evolve to be dangerous in the near future.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn-07fc06:1&quot;&gt;
      &lt;p&gt;Lengauer T. Bioinformatical Assistance of Selecting Anti-HIV Therapies: Where Do We Stand? &lt;em&gt;Intervirology&lt;/em&gt;. 2012;55(2):108–112. &lt;a href=&quot;https://doi.org/10.1159/000332000&quot;&gt;doi:10.1159/000332000&lt;/a&gt;. &lt;a href=&quot;#fnref-07fc06:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-07fc06:2&quot;&gt;
      &lt;p&gt;Raj A, Dewar M, Palacios G, Rabadan R, Wiggins CH. Identifying Hosts of Families of Viruses: A Machine Learning Approach. &lt;em&gt;PLoS ONE&lt;/em&gt;. 2011;6(12):e27631. &lt;a href=&quot;https://doi.org/10.1371/journal.pone.0027631.s004&quot;&gt;doi:10.1371/journal.pone.0027631.s004&lt;/a&gt;. &lt;a href=&quot;#fnref-07fc06:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-07fc06:3&quot;&gt;
      &lt;p&gt;Hraber P, Kuiken C, Waugh M, Geer S, Bruno WJ, Leitner T. Classification of hepatitis C virus and human immunodeficiency virus-1 sequences with the branching index. &lt;em&gt;Journal of General Virology&lt;/em&gt;. 2008;89(9):2098–2107. &lt;a href=&quot;https://doi.org/10.1099/vir.0.83657-0&quot;&gt;doi:10.1099/vir.0.83657-0&lt;/a&gt;. &lt;a href=&quot;#fnref-07fc06:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-07fc06:4&quot;&gt;
      &lt;p&gt;Attaluri PK, Chen Z, Weerakoon AM, Lu G. Integrating Decision Tree and Hidden Markov Model (HMM) for Subtype Prediction of Human Influenza A Virus. In: Shi Y, Wang S, Peng Y, eds. &lt;em&gt;Cutting-Edge Research Topics on Multiple Criteria Decision Making&lt;/em&gt;. Springer; 2009:52–58. &lt;a href=&quot;#fnref-07fc06:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-07fc06:5&quot;&gt;
      &lt;p&gt;Trtica-Majnaric L, Zekic-Susac M, Natasa Sarlija, Vitale B. Prediction of influenza vaccination outcome by neural networks and logistic regression. &lt;em&gt;Journal of Biomedical Informatics&lt;/em&gt;. 2010;43(5):774–781. &lt;a href=&quot;https://doi.org/10.1016/j.jbi.2010.04.011&quot;&gt;doi:10.1016/j.jbi.2010.04.011&lt;/a&gt;. &lt;a href=&quot;#fnref-07fc06:5&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-07fc06:6&quot;&gt;
      &lt;p&gt;Xia Z, Das P, Huynh T, Royyuru AK, Zhou R. Modeling mutations of influenza virus with IBM Blue Gene. &lt;em&gt;IBM J Res &amp;amp; Dev&lt;/em&gt;. 2011;55(5):7:1–7:11. &lt;a href=&quot;https://doi.org/10.1147/JRD.2011.2163276&quot;&gt;doi:10.1147/JRD.2011.2163276&lt;/a&gt;. &lt;a href=&quot;#fnref-07fc06:6&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-07fc06:7&quot;&gt;
      &lt;p&gt;Tscherne DM, García-Sastre A. Virulence determinants of pandemic influenza viruses. &lt;em&gt;J Clin Invest&lt;/em&gt;. 2011;121(1):6–13. &lt;a href=&quot;https://doi.org/10.1172/JCI44947&quot;&gt;doi:10.1172/JCI44947&lt;/a&gt;. &lt;a href=&quot;#fnref-07fc06:7&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-07fc06:8&quot;&gt;
      &lt;p&gt;Conenello GM, Zamarin D, Perrone LA, Tumpey T, Palese P. A Single Mutation in the PB1-F2 of H5N1 (HK/97) and 1918 Influenza A Viruses Contributes to Increased Virulence. &lt;em&gt;PLoS Pathog&lt;/em&gt;. 2007;3(10):e141. &lt;a href=&quot;#fnref-07fc06:8&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-07fc06:9&quot;&gt;
      &lt;p&gt;Lycett SJ, Ward MJ, Lewis FI, Poon AFY, Kosakovsky Pond SL, Brown AJL. Detection of Mammalian Virulence Determinants in Highly Pathogenic Avian Influenza H5N1 Viruses: Multivariate Analysis of Published Data. &lt;em&gt;Journal of Virology&lt;/em&gt;. 2009;83(19):9901–9910. &lt;a href=&quot;https://doi.org/10.1128/JVI.00608-09&quot;&gt;doi:10.1128/JVI.00608-09&lt;/a&gt;. &lt;a href=&quot;#fnref-07fc06:9&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-07fc06:10&quot;&gt;
      &lt;p&gt;Lambert LC, Fauci AS. Influenza vaccines for the future. &lt;em&gt;N Engl J Med&lt;/em&gt;. 2010;363(21):2036–2044. &lt;a href=&quot;https://doi.org/10.1056/NEJMra1002842&quot;&gt;doi:10.1056/NEJMra1002842&lt;/a&gt;. &lt;a href=&quot;#fnref-07fc06:10&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-07fc06:11&quot;&gt;
      &lt;p&gt;Nabel GJ, Fauci AS. Induction of unnatural immunity: prospects for a broadly protective universal influenza vaccine. &lt;em&gt;Nature Publishing Group&lt;/em&gt;. 2010;16(12):1389–1391. &lt;a href=&quot;https://doi.org/10.1038/nm1210-1389&quot;&gt;doi:10.1038/nm1210-1389&lt;/a&gt;. &lt;a href=&quot;#fnref-07fc06:11&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-07fc06:12&quot;&gt;
      &lt;p&gt;Goh G, Dunker AK, Uversky VN. Protein intrinsic disorder and influenza virulence: the 1918 H1N1 and H5N1 viruses. &lt;em&gt;Virol J&lt;/em&gt;. 2009;6(1):69. &lt;a href=&quot;https://doi.org/10.1186/1743-422X-6-69&quot;&gt;doi:10.1186/1743-422X-6-69&lt;/a&gt;. &lt;a href=&quot;#fnref-07fc06:12&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-07fc06:13&quot;&gt;
      &lt;p&gt;Govorkova EA, Rehg JE, Krauss S, et al. Lethality to Ferrets of H5N1 Influenza Viruses Isolated from Humans and Poultry in 2004. &lt;em&gt;Journal of Virology&lt;/em&gt;. 2005;79(4):2191–2198. &lt;a href=&quot;https://doi.org/10.1128/JVI.79.4.2191-2198.2005&quot;&gt;doi:10.1128/JVI.79.4.2191-2198.2005&lt;/a&gt;. &lt;a href=&quot;#fnref-07fc06:13&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-07fc06:14&quot;&gt;
      &lt;p&gt;Kuiken C, Yoon H, Abfalterer W, Gaschen B, Lo C, Korber B. Viral Genome Analysis and Knowledge Management. In: &lt;em&gt;Methods in Molecular Biology&lt;/em&gt;. Totowa, NJ: Humana Press; 2012:253–261. &lt;a href=&quot;#fnref-07fc06:14&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-07fc06:15&quot;&gt;
      &lt;p&gt;Hughey R, Krogh A. Hidden Markov models for sequence analysis: extension and analysis of the basic method. &lt;em&gt;Comput Appl Biosci&lt;/em&gt;. 1996;12(2):95–107. &lt;a href=&quot;#fnref-07fc06:15&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-07fc06:16&quot;&gt;
      &lt;p&gt;Adzhubei IA, Schmidt S, Peshkin L, et al. A method and server for predicting damaging missense mutations. &lt;em&gt;Nature Publishing Group&lt;/em&gt;. 2010;7(4):248–249. &lt;a href=&quot;https://doi.org/10.1038/nmeth0410-248&quot;&gt;doi:10.1038/nmeth0410-248&lt;/a&gt;. &lt;a href=&quot;#fnref-07fc06:16&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</content>
 </entry>
 
 <entry>
   <title>What Makes an Extraordinary Physician</title>
   <link href="https://tedpak.com/2013/05/06/what-makes-an-extraordinary-physician.html"/>
   <updated>2013-05-06T00:00:00-04:00</updated>
   <id>https://tedpak.com/2013/05/06/what-makes-an-extraordinary-physician</id>
   <content type="html">
&lt;p class=&quot;figure&quot;&gt;&lt;a href=&quot;http://www.flickr.com/photos/jreed/4053911941/&quot; title=&quot;Day 9 (improved version) by j.reed, on Flickr&quot;&gt;&lt;img src=&quot;http://farm3.staticflickr.com/2619/4053911941_f0772df223.jpg&quot; alt=&quot;Day 9 (improved version)&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I wrote this essay for my &lt;a href=&quot;http://icahn.mssm.edu/education/medical-education/programs/md-program/curriculum/first-year&quot;&gt;Art and Science of Medicine I&lt;/a&gt; course, and decided to share it here since the topic is general and reflects a broad sampling of what I’ve learned in the last couple years.  Names of doctors and patients and some personal details are redacted to preserve privacy.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The duty of doctors is widely recognized as a profoundly high standard: every day, encountering disease, using conversation and examination to reveal details inscrutable to most people, and applying science and compassion to restore a patient to health.  To “first, do no harm” is difficult enough when a patient lies mysteriously sick and the number of possible maladies is endless; to find the right treatment to cure or relieve them is an ordeal of another magnitude.  In order for doctors to perform these duties, society places a remarkable amount of trust in them, allowing them to touch and manipulate the flesh of people and hear their most intimate secrets.  We need doctors because we often encounter them at our weakest, when the natural functions we expect from our bodies suddenly fail either due to accident, the environment, or defect.  To restore that function is an extraordinary power and an extraordinary privilege.  To perform these duties extraordinarily is even more superlative.  Superlative doctors inspire everyone in the practice of medicine to reach for that standard that seems so profoundly high.  To find compassion for a patient that may not summon it naturally, to make time for an extra conversation with family after an exhausting shift, to always place the patient first in spite of potential conflicts with our own interests—these are deeds that encourage other physicians to improve their own qualities in the course of the profession.&lt;/p&gt;

&lt;p&gt;In my experience, an extraordinary physician must have at least four core characteristics.  Firstly, there is the ability to &lt;em&gt;listen&lt;/em&gt;.  It would seem that every doctor does this, but few do it perfectly.  Is it necessarily their fault?  Usually, no; clinics and hospitals are busy places: there are phones ringing, intercoms screeching, machines beeping, emails inbound, computers with forms that need to be filled.  But to shut out all of that noise and distraction, and stare a patient in the eyes and listen to and &lt;em&gt;feel&lt;/em&gt; every word that they are saying—that is something that every patient not only deserves, but often &lt;em&gt;needs&lt;/em&gt; in order to become healthy again.&lt;/p&gt;

&lt;p&gt;One physician I shadowed before coming to Sinai—in fact, the first one that inspired me to consider medicine as my calling—was an exceptional listener.  As soon as Dr. K entered the room, the door closed, and he would lighten the mood with a few jokes, mostly at his own expense.  (They were usually the same jokes over and over, but the different patients wouldn’t have known, and so they always worked.)  He was a cardiologist; his patients almost universally had chronic heart failure, and he needed to change their daily habits to save their lives.  That meant understanding everything about them: when they got up, what they ate, what made them stressed, how the medicines made them feel, what they expected from their new life post-cardiac incident.  Talking about this, therefore, was the crux of his role in their healthcare team.  I never saw him touch a phone or a computer in the presence of the patient. They trusted him because he really listened, eyes on their face, sharing himself with them, and only taking notes after the conversation was over.&lt;/p&gt;

&lt;p&gt;He once told me, somewhat surprisingly to my ears, that if he had to choose between all the labs and tests that he could order and the ability to talk to them he would pick the personal history every single time.  I heard his patients open up to him about everything—a father whose son who just committed suicide, a man struggling with cocaine, a mother who was frightened she would outlive her daughter.  It was startling and humbling that I was even allowed in the room when it happened.  All of these things mattered because without them, how could a physician realistically plan out the rest of these people’s lives?  Would a battery of pharmaceuticals, taken regularly or not, make a dent in a patient’s sclerotic arteries in the face of the kind of life-altering stress that these patients had?  A change involving the fabric of a patient’s life, like what they ate, thought, aspired to and valued, needed to happen one step at a time, and Dr. K perfectly understood and demonstrated this respect for the complexity of human life by &lt;em&gt;listening&lt;/em&gt; to them.&lt;/p&gt;

&lt;p class=&quot;figure&quot;&gt;&lt;a href=&quot;http://www.flickr.com/photos/andrewpenny/6661467365/&quot; title=&quot;TK-421 Jr. learns to ride his bike by Andrew Penny, on Flickr&quot;&gt;&lt;img src=&quot;http://farm8.staticflickr.com/7020/6661467365_c1059aceeb.jpg&quot; alt=&quot;TK-421 Jr. learns to ride his bike&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Extraordinary physicians also need to be able to &lt;em&gt;teach&lt;/em&gt;.  A doctor encounters his patient for a ridiculously small fraction of their natural lives, and yet often aspires to fundamentally change the 99% of the lifetime that he will not witness.  This would be impossible unless the patient can take away something more than a few prescription slips’ worth of information, particularly when the reason they are sick is a molecular defect that exerts its effects through multiple layers of biochemistry, physiology, and pathophysiology and requires their continual effort to be mitigated.  Explaining all of this to them and translating it into actionable information they can apply—what to do if X, why do I sometimes feel Y—is no simple matter.&lt;/p&gt;

&lt;p&gt;There are many doctors that I could commend for being amazing educators, both from before I came to Sinai and within this hospital.  I want to recognize an awesome allergist-immunologist, Dr. L, whom I decided to shadow after seeing his remarkable lectures for my college’s physiology class figuring that he would likely be just as funny, kind, and insightful with his patients.  He was all of the above, and had a particularly grueling body of knowledge to transfer to them, as many of them had complex immunological conditions that could not possibly be described in a few succinct sentences.  The pen came out often, scribbling figures on papers that he would show them, diagramming what was wrong and how it could be fixed.  I saw him draw pancreatic ducts and uric acid crystals, antibodies and lymphatic systems.  The phrase “it’s too complicated to explain” never came out of his mouth, no matter whether the patient was six or sixty.  Somebody with unpredictable bouts of debilitating pain comes to a doctor because they want answers as well as relief, and he took that duty incredibly seriously, offering his personal cell number to every patient in case they had lingering doubts or concerns.&lt;/p&gt;

&lt;p class=&quot;figure&quot;&gt;&lt;a href=&quot;http://www.flickr.com/photos/st3f4n/4370515705/&quot; title=&quot;Baby care lesson by Darth Vader by Stéfan, on Flickr&quot;&gt;&lt;img src=&quot;http://farm5.staticflickr.com/4052/4370515705_3b81ef52eb.jpg&quot; alt=&quot;Baby care lesson by Darth Vader&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sinai educators are almost too numerous to praise, although I will do my best.  Firstly my small group leader Dr. A, who walks that beautiful line between tough love and caring approachability like no other teacher here, steering discussions back on topic, unafraid of giving us the no-nonsense raw deal on any topic using episodes from her personal experiences.  How do you communicate the “soft skills” of being a doctor to a room full of bright-eyed medical students that have absolutely no experience and barely any practical medical knowledge?  It’s not a task that I can even comprehend at this point, so major kudos to her for charging into it with such fearlessness.  Dr. O, for putting a whole curriculum together on this very subject.  Dr. I, who helped me educate a Spanish-speaking EHHOP patient on dietary recommendations despite my formidable level zero Spanish skills.  Drs. Z and T, for always accommodating two medical students whenever my LCE patient came back for appointments, afterward offering the full debrief on what happened throughout the encounter.&lt;/p&gt;

&lt;p&gt;One more Sinai doctor is memorable because he showed me another important quality of an extraordinary physician: humility in the face of uncertainty.  Perhaps just as important in educating the patient from the endless textbooks and journals that support modern medicine is the admission that sometimes the answer is unknown.  […patient history redacted…] Our preceptor for this course, Dr. G, has decades of experience with this disease and yet must admit to each and every patient diagnosed that the etiology is not clear and the treatments are supportive at best.  It is a difficult topic to broach, one that requires a tricky combination of empathy and humbleness, but he does it without hesitation or diminishing the patient’s confidence in his plan of care.  Nobody likes to say “I don’t know,” and therefore it is an onerous task (even though I am getting plenty of practice as a first year medical student).  Being able to do it well, every day, with people that put their life in your hands, is extraordinary.&lt;/p&gt;

&lt;p&gt;The fourth quality of an extraordinary physician is the willingness to &lt;em&gt;make sacrifices&lt;/em&gt; for the good of your patient, and to do so gracefully under pressure.  Sometimes you have to let them have your dignity, your patience, or both.  On our hospital-based rounds, Dr. A had the unenviable task of introducing us to bedridden patients, some of whom made not-quite-appropriate comments about her appearance as a female doctor.  The behavior, while clearly unacceptable, did not faze her in the slightest—she placed the rapport she was trying to develop between us students and the patient first, and the encounter turned out to be educational.  You never know when you might need to treat a patient that riles you in every possible way, and the ability to control this is a hallmark of medical professionalism.  The doctors at my clinical site, a private pediatrics office, have families that are less cooperative than others, but they receive the same attention and care regardless.  I watched my preceptor, Dr. R, take a call from a family whose son was having severe psychological issues, even though they had moved out of state and hadn’t seen her in years.  Their concern was genuine, and therefore so was hers.  In her clinic the littlest patients often resisted most medical care, and therefore patience and specialized communication skills are vital.  A triumvirate of disagreeable conditions—the screaming, hostile patient, the anxious and frazzled parents, the need to administer shots or other painful meds—never deterred her from her goal.  She made it look routine, because it was.&lt;/p&gt;

&lt;p&gt;Therefore, what makes an extraordinary physician is not just one talent, but a balance of orthogonal qualities: to listen, to educate, to be humble, and to gracefully make sacrifices.  On a given day, a physician may be called upon to exercise any or all of these talents, and when they do it well, they become extraordinary.  However, in order to maintain the trust that physicians are given by our society, doctors must above all be honest and worthy of that trust.  That means being honest to the patient, of course, but honesty toward colleagues and toward themselves is just as critical.  Medicine is not practiced in a vacuum; it requires the support of the people working in its institutions for one another, and the support of the community that it serves.  On the day when the ethical dilemmas we discuss in class become real situations, we will all be tested.  We will be tested when we see our colleagues fall short of their responsibilities, and we will be tested when our supervisors ask us to do things we find questionable.  What is most extraordinary about medicine—besides its individual physicians—is that we are given the privilege to serve the people around us in such a valuable way with our lives, and it is this privilege that must be respected first before we even attempt to learn the talents that will make us extraordinary as individuals.&lt;/p&gt;

&lt;p class=&quot;figure&quot;&gt;&lt;a href=&quot;http://www.flickr.com/photos/alkindus/5850010056/&quot; title=&quot;The Lego Doctor by Ziyaad, on Flickr&quot;&gt;&lt;img src=&quot;http://farm4.staticflickr.com/3260/5850010056_d81590e88f.jpg&quot; alt=&quot;The Lego Doctor&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>What New York Does Right: Street Layout</title>
   <link href="https://tedpak.com/2013/03/31/what-new-york-does-right.html"/>
   <updated>2013-03-31T00:00:00-04:00</updated>
   <id>https://tedpak.com/2013/03/31/what-new-york-does-right</id>
   <content type="html">
&lt;p class=&quot;figure&quot;&gt;&lt;img src=&quot;/images/nyc_midtown.png&quot; alt=&quot;midtown nyc&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I’ll admit it.  Coming back to New York after a week on the coast of South Florida in March can be a little bit of a downer.  According to my roommate’s trusty &lt;a href=&quot;https://itunes.apple.com/us/app/game-of-thrones-ice-and-fire/id425700034?mt=8&quot;&gt;Game of Thrones weather app&lt;/a&gt;, on a three hour flight I went from &lt;a href=&quot;http://www.wunderground.com/history/airport/KFLL/2013/3/30/DailyHistory.html?req_city=Fort+Lauderdale-Hollywood+International&amp;amp;req_state=FL&amp;amp;req_statename=Florida&quot;&gt;Pentos&lt;/a&gt; to &lt;a href=&quot;http://www.wunderground.com/history/airport/KNYC/2013/3/30/DailyHistory.html&quot;&gt;Winterfell&lt;/a&gt;.  Sadly, beaches here will never compare with Miami’s South Beach, and neither palm trees nor mangroves will ever bloom in Central Park.&lt;/p&gt;

&lt;p&gt;But with my feet firmly on New York concrete and a $2 slice of excellent pizza in my hand, the regret faded away.  I’ve driven from New York to Seattle and back, and been all over the east and west coast (thanks to med school interviews).  Despite what I’ve seen, there is a reason so many Americans, particularly young people, want to live in the city.  &lt;strong&gt;New York gets so many things right&lt;/strong&gt;, and these things are so entwined with the culture of this place that even if I leave for a bit, I &lt;em&gt;know&lt;/em&gt; that they will be here for me when I get back, and that is the best comfort a home can offer.  Here lies what New Yorkers can be proud to call their own, from birth to death.  I’ll tackle one topic per post.  Let’s start with what binds the whole city together: &lt;strong&gt;the streets.&lt;/strong&gt;&lt;/p&gt;

&lt;h2 id=&quot;history&quot;&gt;History&lt;/h2&gt;

&lt;p&gt;By the miraculous circumstance of three historical forces: the &lt;a href=&quot;http://en.wikipedia.org/wiki/Commissioners%27_Plan_of_1811&quot;&gt;Commissioner’s Plan of 1811&lt;/a&gt;, the design of Central Park by Frederick Law Olmstead, and the battle between &lt;a href=&quot;http://en.wikipedia.org/wiki/The_Power_Broker&quot;&gt;Robert Moses&lt;/a&gt; and &lt;a href=&quot;http://en.wikipedia.org/wiki/The_Death_and_Life_of_Great_American_Cities&quot;&gt;Jane Jacobs&lt;/a&gt; over the adaptation of the city to the automobile, Manhattan has evolved into one of the most fantastic urban landscapes to be traversed by cars, pedestrians, and bikers alike.  Nowhere else in America will you find two-thousand-odd blocks of &lt;a href=&quot;http://en.wikipedia.org/wiki/File:NASA_Manhattan.jpg&quot;&gt;dense cityscape&lt;/a&gt; unbroken by the scars of massive highways.&lt;/p&gt;

&lt;p class=&quot;figure&quot;&gt;&lt;img src=&quot;/images/galt_and_hoy.png&quot; alt=&quot;Taylor map, Galt and Hoy, 1879&quot; /&gt;
The &lt;a href=&quot;http://memory.loc.gov/cgi-bin/query/h?ammem/gmd:@field(NUMBER+@band(g3804n+pm005990))&quot;&gt;Taylor map&lt;/a&gt;, 1879.&lt;sup id=&quot;fnref-7e1a97:9&quot;&gt;&lt;a href=&quot;#fn-7e1a97:9&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;  The street layout seen here is practically identical to what we have today in 2013. The even “grid” starting at Houston is noticeable.&lt;/p&gt;

&lt;p&gt;The result is astonishing in scope and is, at once, delightfully rational &lt;em&gt;and&lt;/em&gt; historical.  Above Houston St. (the effective extent of the city before the Commissioner’s plan), a mostly regular grid of narrow streets and wide avenues reigns, where one can think of a location—say, “Fifty-first and eighth”&lt;sup id=&quot;fnref-7e1a97:5&quot;&gt;&lt;a href=&quot;#fn-7e1a97:5&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;—and immediately grasp the distance to it as well as the most likely routes.  Below Houston St., a cobweb of competing street orientations must be learned, but therein lies sparkling neighborhoods and cultures that can be discovered and rediscovered over a lifetime.  Because the grid expanded north as the city grew&lt;sup id=&quot;fnref-7e1a97:1&quot;&gt;&lt;a href=&quot;#fn-7e1a97:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;3&lt;/a&gt;&lt;/sup&gt; (to 21st St by 1834, and 57th St by 1844) and the central business district shifted from Lower Manhattan to Midtown as the main industries of the city evolved, the centrality of the street grid also coincides with the area of greatest commercial density, unlike cities with less room to grow (e.g., Boston).&lt;/p&gt;

&lt;h2 id=&quot;comparison&quot;&gt;Comparison&lt;/h2&gt;

&lt;p&gt;You might protest: “Oh, but many other great American cities use a grid layout.”  None get it quite as perfect, however.  Let’s use the following comparison, taken with all maps at the same scale, to start the discussion:&lt;/p&gt;

&lt;p class=&quot;figure&quot;&gt;&lt;img src=&quot;/images/street_grids.png&quot; alt=&quot;comparison of street grids&quot; /&gt;
Imagery from Google Maps.&lt;/p&gt;

&lt;p&gt;Two questions as should arise as you compare these: Which is the easiest for the motorist and pedestrian to navigate? Which creates the most pleasing city environment? A number of things can disrupt a street grid plan:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;em&gt;Too many irregularities.&lt;/em&gt;  Philadelphia was &lt;a href=&quot;http://en.wikipedia.org/wiki/Grid_plan#Early_United_States&quot;&gt;one of the first cities&lt;/a&gt; in North America to use a grid system, but it did not enforce it as rigorously as New York; therefore, every block encountered is a potential surprise, and the order of the east-west street names must be memorized. This applies double to Toronto, because none of the streets are named predictably, and exceptions abound.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;em&gt;No contrast between streets and avenues.&lt;/em&gt; DC was more rigorous in sticking to the grid, but the blocks are too squarish.  The result is there is no rhythm between commercial “edges” facing the avenues and residential “meat” on the interior of each block, as there is in New York, allowing better mixed use of every block—even in high density zones, many blocks can accomodate smaller townhouses and walk-up buildings within their interior&lt;sup id=&quot;fnref-7e1a97:8&quot;&gt;&lt;a href=&quot;#fn-7e1a97:8&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;.  Having uniformly wide roads also fails to concentrate traffic along one axis.  Because avenues are wider &lt;em&gt;and&lt;/em&gt; farther apart in the &lt;a href=&quot;http://en.wikipedia.org/wiki/Commissioners%27_Plan_of_1811&quot;&gt;Commissioner’s Plan&lt;/a&gt;, north-south travel is more busy but also more efficient (this also happens to be the long axis of Manhattan, and thus the one more traversed).  This avenue layout creates traffic, visibility, and natural congregation points within each neighborhood for street-level commerce.  Such traffic can be tolerated only because there aren’t…&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;em&gt;Too many two-way roads.&lt;/em&gt; Toronto is a terrible offender here. While motorists might think that two-way roads simplify route calculations, the reality is that they completely snarl traffic during high demand periods.  &lt;em&gt;Turning&lt;/em&gt; is the most expensive operation for traffic at an intersection, as cars have to cross through either other cars (with left turns) and possibly pedestrians in the crosswalk to clear the box.  Until they can do that, cars in the lane behind them cannot move.  At an intersection of two-way roads where all turns and pedestrian crossings are allowed, four lanes per road are going to be jammed for every green light without some special accomodation: separate left turn/right turn lanes and signals, which cost space and time per signal change, or randomly &lt;a href=&quot;/images/toronto_yonge.png&quot;&gt;disallowing left or right turns&lt;/a&gt;, which destroys any claimed advantages in navigability.&lt;/p&gt;

    &lt;p&gt;In New York, the average intersection is two unidirectional streets, causing no crossing of car paths and only one possible turning direction.  Combined with the &lt;a href=&quot;http://en.wikipedia.org/wiki/Pedestrian_scramble&quot;&gt;Barnes Dance&lt;/a&gt; to clear crowded intersections of pedestrians, and &lt;a href=&quot;http://www.nytimes.com/1998/09/17/technology/choreographing-the-dance-of-traffic-lights.html&quot;&gt;synchronized green lights&lt;/a&gt; (called a &lt;a href=&quot;http://en.wikipedia.org/wiki/Green_wave&quot;&gt;“green wave”&lt;/a&gt;) down major arteries, one can typically drive 50 blocks north or south on a large artery without hitting a red light.  There is also a nearly regular alternation of north/south and east/west travel, with changes in directionality made very rarely throughout the grid.  The result: a graceful compromise between pedestrian and automobile friendliness.&lt;/p&gt;

    &lt;p class=&quot;figure&quot;&gt;&lt;img src=&quot;/images/third_ave.png&quot; alt=&quot;third avenue&quot; /&gt;
 Get on 3rd Avenue in the center lane and you will practically &lt;em&gt;fly&lt;/em&gt; uptown. Taken from &lt;a href=&quot;http://goo.gl/maps/LUS6b&quot;&gt;Google Street View&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;em&gt;Streetcars and elevated trains.&lt;/em&gt; Driving among streetcars that occupy center lanes shared with cars is supremely frustrating. Not only is there a mad dash to slip around them between intersections, but every time the streetcars stop, all other lanes must stop as well to avoid harming entering and discharged passengers. This happens to be &lt;a href=&quot;http://en.wikipedia.org/wiki/Toronto_streetcar_system&quot;&gt;precisely the system&lt;/a&gt; that Toronto employs in its central business district.  Elevated trains remove the traffic issues, but pollute thunderous noise, block out sunlight at the street level, and create an intimidating row of pillars for motorists to dodge.  Sorry Chicago, your &lt;a href=&quot;http://goo.gl/maps/6k7bL&quot;&gt;‘L’ train&lt;/a&gt; may hold some quaint charm and &lt;a href=&quot;http://www.chicagotribune.com/entertainment/chi-dark-knight-location-map,0,3631449.mapmashup&quot;&gt;makes&lt;/a&gt; for &lt;a href=&quot;http://youtu.be/iSXL58MPPQc&quot;&gt;a cool scene&lt;/a&gt; in The Dark Knight, but Manhattan made life so much better by sinking most trains underground.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;There are two more things that really kill street grids.  They are probably best explained pictorially, since they would have been too unfair to show in the tiny representative samples I chose above.  Here’s the first offender, seen across the street from where I lived in Toronto.&lt;/p&gt;

&lt;p class=&quot;figure&quot;&gt;&lt;img src=&quot;/images/toronto_rail.png&quot; alt=&quot;Toronto rail line&quot; /&gt;
Hey, it’s the CN tower over there! Should be an enjoyable five-block walk from here. Oh, wait. Taken from &lt;a href=&quot;http://goo.gl/maps/kQYA1&quot;&gt;Google Street View&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is not an angle of the CN tower often advertised in Toronto tourism material.  Railway lines through a downtown core?  Unsightly, loud, and difficult to cross, they are an impenetrable wall for pedestrians and bikers, which is a shame, because those brand new lakefront condos are aching to be connected to the rest of the city.  Once railways are buried, as in the &lt;a href=&quot;http://en.wikipedia.org/wiki/Park_Avenue_Tunnel_(railroad)&quot;&gt;Park Avenue tunnel&lt;/a&gt; or the &lt;a href=&quot;http://en.wikipedia.org/wiki/East_River_Tunnels&quot;&gt;East River tunnels&lt;/a&gt; under 32nd and 33rd St. (both operational &lt;em&gt;and&lt;/em&gt; electrified by 1910!), the street level can be pleasant again&lt;sup id=&quot;fnref-7e1a97:6&quot;&gt;&lt;a href=&quot;#fn-7e1a97:6&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;.  Here’s another neighborhood destroyer, in Philadelphia:&lt;/p&gt;

&lt;p class=&quot;figure&quot;&gt;&lt;img src=&quot;/images/philly_highway.png&quot; alt=&quot;Vine St. expressway&quot; /&gt;
Hey, it’s downtown Philadelphia over there! Should be an enjoyable five-block walk from here. Oh, wait. Taken from &lt;a href=&quot;http://goo.gl/maps/pKMCo&quot;&gt;Google Street View&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Expressways can likewise destroy the walkability and street atmosphere of a neighborhood.  Take for instance the South Bronx, fully &lt;a href=&quot;http://en.wikipedia.org/wiki/Bruckner_expressway#History&quot;&gt;wrapped&lt;/a&gt; and &lt;a href=&quot;http://en.wikipedia.org/wiki/Cross_Bronx_Expressway#Controversy&quot;&gt;skewered&lt;/a&gt; by interstates.  Fortunately, most of Manhattan avoided a similar fate thanks to &lt;a href=&quot;http://en.wikipedia.org/wiki/The_Death_and_Life_of_Great_American_Cities&quot;&gt;Jane Jacobs&lt;/a&gt; and other militant conservationists, who successfully fought off a &lt;a href=&quot;http://en.wikipedia.org/wiki/Lower_Manhattan_Expressway&quot;&gt;Lower Manhattan Expressway&lt;/a&gt; that would have destroyed Soho and Little Italy (two of New York’s most vibrant neighborhoods today) and a &lt;a href=&quot;http://en.wikipedia.org/wiki/Mid-Manhattan_Expressway&quot;&gt;Mid-Manhattan Expressway&lt;/a&gt; which, even more insanely, would have leveled some of the most expensive commercial real estate in the world and driven highways through the middle of skyscrapers&lt;sup id=&quot;fnref-7e1a97:2&quot;&gt;&lt;a href=&quot;#fn-7e1a97:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;6&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;p&gt;The division and congestion created by a highway is expensive and difficult to remedy.  Just look at Boston, which opened a &lt;a href=&quot;http://en.wikipedia.org/wiki/Central_Artery&quot;&gt;Central Artery&lt;/a&gt; straight through downtown in the 1950’s only to see it clog up with cars and decrease access to historical and cultural neighborhoods like the North End from downtown.  The problem was recognized by 1982, with construction on the infamous &lt;a href=&quot;http://en.wikipedia.org/wiki/Big_dig&quot;&gt;“Big Dig”&lt;/a&gt; to bury the expressway underground taking sixteen years and costing an estimated $22 billion, several investigations, and one death&lt;sup id=&quot;fnref-7e1a97:3&quot;&gt;&lt;a href=&quot;#fn-7e1a97:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;7&lt;/a&gt;&lt;/sup&gt;.  The result is obviously much more pedestrian friendly, and the surrounding neighborhoods may eventually heal together with enough creative landscaping, but it came at an enormous price.&lt;/p&gt;

&lt;p class=&quot;figure&quot;&gt;&lt;img src=&quot;/images/boston_bigdig.png&quot; alt=&quot;Big dig&quot; /&gt;
This used to be a expressway in Boston. Moving it underground was the most expensive US highway project to date. Taken from &lt;a href=&quot;http://goo.gl/maps/B9P2x&quot;&gt;Google Street View&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is not to say that highways are completely unimportant; Robert Moses dutifully ensured that Manhattan had limited-access north/south arteries along the East and Hudson rivers.  And they can be used, for instance, to &lt;a href=&quot;http://goo.gl/maps/619RO&quot;&gt;zip from City Hall to the Apollo in 20 minutes&lt;/a&gt; during off-peak hours, a trip spanning most of the island.  But their disruption to pedestrians is constrained to the margins, leaving the city inbetween magnificently unblemished.  From Avenue D to West End Ave, a pedestrian will be hard-pressed to find more than six lanes of traffic between him and the other end of a crosswalk.&lt;/p&gt;

&lt;p class=&quot;figure&quot;&gt;&lt;img src=&quot;/images/nyc_gearth.png&quot; alt=&quot;New york grid&quot; /&gt;
Blocks on blocks on blocks.  Imagery from Google Earth.&lt;/p&gt;

&lt;h2 id=&quot;continuity-of-neighborhoods&quot;&gt;Continuity of neighborhoods&lt;/h2&gt;

&lt;p&gt;Here’s a maxim that could probably be proven using New York as a test case: the natural limit of neighborhood continuity across pavement is somewhere around six lanes. It’s a distance where you can still recognize your friend in front of a store on the other side of the avenue and &lt;a href=&quot;http://sauntering.blogspot.com/2007/09/simple-rules-for-jaywalking-in.html&quot;&gt;jog over to her&lt;/a&gt; when traffic slows.  Unlike, say, the &lt;a href=&quot;http://goo.gl/maps/DMAbG&quot;&gt;twelve-lane death trap&lt;/a&gt; that some call Queens Boulevard&lt;sup id=&quot;fnref-7e1a97:4&quot;&gt;&lt;a href=&quot;#fn-7e1a97:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;8&lt;/a&gt;&lt;/sup&gt;, you could get comfortable with your grandmother crossing a Manhattan avenue by herself.  Anything just over six, e.g., by replacing two lanes with streetcar tracks on &lt;a href=&quot;http://goo.gl/maps/DMw8G&quot;&gt;Spadina Ave in Toronto&lt;/a&gt;, and you start feeling noticeably less happy about crossing it every day.  Let’s recall that six lanes are more than sufficient for fast travel &lt;em&gt;in one direction&lt;/em&gt;—refer to that picture of 3rd Avenue above, which has five, giving you one center lane, a passing lane on either side, and outer lanes, which can accommodate the cars turning, parking, and performing general shenanigans without slowing down thru traffic.&lt;/p&gt;

&lt;p&gt;On the other hand, there is also a reasonable minimum for street width.  New York’s is generally a central quasi-double lane with parking on both sides of the street.  Observe the following comparison between typical streets in New York and Philadelphia.&lt;/p&gt;

&lt;p class=&quot;figure&quot;&gt;&lt;img src=&quot;/images/min_street_width.png&quot; alt=&quot;Street width woes&quot; /&gt;
E 70th in NYC vs. S 12th in Philly. &lt;a href=&quot;http://goo.gl/maps/BEXcb&quot;&gt;Both&lt;/a&gt; &lt;a href=&quot;http://goo.gl/maps/EnsB9&quot;&gt;images&lt;/a&gt; courtesy of Google Street View.&lt;/p&gt;

&lt;p&gt;In New York, residents can park on both sides of most streets, and traffic flows down the large center lane.  If somebody double-parks to unload a passenger or perform some shenanigans, as this minivan has done in the picture (it is a fact of American city traffic that vehicles will selfishly stop to occupy &lt;em&gt;any point&lt;/em&gt; along a streetside), no matter: there is still enough room for cars to squeeze past, as the yellow taxi is doing.  In Philadelphia, one whole side of the street is typically wasted.  Why?  It’s the awkward width of the street: if there were parked cars on both sides, somebody stopping to unload or perform shenanigans, as these construction guys are doing, would be impeding all movement.  The center lane of this street has insufficient “wiggle room” and thus a whole edge must be lost to bare curbside that becomes the de facto “shenanigans” lane.  Philly should try to repurpose some of this awkward space to make more bike lanes.  (Also, what’s the deal with the abandoned trolley tracks in the center of the street, perfectly positioned to provoke anxiety in motorists and tip over passing cyclists?)&lt;/p&gt;

&lt;p&gt;There is no way the &lt;a href=&quot;http://en.wikipedia.org/wiki/Commissioners%27_Plan_of_1811&quot;&gt;Commissioner’s Plan&lt;/a&gt; could have predicted that 60 feet would be the perfect width for three cars with squeeze room for one more and two sidewalks on either side, but &lt;em&gt;it works so well&lt;/em&gt; that it makes you wonder if New York streets didn’t unintentionally influence the standard &lt;a href=&quot;http://en.wikipedia.org/wiki/Lane#Lane_width_and_capacity&quot;&gt;12 foot lane width&lt;/a&gt; for automobile traffic or the width of cars in general.  &lt;a href=&quot;/images/boston_street.png&quot;&gt;Other&lt;/a&gt; &lt;a href=&quot;/images/sf_shenanigans.png&quot;&gt;cities&lt;/a&gt; that contend with comparable urban density in America can only wish they had evolved with such a fortuitous configuration&lt;sup id=&quot;fnref-7e1a97:10&quot;&gt;&lt;a href=&quot;#fn-7e1a97:10&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;9&lt;/a&gt;&lt;/sup&gt;.  As the outer boroughs of New York largely perpetuated the spread of the rectangular block style and street widths of Manhattan, the city has a remarkable uniformity to its street texture, from Coney Island Ave all the way to E 233rd St in the Bronx, with each block theoretically capable of the same eventual mixed residential and commercial density as a block in Midtown.&lt;/p&gt;

&lt;p class=&quot;figure&quot;&gt;&lt;img src=&quot;/images/same_grid.png&quot; alt=&quot;Street grid uniformity&quot; /&gt;
From left to right, the Bronx, Queens, Manhattan, and Brooklyn. Each tile is at the same scale. Imagery from Google Maps.&lt;/p&gt;

&lt;h2 id=&quot;streets-arent-just-for-cars&quot;&gt;Streets aren’t just for cars&lt;/h2&gt;

&lt;p&gt;So far I’ve argued mostly on the premise that streets should be built for pedestrians as well as for cars.  To anyone in New York, where just as many walk and use public transit to get to work as drive, this seems blatantly obvious.  &lt;a href=&quot;http://www.ncbi.nlm.nih.gov/pubmed/23332335&quot;&gt;Many&lt;/a&gt; &lt;a href=&quot;http://www.ncbi.nlm.nih.gov/pubmed/20712934&quot;&gt;studies&lt;/a&gt; indicate, as should common sense, that supporting only a car-commuter culture will negatively affect public health.  Having trudged around the dismal central business districts of &lt;a href=&quot;http://goo.gl/maps/FkgOm&quot;&gt;Worcester&lt;/a&gt;, &lt;a href=&quot;http://goo.gl/maps/5oSEL&quot;&gt;New Haven&lt;/a&gt;, &lt;a href=&quot;http://goo.gl/maps/7c13G&quot;&gt;Hartford&lt;/a&gt;, &lt;a href=&quot;http://goo.gl/maps/X83fH&quot;&gt;Springfield&lt;/a&gt;, &lt;a href=&quot;http://goo.gl/maps/8tsUT&quot;&gt;Sioux Falls&lt;/a&gt;, &lt;a href=&quot;http://goo.gl/maps/6on6i&quot;&gt;Detroit&lt;/a&gt; and so many other American cities that seem to have given up on attracting pedestrians, it’s clear that any street life that would inspire young workers and businesses to come and explore has been lost.  All of these places seem to have the same vacant storefronts surrounded by massive buildings and parking structures.  How free can one feel in a city where it seems safer to stay in the car?  What’s the psychological effect of being chronically tethered to a two-ton hunk of aluminum and steel?&lt;/p&gt;

&lt;p&gt;Let’s not forget the bicyclists, either.  Say what you will about Mayor Bloomberg, but watching &lt;a href=&quot;http://www.nycbikemaps.com/maps/nyc-bike-map/&quot;&gt;this map&lt;/a&gt; grow and exploring its fringes over the past decade has transformed how I feel about and move around the city.  You can now bike from Westchester County to Jacob Riis Park mostly along reserved bike lanes, some of them separated from auto traffic&lt;sup id=&quot;fnref-7e1a97:7&quot;&gt;&lt;a href=&quot;#fn-7e1a97:7&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;10&lt;/a&gt;&lt;/sup&gt;. I’m planning some posts about some of the nice longer trips that can be made into the Palisades, the South County Trail, and others.  The bike lane effort has been a stunning accomplishment for the DOT and I only hope that they’re here to stay &lt;a href=&quot;http://www.nytimes.com/2013/02/13/nyregion/new-york-bike-lane-advocates-fear-new-mayor-will-roll-back-gains.html&quot;&gt;after the mayor leaves&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;coming-next&quot;&gt;Coming next&lt;/h2&gt;

&lt;p&gt;Alright, I’ve said my piece and that wraps this first part of a (possibly never-ending) series on &lt;strong&gt;things New York gets right.&lt;/strong&gt;  Stay tuned for articles planned on, but not limited to: pizza, subways, taxis, skylines, street food, bagels and lox… need I go on?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post used the word “shenanigans” a total of five times.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Did I get something wrong? You can &lt;a href=&quot;http://www.reddit.com/r/nyc/comments/1bxsx0/ted_pak_explains_what_new_york_does_right/&quot;&gt;flame me on Reddit&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn-7e1a97:9&quot;&gt;
      &lt;p&gt;&lt;a href=&quot;http://www.codex99.com/&quot;&gt;Codex 99&lt;/a&gt;, a bottomless blog on the history of the visual arts and graphic design, has a &lt;a href=&quot;http://www.codex99.com/cartography/110.html&quot;&gt;fantastic review&lt;/a&gt; on the evolution of three-dimensional cartography depicting New York. &lt;a href=&quot;#fnref-7e1a97:9&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-7e1a97:5&quot;&gt;
      &lt;p&gt;This is the correct way to say a Manhattan address, with street name before avenue.  If you’re cabbing to the East Village, don’t mess this up.  &lt;a href=&quot;http://www.quora.com/Cultural-Faux-Pas/What-are-some-cultural-faux-pas-in-New-York-City&quot;&gt;It’s in the rules.&lt;/a&gt;  Technically &lt;a href=&quot;http://goo.gl/maps/uqOTo&quot;&gt;only two blocks exist&lt;/a&gt; where this could be ambiguous, but still.  If you clicked that link, you may have noticed Google gets it wrong.  Google is not a New Yorker. &lt;a href=&quot;#fnref-7e1a97:5&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-7e1a97:1&quot;&gt;
      &lt;p&gt;The Times hosts &lt;a href=&quot;http://www.nytimes.com/interactive/2011/03/21/nyregion/map-of-how-manhattan-grid-grew.html?_r=0&quot;&gt;an interactive map&lt;/a&gt; showing the order in which Manhattan streets opened. &lt;a href=&quot;#fnref-7e1a97:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-7e1a97:8&quot;&gt;
      &lt;p&gt;In crowded commercial districts like Midtown, you might find this situation inverted—sometimes with &lt;a href=&quot;http://www.scoutingny.com/?p=6495&quot;&gt;goofy results&lt;/a&gt;—but the streetfront is usually so continuous that it can be hard to notice! &lt;a href=&quot;#fnref-7e1a97:8&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-7e1a97:6&quot;&gt;
      &lt;p&gt;Boston had a rail line through the South End and Back Bay sunk into a tunnel in preparation for &lt;a href=&quot;http://www.bostonroads.com/roads/southwest/&quot;&gt;the construction of a new highway&lt;/a&gt;, but resistance was so fierce following the Central artery disaster that it was abandoned.  Decades later, it was repurposed into one of a &lt;a href=&quot;http://goo.gl/maps/lJqJ8&quot;&gt;neat linear park&lt;/a&gt; that connects the surrounding neighborhoods. &lt;a href=&quot;#fnref-7e1a97:6&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-7e1a97:2&quot;&gt;
      &lt;p&gt;The idea was to facilitate movement between Long Island and Jersey, although why this had to occur through the most crowded and expensive part of Manhattan was an objection that thankfully was never overcome.  The only expressway of this category, the &lt;a href=&quot;http://en.wikipedia.org/wiki/Trans_manhattan_expressway&quot;&gt;Trans-Manhattan Expressway&lt;/a&gt;, has become a continually-clogged pinchpoint for interstate trucking and travellers, with &lt;a href=&quot;http://www.nytimes.com/2004/06/18/nyregion/life-on-the-road-learning-to-sleep-as-trucks-roar-through-basement.html&quot;&gt;less than ideal consequences&lt;/a&gt; for local residents.  The Mid-Manhattan Expressway project did inspire some impressive “futurism”-laden &lt;a href=&quot;http://www.nycroads.com/roads/mid-manhattan/&quot;&gt;design illustrations&lt;/a&gt;, though. &lt;a href=&quot;#fnref-7e1a97:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-7e1a97:3&quot;&gt;
      &lt;p&gt;12 tons of concrete ceiling panels in a tunnel collapsed, crushing a car and killing one of its passengers. This resulted in criminal charges and a &lt;a href=&quot;http://web.archive.org/web/20060715075257/http://edition.cnn.com/2006/US/07/12/bigdigdeath.ap/index.html&quot;&gt;review of Boston’s entire highway system&lt;/a&gt;. &lt;a href=&quot;#fnref-7e1a97:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-7e1a97:4&quot;&gt;
      &lt;p&gt;I’m not kidding about it being dangerous.  In the 90’s an average of 10 people were killed per year trying to cross Queens Boulevard, earning it the name &lt;a href=&quot;http://en.wikipedia.org/wiki/Queens_boulevard#History&quot;&gt;The Boulevard of Death&lt;/a&gt; and the installation of cheerful signs proclaiming &lt;a href=&quot;http://en.wikipedia.org/wiki/File:QueensBlvd-GrandAve_PedWarning_Sign-Elmhurst.jpg&quot;&gt;A pedestrian was killed crossing here&lt;/a&gt;. &lt;a href=&quot;#fnref-7e1a97:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-7e1a97:10&quot;&gt;
      &lt;p&gt;A rather fun counterpoint to this article is &lt;a href=&quot;http://www.oldandsold.com/articles14/new-york-12.shtml&quot;&gt;a critique of the Commissioner’s Plan&lt;/a&gt;   apparently written in the 1930’s, which marveled that a city of 85,000 could have laid itself out in preparation for millions of residents, but proposes that more avenues and diagonal arteries should have been included, and less cross streets.  From the standpoint of 2013, I’m not sure I agree.  Broadway creates confusing and crowded 6-way intersections wherever it crosses an avenue, and its controversial replacement with &lt;a href=&quot;http://manhattan.ny1.com/content/top_stories/113521/pedestrian-plaza-to-remain-permanent-fixture-of-times-square&quot;&gt;a pedestrian plaza in Times Square&lt;/a&gt; has actually improved safety and traffic in that area. &lt;a href=&quot;#fnref-7e1a97:10&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-7e1a97:7&quot;&gt;
      &lt;p&gt;They aren’t always respected: as &lt;a href=&quot;http://youtu.be/3EPHXAON5HA&quot;&gt;this short video&lt;/a&gt; tracing the bike lane on W 106th St. shows, many cars and UPS men will use the lane as an excuse for more shenanigans.  But the occasional intrusions aside, is this not a glorious way to move about a city? &lt;a href=&quot;#fnref-7e1a97:7&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</content>
 </entry>
 
 <entry>
   <title>Hacker News Sidebar: An Extension for Google Chrome</title>
   <link href="https://tedpak.com/2013/03/20/hacker-news-sidebar-a-chrome-extension.html"/>
   <updated>2013-03-20T00:00:00-04:00</updated>
   <id>https://tedpak.com/2013/03/20/hacker-news-sidebar-a-chrome-extension</id>
   <content type="html">
&lt;p&gt;&lt;em&gt;tldr: I’ve fixed up the Hacker News Sidebar Chrome extension. It shows comment threads from HN in a handy tab next to any other pages that you visit. Browse the source code &lt;a href=&quot;https://github.com/powerpak/hn-sidebar&quot;&gt;on GitHub&lt;/a&gt;, and install the extension from &lt;a href=&quot;https://chrome.google.com/webstore/detail/hacker-news-sidebar/ngljhffenbmdjobakjplnlbfkeabbpma&quot;&gt;the Chrome Store&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p class=&quot;figure shadow&quot;&gt;&lt;img src=&quot;/images/hn_sidebar.png&quot; alt=&quot;screenshot&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Like many other web developers, I use &lt;a href=&quot;https://www.google.com/intl/en/chrome/browser/&quot;&gt;Google Chrome&lt;/a&gt; as my primary web browser because it is incredibly fast, the UI gets out of the way, and the &lt;a href=&quot;https://developers.google.com/chrome-developer-tools/&quot;&gt;web development tools&lt;/a&gt; are superlative.  That might change some day—Firefox is &lt;a href=&quot;http://www.campaul.net/blog/2013/03/10/why-im-switching-back-to-firefox/&quot;&gt;making a comeback&lt;/a&gt; with regard to all of these things, and I like using it as well, just not quite as much to make me switch back yet.&lt;/p&gt;

&lt;p&gt;One surprisingly nice thing about Chrome is that it is really easy to &lt;a href=&quot;https://developer.chrome.com/extensions/getstarted.html&quot;&gt;develop extensions&lt;/a&gt;, particularly if you are a web developer. Generally all that’s required are a few JavaScript files and optionally some HTML and CSS and you could do anything from &lt;a href=&quot;https://chrome.google.com/webstore/detail/xmarks-bookmark-sync/ajpgkpeckebdhofmmjfgcjjiiejpodla&quot;&gt;bookmark syncing&lt;/a&gt;, &lt;a href=&quot;https://chrome.google.com/webstore/detail/google-chrome-to-phone-ex/oadboiipflhobonjjffjbfekfjcgkhco&quot;&gt;page syncing across devices&lt;/a&gt;, or &lt;a href=&quot;https://chrome.google.com/webstore/detail/ghostery/mlomiejdfkolichcflejclcbmpeaniij&quot;&gt;elimination of those pesky tracking scripts&lt;/a&gt;.  Admittedly there are limitations: you can only modify the browser UI in a few specific ways, like adding buttons or icons next to the Omnibox that pop out content, or items to the context menu.&lt;/p&gt;

&lt;p&gt;Chrome extensions function much like an offline HTML5 app, running in the background as a hidden tab.  Besides all the typical features of the DOM, like the &lt;a href=&quot;https://developer.chrome.com/extensions/xhr.html&quot;&gt;XHR object&lt;/a&gt; for asynchronously communicating with webservers, they can access special Javascript APIs (under the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chrome&lt;/code&gt; global object) for opening and manipulating tabs, history, windows, and bookmarks.  They can also selectively insert Javascript into webpages, like the &lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/&quot;&gt;Greasemonkey scripts&lt;/a&gt; or &lt;a href=&quot;http://userscripts.org/&quot;&gt;Userscripts&lt;/a&gt; that are popular for enhancing the functionality of certain websites.  To securely communicate between code running in the user’s browser tabs and your extension’s hidden background tab, you use a &lt;a href=&quot;https://developer.chrome.com/extensions/messaging.html&quot;&gt;messaging API&lt;/a&gt;.  All the special permissions your extension needs must be specified in a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;manifest.json&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;As you may have guessed by the links at the end of each post on this blog, I read HN quite a bit—enough so that I’d rather just direct any discussion to that forum, rather than try to police my own comments database.  Meta-discussions on link-aggregating websites (e.g. HN, reddit) are often more interesting than the original content.  Once upon a time I used &lt;a href=&quot;https://chrome.google.com/webstore/detail/hacker-news-sidebar/hhedbplnihmkekhgmaoikgfbkjjaocnl?hl=en)&quot;&gt;this Chrome extension&lt;/a&gt; to reveal these HN threads automatically: it would pop out a side tab on any page that had been posted to HN.  Whenever the orange tab happily emerged, a quick scan of the sidebar would show what HN thought and how many upvotes it had, sometimes significantly changing my impression of the original page.&lt;/p&gt;

&lt;p&gt;Unfortunately, that extension has fallen into disrepair.  HN has switched to HTTPS and now disallows framing of their site via the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;X-Frame-Options: DENY&lt;/code&gt; header &lt;sup id=&quot;fnref-24d7c7:1&quot;&gt;&lt;a href=&quot;#fn-24d7c7:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;, causing the tab to be blank.  Additionally, the Chrome extension packaging scheme has &lt;a href=&quot;https://developer.chrome.com/extensions/tut_migration_to_manifest_v2.html&quot;&gt;changed&lt;/a&gt; to tighten security policies, so barring some serious updates, this extension will &lt;a href=&quot;https://developer.chrome.com/extensions/manifestVersion.html&quot;&gt;stop working in September 2013&lt;/a&gt;.  In order to get this extension running again, I had to rewrite much of it.  Let’s break down the &lt;a href=&quot;https://github.com/powerpak/hn-sidebar&quot;&gt;source code&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;All Chrome extensions begin with a &lt;a href=&quot;https://github.com/powerpak/hn-sidebar/blob/master/manifest.json&quot;&gt;manifest.json&lt;/a&gt; file.  The first half of this file says that I need the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xhr_handler.js&lt;/code&gt; script to run in my background tab, and I need to insert &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hn.css&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jquery.js&lt;/code&gt;, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;script.js&lt;/code&gt; into all pages (as specified by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;matches&lt;/code&gt;).  Note that through some &lt;a href=&quot;https://developer.chrome.com/extensions/content_scripts.html#execution-environment&quot;&gt;scoping magic&lt;/a&gt; that Chrome does, these inserted scripts will not interfere with any global variables or functions created by their host pages, but they will still be able to affect the DOM.  Finally, there is some metadata for the Chrome Store in the second half, along with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;permissions&lt;/code&gt;, which enumerates the domains that I want my background script to be able to access.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-json&quot; data-lang=&quot;json&quot;&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
   &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;manifest_version&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
   &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;background&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;scripts&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;xhr_handler.js&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
   &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;content_scripts&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;css&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;hn.css&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;js&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;jquery.js&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;script.js&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;matches&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;http://*/*&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;https://*/*&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
   &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
   &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;icons&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;48&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;icon-48.png&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
             &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;128&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;icon-128.png&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
   &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;description&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Hacker News integration for Chrome&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
   &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Hacker News Sidebar&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
   &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;permissions&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;http://api.thriftdb.com/api.hnsearch.com/items/*&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;https://news.ycombinator.com/*&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
   &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;version&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;1.0.8&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Let’s look at the &lt;a href=&quot;https://github.com/powerpak/hn-sidebar/blob/master/script.js&quot;&gt;script.js&lt;/a&gt; file next, which will be inserted into every page I visit.  For the most part, this looks like a run of the mill jQuery script.  The first atypical tidbit is this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;port&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;chrome&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;extension&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;connect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({}),&lt;/span&gt;
   &lt;span class=&quot;nx&quot;&gt;callbacks&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[];&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// ...[snip]...&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;onMessage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;addListener&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;callbacks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;](&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;delete&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;callbacks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;doXHR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;params&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;params&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;callbacks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;postMessage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;params&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This appears to be a wrapper for performing XHR (also called AJAX requests), but why all the bother when I would typically just use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$.ajax&lt;/code&gt;?  Well, despite their special scope, content scripts still execute with all the &lt;a href=&quot;http://en.wikipedia.org/wiki/Same_origin_policy&quot;&gt;cross domain restrictions&lt;/a&gt; that the host page has; they can’t perform AJAX requests outside the host, port, and protocol the host page was served rom.  That’s a problem because we need to pull outside content from both the &lt;a href=&quot;https://www.hnsearch.com/api&quot;&gt;HNSearch API&lt;/a&gt; and &lt;a href=&quot;https://news.ycombinator.com&quot;&gt;HN itself&lt;/a&gt;.  So, to work around this, the code packages the parameters for the XHR into a message that is &lt;a href=&quot;https://developer.chrome.com/extensions/messaging.html&quot;&gt;sent via the Message Passing API&lt;/a&gt; under the special &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chrome&lt;/code&gt; global object to the background script, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xhr_handler.js&lt;/code&gt;, where it can executed with the correct permissions.&lt;/p&gt;

&lt;p&gt;What happens there?  &lt;a href=&quot;https://github.com/powerpak/hn-sidebar/blob/master/xhr_handler.js&quot;&gt;Let’s see&lt;/a&gt;:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;xhrCall&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;xhr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;XMLHttpRequest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;xhr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;GET&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;xhr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;onreadystatechange&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;xhr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;readyState&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;postMessage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;xhr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;responseText&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;xhr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;chrome&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;extension&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;onConnect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;addListener&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;onMessage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;addListener&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;xhrCall&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Pretty much all it does is actually perform the XHR request and send the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;responseText&lt;/code&gt; (the raw text content of the response) right back.  Note the use on both ends of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;port.postMessage&lt;/code&gt; method to &lt;em&gt;send&lt;/em&gt; data and the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;addListener&lt;/code&gt; methods to create event handlers that &lt;em&gt;receive&lt;/em&gt; data.  This is very reminiscent of the HTML5 &lt;a href=&quot;http://www.html5rocks.com/en/tutorials/workers/basics/&quot;&gt;Web Workers API&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So now that we can perform XHR to the necessary outside sites, back in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;script.js&lt;/code&gt;, we query the &lt;a href=&quot;https://www.hnsearch.com/api&quot;&gt;HNSearch API&lt;/a&gt; filtering by the URL of the current page:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;exclude&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sr&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\.(&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;xml|txt|jpg|png|avi|mp3|pdf|mpg&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;$/&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// ...[snip]...&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;curPath&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;location&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;exclude&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;curPath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;queryURL&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;https://api.thriftdb.com/api.hnsearch.com/items/_search?filter[fields][url][]=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;encodeURIComponent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;curPath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;doXHR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;action&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;queryURL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// JSON.parse will not evaluate any malicious JavaScript embedded into JSON&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;parse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;// No results, maybe it&apos;s too new&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;doXHR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;action&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;HN_BASE&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;newest&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;nf&quot;&gt;searchNewestHN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;// If there is a result, create the orange tab and panel&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;foundItem&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nf&quot;&gt;createPanel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;HN_BASE&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;item?id=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;foundItem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;and if we find results, we kick off creation of the orange tab with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;createPanel&lt;/code&gt;; if not, we give the newest HN stories a try with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;searchNewestHN&lt;/code&gt;, in case this is a story that just made it to the front page.  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;searchNewestHN&lt;/code&gt; works by parsing the HTML of the front page and finding any anchors that link to this page.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;searchNewestHN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;titleAnchor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;a[href=&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&apos;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;location&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/&apos;/g&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;linkAnchor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;titleAnchor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;parent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;parent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;linkAnchor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;createPanel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;HN_BASE&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;linkAnchor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;attr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;If it does find it, it too calls &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;createPanel&lt;/code&gt;.  The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;createPanel&lt;/code&gt; function is pretty dry with a lot of dry DOM construction, but the fun part is when we actually need to put the HN comment thread into the DOM:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;createPanel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;HNurl&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// ...[snip]...&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;HNembed&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;lt;div /&amp;gt;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;attr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;HNembed&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;HNsite&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;lt;iframe /&amp;gt;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;attr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;HNsite&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;about: blank&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// ...[snip]...&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;HNembed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;HNsite&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;HNembed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;hide&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

  &lt;span class=&quot;nf&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;HNtab&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;nf&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;HNembed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

  &lt;span class=&quot;nf&quot;&gt;doXHR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;action&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;HNurl&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;doc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;HNsite&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;contentDocument&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/&amp;lt;head&amp;gt;/&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;lt;head&amp;gt;&amp;lt;base target=&quot;_blank&quot; href=&quot;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;HN_BASE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;/&amp;gt;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This is not your typical use of an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;iframe&amp;gt;&lt;/code&gt;: instead of setting the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src&lt;/code&gt; attribute to the comment thread URL, which we can’t do because HN forbids framing, we have to leave it as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;about:blank&lt;/code&gt;, fetch the contents of the comment thread page via XHR, and then write to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;iframe&amp;gt;&lt;/code&gt;’s &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;document&lt;/code&gt; object extracted with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;contentDocument&lt;/code&gt; property.  We can write the same HTML that HN serves, with one modification: by adding a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;base&amp;gt;&lt;/code&gt; element to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;head&amp;gt;&lt;/code&gt; of this document, we can ensure that all the links within are followed relative to HN, and not the URL of the host site.  The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.open()&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.write()&lt;/code&gt; calls here are indeed &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/DOM/document.write&quot;&gt;those yucky methods&lt;/a&gt; you have been taught to never use since DOM scripting became practical, and in general you really shouldn’t, but here it is fair game because the document we are writing to is completely empty.&lt;/p&gt;

&lt;p&gt;So, after all of that lovely bit-pushing, we get a collapsible sidebar with an HN comment thread in it!  To try it out yourself, install the extension from &lt;a href=&quot;https://chrome.google.com/webstore/detail/hacker-news-sidebar/ngljhffenbmdjobakjplnlbfkeabbpma&quot;&gt;the Chrome Store&lt;/a&gt;, or clone the &lt;a href=&quot;https://github.com/powerpak/hn-sidebar&quot;&gt;source code&lt;/a&gt; and &lt;a href=&quot;https://developer.chrome.com/extensions/getstarted.html#unpacked&quot;&gt;load the directory into Chrome as an unpacked extension&lt;/a&gt;.&lt;/p&gt;

&lt;p class=&quot;figure shadow&quot;&gt;&lt;img src=&quot;/images/hn_sidebar-2.png&quot; alt=&quot;screenshot&quot; /&gt;&lt;/p&gt;

&lt;p&gt;One note on a privacy weakness of this extension, which you may have noticed if you were following the code above: the extension sends all the URLs that you visit to &lt;a href=&quot;https://api.thriftdb.com/&quot;&gt;https://api.thriftdb.com/&lt;/a&gt;.  Obviously, that isn’t going to be acceptable for some users, but there’s no way to look up Hacker News threads for all the URLs you visit without sending those URLs somewhere.  &lt;a href=&quot;https://chrome.google.com/webstore/detail/hacker-newsd/njdndkhkelkeepcnmookckfhleebcokl&quot;&gt;The Hacker News’d extension&lt;/a&gt;, which does something similar but doesn’t add the comment thread to the browser window, makes a strange attempt to mitigate privacy concerns by MD5ing URLs, but then it requires a special &lt;a href=&quot;https://github.com/michaelfairley/hnd-server&quot;&gt;server-side component&lt;/a&gt; that is constantly scraping the front page and shoving the MD5s into a MongoDB on Heroku, and besides that MongoDB being necessarily more incomplete than the &lt;a href=&quot;https://www.hnsearch.com/api&quot;&gt;official API&lt;/a&gt;, it &lt;a href=&quot;https://news.ycombinator.com/item?id=2966586&quot;&gt;doesn’t really solve the privacy problem&lt;/a&gt; anyway.  So, if you want to use this on your primary browser you basically have to trust the ThriftDB folks with your browsing history (hey, at least it’s being sent over SSL).&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn-24d7c7:1&quot;&gt;
      &lt;p&gt;Presumably, HN uses &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options&quot;&gt;the relatively new X-Frame-Options header&lt;/a&gt; to prevent people from embedding HN comment threads directly into their own site, either because they don’t want them surrounded by other people’s content or because they want to block &lt;a href=&quot;http://en.wikipedia.org/wiki/Clickjacking&quot;&gt;clickjacking&lt;/a&gt; schemes for tricking users into upvoting items.  Unfortunately this also precludes the simplest method of accomplishing what the extension used to do—loading the comment thread into an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;iframe&amp;gt;&lt;/code&gt; by setting its &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src&lt;/code&gt; attribute.  I suppose I could have also tried to get around this restriction by &lt;a href=&quot;https://developer.chrome.com/trunk/extensions/webRequest.html#event-onHeadersReceived&quot;&gt;modifying HTTP headers as they are received&lt;/a&gt;, but the way I did it seemed easier. &lt;a href=&quot;#fnref-24d7c7:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</content>
 </entry>
 
 <entry>
   <title>All Science is Anthropological at the Margins</title>
   <link href="https://tedpak.com/2013/02/28/all-science-is-anthropological-at-the-margins.html"/>
   <updated>2013-02-28T00:00:00-05:00</updated>
   <id>https://tedpak.com/2013/02/28/all-science-is-anthropological-at-the-margins</id>
   <content type="html">
&lt;p&gt;It is no secret that hard science folks (think Physics, Engineering, and Math majors) sometimes look down on the “softer” sciences for being less rigorous. There is a joke that a professor from my college once told, which I’m copping directly from &lt;a href=&quot;http://blog.chriskelvinlee.com/courses-on-mathematics&quot;&gt;a former classmate’s blog&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The library at the Princeton Institute of Advance Study was divided into two wings. One wing was for the sciences, which included all the updated journals in math, physics, etc. The other wing was for the humanities, which had the analog journals in history, literature, etc. Given that this was an advanced institute, these scholars spent a great many hours in the library, in their respective wings. One day, Kurt Gödel had enough, gathered a stack of journals, walked to the central librarian, and stated that these journals have been shelved incorrectly. The librarian looked puzzled because all the call numbers to the anthropology journals were correct. In response, Gödel supposedly shouted, “These surely cannot belong in the science wing!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As much as anthropology &lt;a href=&quot;https://www.youtube.com/watch?v=m4qe4QcymLM&quot;&gt;can’t get no respect&lt;/a&gt;, I’m starting to notice a funny trend in the classes I’m taking in grad and med school as compared to college.  Introductory science and mathematics classes in college are very didactic: you learn principles and their applications.  Although in introducing a topic professors talk a little about its backstory—e.g., how Rutherford’s experiment with gold foil led to the development of the Rutherford model of the atom, which became the Bohr model—the who and the why is secondary to grokking the setup, the principle demonstrated, and its logical consequences.&lt;/p&gt;

&lt;p&gt;And that is in fact a wonderful thing about math and science, and a large part of why I liked it throughout grade school: rote memorization was de-emphasized to the point of remembering only a small set of principles, and the skill lay in combining and applying them.  By contrast, history courses seemed to be full of details that had to be slowly committed to memory with little to tie them together except that &lt;em&gt;things happened to turn out that way&lt;/em&gt;.  Whereas knowing F = dp/dt could take you very far in solving a multitude of physics problems, knowing Moctezuma took power in 1440 would not help you guess how long he stayed in power, how he died, or much else about his life or Aztec history.&lt;/p&gt;

&lt;p&gt;There is a tide shifting, however, in my grad school courses on the biomedical sciences.  Whereas the principles taught in college are usually well established, once you reach the fringes of what is known (i.e., results from just a few years ago), there are enough potholes that the multiplicative benefits of combining prior knowledge breaks down. For example, here’s a slide from a developmental biology lecture I had this week:&lt;/p&gt;

&lt;p class=&quot;figure&quot;&gt;&lt;img src=&quot;/images/mlodzik.png&quot; alt=&quot;non-canonical Wnt pathway&quot; /&gt;&lt;/p&gt;

&lt;p&gt;There are almost as many question marks here as named proteins!  It turns out that this is the &lt;a href=&quot;http://en.wikipedia.org/wiki/Wnt_pathway#Non-canonical_Wnt_signaling&quot;&gt;“non-canonical” Wnt pathway&lt;/a&gt;, which &lt;a href=&quot;http://www.mountsinai.org/profiles/marek-mlodzik&quot;&gt;the lecturer&lt;/a&gt; happens to research in his own lab. That name already tells you a few things: that there is a “canonical” pathway (the one &lt;a href=&quot;http://www.ncbi.nlm.nih.gov/books/NBK26918/#ui-ncbiinpagenav-heading-6&quot;&gt;enshrined in Alberts’ MBOC&lt;/a&gt;, of course), that this one is less established, and that people don’t completely understand the relationship between the two yet.  The fact that one pathway is “canonical” is a complete accident, since that one would have likely been considered differently had it been discovered later, or at the same time as the “non-canonical” pathway.&lt;/p&gt;

&lt;p&gt;This is starting to sound as arbitrary as history, right?  It is, and the reality is that in order to do research at the fringes of science, particularly in super sparse fields like the life sciences where there are a lot less researchers than things to study (there are possibly billions of molecular interactions that take place in the human body), you need an anthropological backstory of what you are studying.  That includes: 1) who worked on it and what else they worked on, 2) why they started working on it, and 3) what their assumptions were.  Not only is it helpful for understanding how things in the subfield were named—gene names have a tendency to get really fanciful&lt;sup id=&quot;fnref-41eb99:1&quot;&gt;&lt;a href=&quot;#fn-41eb99:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;—but it is crucial for properly evaluating the claims made and the way the evidence is presented.&lt;/p&gt;

&lt;p&gt;Speaking of naming things: odd names pop up just as frequently in Anatomy and lately, Histology.  For better or worse, many of the cells in the body were named by histologists who were working in the late 19th and early 20th century and could often see a lot more than they could understand (certainly at a molecular level).  Also, what they saw depended on the stains they chose. The result is that in the 21st century, we still use names like “enterochromaffin cells”, “eosinophils”, and “basophils,” which have nothing to do with the function of the cells, but reflect the stains that revealed them on microscope slides.&lt;/p&gt;

&lt;p&gt;So lately, science classes seem to be more and more dependent on the history and people behind them.  A unit on a particular cellular transport mechanism, summarized as “this person argued for this controversial idea, the more established groups vehemently responded, and a great solution was overlooked for years because the author died before he was recognized” could equally describe a history of cultural movements in 19th century France.  Is there something to be learned from this?  Well, a new scientific hypothesis has much in common with a cultural movement: when only a few labs are willing to come up with supportive data, how the greater scientific community will respond depends quite a bit on the kind of the people behind it, how well the idea is marketed, and the responses of others with vested interests.  (A 1% rule &lt;a href=&quot;http://en.wikipedia.org/wiki/1%25_rule_(Internet_culture)&quot;&gt;borrowed from web design&lt;/a&gt; is probably appropriate here: for every 100 people that hear about your great idea, 10 will actually understand it enough to care, and maybe 1 will do something about it.)&lt;/p&gt;

&lt;p&gt;The beauty of science is that data trumps all, as &lt;a href=&quot;http://www.bnl.gov/chemistry/bio/PakRobert.asp&quot;&gt;my dad&lt;/a&gt; says.  The tough news is that getting enough other people to hear your idea and generate data about it, to the point where it becomes a principle that stands on its own, is an anthropological problem.  That’s why it takes two decades from an initial (amazing) result to get a Nobel Prize, assuming of course that it is even awarded to the &lt;a href=&quot;http://en.wikipedia.org/wiki/Rosalind_Franklin&quot;&gt;right person&lt;/a&gt;.  Until then, to make sense of brand-new science, &lt;em&gt;you have to learn just as much about the people behind the ideas&lt;/em&gt;, because that is often the only way to comprehend and contextualize what they are trying to say.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn-41eb99:1&quot;&gt;
      &lt;p&gt;A sample of actual gene names made up by goofy &lt;em&gt;D. melanogaster&lt;/em&gt; researchers: Bride-of-Sevenless, Kevin and Barbie, Swiss Cheese, cheapdate, Mothers-Against-Dpp, Sugar Daddy, and John Wayne Bobbit.  Must be all those ether fumes… &lt;a href=&quot;#fnref-41eb99:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</content>
 </entry>
 
 <entry>
   <title>Pebble, a watch made for iPhone/Android</title>
   <link href="https://tedpak.com/2013/02/26/pebble.html"/>
   <updated>2013-02-26T00:00:00-05:00</updated>
   <id>https://tedpak.com/2013/02/26/pebble</id>
   <content type="html">
&lt;p&gt;I ran across this &lt;a href=&quot;http://getpebble.com&quot;&gt;interesting gadget&lt;/a&gt; while stumbling upon a &lt;a href=&quot;http://danilocampos.com/2013/02/five-days-with-pebble/&quot;&gt;favorable review of it&lt;/a&gt; on another blog.&lt;/p&gt;

&lt;p&gt;&lt;iframe src=&quot;http://player.vimeo.com/video/40128933&quot; width=&quot;480&quot; height=&quot;270&quot; frameborder=&quot;0&quot; webkitallowfullscreen=&quot;&quot; mozallowfullscreen=&quot;&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/p&gt;

&lt;p&gt;It’s a watch with an e-Ink display that is meant to be tethered via Bluetooth to an iPhone.  Besides displaying the time, which it can obviously do in just about any format (analog/digital/words), it will discreetly display texts, caller ID data, and other alerts from your phone. When the phone is playing music, it can control playback.&lt;/p&gt;

&lt;p&gt;Watches seem to currently occupy a tenuous and nostalgic place in our digital lives—unless you are wearing them for show, sport, or jewelry, a brick phone from 2001, functionally speaking, can outdo a Swiss chronometer in every regard except size. Sadly, that includes displaying an accurate time for the local timezone: &lt;a href=&quot;http://www.answerbag.com/q_view/701202&quot;&gt;GSM time&lt;/a&gt; has always been more consistent than whatever my radio-synchronized watch showed, and it required zero fiddling. Having been wristwatch-less for a while now, I’ve only missed it in two scenarios: 1) when, in the middle of a conversation, I needed to check the time and pulling out a phone seemed faux pas; and 2) trying to time something while my hands are occupied, e.g. taking a pulse or respiratory rate (who took all the clocks out of hospital exam rooms?)&lt;/p&gt;

&lt;p&gt;So, the smart move by watchmakers is to have them piggyback off of a phone’s capabilities. However, the established brands have mostly ignored this potential, with only two lackluster products that I can find: &lt;a href=&quot;http://www.sonymobile.com/us/products/accessories/smartwatch/&quot;&gt;Sony’s&lt;/a&gt; is only Android compatible, and &lt;a href=&quot;http://www.gshock.com/watches/Classic/GB6900AA-1&quot;&gt;G-Shock&lt;/a&gt; is still using the same LCD screens as ten years ago. Even car manufacturers like GM are ahead of the game on this one, &lt;a href=&quot;http://blogs.cars.com/kickingtires/2012/01/cd-players-make-slow-exit-from-new-cars.html&quot;&gt;dropping CD players&lt;/a&gt; from cars marketed to younger drivers and prioritizing smartphone integration. Because seriously, besides an FM radio, what can a car audio system offer that a phone with an iTunes library, Pandora, and Spotify couldn’t outdo?&lt;/p&gt;

&lt;p&gt;Thankfully, it appears that Kickstarter projects have stepped in to fill the void. The Pebble makes a case for being permanently clasped to your wrist by offering a second interface to your phone during those times when yanking out the phone seems rude, inconvenient, or both.  And when it’s not doing that, it is probably pretty good at telling the time, since it pulls that from your phone too.  Unlike most geeky watches, it looks more nondescript than ridiculous, and the e-Ink display can display information all day long without sucking down battery life.&lt;/p&gt;

&lt;p&gt;Particularly cool for the programming crowd is that they will &lt;a href=&quot;http://getpebble.com/#customize-with-coding&quot;&gt;release an SDK&lt;/a&gt;. Surely, hackers will find interesting uses for a 10k-pixel wrist display with a 4G data connection.&lt;/p&gt;

&lt;p&gt;I can’t justify buying it yet, but I’ll be curious enough to follow this product type and see if it catches on.  &lt;a href=&quot;http://www.amazon.com/Bluetooth-Bracelet-Vibrating-Caller-Vibration-Wristwatch/dp/B0058G771G/ref=pd_sim_e_1&quot;&gt;Other&lt;/a&gt; &lt;a href=&quot;http://www.amazon.com/Bluetooth-Bracelet-Vibration-Function-Digital/dp/B00512Z8H2/ref=pd_cp_cps_0&quot;&gt;comparable&lt;/a&gt; &lt;a href=&quot;http://www.amazon.com/Koolertron-Bluetooth-Bracelet-Cellphone-Wristwatch/dp/B004FOULAQ/ref=pd_sim_e_5&quot;&gt;items&lt;/a&gt; in this space from no-name brands have been cheap and trashy so far; by creating something that looks like a watch, designing it around seamless integration with popular smartphones, and promoting a dev environment for the geeks that might want to make apps, Pebble and its self-funded design team could win big.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Creating Animated GIFs with ImageMagick &amp; ffmpeg</title>
   <link href="https://tedpak.com/2013/02/07/creating-animated-gifs.html"/>
   <updated>2013-02-07T00:00:00-05:00</updated>
   <id>https://tedpak.com/2013/02/07/creating-animated-gifs</id>
   <content type="html">
&lt;p&gt;I’ll start off this blog with something lightweight and relatively useless except for creating amusing internet gimmicks and perhaps the occasional &lt;a href=&quot;http://chromozoom.org/docs/#mouse-interactions&quot;&gt;animated diagram&lt;/a&gt;.  Surprisingly, there are few good tools for making animated GIFs on a Mac or Linux desktop. On Windows, &lt;a href=&quot;http://download.cnet.com/Paint-Shop-Pro-With-Animation-Shop/3000-2192_4-7057820.html&quot;&gt;Paint Shop/Animation Shop&lt;/a&gt; used to be the go-to suite for doing this—now, the closest thing for Mac folks might be &lt;a href=&quot;https://itunes.apple.com/us/app/GIFBrewery/id435989461?mt=12&quot;&gt;GIFBrewery&lt;/a&gt;, which has far less features and some mixed reviews.  I haven’t plunked down $6 for that yet, so I’ve still been trekking about on the command line, which is certainly more tedious, but you can control every step of the process and get exactly the results you want.&lt;/p&gt;

&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;/h2&gt;

&lt;p&gt;You won’t be able to jump into this without a little comfort on the command line, and the installation of &lt;a href=&quot;http://www.ffmpeg.org/&quot;&gt;ffmpeg&lt;/a&gt; (if you are working from a video source) and &lt;a href=&quot;http://www.imagemagick.org/script/index.php&quot;&gt;ImageMagick&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you’re on a Mac, and you already use &lt;a href=&quot;http://www.macports.org/&quot;&gt;MacPorts&lt;/a&gt;, it should be a simple &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo port install ImageMagick ffmpeg&lt;/code&gt; and a lot of thumb twiddling. If you don’t, try installing &lt;a href=&quot;http://mxcl.github.com/homebrew/&quot;&gt;HomeBrew&lt;/a&gt; which is a little more lightweight, and run a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;brew install imagemagick ffmpeg&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For Linuxes, I’ll leave you to figure out how to get those two packages from your package manager.  Depending on how idealistic your distro is, it might require adding some non-free repositories or even compiling ffmpeg from scratch.  You only &lt;em&gt;really&lt;/em&gt; need ffmpeg if you have a video source file, though; everything else is done with ImageMagick.&lt;/p&gt;

&lt;h2 id=&quot;the-full-workflow&quot;&gt;The full workflow&lt;/h2&gt;

&lt;p&gt;First, you want to start with your source video or images. If it’s video, you can crop/trim it down to the relevant clip with Quicktime X or any more advanced video-editing suite.  Then, it’s time to extract the images with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ffmpeg&lt;/code&gt;.  Open a terminal and change to the directory with your movie file, and assuming &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;whatever.mov&lt;/code&gt; is the filename:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ mkdir decode
$ ffmpeg -i whatever.mov decode/%d.png
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now you’ll have a sequence of images in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;decode&lt;/code&gt; folder that correspond to each frame of your movie.  At this point, it’s a good idea to check out this folder and preview the sequence of images.  They are likely to be far too big to be appropriate for a GIF, so we have to resize and crop them.  We may also want to refine the range of frames that will be used in the gif.&lt;/p&gt;

&lt;p&gt;Bash can expand a sequence of numbers using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{$begin..$end}&lt;/code&gt; notation, which functions as a shell glob.  We can use this to select the frames we want, resize and crop them with ImageMagick, and put these into a new folder.  In this example, we’ll take the first 12 frames, crop them to 405x720 starting 437 pixels from the left side, and resize them by 30%.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ mkdir resized
$ convert decode/{1..12}.png -crop 405x720+437+0 -resize 30% resized/%d.png
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Time to check the output images again; if they aren’t how you like, you might try fiddling with the parameters in the previous command until it looks better.&lt;/p&gt;

&lt;p&gt;A typical thing you might need to do at this point is label some of the frames. For that, we can use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-annotate&lt;/code&gt; feature of ImageMagick.&lt;/p&gt;

&lt;p&gt;Quick aside: It might so happen that you don’t have any civilised fonts (e.g. Impact) available for use by ImageMagick, which requires them to be in TTF format and specified by an XML configuration file.  To fix that, you can follow &lt;a href=&quot;http://gothick.org.uk/2008/03/14/using-os-x-fonts-in-imagemagick/&quot;&gt;this guide&lt;/a&gt;; the short version is, convert the font into TTF format, put it somewhere sane like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/usr/local/share/fonts&lt;/code&gt; and then write up an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.magick/type.xml&lt;/code&gt; that points to it:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;typemap&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;type&lt;/span&gt;
     &lt;span class=&quot;na&quot;&gt;format=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ttf&quot;&lt;/span&gt;
     &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Impact&quot;&lt;/span&gt;
     &lt;span class=&quot;na&quot;&gt;fullname=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Impact&quot;&lt;/span&gt;
     &lt;span class=&quot;na&quot;&gt;family=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Impact&quot;&lt;/span&gt;
     &lt;span class=&quot;na&quot;&gt;glyphs=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/usr/local/share/fonts/Impact.ttf&quot;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/typemap&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Back to text annotation.  Note that we set the text and Y coordinate (from the bottom of the image) at the start of this command to avoid repetition, since the text must be &lt;a href=&quot;http://www.imagemagick.org/Usage/fonts/#thick_stroke&quot;&gt;painted twice&lt;/a&gt; for best results (once for the outline, and once for the fill).  To print it near the top of the image instead, change &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-gravity south&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-gravity north&lt;/code&gt;.  We can copy over any images that we don’t want labeled.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ mkdir annotated 
$ TEXT=&quot;CAPTION&quot; &amp;amp;&amp;amp; YDIST=&quot;10&quot; &amp;amp;&amp;amp; convert resized/{5..8}.png -pointsize 24 \
  -font Impact -strokewidth 2 -stroke black -fill white -gravity south -annotate \
  &quot;+0+$YDIST&quot; &quot;$TEXT&quot; -stroke none -annotate &quot;+0+$YDIST&quot; &quot;$TEXT&quot; annotated/%d.png
$ cp {0..4}.png {9..11}.png annotated
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;One last thing we may want to do is play the frames in reverse at the end of the GIF, so it appears to play seamlessly when looped.  For that, a simple &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cp&lt;/code&gt; inside a for loop will do, but note that we omit copying the first and last frames to avoid playing them twice.  Set &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;LAST&lt;/code&gt; to the number of the last image in your animation.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ LAST=11 &amp;amp;&amp;amp; for i in `seq $[LAST-1]`; do cp annotated/$i.png \
  annotated/$[LAST*2-i].png; done
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Finally, it’s time to assemble this bad boy into a GIFfy little bundle of web-friendly glory.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ convert -delay 6 -loop 0 annotated/{0..21}.png out.gif
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;out.gif&lt;/code&gt; will contain your masterpiece.  Preview it in a few web browsers to get a sense for its flavor.  N.B. with that argument to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-delay&lt;/code&gt;: Using any value lower than 6 is liable to produce strange results in Internet Explorer. This has to do with legacy-compatible interpretations of what the maximum reasonable frame rate for a web browser animation is, &lt;a href=&quot;http://humpy77.deviantart.com/journal/Frame-Delay-Times-for-Animated-GIFs-240992090&quot;&gt;explained in great detail elsewhere&lt;/a&gt;.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Why Blag</title>
   <link href="https://tedpak.com/2013/02/06/why-blag.html"/>
   <updated>2013-02-06T00:00:00-05:00</updated>
   <id>https://tedpak.com/2013/02/06/why-blag</id>
   <content type="html">
&lt;p&gt;Ah, the old existentialist topic that plagues all too many blogs, sometimes as a “frist post!” article, other times as a retrospective question from a blogger that wonders if it has been sucking up too much time.  I’ve read these posts all too often wondering if any of the reasons apply to me.  Currently, I’m a medical and graduate student, not an &lt;a href=&quot;http://www.gabrielweinberg.com/blog/2011/08/why-i-blog.html&quot;&gt;entrepreneur&lt;/a&gt; seeking publicity, nor a &lt;a href=&quot;http://www.theatlantic.com/magazine/archive/2008/11/why-i-blog/307060/&quot;&gt;writer&lt;/a&gt; for a magazine, nor a &lt;a href=&quot;http://krogsgard.com/2011/why-blog/&quot;&gt;full-time web dev&lt;/a&gt; sharing tips on design and content.  Therefore, their opinions, while sensible, don’t seem to apply as much to my life.  &lt;a href=&quot;http://ivory.idyll.org/blog/&quot;&gt;Dr. C. Titus Brown&lt;/a&gt;, a bioinformatician, perhaps hits closest to home in &lt;a href=&quot;http://ivory.idyll.org/blog/why-i-blog-2013-version.html&quot;&gt;his take&lt;/a&gt;, where he draws from &lt;a href=&quot;http://www.paulgraham.com/essay.html&quot;&gt;Paul Graham&lt;/a&gt; (a idol among young Valley founders) to outline his thoughts on blogging as scientist.  The punchline:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;I write blog posts because I want to figure out why I think what I think.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This rings true for me. I can’t count the number of times I’ve stopped mid-sentence while writing, discovering that what I’m trying to express had a hidden problem. The process of writing forces you to think through the details, refining mental mush into crystallized logic. Best of all, you can refer back to written words whenever you want to recall exactly &lt;em&gt;how&lt;/em&gt; you formed your arguments.&lt;/p&gt;

&lt;p&gt;Furthermore, I want to write faster, and that requires practice. There are a few people I’ve met who have the enviable skill of banging out 10-sentence emails in under a minute. Email is not going anywhere for decades. As far as I could tell, all of my past PIs (bosses, for anybody who hasn’t worked in a lab) spent a lot of time handling email. Not to mention, physicians are now expected to write tens to hundreds of notes into medical records every day, without having time explicitly allotted for it. So, my future day-to-day will inevitably involve a lot of writing, and I might as well get ready for it.&lt;/p&gt;

&lt;p&gt;On the proposition of blogging, researchers sometimes counter that they are already expected to do a lot of writing: grant proposals, abstracts, and publications, publications, publications. Time spent blogging is time spent not doing those things. Should scientists really only communicate via peer-reviewed journal articles? There are obvious drawbacks:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The lag time on publication is something on the order of months, even with early access.&lt;/li&gt;
  &lt;li&gt;Not all opinions or pieces of data merit publication in a “worthwhile” journal for an author to bear the costs of submission, but they may be interesting to other scientists anyway.&lt;sup id=&quot;fnref-c3a9be:1&quot;&gt;&lt;a href=&quot;#fn-c3a9be:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
  &lt;li&gt;Most journals are locked up behind paywalls, despite publishing mostly publicly-funded work.&lt;/li&gt;
  &lt;li&gt;Publication bias almost certainly exists in most journals, leading to an overrepresentation of positive results.&lt;sup id=&quot;fnref-c3a9be:2&quot;&gt;&lt;a href=&quot;#fn-c3a9be:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On the other hand, there are equally concerning drawbacks to moving most scientific conversation into the blogosphere:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Blogs mostly operate as a huge decentralized network, with content appearing and disappearing at will, and no central index (blog search engines exist, yes, but not specifically for content by scientists.) Citations are much less useful without content archival.&lt;/li&gt;
  &lt;li&gt;Statements are made without any peer review. (The obvious counter-argument here is that the current peer-review culture of science has serious flaws, which is already &lt;a href=&quot;http://scholar.google.com/scholar?hl=en&amp;amp;q=peer+review+flawed&quot;&gt;believed by many&lt;/a&gt;.)&lt;/li&gt;
  &lt;li&gt;Most frightening, and a specific drawback of the current peer-review process: scientists might blog about opinions that come back to haunt him in the anonymous review process for a journal or grant.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because this debate is playing out slowly within the current ecosystem of journals, reviewers, and funding sources, it might be a while before scientists can start putting blogs on R01 applications.  I am heartened by the amount of attention &lt;a href=&quot;http://en.wikipedia.org/wiki/Open_access&quot;&gt;Open Access&lt;/a&gt; is now getting, along with innovators in science publishing like &lt;a href=&quot;http://figshare.com/&quot;&gt;Figshare&lt;/a&gt;.  But that’s not really what motivates me to start a blog now, anyway.&lt;/p&gt;

&lt;p&gt;What really tips the scales is that &lt;em&gt;the web will the publishing vehicle of choice for next-generation science&lt;/em&gt;, certainly for people in my field of interest (systems and computational biology). It’s the nature of the beast: models, databases, live visualizations, and tools cannot live exclusively within the hallowed confines of a PDF article. Biblical bioinformatics projects already reside entirely inside websites, and essentially only publish journal articles to maintain a current citation: the &lt;a href=&quot;http://genome.ucsc.edu&quot;&gt;UCSC genome browser&lt;/a&gt;, &lt;a href=&quot;http://www.uniprot.org/&quot;&gt;UniProt&lt;/a&gt;, &lt;a href=&quot;http://www.ncbi.nlm.nih.gov/sites/gquery&quot;&gt;Entrez&lt;/a&gt;, &lt;a href=&quot;http://www.yeastgenome.org&quot;&gt;Saccharomyces Genome Database&lt;/a&gt;, etc.  While the information they contain will remain relevant for a long time, web technologies tend to move a lot faster than science.  Sometimes cool things happen when you marry newer web technologies with the data on the venerable genomics sites; indeed, this was the premise for &lt;a href=&quot;http://chromozoom.org&quot;&gt;ChromoZoom&lt;/a&gt;, a genome browser that feels as slick as Google Maps.&lt;/p&gt;

&lt;p&gt;How can you stay up to date with technology (particularly for the web) when it moves so much faster than science?  It requires practice and experience.  That means building and maintaining any sort of project, even if it as lowly as a blog. Blog technology has evolved a lot over the past decade, with homespun static websites evolving into the Livejournals and Xangas, replaced by the more customizable and self-hostable Wordpress and Movable Type blogs, and most recently, the wave of sleeker Twitter-inspired microblogs like Tumblr.  As blogs started catering more content to link listing sites like Digg and Reddit, traffic tended to get more “spikey,” and there was nothing more embarassing than losing 10,000 potential hits to a slow backend database; therefore, another recent blog-engineering trend has been to host as much content as possible from static files, with dynamic features like comments “outsourced” to services like Disqus, Facebook, and IntenseDebate.  For HuffPost-tier sites, it is then easy to push static content to &lt;a href=&quot;http://en.wikipedia.org/wiki/Content_delivery_network&quot;&gt;content-delivery networks&lt;/a&gt; like Akamai and Amazon so &lt;em&gt;they&lt;/em&gt; can handle serving it from high-performance datacenters while the bloggers focus on churning out more linkbait.&lt;/p&gt;

&lt;p&gt;As much as Linux gearheads will groan at the premise that building a blog is at all interesting, there is actually a lot to learn by doing so.  (There is a reason Rails and most other web frameworks continue to push screencasts showing &lt;a href=&quot;http://www.railsinside.com/screencasts/167-building-a-blog-in-15-minutes-with-rails-22-a-new-screencast.html&quot;&gt;how fast&lt;/a&gt; you can code up a blog.)  The web will need to host blog-like content until the internet dies.  Engineering innovations will follow this need, whether it’s &lt;a href=&quot;http://nginx.org/&quot;&gt;nginx&lt;/a&gt; for super-fast static content hosting, &lt;a href=&quot;http://jekyllrb.com/&quot;&gt;jekyll&lt;/a&gt; for neatly transforming source content into web content, or &lt;a href=&quot;http://unicorn.bogomips.org/&quot;&gt;unicorn&lt;/a&gt; for running Rack applications behind nginx.  On that note, a post on the tools that power this site is forthcoming.&lt;sup id=&quot;fnref-c3a9be:3&quot;&gt;&lt;a href=&quot;#fn-c3a9be:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;3&lt;/a&gt;&lt;/sup&gt; I hadn’t worked with any of them before making this and I’m glad I took some time to learn them.&lt;/p&gt;

&lt;p&gt;So why blog, if you are a budding medical or graduate student? If you are at all interested in computational research, I say do it for three reasons: 1. it helps refine your thoughts, and improve your writing; 2. it promotes an alternative and open form of scientific dialogue; and 3. it keeps you current on web technology. That’s all for now folks—let me &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git commit -a &amp;amp;&amp;amp; git push&lt;/code&gt; and get these bits on the web already!&lt;/p&gt;

&lt;p&gt;Update: Soon after I wrote this, I ran across an &lt;a href=&quot;http://blogs.lse.ac.uk/impactofsocialsciences/2012/02/24/five-minutes-patrick-dunleavy-chris-gilson/&quot;&gt;interview&lt;/a&gt; with two social scientists on this very topic.  Their takeaway: “Blogging is quite simply, one of the most important things that an academic should be doing right now.”  Quite different reasons than mine, but informative nonetheless, and it is followed by a recent &lt;a href=&quot;http://blogs.discovermagazine.com/gnxp/2013/03/why-more-academics-should-blog-cuz-you-can/&quot;&gt;reply from a Discover Magazine writer&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn-c3a9be:1&quot;&gt;
      &lt;p&gt;This is almost certainly true for computational work: new processes, tools, and scripts are exciting and interesting to other people on the web, and while none of these typically merit publication, they can really help others in the field and usually are easily suited to sharing over the web. I’ve probably learned a thousand random tricks from blog posts that help me each day. &lt;a href=&quot;#fnref-c3a9be:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-c3a9be:2&quot;&gt;
      &lt;p&gt;A lot of the contemporary discussion on this stems from a widely-cited article called &lt;a href=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC1182327/&quot;&gt;Why Most Published Research Findings Are False&lt;/a&gt; by Dr. John P. A. Ioannidis. &lt;a href=&quot;#fnref-c3a9be:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn-c3a9be:3&quot;&gt;
      &lt;p&gt;Short version: the three things I just mentioned, on a Linode 512. &lt;a href=&quot;#fnref-c3a9be:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</content>
 </entry>
 
 
</feed>
