<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.5">Jekyll</generator><link href="https://schwad.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://schwad.github.io/" rel="alternate" type="text/html" /><updated>2024-06-22T07:57:36+00:00</updated><id>https://schwad.github.io/feed.xml</id><title type="html">schwad</title><subtitle>I am a Rubyist enjoying solving challenging problems.
</subtitle><entry><title type="html">schawad_performance_logger 0.5 released</title><link href="https://schwad.github.io/2024/06/21/schwad-performance-logger-0-5-released.html" rel="alternate" type="text/html" title="schawad_performance_logger 0.5 released" /><published>2024-06-21T07:34:09+00:00</published><updated>2024-06-21T07:34:09+00:00</updated><id>https://schwad.github.io/2024/06/21/schwad-performance-logger-0-5-released</id><content type="html" xml:base="https://schwad.github.io/2024/06/21/schwad-performance-logger-0-5-released.html"><![CDATA[<p>In 2019 I authored the <a href="https://github.com/Schwad/schwad_performance_logger">schwad_performance_logger</a> gem to solve a problem that seemingly only I had. I wanted a thin DSL for <code class="language-plaintext highlighter-rouge">get_process_mem</code>, <code class="language-plaintext highlighter-rouge">memory_profiler</code>, <code class="language-plaintext highlighter-rouge">benchmark-ips</code> and time performance.</p>

<p>I wanted to package up these tools together and have easy access to them. With one line of code I can get all the information I want.</p>

<p>This weekend I shipped an update.</p>

<h2 id="better-rendering">Better rendering</h2>

<p>The current output of <code class="language-plaintext highlighter-rouge">#log_performance</code> used to be a sloppy mess. I didn’t care because it was <em>my</em> gem. Well I care now. Let’s clean that up.</p>

<p><strong>Before v0.5</strong></p>

<p style="text-align:center"><img src="https://i.imgur.com/PDL2Fwt.png" alt="Favorite" /></p>

<p><strong>After v0.5</strong></p>

<p style="text-align:center"><img src="https://i.imgur.com/RsuoVj3.png" alt="Favorite" /></p>

<h2 id="better-ux">Better UX</h2>

<ul>
  <li><code class="language-plaintext highlighter-rouge">#log_performance</code> is a bit verbose if you’re using it a lot. There’s also now a <code class="language-plaintext highlighter-rouge">#lp</code> alias to save your fingers if you want.</li>
  <li><em>Block syntax!</em> I’m super excited about this. I often found I wanted to inspect the performance of a “chunk” of code along the way. But I’d have to do two logs - before <em>and</em> after the block. Now you can wrap that up neatly in a block and the logger will let you know performance details within the block.</li>
  <li>Cleanups. The raw logger used to always start memos with “Starting  #{your_memo}”, now, it’s just your memo. <code class="language-plaintext highlighter-rouge">CSV</code> now has headers. Logfile writing output is cleaned up a bit</li>
</ul>

<p><strong>Before v0.5</strong></p>

<p style="text-align:center"><img src="https://i.imgur.com/6MCMPCq.png" alt="Favorite" /></p>

<p><strong>After v0.5</strong></p>

<p style="text-align:center"><img src="https://i.imgur.com/E6Ib2v8.png" alt="Favorite" /></p>]]></content><author><name></name></author><summary type="html"><![CDATA[In 2019 I authored the schwad_performance_logger gem to solve a problem that seemingly only I had. I wanted a thin DSL for get_process_mem, memory_profiler, benchmark-ips and time performance.]]></summary></entry><entry><title type="html">Did I watch the 90’s Foster’s beer ad thousands of times?</title><link href="https://schwad.github.io/2024/04/19/did-i-watch-the-fosters-ad-1000s-of-times.html" rel="alternate" type="text/html" title="Did I watch the 90’s Foster’s beer ad thousands of times?" /><published>2024-04-19T10:34:09+00:00</published><updated>2024-04-19T10:34:09+00:00</updated><id>https://schwad.github.io/2024/04/19/did-i-watch-the-fosters-ad-1000s-of-times</id><content type="html" xml:base="https://schwad.github.io/2024/04/19/did-i-watch-the-fosters-ad-1000s-of-times.html"><![CDATA[<p style="text-align:center"><img src="https://static6.depositphotos.com/1006899/541/i/450/depositphotos_5414087-stock-photo-business-graph.jpg" alt="Favorite" /></p>

<p>In my post <a href="https://schwad.github.io/2024/04/18/you-are-what-you-see.html">“You are what you see”</a> I talk about the Foster’s ad that I’d seen, what seemed like, endlessly during my youth. Which prompted a little niggling curiosity in my mind. Did I actually watch this ad <em>thousands</em> of times?</p>

<p>Let’s explore.</p>

<p>We didn’t have smartphones. In my free time I did do a fair few enriching activities (raising poultry, archery, hiking, swimming, fishing) and some unenriching activites (Playstation, Gameboy, chatrooms). But where I grew up <em>television was king</em>.</p>

<p>Thursday nights? ER. Sunday nights? X-Files. Weekend afternoon? Family blockbuster movie. We didn’t go on “holidays” like many in Europe do, and we didn’t camp like many where I lived did. The TV was the down time and our chance to connect with the world.</p>

<hr />

<p>This source alleges the mean number of hours of TV watched in America is around <a href="https://www.csun.edu/science/health/docs/tv&amp;health.html#tv_stats">4 hours a day</a>. This <a href="https://www.statista.com/statistics/411775/average-daily-time-watching-tv-us-by-age/">slightly-better-looking</a> data indicates the number is actually less for non-retirees, and is decreasing year on year for the younger folks.</p>

<p style="text-align:center"><img src="https://i.imgur.com/t7wTsSA.png" alt="Favorite" /></p>

<p>Let’s just say I averaged 4.5 hours of TV per day. Though I know some days would’ve been MUCH more. This <em>very</em> helpful <a href="https://www.encyclopedia.com/marketing/encyclopedias-almanacs-transcripts-and-maps/fosters-group-limited">overview of the campaign</a> indicates it ran from 1994 to 2001. Allegedly it won awards. The budget was initially $3 million a year and then $10 million a year. It seems I wouldn’t have seen it before 1997 on the lower budget.The <em>conclusion</em> of the ad campaign is unclear, but it appears reasonable to assume it wrapped up around 2004.</p>

<p style="text-align:center"><img src="https://i.imgur.com/aBvoD5C.png" alt="Favorite" /></p>

<p>Seven years? Cool. That should be enough information to start making some inferences.</p>

<p><strong>Seven</strong> years times <strong>365</strong> days times <strong>4.5</strong> hours is <strong>11,497.5</strong> hours of television-watching. That’s 14-28 ads per hour based <a href="https://mocktheagency.com/content/how-many-tv-ads-per-hour/#:~:text=On%20average%2C%20viewers%20watch%20around,ad%20is%2030%20seconds%20long.">on estimates</a>. This changes based on the length of the ad - some are 5 second bumpers and others are 60 seconds long.</p>

<p style="text-align:center"><img src="https://i.imgur.com/epEDq4s.png" alt="Favorite" /></p>

<p>I would’ve watched HBO and films too. Let’s say that was a quarter of my watching (generous - probably less). And also considering time where there would <em>never</em> be a Foster’s commercial (Saturday morning cartoons). I think 10 qualified ads per hour of TV watched is a reasonable estimate.</p>

<p>Which makes us at a cool 114,975 ads. Let’s make it 115,000 because we can.</p>

