<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>ryan.sh</title><link href="http://ryan.sh/" rel="alternate"></link><link href="http://ryan.sh/feeds/misc.atom.xml" rel="self"></link><id>http://ryan.sh/</id><updated>2014-06-02T00:00:00-04:00</updated><entry><title>Cocktail: The Heart</title><link href="http://ryan.sh/2014/06/02/cocktail-the-heart/" rel="alternate"></link><published>2014-06-02T00:00:00-04:00</published><updated>2014-06-02T00:00:00-04:00</updated><author><name>Ryan Witt</name></author><id>tag:ryan.sh,2014-06-02:2014/06/02/cocktail-the-heart/</id><summary type="html">&lt;p&gt;The &lt;a href="http://www.flatironlounge.com"&gt;Flatiron Lounge&lt;/a&gt; is my favorite cocktail bar in &lt;span class="caps"&gt;NYC&lt;/span&gt;. I&amp;#8217;ve long been captivated by the multi-step flavor of &lt;em&gt;The Heart it Races&lt;/em&gt; by &lt;a href="https://twitter.com/mixtressnyc"&gt;Julie Reiner&lt;/a&gt; which is no longer on the menu but known to the mixologists there. The real magic in this drink is the muddled coffee beans, which follow the rest of the flavors&amp;nbsp;chronologically. &lt;/p&gt;
&lt;p&gt;This drink is so superbly blended (and a Flatiron visit so fun) that I never had much luck identifying the components (other than coffee). But tonight, searching for ways to use Campari, I ran across a &lt;a href="http://kaldiscoffee.com/blogs/news/tagged/coffee-cocktail"&gt;variation&lt;/a&gt; on the classic Rye/Vermouth/Campari &lt;a href="http://www.nytimes.com/2014/01/29/dining/the-boulevardier-is-back-on-the-menu.html"&gt;Boulivardier&lt;/a&gt; (itself a variation on the crisp Negroni made with Gin/Vermouth/Campari) that gave me a&amp;nbsp;hunch:&lt;/p&gt;
&lt;p&gt;Swapping the gin for whiskey opens the drink up to blending with smoky flavors. Just add coffee beans and, voilà! It tastes like &lt;em&gt;The Heart it Races&lt;/em&gt;! Here&amp;#8217;s how to make my version, &lt;em&gt;The Heart&lt;/em&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img alt="The Heart" src="http://ryan.sh/2014/06/02/cocktail-the-heart/the-heart.jpg" /&gt;&lt;/p&gt;
&lt;h1&gt;The&amp;nbsp;Heart&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;2 oz. &lt;a href="http://widowjane.com/products/"&gt;Widow Jane&lt;/a&gt; 7-year straight&amp;nbsp;bourbon&lt;/li&gt;
&lt;li&gt;1/2 oz. Sweet&amp;nbsp;vermouth&lt;/li&gt;
&lt;li&gt;1/2 oz.&amp;nbsp;Campari&lt;/li&gt;
&lt;li&gt;3 freshly roasted espresso&amp;nbsp;beans&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Fill a mixing glass half-full of ice. Crush the espresso beans with a mortar and pestle and add to glass. Add bourbon, vermouth and Campari and stir for 30 seconds. Strain through a fine sieve into chilled cocktail glass. Garnish with a lemon&amp;nbsp;twist.&lt;/p&gt;</summary><category term="cocktail"></category></entry><entry><title>Let’s get ready to rumble</title><link href="http://ryan.sh/2013/11/26/lets-get-ready-to-rumble/" rel="alternate"></link><published>2013-11-26T00:00:00-05:00</published><updated>2013-11-26T00:00:00-05:00</updated><author><name>Ryan Witt</name></author><id>tag:ryan.sh,2013-11-26:2013/11/26/lets-get-ready-to-rumble/</id><summary type="html">&lt;p&gt;If there&amp;#8217;s one thing I like about Apple besides aluminum, glass and parting with my money, it&amp;#8217;s their attitude toward people who use&amp;nbsp;computers.&lt;/p&gt;
&lt;p&gt;Not that people who use computers (or people in general) are all that deserving or likable or easy to deal with. This story captures some of what I&amp;nbsp;mean.&lt;/p&gt;</summary></entry><entry><title>Mobile is eating the world</title><link href="http://ryan.sh/2013/05/25/mobile-is-eating-the-world/" rel="alternate"></link><published>2013-05-25T00:00:00-04:00</published><updated>2013-05-25T00:00:00-04:00</updated><author><name>Ryan Witt</name></author><id>tag:ryan.sh,2013-05-25:2013/05/25/mobile-is-eating-the-world/</id><summary type="html">&lt;blockquote&gt;
&lt;p&gt;I’ll be presenting these slides (or something pretty close to them) on 29 May at &lt;span class="caps"&gt;BEA&lt;/span&gt; in New York. They give a pretty good overview of where the industry sits&amp;nbsp;today.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I recently discovered Benedict Evans and subscribed to his &lt;a href="http://ben-evans.com/newsletter/"&gt;excellent mobile newsletter&lt;/a&gt;. Slides from his above presentation have been cherry-picked by the tech press over the last few days, but I&amp;#8217;d like to draw attention to this&amp;nbsp;one:&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="https://image.slidesharecdn.com/201305bea-130517184340-phpapp01/95/slide-6-638.jpg?1369044063" /&gt;&lt;/p&gt;
&lt;p&gt;Fantastic storytelling with data. Very&amp;nbsp;Tufte.&lt;/p&gt;</summary></entry><entry><title>Regular expression tester</title><link href="http://ryan.sh/2013/05/15/regular-expression-tester/" rel="alternate"></link><published>2013-05-15T00:00:00-04:00</published><updated>2013-05-15T00:00:00-04:00</updated><author><name>Ryan Witt</name></author><id>tag:ryan.sh,2013-05-15:2013/05/15/regular-expression-tester/</id><summary type="html">&lt;div style="margin: 15px 0; padding:5%; background-color:#f5f5f5"&gt;

&lt;table id="regex-2" class="table table-border"&gt;
    &lt;thead&gt;
        &lt;th&gt;
            Regular Expression:
            &lt;input
                style="border:none; padding:1ex; width:90%; font-size:16px;"
                id="exp1-2"
                value="ab"
                spellcheck="false"
            &gt;&lt;/input&gt;
        &lt;/th&gt;
        &lt;th&gt;
            Text:
            &lt;input
                style="border:none; padding:1ex; width:90%; font-size:16px;"
                id="exp2-2"
                value="aaabbb"
                spellcheck="false"
            &gt;&lt;/input&gt;
        &lt;/th&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
    &lt;/tbody&gt;
&lt;/table&gt;

&lt;div id="out" style="font-size:64px; color: red; text-align:center; line-height: 1;"&gt;aaabbb&lt;/div&gt;

&lt;script src="http://code.jquery.com/jquery-1.9.1.min.js"&gt;&lt;/script&gt;
&lt;script&gt;
var jqRX = $.noConflict();
jqRX('#exp1-2, #exp2-2').keydown(function(e) {e.stopPropagation();});
jqRX('#exp1-2, #exp2-2').keyup(function(e) {
    jqRX('#out').text(jqRX('#exp2-2').val()).html(
        jqRX('#out').text().replace(
            RegExp(jqRX('#exp1-2').val()),
            function(m) {return "&lt;span style=\"color:green\"&gt;"+m+"&lt;/span&gt;"}
        )
    );
    return false;
})
jqRX(document).ready(function(){jqRX('#exp1-2').trigger('keyup')});
&lt;/script&gt;