<p>That’s….. not a lot? The upper bound (if I watched more TV and underestimated ad density) is probably around 200,000 and the lower bound I would be shocked if it’s under 100,000. The smell test estimates 45 ads a day and I tell you what I’m pretty sure I <em>far</em> exceeded that number some afternoons watching MTV.</p>

<p>So what we need is 1 Fosters ad apperance in a 100, or 1 in 50 if we want to say I saw it “thousands” of times. That’s our final question.</p>

<p>(That or debunk one of my estimates above to vastly increase the gross number of ads watched.)</p>

<p>This <a href="https://www.nytimes.com/2001/03/06/business/media-business-advertising-foster-s-beer-putting-new-twist-its-longtime-speak.html#:~:text=The%20new%20TV%20spots%20run%20for%2030%20seconds%20%2D%2D%20twice%20the%20length%20of%20previous%20commercials%20%2D%2D%20and%20are%20being%20shown%20on%20cable%20channels%20like%20ESPN%2C%20Comedy%20Central%20and%20VH1.">2001 NYT Article</a> hints that the ads were played heavily on Comedy Central, VH1, ESPN and also <em>radio</em>.</p>

<p style="text-align:center"><img src="https://i.imgur.com/2toG3kY.png" alt="Favorite" /></p>

<p>And if you remember how these ads come along, it’s not an even distribution. An afternoon of Comedy Central or Sportscenter and you might see this ad <em>every ad break</em>. So perhaps 12 times in a day. This would be nearly 4,000 times a <em>year</em> at that pace!</p>

<p>I watched ESPN, Comedy Central and VH1 a lot as a teen. And if you wrap in radio (~5-8 hrs a week?) - I declare this to be <strong>plausible</strong>. I’ve even been conservative enough that the true figure could be much, much higher!</p>

<p>I’ve watched the Foster’s ad thousands of times. Maybe you have too.</p>

<p style="text-align:center"><img src="https://i.ytimg.com/vi/uCG6N1w6zp0/hqdefault.jpg" alt="Favorite" /></p>]]></content><author><name></name></author><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">You are what you see</title><link href="https://schwad.github.io/2024/04/18/you-are-what-you-see.html" rel="alternate" type="text/html" title="You are what you see" /><published>2024-04-18T07:34:09+00:00</published><updated>2024-04-18T07:34:09+00:00</updated><id>https://schwad.github.io/2024/04/18/you-are-what-you-see</id><content type="html" xml:base="https://schwad.github.io/2024/04/18/you-are-what-you-see.html"><![CDATA[<p style="text-align:center"><img src="https://i.ytimg.com/vi/uCG6N1w6zp0/hqdefault.jpg" alt="Favorite" /></p>

<p>The 90s and 2000s were high tide for offbeat beer ads. Many did not age well. Some were fairly funny. Some that weren’t particularly funny but were RIFE were Foster’s commercials.</p>

<p>The setup was simple. A weird video clip, <a href="https://www.youtube.com/watch?v=uCG6N1w6zp0">like this one</a>, followed by a word and then the slogan “Fosters: Australian for Beer”.</p>

<p>I have never seen a can of Fosters in the United States. Let alone someone drinking it. (Though weirdly, in the UK, from 2009-2012, I drank plenty). Although the ad campaign was a practical failure, and that I did not drink as a 16 year old, it culturally held a HUGE relative space in the minds of myself and my classmates. The ad was on ALL the time.</p>

<p>Two of those classmates had a secret. They openly broadcasted it. They had an <em>idea</em>. A <em>powerful</em> idea. For a new “Australian for Beer” commercial. But they would never share it. They knew when they had the opportunity to share this hilarious idea with the execs in Hollywood, they would make their millions. No <em>way</em> were they going to share it with others. Too risky.</p>

<p>I never heard what that funny idea was. But there was a kind of like envy. “Man, lucky guys, it’s probably a great idea”</p>

<p>Sounds stupid now, right?</p>

<p>Take this critical view and now point it firmly in your own life. Your own circles. Your own social scenarios. Your own social newsfeeds. What you’re consuming all the time.</p>

<p>What “thing” are you overexposed to that has disproportionate gravity in your life? Something that in the grand scheme of the universe is inconsequential? Something that you measure yourself by, and compare yourself to, and feels so important?</p>

<p>This reminds me tangentially of Paul Graham’s 2009 writings <a href="https://paulgraham.com/identity.html">on identity</a>. Tying your identity to something is limiting. You are precluded to new free thoughts and growth that would violate that identity.</p>

<p>Having narrow exposure to “what you see” is also limiting. In 2005 we thought Fosters was a big deal as a company as we spent a lot of our time consuming those television commercials.</p>

<p>For me in 2024, I see Ruby. Ruby on Rails. The frameworks, the lovely people, the community, the conferences, the companies, the challenges, the banter. I size myself up against people in this community. I challenge my views and cut my teeth in the realm of this community. It’s what I see. The blogs I read, the websites I go to, who I follow on Twitter and other social media.</p>

<p>But I need to accept that that’s a narrowing exposure of “what I see”.</p>

<p>I can still think of this community as “home”. But it does me no harm to start widening my goggles to see what’s happening in the other technical and social communities in the universe.</p>

<p>Or even wider.</p>

<p>I’ve been on paternity leave, and a miraculous thing has happened. You realize how many important people, conversations and interactions are locked “in your laptop” or “in your phone”. If you don’t open the device on your desk or fire up the black square in your pocket, in a way they don’t exist. Especially with remote teams, which is all I’ve ever had.</p>

<p>However, there’s my 95-year-old neighbour who wants to stop and talk about the weather and lend me a book. My newborn son, who often seems happy to just sit there and look me directly in the eyes. There are my in-laws, who are coming around to try my new barbeque experiment in the smoker. It’s nice.</p>

<p>You are what you see.</p>]]></content><author><name></name></author><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">Using Rubyfmt with Atom</title><link href="https://schwad.github.io/ruby/rails/tutorials/2019/12/02/using-rubyfmt-on-atom.html" rel="alternate" type="text/html" title="Using Rubyfmt with Atom" /><published>2019-12-02T07:34:09+00:00</published><updated>2019-12-02T07:34:09+00:00</updated><id>https://schwad.github.io/ruby/rails/tutorials/2019/12/02/using-rubyfmt-on-atom</id><content type="html" xml:base="https://schwad.github.io/ruby/rails/tutorials/2019/12/02/using-rubyfmt-on-atom.html"><![CDATA[<p style="text-align:center"><img src="https://i.imgur.com/cdkKQBu.png" alt="Favorite" /></p>

<p>Rubyfmt, the exciting project from <a href="https://twitter.com/penelope_zone">@penelope_zone</a> continues to grow by the day. After being a fan of this work for quite a while, I set out to hack together a way to get it running slick on Atom. I’m writing today to share those few steps so that you, too, can enjoy the magic of Rubyfmt on Atom!</p>

<h2 id="what-is-rubyfmt">What is Rubyfmt?</h2>

<p>I reckon 90% of people reading this article will already be intimately familiar with this project. If not, here’s the quick hits.</p>

<p><a href="https://github.com/penelopezone/rubyfmt">Rubyfmt</a> is inspired by <a href="https://golang.org/cmd/gofmt/">gofmt</a>. It formats existing Ruby code, and you can set this up as you like (today we will do it after save). It is mature enough to be able to run against all of rspec-core without breaking. You can read more details on the Github README.</p>

<p>I first heard about this when Penelope discussed it with <a href="https://twitter.com/sgrif?lang=en">@sgrif</a> on the <a href="http://yakshave.fm/">Yak Shave</a> podcast. The subject came up in multiple episodes, and if I’m honest the technical details of creating this awesome tool likely went over my head. I still recommend taking a listen!</p>

<p style="text-align:center"><img src="https://i.imgur.com/DdzSG3u.png" alt="Favorite" /></p>

<h2 id="okay-lets-get-this-running-on-atom">Okay, let’s get this running on Atom</h2>

<h3 id="1-follow-initial-readme-instructions">1. <a href="https://github.com/penelopezone/rubyfmt">Follow initial README instructions</a></h3>

<p>At time of writing these are:</p>
<ul>
  <li><code class="language-plaintext highlighter-rouge">git init</code></li>
  <li><code class="language-plaintext highlighter-rouge">git clone https://github.com/penelopezone/rubyfmt.git</code></li>
  <li><code class="language-plaintext highlighter-rouge">make</code></li>
  <li><code class="language-plaintext highlighter-rouge">make install</code></li>
</ul>

<h3 id="2-set-up-atom-after-save-listener">2. Set up Atom ‘after-save’ listener.</h3>
<ul>
  <li><a href="https://atom.io/packages/save-commands">Install Atom package save-commands</a></li>
  <li>add the following to your save-commands.json in your directory:</li>
  <li><code class="language-plaintext highlighter-rouge">"**/*.rb": "ruby --disable=gems path/to/bin/rubyfmt.rb -i {absPath}{filename}"</code></li>
</ul>

<p>Full example:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># save-commands.json
{
	"commands": [
		"**/*.rb : ruby --disable=gems /path/to/bin/rubyfmt.rb -i {absPath}{filename}"
  ]
}
</code></pre></div></div>

<p>And voila! You should be in business. As a test you can add something unRuby-ish to a Ruby file (or just excess whitespace), save, and it should autoformat!</p>

<h3 id="3-gotchas">3. Gotchas:</h3>
<ul>
  <li>Atom didn’t like the recommended command on RubyFmt of <code class="language-plaintext highlighter-rouge">ruby --disable=gems ~/bin/rubyfmt.rb -i ${file}</code></li>
  <li>To get around this I manually passed in the actual path, obtained with <code class="language-plaintext highlighter-rouge">realpath rubyfmt.rb</code></li>
  <li>Happy to improve this if a reader has a more elegant solution</li>
</ul>

<h3 id="4-moving-forward">4. Moving forward:</h3>
<ul>
  <li>I will try to keep this post updated, but following <a href="https://twitter.com/penelope_zone">@penelope_zone</a> on Twitter and checking out the <a href="https://github.com/penelopezone/rubyfmt">README</a> are the current best sources of truth</li>
  <li>It would be nice to wrap this up automatically in an atom package in future, so these steps aren’t necessary. I’ve started looking into this but it may be more straightforward with someone more familiar with writing Atom package plugin code</li>
  <li>If you have any “this doesn’t format correctly” feedback, hold fire for the moment as there’s <a href="https://twitter.com/penelope_zone/status/1199674689578295301?s=20">a lot of work happening on this right now</a></li>
</ul>

<h3 id="thanks-penelope-️">Thanks, Penelope! ❤️</h3>]]></content><author><name></name></author><category term="ruby" /><category term="rails" /><category term="tutorials" /><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">Introducing my Schwad Performance Logger gem</title><link href="https://schwad.github.io/ruby/rails/gem/performance/2019/10/14/introducing-schwad-performance-logger-gem.html" rel="alternate" type="text/html" title="Introducing my Schwad Performance Logger gem" /><published>2019-10-14T07:34:09+00:00</published><updated>2019-10-14T07:34:09+00:00</updated><id>https://schwad.github.io/ruby/rails/gem/performance/2019/10/14/introducing-schwad-performance-logger-gem</id><content type="html" xml:base="https://schwad.github.io/ruby/rails/gem/performance/2019/10/14/introducing-schwad-performance-logger-gem.html"><![CDATA[<p style="text-align:center"><img src="https://i.imgur.com/gdeS97j.jpg" alt="Favorite" /></p>

<p>Do you find yourself writing <code class="language-plaintext highlighter-rouge">puts</code> statements all throughout your code - only to check which chunks are burning the most time (or memory)?</p>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">puts</span> <span class="s1">'*'</span> <span class="o">*</span> <span class="mi">300</span>
<span class="n">start_time</span> <span class="o">=</span> <span class="no">Time</span><span class="p">.</span><span class="nf">now</span>
<span class="c1"># your actual code</span>
<span class="n">time_elapsed</span> <span class="o">=</span> <span class="no">Time</span><span class="p">.</span><span class="nf">now</span> <span class="o">-</span> <span class="n">start_time</span>
<span class="nb">puts</span> <span class="s2">"Time elapsed is: </span><span class="si">#{</span><span class="n">time_elapsed</span><span class="si">}</span><span class="s2">"</span>
<span class="nb">puts</span> <span class="s1">'*'</span> <span class="o">*</span> <span class="mi">300</span>
</code></pre></div></div>

<p>Do you also find yourself manually recording these values from your terminal to later include in a PR explaining how you’ve improved code performance?</p>

<p>Further, how often do you reach for one of half-a-dozen different performance profiling tools to get simple measurements?</p>

<p>If one or more of these is you - then I think you’re going to like my nifty little gem I’ve just open-sourced: <a href="https://github.com/Schwad/schwad_performance_logger">SchwadPerformanceLogger</a> I’ve used it myself for years and reckoned it’s time to share it with my Ruby Friends.</p>

<h2 id="so-what-does-it-do">So what does it do?</h2>

<p>This gem allows you to log memory and time usage throughout your code quickly- and on your terms. It also gives you very quick access to basic features of a handful of other (fantastic) performance tracking tools.</p>

<h2 id="logging-time-and-memory">Logging time and memory</h2>

<p>In your code:</p>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">pl</span> <span class="o">=</span> <span class="no">SPL</span><span class="p">.</span><span class="nf">new</span><span class="p">({</span><span class="ss">full_memo: </span><span class="s1">'Check extract method refactoring'</span><span class="p">})</span>
</code></pre></div></div>

<p>In your terminal:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>**********************************************************************
Starting initialization. Current memory: 12(Mb), difference of 0
(mb) since beginning and difference of 0 since last log. time
passed: 0.004678 seconds, time since last run: 0.004678
**********************************************************************
</code></pre></div></div>

<p>The object is now ‘live’. Anywhere in your file call the object again with a memo of your choice:</p>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">pl</span><span class="p">.</span><span class="nf">log_performance</span><span class="p">(</span><span class="s2">"Test memo"</span><span class="p">)</span>
</code></pre></div></div>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>*********************************************************************
Starting Test memo. Current memory: 12(Mb), difference of 0 (mb)
since beginning and difference of 0 since last log. time passed:
22.493993 seconds, time since last run: 9.616874
*********************************************************************
</code></pre></div></div>

<p>As you can see you can track the time since the object was last called, same with memory. You also get a running track of the total time elapsed and memory grown.</p>

<p><strong>(NOTE: Remember Ruby is garbage collected, so hopefully memory doesn’t go up forever - if it does this gem will help you debug it!)</strong></p>

<p>These logs can be written to the terminal, their own logfile, and even a CSV file in real time so you don’t have to write them down.</p>

<h3 id="options">Options:</h3>

<p><code class="language-plaintext highlighter-rouge">full_memo</code> option adds an extra header in the <code class="language-plaintext highlighter-rouge">log</code> outputs as well as a header to each new set of csv outputs. This is not to be confused with the ‘per-run’ message passed to <code class="language-plaintext highlighter-rouge">#log_performance</code> which is only passed to that check.</p>