&lt;/div&gt;</summary></entry><entry><title>Hierarchy of caches</title><link href="http://ryan.sh/2013/05/13/hierarchy-of-caches/" rel="alternate"></link><published>2013-05-13T00:00:00-04:00</published><updated>2013-05-13T00:00:00-04:00</updated><author><name>Ryan Witt</name></author><id>tag:ryan.sh,2013-05-13:2013/05/13/hierarchy-of-caches/</id><summary type="html">&lt;p&gt;Computers are a &lt;strong&gt;hierarchy of caches&lt;/strong&gt; that are &lt;strong&gt;fast in the average case&lt;/strong&gt;.
I&amp;#8217;m fond saying this, because it pretty much explains all of the decisions made in the last 60 years of computer&amp;nbsp;science.&lt;/p&gt;
&lt;p&gt;If you&amp;#8217;re a computer, there are quite a few choices for how to store things you&amp;#8217;re working on beyond
hard drives and memory that most often get talked about. The fastest are &lt;strong&gt;registers&lt;/strong&gt;, the hundered-or-so little number
pockets embedded right in the same circuts that do the adding subtracting, multiplying and dividing.
Unfortunately, they hold a mere &lt;strong&gt;thimblefull&lt;/strong&gt; of&amp;nbsp;data.&lt;/p&gt;
&lt;p&gt;Enter the &lt;strong&gt;L1 cache&lt;/strong&gt;, which holds a &lt;strong&gt;coffee cup&lt;/strong&gt; worth of data. This is still on the chip, and
pretty close to the registers, but a bit slower. L1 has some even bigger, even slower cousins called
the &lt;strong&gt;L2/L3 cache&lt;/strong&gt;, who live on the chip (often taking up half of it) and hold &lt;strong&gt;a large trash can&lt;/strong&gt;
worth of&amp;nbsp;data. &lt;/p&gt;
&lt;p&gt;Now we&amp;#8217;re getting somewhere! But we&amp;#8217;ve also run out of chip. Sillicon is expensive, and those
registers and cache take up a lot of space. Time to bring out the &lt;strong&gt;main memory&lt;/strong&gt; which holds a few
&lt;strong&gt;railway tankers&lt;/strong&gt; of data by squeezing it into a smaller&amp;nbsp;area.&lt;/p&gt;
&lt;p&gt;But what about our boatloads of photos, and videos we stash on the &lt;strong&gt;hard disk&lt;/strong&gt;? Keeping up the analogy, this
amount of data is comparable to the daily oil output of the &lt;strong&gt;Arctic National Wildlive Refuge&lt;/strong&gt; (&lt;a href="http://en.wikipedia.org/wiki/Arctic_National_Wildlife_Refuge"&gt;&lt;span class="caps"&gt;ANWR&lt;/span&gt;&lt;/a&gt;).
For more data than that, we&amp;#8217;ve got to go &lt;a href="http://www.youtube.com/watch?v=mjtqoQE_ezA"&gt;to the cloud&lt;/a&gt;, which is really
just a bunch of disks over &lt;strong&gt;a network&lt;/strong&gt; that can store as much data as &lt;strong&gt;&lt;span class="caps"&gt;US&lt;/span&gt; diesel consumption in one year&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;All this extra space comes a cost. Cache, memory and disks are increasingly further away from where
the calculation is taking place, so it takes increasingly long trips to get&amp;nbsp;there.&lt;/p&gt;
&lt;p&gt;A trip to the registers? That&amp;#8217;s like going to the &lt;strong&gt;coffee shop downstairs&lt;/strong&gt;. I wouldn&amp;#8217;t think twice, and
neither would an electron. L1 cache is a bit further, like heading to that tasty take out place &lt;strong&gt;down
the street&lt;/strong&gt;. But to get to the L2/L3 cache, I&amp;#8217;d want to hop on the &lt;strong&gt;subway for a few stops&lt;/strong&gt; (New Yorkers
are impatient, if you hadn&amp;#8217;t&amp;nbsp;heard).&lt;/p&gt;
&lt;p&gt;Now, getting to the main memory is like me heading from &lt;strong&gt;&lt;span class="caps"&gt;NYC&lt;/span&gt; to Westchester&lt;/strong&gt; on the Metro-North, 
perhaps a little over an hour. This is not a trip I&amp;#8217;d take on a whim. But now we&amp;#8217;ve got a really
big jump from memory and disk drives. The fastest drive you can get, a fancy new &lt;span class="caps"&gt;SSD&lt;/span&gt;, is like taking
the &lt;strong&gt;bus to Boston&lt;/strong&gt; (4 hours or so), but that&amp;#8217;s only reading from the drive, writing is like &lt;strong&gt;going to California&lt;/strong&gt;!
It gets even worse with disk drives that actually have spinny discs in them. This leg of the journey is
like &lt;strong&gt;going to China&lt;/strong&gt; for the very fastest drives, and flying a &lt;strong&gt;quarter of the way to the moon&lt;/strong&gt; for the slow&amp;nbsp;ones!&lt;/p&gt;
&lt;p&gt;It&amp;#8217;s easy to get caught up in the jargon of megabytes and gigabytes and loose perspective on the vast
numbers involved. I made a chart to help&lt;sup id="fnref:1"&gt;&lt;a class="footnote-ref" href="#fn:1" rel="footnote"&gt;1&lt;/a&gt;&lt;/sup&gt;:&lt;/p&gt;
&lt;div style="text-align:center"&gt;
&lt;img src="http://ryan.sh/2013/05/13/hierarchy-of-caches/orders-of-magnitude-anthro.png" class="img-rounded" style="width:85%; margin: 15px 0; padding:5%; background-color:#f5f5f5"&gt;
&lt;/div&gt;