<p>To disable any of the outputs:</p>

<p><code class="language-plaintext highlighter-rouge">SPL.new({puts: false, log: false, csv: false})</code></p>

<p>To have the logger ‘pause’ a number of seconds during the <code class="language-plaintext highlighter-rouge">puts</code> logging so that
you can actually see the log as it goes by. This does not affect the ‘time’ measurement:</p>

<p><code class="language-plaintext highlighter-rouge">SPL.new({pause: 8})</code></p>

<h2 id="further-profiling-tools">Further Profiling Tools</h2>

<p>As well as logging memory and time throughout your code, SPL gives you easy access to frequently used popular profiling tools to inspect your code blocks. Note - if you want to a deep dive on a particular area of profiling I recommend visiting the gems listed below and giving them a whirl.</p>

<h3 id="ips">IPS</h3>

<p>Handy access to <a href="https://github.com/evanphx/benchmark-ips">Benchmark-ips</a> measurements, just pass a block to ips:</p>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">SPL</span><span class="p">.</span><span class="nf">ips</span> <span class="k">do</span>
   <span class="n">ary</span> <span class="o">=</span> <span class="p">[]</span>
   <span class="mi">35</span><span class="p">.</span><span class="nf">times</span> <span class="k">do</span>
     <span class="n">ary</span> <span class="o">&lt;&lt;</span> <span class="p">(</span><span class="mi">1</span><span class="o">..</span><span class="mi">99</span><span class="p">).</span><span class="nf">to_a</span><span class="p">.</span><span class="nf">sample</span>
   <span class="k">end</span>
<span class="k">end</span>

<span class="c1">#=&gt; #&lt;Benchmark::IPS::Report:0x00007fbc7f91df50 @entries=[#&lt;Benchmark::IPS::Report::Entry:0x00007fbc7e0c3bd0 @label="PerformanceLogMethod", @microseconds=5002798.0, @iterations=34020, @stats=#&lt;Benchmark::IPS::Stats::SD:0x00007fbc7e0c3c48 @mean=6805.780564500376, @error=195&gt;, @measurement_cycle=630, @show_total_time=true&gt;], @data=nil&gt;</span>
</code></pre></div></div>

<h3 id="time">Time</h3>

<p>Same flow as above. Tired of writing out <code class="language-plaintext highlighter-rouge">start_time</code> and <code class="language-plaintext highlighter-rouge">Time.now - start_time</code> and also needing to ‘puts’ it out? Pass a block to <code class="language-plaintext highlighter-rouge">#time</code>. Runs ten times and spits out an average as well.</p>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">SPL</span><span class="p">.</span><span class="nf">time</span> <span class="k">do</span>
   <span class="n">ary</span> <span class="o">=</span> <span class="p">[]</span>
   <span class="mi">35</span><span class="p">.</span><span class="nf">times</span> <span class="k">do</span>
     <span class="n">ary</span> <span class="o">&lt;&lt;</span> <span class="p">(</span><span class="mi">1</span><span class="o">..</span><span class="mi">99</span><span class="p">).</span><span class="nf">to_a</span><span class="p">.</span><span class="nf">sample</span>
   <span class="k">end</span>
<span class="k">end</span>

<span class="c1">#=&gt; Average runtime 0.0002649 seconds. Max time 0.000508.seconds</span>
</code></pre></div></div>

<h3 id="allocate-count">Allocate Count</h3>

<p>Before, you would have to enable the <code class="language-plaintext highlighter-rouge">GC</code> before your code, use <code class="language-plaintext highlighter-rouge">ObjectSpace</code> to count objects before your code, then use it again after your code to compare allocated objects during your block of code. You’d also have to re-enable the <code class="language-plaintext highlighter-rouge">GC</code>! Gosh, that sure is a lot of work if you want to do this frequently. We make it simple.</p>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">SPL</span><span class="p">.</span><span class="nf">allocate_count</span> <span class="k">do</span>
   <span class="n">ary</span> <span class="o">=</span> <span class="p">[]</span>
   <span class="mi">35</span><span class="p">.</span><span class="nf">times</span> <span class="k">do</span>
     <span class="n">ary</span> <span class="o">&lt;&lt;</span> <span class="p">(</span><span class="mi">1</span><span class="o">..</span><span class="mi">99</span><span class="p">).</span><span class="nf">to_a</span><span class="p">.</span><span class="nf">sample</span>
   <span class="k">end</span>
<span class="k">end</span>

<span class="c1">#=&gt; {:FREE=&gt;-121, :T_STRING=&gt;50, :T_ARRAY=&gt;36, :T_IMEMO=&gt;35}</span>
</code></pre></div></div>

<h3 id="profile-memory">Profile Memory</h3>

<p>Gives you quick access to the amazing <a href="https://github.com/SamSaffron/memory_profiler">memory_profiler</a> gem.</p>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">SPL</span><span class="p">.</span><span class="nf">profile_memory</span> <span class="k">do</span>
   <span class="n">ary</span> <span class="o">=</span> <span class="p">[]</span>
   <span class="mi">35</span><span class="p">.</span><span class="nf">times</span> <span class="k">do</span>
     <span class="n">ary</span> <span class="o">&lt;&lt;</span> <span class="p">(</span><span class="mi">1</span><span class="o">..</span><span class="mi">99</span><span class="p">).</span><span class="nf">to_a</span><span class="p">.</span><span class="nf">sample</span>
   <span class="k">end</span>
<span class="k">end</span>

<span class="c1"># Total allocated: 37576 bytes (36 objects)</span>
<span class="c1"># Total retained:  0 bytes (0 objects)</span>
<span class="c1">#</span>
<span class="c1"># allocated memory by gem</span>
<span class="c1"># -----------------------------------</span>
<span class="c1">#      37576  other</span>
<span class="c1">#</span>
<span class="c1"># allocated memory by file</span>
<span class="c1"># -----------------------------------</span>
<span class="c1">#      37576  (irb)</span>
<span class="c1">#</span>
<span class="c1"># allocated memory by location</span>
<span class="c1"># -----------------------------------</span>
<span class="c1">#      37240  (irb):37</span>
<span class="c1">#        336  (irb):35</span>
<span class="c1">#</span>
<span class="c1"># allocated memory by class</span>
<span class="c1"># -----------------------------------</span>
<span class="c1">#      37576  Array</span>
<span class="c1">#</span>
<span class="c1"># allocated objects by gem</span>
<span class="c1"># -----------------------------------</span>
<span class="c1">#         36  other</span>
<span class="c1">#</span>
<span class="c1"># allocated objects by file</span>
<span class="c1"># -----------------------------------</span>
<span class="c1">#         36  (irb)</span>
<span class="c1">#</span>
<span class="c1"># allocated objects by location</span>
<span class="c1"># -----------------------------------</span>
<span class="c1">#         35  (irb):37</span>
<span class="c1">#          1  (irb):35</span>
<span class="c1">#</span>
<span class="c1"># allocated objects by class</span>
<span class="c1"># -----------------------------------</span>
<span class="c1">#         36  Array</span>
</code></pre></div></div>

<h3 id="all-objects">All Objects</h3>