&lt;p&gt;It fascinates me that each rung on the ladder is one &lt;strong&gt;order of magnitude&lt;/strong&gt; bigger (nerd speak for 10 times bigger)
than the previous, in both directions. I don&amp;#8217;t think this is a coincidence. Here&amp;#8217;s are the rough&amp;nbsp;numbers:&lt;/p&gt;
&lt;div style="text-align:center"&gt;
&lt;img src="http://ryan.sh/2013/05/13/hierarchy-of-caches/orders-of-magnitude.png" class="img-rounded" style="width:80%; margin: 15px 0; padding:5%; background-color:#f5f5f5"&gt;
&lt;/div&gt;

&lt;p&gt;Why are size and latency so close to linear? My best theory is we&amp;#8217;ve spend &lt;strong&gt;equal amounts of
time and money&lt;/strong&gt; making each part fast. Leaving a gap is either too expensive if you use the small fast
thing or too slow if you use the large thing (maybe &lt;a href="http://hypercritical.co"&gt;Siracusa&lt;/a&gt; or &lt;a href="http://anandtech.com"&gt;Anand&lt;/a&gt;
have a better&amp;nbsp;theory).&lt;/p&gt;
&lt;p&gt;The reason this chart is so important, is our &lt;strong&gt;hierarchy of caches&lt;/strong&gt; that says that you pay a lot of
latency to access data that&amp;#8217;s already in a fast cache. Much of the history of algorithms and data structures
are a &lt;strong&gt;series of clever tricks&lt;/strong&gt;&lt;sup id="fnref:2"&gt;&lt;a class="footnote-ref" href="#fn:2" rel="footnote"&gt;2&lt;/a&gt;&lt;/sup&gt; to keep the data that you&amp;#8217;re working on in the lower left side of the&amp;nbsp;chart. &lt;/p&gt;
&lt;p&gt;The term &lt;em&gt;d&amp;#8217;art&lt;/em&gt; for this is &lt;strong&gt;data locality&lt;/strong&gt;.&lt;/p&gt;
&lt;div class="footnote"&gt;
&lt;hr /&gt;
&lt;ol&gt;
&lt;li id="fn:1"&gt;
&lt;p&gt;I made the charts for &lt;a href="http://cs4h.com"&gt;&lt;span class="caps"&gt;CS&lt;/span&gt; for Hackers&lt;/a&gt; at &lt;a href="http://generalassemb.ly"&gt;General Assembly&lt;/a&gt;, so they&amp;#8217;re licensed &lt;a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/"&gt;cc-by-nc-sa&lt;/a&gt;.&amp;#160;&lt;a class="footnote-backref" href="#fnref:1" rev="footnote" title="Jump back to footnote 1 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:2"&gt;
&lt;p&gt;Next time we&amp;#8217;ll talk more about why computers are &lt;strong&gt;fast in the average case&lt;/strong&gt;.&amp;#160;&lt;a class="footnote-backref" href="#fnref:2" rev="footnote" title="Jump back to footnote 2 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;</summary></entry></feed>