<p>Similarly, it’s nice to get a rundown of all objects, in hash format, instead of goofing around with <code class="language-plaintext highlighter-rouge">ObjectSpace</code> manually we offer that up for you as well.</p>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">SPL</span><span class="p">.</span><span class="nf">all_objects</span> <span class="k">do</span>
  <span class="n">ary</span> <span class="o">=</span> <span class="p">[]</span>
  <span class="mi">35</span><span class="p">.</span><span class="nf">times</span> <span class="k">do</span>
    <span class="n">ary</span> <span class="o">&lt;&lt;</span> <span class="p">(</span><span class="mi">1</span><span class="o">..</span><span class="mi">99</span><span class="p">).</span><span class="nf">to_a</span><span class="p">.</span><span class="nf">sample</span>
  <span class="k">end</span>
<span class="k">end</span>

<span class="c1">#=&gt; [[Benchmark::IPS::Job, 1], [Rational, 1], [Benchmark::IPS::Report::Entry, 1], [Benchmark::IPS::Stats::SD, 1], [FFI::DynamicLibrary, 1], [DidYouMean::ClassNameChecker, 1], [Thread::Backtrace, 1], [NameError::message, 1], [NameError, 1], [#&lt;Class:0x00007fbc7e816478&gt;, 1], [Gem::Platform, 1], [IRB::Notifier::CompositeNotifier, 1], [IRB::Notifier::NoMsgNotifier, 1], [Enumerator, 1], [RubyToken::TkSPACE, 1], [FFI::Type::Mapped, 1], [IRB::ReadlineInputMethod, 1].... etc</span>
</code></pre></div></div>

<h3 id="objects-by-size">Objects by Size</h3>

<p>You can break down your objects by size as well, useful for debugging.</p>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">SPL</span><span class="p">.</span><span class="nf">objects_by_size</span> <span class="k">do</span>
  <span class="n">ary</span> <span class="o">=</span> <span class="p">[]</span>
  <span class="mi">35</span><span class="p">.</span><span class="nf">times</span> <span class="k">do</span>
    <span class="n">ary</span> <span class="o">&lt;&lt;</span> <span class="p">(</span><span class="mi">1</span><span class="o">..</span><span class="mi">99</span><span class="p">).</span><span class="nf">to_a</span><span class="p">.</span><span class="nf">sample</span>
  <span class="k">end</span>
<span class="k">end</span>

<span class="c1">#=&gt; {:T_OBJECT=&gt;101848, :T_CLASS=&gt;730344, :T_MODULE=&gt;76808, :T_FLOAT=&gt;240, :T_STRING=&gt;882168, :T_REGEXP=&gt;200350, :T_ARRAY=&gt;714384, :T_HASH=&gt;150408, :T_STRUCT=&gt;800, :T_BIGNUM=&gt;80, :T_FILE=&gt;1160, :T_DATA=&gt;1074338, :T_MATCH=&gt;28280, :T_COMPLEX=&gt;40, :T_RATIONAL=&gt;40, :T_SYMBOL=&gt;5080, :T_IMEMO=&gt;325040, :T_ICLASS=&gt;3280, :TOTAL=&gt;4294688}</span>
</code></pre></div></div>

<h2 id="thats-it">That’s it!</h2>

<p>If there’s more tooling you think I should add, or you want to help out and chuck in a PR, you are more than welcome to join the discussion <a href="https://schwad.github.io/ruby/rails/gem/performance/2019/10/14/introducing-schwad-performance-logger-gem.html">on the repo</a> thanks for reading!</p>

<form action="https://www.getdrip.com/forms/275494850/submissions" method="post" data-drip-embedded-form="275494850">
  <h3 data-drip-attribute="headline">Stay in Touch</h3>
  <div data-drip-attribute="description">I like to write about Ruby and building things, typically once every month or so. Get an email when I have written something new.</div>
    <div>
        <label for="drip-email">Email Address</label><br />
        <input type="email" id="drip-email" name="fields[email]" value="" />
    </div>
  <div>
    <input type="submit" value="I Love Ruby too! 💎" data-drip-attribute="sign-up-button" />
  </div>
</form>

<!-- Drip -->
<script type="text/javascript">
  var _dcq = _dcq || [];
  var _dcs = _dcs || {};
  _dcs.account = '2671646';

  (function() {
    var dc = document.createElement('script');
    dc.type = 'text/javascript'; dc.async = true;
    dc.src = '//tag.getdrip.com/2671646.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(dc, s);
  })();
</script>

<!-- end Drip -->]]></content><author><name></name></author><category term="ruby" /><category term="rails" /><category term="gem" /><category term="performance" /><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">Past Rubies #4: Matz Joins Heroku</title><link href="https://schwad.github.io/past_rubies/2019/07/10/past-rubies-4.html" rel="alternate" type="text/html" title="Past Rubies #4: Matz Joins Heroku" /><published>2019-07-10T14:34:09+00:00</published><updated>2019-07-10T14:34:09+00:00</updated><id>https://schwad.github.io/past_rubies/2019/07/10/past-rubies-4</id><content type="html" xml:base="https://schwad.github.io/past_rubies/2019/07/10/past-rubies-4.html"><![CDATA[<p><em>Past Rubies is a tiny weekly newsletter that shares curated historical content from the Ruby community. Consider it Ruby’s version of ‘on this day in history’. New issues every Wednesday. <a href="https://schwad.github.io">See online</a></em></p>

<hr />

<h3 style="text-align:center" id="matz-joins-heroku-2011-07-12"><a href="https://blog.heroku.com/matz_joins_heroku">Matz joins Heroku (2011-07-12)</a></h3>
<p><img src="https://i.imgur.com/J8sGfzB.png" alt="Dundies" /></p>

<p>Yep, eight years ago this week Matz joined Heroku as their Chief Ruby Architect. Thanks for supporting open source, Heroku!</p>
<hr />

<h3 style="text-align:center" id="_why-methods-that-self-destruct-2006-07-11"><a href="https://web.archive.org/web/20090616153605/http://redhanded.hobix.com/inspect/methodsThatSelfDestruct.html">_why: Methods That Self-Destruct (2006-07-11)</a></h3>
<p><img src="https://i.imgur.com/oCVCio6.png" alt="Dundies" /></p>

<p>Ever want to write a ‘singleton method’ that can only ever be called once? Our pal _why has a bit of fun digging into this approach thirteen years ago this week.</p>
<hr />

<h3 style="text-align:center" id="digging-into-loggers-with-ryan-bates-2007-07-11"><a href="http://railscasts.com/episodes/56-the-logger">Digging into Loggers with Ryan Bates (2007-07-11)</a></h3>
<p><img src="https://i.imgur.com/YjQ6rxw.png" alt="Dundies" /></p>

<p>It’s amazing how far you can go in Ruby and Rails without manually playing with the Logger yourself. Take a peek at this classic still-relevant Railscast on the subject!</p>
<hr />

<h3 style="text-align:center" id="euruko-2010-lightning-talks-2010-07-11"><a href="https://vimeo.com/12610211">Euruko 2010 Lightning Talks (2010-07-11)</a></h3>
<p><img src="https://i.imgur.com/rLutowf.png" alt="Dundies" /></p>

<p>Love Ruby? Love Lightning Talks? Love Euruko? This video is definitely for you. Since it’s not tucked away on Youtube, it’s possible you may have missed this gem on your Ruby video deep-dives.</p>
<hr />

<h3 style="text-align:center" id="driftingruby-actioncable-walkthrough-2016-07-10"><a href="https://www.driftingruby.com/episodes/actioncable-part-1-configuration-and-basics?utm_source=rubyweekly&amp;utm_medium=email">DriftingRuby: ActionCable Walkthrough (2016-07-10)</a></h3>
<p><img src="https://i.imgur.com/YMEdjCd.png" alt="Dundies" /></p>

<p>2016 still counts as a blast from the past! Three years ago this week we enjoyed a great ActionCable Screencast from DriftingRuby.</p>

<p>Until next week!</p>
<hr />

<form action="https://www.getdrip.com/forms/275494850/submissions" method="post" data-drip-embedded-form="275494850">
  <h3 data-drip-attribute="headline">Stay in Touch</h3>
  <div data-drip-attribute="description">If you want Past Rubies sent straight to your inbox, or to get notified when I write something new, subscribe below</div>
    <div>
        <label for="drip-email">Email Address</label><br />
        <input type="email" id="drip-email" name="fields[email]" value="" />
    </div>
  <div>
    <input type="submit" value="I Love Past Rubies! 💎" data-drip-attribute="sign-up-button" />
  </div>
</form>

<!-- Drip -->
<script type="text/javascript">
  var _dcq = _dcq || [];
  var _dcs = _dcs || {};
  _dcs.account = '2671646';

  (function() {
    var dc = document.createElement('script');
    dc.type = 'text/javascript'; dc.async = true;
    dc.src = '//tag.getdrip.com/2671646.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(dc, s);
  })();
</script>

<!-- end Drip -->]]></content><author><name></name></author><category term="past_rubies" /><summary type="html"><![CDATA[Past Rubies is a tiny weekly newsletter that shares curated historical content from the Ruby community. Consider it Ruby’s version of ‘on this day in history’. New issues every Wednesday. See online]]></summary></entry><entry><title type="html">Past Rubies #3: Whipping out a Rails Facebook Clone 12 Years Ago</title><link href="https://schwad.github.io/past_rubies/2019/07/03/past-rubies-3.html" rel="alternate" type="text/html" title="Past Rubies #3: Whipping out a Rails Facebook Clone 12 Years Ago" /><published>2019-07-03T14:34:09+00:00</published><updated>2019-07-03T14:34:09+00:00</updated><id>https://schwad.github.io/past_rubies/2019/07/03/past-rubies-3</id><content type="html" xml:base="https://schwad.github.io/past_rubies/2019/07/03/past-rubies-3.html"><![CDATA[<p><em>Past Rubies is a tiny weekly newsletter that shares curated historical content from the Ruby community. Consider it Ruby’s version of ‘on this day in history’. New issues every Wednesday.</em></p>

<hr />

<h3 style="text-align:center" id="writing-a-2007-facebook-clone-in-rails-2007-06-29"><a href="http://web.archive.org/web/20080201173730/http://www.liverail.net/articles/2007/6/29/tutorial-on-developing-a-facebook-platform-application-with-ruby-on-rails">Writing a 2007 Facebook Clone in Rails (2007-06-29)</a></h3>
<p><img src="https://i.imgur.com/3SzVlKD.png" alt="Dundies" /></p>

<p>Wow, I remember knocking my way through my first Rails Clone in 2014. Looks like our author beat us to the trend a whopping seven years earlier! I hope you enjoy this week’s leading post as much as I did!</p>
<hr />

<h3 style="text-align:center" id="_why-digging-into-mixins-2007-07-05"><a href="https://web.archive.org/web/20080524094921/http://redhanded.hobix.com/bits/hyperextended.html">_why digging into Mixins (2007-07-05)</a></h3>
<p><img src="https://i.imgur.com/fBUSrvq.png" alt="Dundies" /></p>

<p>Voilá! Introducing our first (and certainly not last) post from _why the lucky stiff, exploring Ruby mixins, edge cases from extending classes, and possible tooling he may want to build to solve the issue.</p>
<hr />

<h3 style="text-align:center" id="peter-cooper-announces-beginning-ruby-2006-07-01"><a href="http://www.rubyinside.com/im-writing-beginning-ruby-for-apress-119.html">Peter Cooper announces ‘Beginning Ruby’ (2006-07-01)</a></h3>
<p><img src="https://i.imgur.com/2z21nVj.png" alt="Dundies" /></p>

<p>This week thirteen years ago the one-and-only Peter Cooper announced to the world that he started work on his fantastic “Beginning Ruby” book!</p>
<hr />

<h3 style="text-align:center" id="florian-hanke-on-building-a-search-engine-in-ruby-2010-07-01"><a href="http://vimeo.com/12614970">Florian Hanke on Building a Search Engine in Ruby (2010-07-01)</a></h3>
<p><img src="https://i.imgur.com/s6rbDZH.png" alt="Dundies" /></p>

<p>This is a real treat. Have a look into a conference talk on building a search engine in Ruby in 2010.</p>
<hr />

<h3 style="text-align:center" id="contributing-to-rails-back-in-the-day-2007-06-27"><a href="http://railscasts.com/episodes/50-contributing-to-rails">Contributing to Rails Back in the Day (2007-06-27)</a></h3>
<p><img src="https://i.imgur.com/F0Rak4x.png" alt="Dundies" /></p>

<p>Check out this nifty video by Ryan Bates, explaining how you would contribute to Rails back in the early days.</p>
<hr />

<form action="https://www.getdrip.com/forms/275494850/submissions" method="post" data-drip-embedded-form="275494850">
  <h3 data-drip-attribute="headline">Stay in Touch</h3>
  <div data-drip-attribute="description">If you want Past Rubies sent straight to your inbox, or to get notified when I write something new, subscribe below</div>
    <div>
        <label for="drip-email">Email Address</label><br />
        <input type="email" id="drip-email" name="fields[email]" value="" />
    </div>
  <div>
    <input type="submit" value="I Love Past Rubies! 💎" data-drip-attribute="sign-up-button" />
  </div>
</form>

<!-- Drip -->
<script type="text/javascript">
  var _dcq = _dcq || [];
  var _dcs = _dcs || {};
  _dcs.account = '2671646';

  (function() {
    var dc = document.createElement('script');
    dc.type = 'text/javascript'; dc.async = true;
    dc.src = '//tag.getdrip.com/2671646.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(dc, s);
  })();
</script>

<!-- end Drip -->]]></content><author><name></name></author><category term="past_rubies" /><summary type="html"><![CDATA[Past Rubies is a tiny weekly newsletter that shares curated historical content from the Ruby community. Consider it Ruby’s version of ‘on this day in history’. New issues every Wednesday.]]></summary></entry><entry><title type="html">Past Rubies #2: Rewriting Rails as a Javascript Framework - in 2007</title><link href="https://schwad.github.io/past_rubies/2019/06/26/past-rubies-2.html" rel="alternate" type="text/html" title="Past Rubies #2: Rewriting Rails as a Javascript Framework - in 2007" /><published>2019-06-26T14:34:09+00:00</published><updated>2019-06-26T14:34:09+00:00</updated><id>https://schwad.github.io/past_rubies/2019/06/26/past-rubies-2</id><content type="html" xml:base="https://schwad.github.io/past_rubies/2019/06/26/past-rubies-2.html"><![CDATA[<p><em>Past Rubies is a tiny weekly newsletter that shares curated historical content from the Ruby community. Consider it Ruby’s version of ‘on this day in history’. New issues every Wednesday.</em></p>

<hr />

<h3 style="text-align:left" id="googler-steve-yegge-fully-ports-rails-to-a-javascript-framework---in-2007-2007-06-24"><a href="https://web.archive.org/web/20071009012555/http://www.iunknown.com/2007/06/steve-yegge-por.html">Googler Steve Yegge fully ports Rails to a Javascript framework - in 2007 (2007-06-24)</a></h3>

<p style="text-align:center"><img src="https://i.imgur.com/mntyagZ.png" alt="Dundies" />
In 2007, then-Googler <a href="https://medium.com/@steve.yegge">Steve Yegge</a> was advocating that Google start using Ruby. Google, of course, said no. So Steve did what any frustrated programmer in 2007 would do. He built an entire serverside Javascript framework as a line-by-line rewrite of Ruby on Rails. Nice.</p>

<hr />

<h3 style="text-align:center" id="rails-50-released-2016-06-27"><a href="https://weblog.rubyonrails.org/2016/6/30/Rails-5-0-final/">Rails 5.0 Released (2016-06-27)</a></h3>
<p><img src="https://i.imgur.com/3vcV6Be.png" alt="Dundies" /></p>

<p>Holy moly. How is Rails 5.0 three years old this week? It only seems like yesterday we were all doing our major upgrades from 4.2. Take a trip down memory lane on this anniversary with a read through the launch post.</p>
<hr />

<h3 style="text-align:center" id="getting-answers-to-your-burning-rails-questions-in-2006"><a href="http://web.archive.org/web/20070701205913/http://guruza.com/question/528/reward-5.00">Getting answers to your burning Rails questions in 2006</a></h3>
<p><img src="https://i.imgur.com/fcc2jL1.png" alt="Dundies" /></p>

<p>In 2006, the programming world didn’t have the sort of resources for answering Rails questions that we enjoy today. Nine times out of ten it seems we can just copy paste a mystery error and find our problem in seconds. Not so in 2006.</p>

<p>As seen above, one option was <a href="http://web.archive.org/web/20070701205913/http://guruza.com/question/528/reward-5.00">Guruza</a>, which allowed you to actually put a dollar-figure on your Rails questions on the honor system and award the bounty to the correct answer.</p>

<p>If money wasn’t your thing but you were into gamification, <a href="http://web.archive.org/web/20060407002746/http://rails.techno-weenie.net/question/2006/4/5/content_management_for_rails">Rails-weenie</a> let you earn and give away “points” for answering Rails questions.</p>

<p style="text-align:center"><img src="https://i.imgur.com/S5G7rAZ.png" alt="Dundies" /></p>
<hr />

<h3 style="text-align:center" id="using-gmail-with-activemailer-2006-06-27"><a href="http://web.archive.org/web/20070109014309/http://typo.onxen.info/articles/2006/06/27/activemailer-sending-via-gmail">Using GMail with ActiveMailer (2006-06-27)</a></h3>
<p><img src="https://i.imgur.com/5GHkIFd.png" alt="Dundies" /></p>

<p>Check out this article which gives us a walkthrough of working with GMail in Rails 13 years ago. (Bonus: There’s a Rails-Weenie link in there!)</p>
<hr />

<h3 style="text-align:center" id="ryan-bates-returns-2017-06-27"><a href="http://railscasts.com/announcements/13">Ryan Bates Returns! (2017-06-27)</a></h3>
<p><img src="https://i.imgur.com/pTaK32G.png" alt="Dundies" /></p>
<p>
After a four-year hiatus, this week two years ago Ryan Bates made his glorious return; and announced free Railscast episodes! Thanks for all you've done for the community, Ryan!
<hr />


<form action="https://www.getdrip.com/forms/275494850/submissions" method="post" data-drip-embedded-form="275494850">
  <h3 data-drip-attribute="headline">Stay in Touch</h3>
  <div data-drip-attribute="description">If you want Past Rubies sent straight to your inbox, or to get notified when I write something new, subscribe below</div>
    <div>
        <label for="drip-email">Email Address</label><br />
        <input type="email" id="drip-email" name="fields[email]" value="" />
    </div>
  <div>
    <input type="submit" value="I Love Past Rubies! 💎" data-drip-attribute="sign-up-button" />
  </div>
</form>

<!-- Drip -->
<script type="text/javascript">
  var _dcq = _dcq || [];
  var _dcs = _dcs || {};
  _dcs.account = '2671646';

  (function() {
    var dc = document.createElement('script');
    dc.type = 'text/javascript'; dc.async = true;
    dc.src = '//tag.getdrip.com/2671646.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(dc, s);
  })();
</script>
<!-- end Drip -->
</p>]]></content><author><name></name></author><category term="past_rubies" /><summary type="html"><![CDATA[Past Rubies is a tiny weekly newsletter that shares curated historical content from the Ruby community. Consider it Ruby’s version of ‘on this day in history’. New issues every Wednesday.]]></summary></entry><entry><title type="html">Past Rubies #1: Ruby Celebrity Free-For-All</title><link href="https://schwad.github.io/past_rubies/2019/06/19/past-rubies-1.html" rel="alternate" type="text/html" title="Past Rubies #1: Ruby Celebrity Free-For-All" /><published>2019-06-19T14:34:09+00:00</published><updated>2019-06-19T14:34:09+00:00</updated><id>https://schwad.github.io/past_rubies/2019/06/19/past-rubies-1</id><content type="html" xml:base="https://schwad.github.io/past_rubies/2019/06/19/past-rubies-1.html"><![CDATA[<p><em>Past Rubies is a tiny weekly newsletter that shares curated historical content from the Ruby community. Consider it Ruby’s version of ‘on this day in history’. New issues every Wednesday.</em></p>

<hr />

<h3 style="text-align:center" id="a-rubyists-whos-who-in-a-gist-debate-2012-06-22"><a href="https://gist.github.com/justinko/2838490">A Rubyist’s “Who’s Who” in a gist debate (2012-06-22)</a></h3>
<p><img src="https://i.imgur.com/4sXzUMn.png" alt="Dundies" />
This actually started in May and raged for weeks, but DHH joined into the discussion seven years ago this week. Have a look at a very interesting Gist discussion on Rails’ best practices featuring Ruby celebrities Michael Perham, Avdi Grimm, Nick Sutterer, Gary Bernhardt, Piotr Solnica, Uncle Bob, DHH and many others.</p>

<hr />

<h3 style="text-align:center" id="rails-12-whats-next-2006-06-26"><a href="http://web.archive.org/web/20060711170219/http://cwilliams.textdriven.com/articles/2006/06/26/railsconf-and-rails-1-2">Rails 1.2: what’s next? (2006-06-26)</a></h3>
<p><img src="https://i.imgur.com/Gkk4IVR.png" alt="Dundies" /></p>

<p>Chris Williams breaks down the talks from a bunch of speakers at 2006’s Railsconf and looks towards the future.</p>

<hr />

<h3 style="text-align:center" id="ruby-benchmarking-showdown-2010-06-28"><a href="https://programmingzen.com/the-great-ruby-shootout-windows-edition/">Ruby Benchmarking Showdown (2010-06-28)</a></h3>
<p><img src="https://i.imgur.com/tmUQOV0.png" alt="Dundies" /></p>

<p>Nine years ago Antonio Cangiano put together a massive amount of benchmarking goodness comparing Ruby 1.8, 1.9, JRuby and, yes, IronRuby. Notable all on a Windows machine!</p>

<hr />

<h3 style="text-align:center" id="code-golf---reddit-in-10-lines-of-code-2012-06-26"><a href="http://www.drurly.com/blog/2012/06/26/reddit-in-10-lines-of-code/">Code Golf - Reddit in 10 Lines of Code (2012-06-26)</a></h3>
<p><img src="https://i.imgur.com/Vi40prK.png" alt="Dundies" /></p>

<p>This post starts out showcasing a reddit build in Sinatra which is cool enough in 2012. It then takes things into hyperactive hyperdrive by walking through a codegolf breakdown into 10 lines of code. Nifty!</p>

<hr />

<h3 style="text-align:center" id="rails-hosting-cant-make-up-my-mind-2009-06-23"><a href="https://groups.google.com/forum/#!topic/rubyonrails-talk/s5u-60VgezY">Rails Hosting: Can’t make up my mind (2009-06-23)</a></h3>
<p><img src="https://i.imgur.com/c5JEzKY.png" alt="Dundies" /></p>

<p>Who could we rely on Rails hosting a decade ago? Have a peek into this google talk forum to see who the players were back when.</p>]]></content><author><name></name></author><category term="past_rubies" /><summary type="html"><![CDATA[Past Rubies is a tiny weekly newsletter that shares curated historical content from the Ruby community. Consider it Ruby’s version of ‘on this day in history’. New issues every Wednesday.]]></summary></entry><entry><title type="html">How Rails and Heroku Saved My Bacon</title><link href="https://schwad.github.io/ruby/rails/heroku/2019/01/11/how-rails-and-heroku-saved-my-bacon.html" rel="alternate" type="text/html" title="How Rails and Heroku Saved My Bacon" /><published>2019-01-11T14:34:09+00:00</published><updated>2019-01-11T14:34:09+00:00</updated><id>https://schwad.github.io/ruby/rails/heroku/2019/01/11/how-rails-and-heroku-saved-my-bacon</id><content type="html" xml:base="https://schwad.github.io/ruby/rails/heroku/2019/01/11/how-rails-and-heroku-saved-my-bacon.html"><![CDATA[<p style="text-align:center"><img src="https://i.imgur.com/I8as7eZ.png" alt="Favorite" /></p>

<p>I love Rails, Ruby and Heroku. If I need to get something that <strong>works</strong> live and on the web <strong>right now</strong>, I know I can trust these tools to the ends of the earth.</p>

<p>The other day I had 30 minutes to do just that.</p>

<h2 style="text-align:center" id="the-schwad-awards">The Schwad Awards</h2>

<p style="text-align:center"><img src="https://i.giphy.com/media/kq42EnMcsHuBG/giphy.webp" alt="Dundies" /></p>

<p>For either 9 or 10 years now (no one is quite sure), every holiday season I have been doing the Schwad Awards. For the first few years they were public on twitter, then I moved them to the more private-and-taggable world of Facebook.</p>

<p>What are the Schwad Awards? They started off as an opportunity to make up jokes and have ended up being a ‘sort-of-dundies’ where a great deal of my friends get nods of affection via an award. Could be an inside joke, a general compliment. (i.e. “The Award for Person Most Likely To Aspirate a Jalapeño goes to Bob Smith! 🙊”)</p>

<p>Funnily enough, I’ve started doing so many of them that they take up a good chunk of time. Once someone has gotten a ‘Schwad Award’ three years in a row, it’s quite a slight to leave them out. It always grows, never shrinks.</p>

<p>This year was particularly interesting for the awards.</p>

<h2 id="schwad-gets-married">Schwad gets married</h2>

<p>Let me back up. <strong>WAY</strong> up. Over four years after our first date, I got to be the luckiest man on the planet and marry my sweetheart last December. Biggest day of our lives by a mile. We spent nearly two years saving and the amount of planning was off the charts.</p>

<p>I promised that on New Years Eve this year, as I’ll have just been married, I would not be spending half the night slowly writing out Facebook schwad award posts.</p>

<p>Around that time I made a post (jokingly) saying that the Schwad Awards would happen ‘during’ the wedding day and only be awarded to those in attendance.</p>

<p>I forgot about this until the week before the wedding, when I found out a fair few guests actually <strong>were</strong> expecting this to happen! I didn’t worry - Facebook has the tooling to allow me to write these out in advance, my plan was to have them drip out on social networking at a steady pace during the time between the ceremony and the dinner. I figured it would be a nice treat while my wife and I were away taking all of our photos.</p>

<h2 id="wrong">WRONG</h2>

<p>As I discovered during the <strong>30 minutes I had allocated myself to write the awards before leaving for the venue</strong> Facebook does NOT allow post scheduling. This was only a feature I had gotten used to on my official facebook pages. Yep. We had a problem.</p>

<h2 style="text-align:center" id="what-do-i-do-now--">WHAT DO I DO NOW 🚨 😵</h2>

<p style="text-align:center"><img src="https://i.giphy.com/media/umMYB9u0rpJyE/giphy.webp" alt="Shock" /></p>

<p>Don’t panic, I told myself. In the scheme of things the Schwad Awards <strong>really do not matter at all</strong>, they can be left behind. But I still had 29.5 minutes. With the pressure off, I thought simply: <strong>‘what do I <em>need</em>‘</strong> to make this work?</p>

<p>I needed text online.</p>

<p>I needed it to become available at only a prespecified time.</p>

<p>I needed only my facebook friends to be able to read it.</p>

<h2 id="rails-and-heroku-to-the-rescue">Rails and Heroku to the Rescue</h2>

<p>Instead of using the limited social networking tooling I whipped out the sharp sword of Ruby on Rails to solve my problem, and fast. I had my app to work with in seconds.</p>

<p><code class="language-plaintext highlighter-rouge">rails new save_my_bacon --database=postgresql</code></p>

<p>Under a minute later I had my routes, controller and linked view created. To test timing in development I checked:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  - if Time.now &lt; end_of_wedding_ceremony
    %h2= "The Schwad Awards will be released at #{end_of_wedding_ceremony}"
  - else
    ....
</code></pre></div></div>

<p>Perfect. All I needed was:</p>

<p><code class="language-plaintext highlighter-rouge">git init</code></p>

<p>And then:</p>

<p><code class="language-plaintext highlighter-rouge">heroku create please-save-my-bacon</code></p>

<p>And finally:</p>

<p><code class="language-plaintext highlighter-rouge">git push heroku master</code></p>

<p>And boom! I was live in under five minutes! I had the rest of the 25 minutes to build out a very rudimentary HTML based table with the data I wanted. Thanks <a href="https://heroku.com">Heroku</a>! ❤️</p>

<h2 id="lets-make-sure-only-my-friends-see-this">Let’s make sure only my friends see this</h2>

<p>One more important thing was to protect these awards from the ‘wide open world’ of the web.</p>

<p>Normally my authentication is done with <a href="https://github.com/plataformatec/devise">Devise</a>, but for a time like this I just needed a simple username and password blocker that I would share on my facebook page. Luckily Rails has slick support for this with <a href="https://guides.rubyonrails.org/action_controller_overview.html#http-basic-authentication">HTTP Basic authentication</a>.</p>

<p>Taken straight from the guides here, you can implement this in any Rails controller in seconds like so:</p>

<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby">  <span class="k">class</span> <span class="nc">AdminsController</span> <span class="o">&lt;</span> <span class="no">ApplicationController</span>
    <span class="n">http_basic_authenticate_with</span> <span class="ss">name: </span><span class="s2">"humbaba"</span><span class="p">,</span> <span class="ss">password: </span><span class="s2">"5baa61e4"</span>
  <span class="k">end</span></code></pre></figure>

<p>Sweet! And I was off to the races!</p>

<p style="text-align:center"><img src="https://i.imgur.com/oBsZpMQ.png" alt="Dundies" /></p>

<h2 id="alls-well">All’s well….</h2>

<p>Thanks to these wonderful tools we have at our disposal, I was able to solve a surprise problem in a fraction of an hour and move on with my life (and my wedding!). I completely forgot about it until some attendees were commenting on their awards over drinks during the reception.</p>

<p>❤️ Rails + Heroku ❤️</p>]]></content><author><name></name></author><category term="ruby" /><category term="rails" /><category term="heroku" /><summary type="html"><![CDATA[]]></summary></entry></feed>