<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jon Schulman on Medium]]></title>
        <description><![CDATA[Stories by Jon Schulman on Medium]]></description>
        <link>https://medium.com/@schulman99?source=rss-c6ead126e47a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kTe3X1oujLAZYLVCEMVAyg.jpeg</url>
            <title>Stories by Jon Schulman on Medium</title>
            <link>https://medium.com/@schulman99?source=rss-c6ead126e47a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 01:11:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@schulman99/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[One More Hidden Cost of Washington’s Shutdown]]></title>
            <link>https://medium.com/@schulman99/one-more-hidden-cost-of-washingtons-shutdown-aad4e871f212?source=rss-c6ead126e47a------2</link>
            <guid isPermaLink="false">https://medium.com/p/aad4e871f212</guid>
            <category><![CDATA[regulation]]></category>
            <category><![CDATA[legal]]></category>
            <category><![CDATA[government]]></category>
            <category><![CDATA[regulatory-affairs]]></category>
            <category><![CDATA[law]]></category>
            <dc:creator><![CDATA[Jon Schulman]]></dc:creator>
            <pubDate>Mon, 07 Jan 2019 15:01:20 GMT</pubDate>
            <atom:updated>2019-01-11T15:21:23.008Z</atom:updated>
            <content:encoded><![CDATA[<h3>Yet Another Hidden Cost of Washington’s Shutdown</h3><h4>Why fully Funded Agencies are Grinding to a Halt</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*efY8OiVvlTDiBGmfxCA7AQ.jpeg" /></figure><p><strong>On Friday, January 4, 2019, the Federal Register contained 1 document from 1 agency for a grand total of less than 2 printed pages worth of material.</strong></p><p>If you’re curious about the health of the America’s federal administrative state, look no further than the <a href="https://www.federalregister.gov/">Federal Register</a>. On nearly every non-holiday weekday since the <a href="https://www.loc.gov/item/fr001001/">middle of 1936</a>, a publication called the Federal Register has served as a physical record of government announcements for the United States of America. From <a href="https://www.federalregister.gov/documents/2002/05/17/02-11707/compendium-of-flood-map-changes">changes to flood maps</a>, to <a href="https://www.federalregister.gov/documents/2018/11/28/2018-25631/draft-list-of-bird-species-to-which-the-migratory-bird-treaty-act-does-not-apply">requests for public input on migratory bird status</a>, to <a href="http://cdn.loc.gov/service/ll/fedreg/fr001/fr001001/fr001001.pdf">Presidential executive orders</a>, the Federal Register is the government’s bulletin board for happenings and goings-on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*hZAtzMB2hWRitJhoL_fxAQ.png" /></figure><p>But more than that, laws like the Administrative Procedure Act (APA) require federal agencies to use the Federal Register. Which is to say, without formal publication of certain notices and intentions to act in the Federal Register, agencies are precluded from doing much of the work of government.</p><p>Consider that on a typical day the Federal Register might include notices, rules, and other documents from 40 to 60 separate federal agencies consuming over 300 pages of print (for whoever it is that’s still reading the print edition). Some might suggest this is evidence of a bloated and sluggish administrative machine. But, in reality, it is evidence of the powerfully democratic ideal that a government of the people and for the people must communicate <em>with</em> the people.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*lgMQUjGWgAzimPV-Z9JPMw.png" /></figure><p>During the current shutdown, however, that communication has come to an end. Let us revisit that on <a href="https://www.federalregister.gov/d/2018-28464"><strong>Friday, January 4, 2019, the Federal Register </strong></a><strong>contained 1 document from 1 agency for a grand total of less than 2 printed pages worth of material. </strong>For what it is worth, the document is a request by the National Oceanic and Atmospheric Administration for public comment on a change in the allowable catch of pollock in the Gulf of Alaska —it’s not nothing, but also it’s not exactly earth-shattering stuff.</p><p>It has been noted repeatedly that only <a href="https://www.foxnews.com/politics/government-shutdown-2018-what-closes-and-who-will-still-need-to-work">about a quarter of the government is actually ‘closed’</a>, while the vast majority of departments and agencies have appropriated funds to continue to operate. So if only nine departments and a few dozen smaller agencies (e.g., the Smithsonian Institutions, Federal Housing Administration, etc.) are not operating, why did only a single agency report out a single action in the January 4th Federal Register?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*nHShSI_b8EPPe7dFbZtWNw.gif" /></figure><p>The review and publication of regulations and regulatory actions involves a complex network of offices, including the principle gatekeepers at the Office of Information and Regulatory Affairs (OIRA), within of Office of Management and Budget (OMB), which is itself an organ of the White House executive offices. Out of OMB’s total full-time staff of 488, a <a href="https://www.whitehouse.gov/wp-content/uploads/2018/12/Memo-to-OMB-EOP-Shutdown-Plan-Lapse-of-Appropriations.pdf">December 21 memorandum from OMB’s director</a> indicated that 156 are expected to continue working. OMB does a lot more than just reviewing agency regulatory actions, but OIRA is nonetheless responsible for reviewing all <a href="https://www.reginfo.gov/public/jsp/Utilities/EO_12866.pdf">“significant regulatory actions”</a> before they can move forward.</p><p>It is understandable that a president, and by extension their administration, should want to review significant rulemakings before they are published. However, even on good days OMB and OIRA are notorious with agency regulatory staff for being slow to provide approval or feedback on proposed actions; including in the face of Congressionally-imposed deadlines. But with OMB operating at 1/3 staff and an untold reduction in OIRA staffing, the harm is as apparent as it is unnerving.</p><p>Even where OIRA has approved publication, there is yet a further wrench in the works. Namely, during a lapse of its own funding, the <a href="https://www.federalregister.gov/reader-aids/office-of-the-federal-register-blog/2018/01/what-happens-if-the-government-shuts-down-2">Office of the Federal Register</a> will not publish documents that are not “<a href="https://www.govinfo.gov/content/pkg/FR-2013-09-30/pdf/2013-23713.pdf">necessary to safeguard human life, protect property, or provide other emergency services consistent with the performance of functions and services exempted under the Antideficiency Act.</a>”Setting aside the question of exactly how NOAA convinced OFR that pollock fishing quotas fit within this exception, it is apparent that almost nothing is currently being published.</p><p>The situation has restricted fully funded agencies, such as the Department of Veterans Affairs (VA) and the Department of Defense, from moving forward on the kinds of important initiatives that are crucial to good governance. For example, the <a href="https://en.wikipedia.org/w/index.php?title=Veterans_Appeals_Improvement_and_Modernization_Act_of_2017&amp;action=edit&amp;redlink=1">Veterans Appeals Improvement and Modernization Act of 2017</a> constitutes the first overhaul of VA’s benefits appeals adjudication process since its inception more than 8 decades ago. But like most legislation, the Act requires VA to promulgate and publication of implementing regulations describing the nuts and bolts of the new process before it goes into effect. This democratizing communications pattern that the APA forces on agencies essentially means that the government fully describes what it will do <em>before </em>it will do it. It’s not just a good idea, it is a fundamental pattern underlying the western idea of rule of law.</p><p>In VA’s case, the target for turning on the new system had been mid-February 2019, but without approval from OIRA/OMB and publication of the final rule in the Federal Register, the delay is functionally indefinite; leaving Veterans and taxpayers to continue to suffer through a system <a href="https://www.govtrack.us/congress/votes/115-2017/h273">everyone</a> <a href="https://www.govtrack.us/congress/votes/115-2017/h273">agrees is broken</a>.</p><p>Because this sort of delay occurs deep within the bowels of the machinery of government, it is all but invisible to the public. But for all its obscurity, the injury is no less real. Every day that VA’s new appeals system is not in place, millions of American Veterans continue to be subjected to a broken system, wasting taxpayer money in the process. Meanwhile the agency and veterans service organizations are left in a maddening state of limbo, unable to effectively advise Veterans and their families.</p><p>VA’s experience is not an isolated one. Because OMB review affects nearly every federal agency, the shutdown affects every company, person, and entity those agencies regulate across the country. If there’s a government agency that touches it, there is a serious risk of ongoing uncertainty until the shutdown ends, OMB returns to its full staffing, and the Federal Register can swell back to its typical size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U-e5mjZ83-Vx-wmRCpz3_A.png" /><figcaption>Screen capture from Federalregister.gov on January 5, 2019</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aad4e871f212" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Software Licensing and You]]></title>
            <link>https://medium.com/@schulman99/software-licensing-and-you-b204471aa94e?source=rss-c6ead126e47a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b204471aa94e</guid>
            <category><![CDATA[licensing]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[copyright]]></category>
            <dc:creator><![CDATA[Jon Schulman]]></dc:creator>
            <pubDate>Thu, 11 Oct 2018 12:31:03 GMT</pubDate>
            <atom:updated>2018-10-11T12:31:03.917Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*gB4kdqNk2aPx6pPAgXCAbA.jpeg" /></figure><p>America’s history of protecting intellectual property is older than America itself, beginning with Parliament’s passage of the <strong>Licensing of the Press Act 1662</strong>. By the late 18th century, issues around intellectual property were seen as so crucial to the underlying principles on-which America was being founded, that the protection of intellectual property was baked right into <strong>Article I of United States Constitution</strong> which gives Congress the power:</p><blockquote>“[t]o promote the progress of science and useful arts, by securing for limited times to authors and inventors the exclusive right to their respective writings and discoveries.”</blockquote><p>More than two and a quarter centuries later, while the world may be a very different place than it was in 1789, the core foundation of how we protect “written” work remains the same.</p><p>There are two distinct worlds of intellectual property that most developers will encounter: <strong>Copyright</strong> and <strong>Licensing</strong>. Though related, they are not synonymous. A copyright comes with a set of ownerships rights the creator of a work, sometimes referred to a a bundle of rights. Included in this bundle, is the right to control the use of a work and to permit use by others. This latter-most right is the right of the creator to license others to have some sort of access or use to a work. To think of it another way, if a <strong>copyright</strong> is the deed to a house, a <strong>license</strong> is the lease allowing someone else to live there. The landlord still owns the home, but the tenant has the right to use it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*nBwxErTTHZuXXnUVtYCwOA.png" /></figure><p>When creating a new repository in GitHub, for example, you are presented with a dozen different choices for adding a public license to your code, and one choice to forgo a license all together. These do not represent <em>all </em>licensing options, but using GitHub’s built-in tools to automatically generate licensing documentation within your new repository is hassle-free and easy to do. So let’s take a look at some of your options; including those incorporated directly into GitHub.</p><h3>No License</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*0301R-uqKWhTkTqUMvo8jQ.png" /></figure><p>While it may be tempting to forgo a license altogether, one should be aware of the full implications. Without any license, your code cannot be used, copied, changed, or distributed by anyone other than its creator. So long as that creator is you, you’re in good shape. But as soon as you involve other contributors, you are no long <em>the</em> creator, and access to your own work begins to become restricted. If your intention is a completely closed-off piece of software, this may be the way to go. However, I suggest that when going this route one should include an express restriction indicating as much.</p><p>Also, if posting your code to GitHub, be aware that you are already agreeing to give GitHub a license “to do things like host Your Content, publish it, and share it.” (<em>see GitHub TOS, sections D4 through D7 </em><a href="https://help.github.com/articles/github-terms-of-service/#d-user-generated-content"><em>https://help.github.com/articles/github-terms-of-service/#d-user-generated-content</em></a><em> </em>)</p><p><strong>tl;dr: Do nothing at all.</strong></p><h3>GNU General Public License v3.0</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*FxBae9sVQlSMLr6FT9LGDw.png" /></figure><p>GNU General Public License (GPL), was the first widely used copyleft license. Copyleft is term used to describe the inverse of copyright. Where a copyright creates a set restrictive limitations for end-users, a copyleft proscribes affirmative permissions to an end user to modify and distribute a work. In other words, a copyleft is a kind of license.</p><p>The GPL affords that a user may modify, copy, and redistribute a work, <em>including commercial redistribution. </em>This is a key difference between GPL and other public licensing schemes, and it is born from the notion that freely distributed software should place few restrictions on the end user, even the restriction against making money off of it. However, GPL requires that a subsequent distributor may not place “further restrictions on the rights granted by the GPL”, such as non-disclosure agreements.</p><p>In order to take advantage of the above, an end-user must make the source code of the original work freely available, with a record of any changes made to the original work. This include providing adequate attribution to the original author.</p><p><strong>tl;dr: Do whatever you want, as long as you provide the original, document changes to the original, and provide attribution.</strong></p><h3>MIT License</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*SPaCuKeXBHLTg--gSFxTww.png" /></figure><p>The MIT License is short, to the point, and highly permissive. This license provides that an end user may do almost anything they wish, as long as the original “<em>copyright notice and this permission notice [are] included in all copies or substantial portions of the Software,</em>” and like the GPL, the MIT license permits commercial-use/sale. Unlike GPL, it even allows the creation and distribution of completely closed-source modifications</p><p>Notably, <strong>Ruby on Rails</strong>, <strong>Node.js</strong>, <strong>Babel</strong>, and <strong>jQuery</strong> are all distributed with the MIT License.</p><p><strong>tl;dr: Do whatever you want, as long as you provide the original copyright notice.</strong></p><h3>Do What The F*ck You Want To Public License</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*leNoacB-3B5obUtJATr8rg.png" /></figure><p>All the way on the other end of the spectrum from issuing no license at all, is the use of WTFPL.</p><p>This license — which is itself copyright protected — states in no uncertain terms that “you” (i.e., the end user) can “just DO WHAT THE [heck] YOU WANT TO.” Ironically the text of WTFPL’s own licensing is longer than the WTFPL itself, though it too is permissive in allowing “[e]veryone . . . to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.”</p><p>In essence, using WTFPL is the same as placing a work directly into the public domain. It is important to recognize that when putting something into the public domain requires an affirmative action on the part of the original creator, and this is one way of accomplishing that.</p><p><strong>tl;dr: Do whatever you want.</strong></p><h3>Using an Open Source License in GitHub</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*8GvTGD34-xdhM35La4h6zg.jpeg" /></figure><p>So you have decided that you want to include a license with your software <em>and</em> you are keeping it in a GitHub repository. No what?</p><p>If you have already created a repository and now you want to add a license to your existing code, it is a good idea to put that license in a spot others will know to look for it. Typically that means placing it intoLICENSE.txt or LICENSE.md right in the root directory of your project, though putting your license in your README.md is also a good option. All you need to do is dig up the licensing language (<a href="https://choosealicense.com/">Choose A License</a> is a great place to start your hunt), and drop it in LICENSE.txt , LICENSE.md or README.md .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/0*KtPuMSj3F8qZmwMj.png" /></figure><p>You can also use GitHub’s built-in tool, by creating a newLICENSE.md file directly in your repository, and clicking on the “Choose a license template” on the left hand side.</p><p>And now you know how to make your own license.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FwK5MqkEPMr4Sk%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FwK5MqkEPMr4Sk%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FwK5MqkEPMr4Sk%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="249" frameborder="0" scrolling="no"><a href="https://medium.com/media/73d00370d1c79b9c61d01d9b5afd8b92/href">https://medium.com/media/73d00370d1c79b9c61d01d9b5afd8b92/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b204471aa94e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GDRP — A Developer’s (very) Quick Guide]]></title>
            <link>https://medium.com/@schulman99/gdrp-a-developers-very-quick-guide-3f1c982d1154?source=rss-c6ead126e47a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f1c982d1154</guid>
            <category><![CDATA[regulatory-compliance]]></category>
            <category><![CDATA[compliance]]></category>
            <category><![CDATA[cookies]]></category>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[gdpr]]></category>
            <dc:creator><![CDATA[Jon Schulman]]></dc:creator>
            <pubDate>Thu, 27 Sep 2018 12:49:34 GMT</pubDate>
            <atom:updated>2018-09-27T12:50:46.733Z</atom:updated>
            <content:encoded><![CDATA[<p><em>*I am a lawyer, but the following are only my opinions and </em><strong><em>not</em></strong><em> legal advice.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*-hw1N_SMDsAPPKsGo1k9vQ.jpeg" /></figure><p>If you use this internet, you may have seen something like this recently when visiting one of your favorite websites:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*tw5h_TeJu-X0uIxCI0WXbw.jpeg" /></figure><p>These notices started popping up in May 2018, and while many users have blithely ignored the warning, others have asked “what is this?” If you’re in the ladder group, continue reading.</p><p>The above is a notice compliant with <strong>Regulation (EU) 2016/679 of the European Parliament and of the Council of 27 April 2016 on the protection of natural persons with regard to the processing of personal data and on the free movement of such data, and repealing Directive 95/46/EC</strong>. But for the sake of brevity, how about we just call it the General Data Protection Regulation(GDPR).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FxTiTnI0lT4IDo6E5t6%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FxTiTnI0lT4IDo6E5t6%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FxTiTnI0lT4IDo6E5t6%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/1cdd68974fcec36768471d834e3ae51c/href">https://medium.com/media/1cdd68974fcec36768471d834e3ae51c/href</a></iframe><p>GDPR is a European Union regulation intended to protect personal data flowing through the interwebs. While GDPR generally applies to entities within the EU, the nature of distributed global information networks means that it is not quite that simple. In particular, GDPR’s scope of enforcement includes data controlled by an organization based in the EU, data processed by an organization based in the EU, or the data about someone who is based in the EU. The takeaway is that GDPR reaches right across the Atlantic to the east and the Urals to the west, with the potential to impact any entity outside of Europe which collect and/or processes the personal data of EU residents.</p><p>In other words, a developer shouldn’t think just because there is an ocean, a sea, or a mountain chain between them and Brussels that they can ignore what GDPR has to say.</p><h4>So what <em>does</em> GDPR require?</h4><p>There are a number of provisions focused on the handling of data, including pseudonymisation (not to be confused with anonymization), that are broadly summed up by saying that the regulation seeks to encourage best practices in the application of <strong>“the principles of data protection by design and data protection by default” </strong>(see recital 78). Additionally, GDPR grants EU citizens the right to access data collected on them, and mandates that data processing records are adequately maintained.</p><p>Someone familiar with US law might see many similarities between GDPR and requirements imposed on the United States federal government by the <strong>Freedom of Information Act</strong> (FOIA) and <strong>Privacy Act</strong>. However, where FOIA and the Privacy Act apply only to the United States government, GDPR targets private organizations, companies, and individuals.</p><p>In particular, although the notice requirements of the Privacy Act and GDPR are not outrageously different in kind, the scope of GDPR’s reach makes all the difference in the world. Recital 30 of GDPR specifically describes that the information being regulated includes the types of data which “may be associated with online identifiers provided by their devices, applications, tools and protocols, such as <strong>internet protocol addresses, cookie identifiers or other identifiers</strong> . . . .” The rules require that</p><blockquote>[c]onsent should be given by a clear affirmative act establishing a freely given, specific, informed and unambiguous indication of the data subject’s agreement to the processing of personal data relating to him or her, such as by a written statement, including by electronic means, or an oral statement.</blockquote><h4><strong>“Cookie identifiers”!?</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*yxr9zCdi0CIBkQ2BETdr9w.jpeg" /></figure><p>The late Senator Ted Stevens once described the internet as “<a href="https://www.wired.com/2006/06/your-own-person/"><strong>a series of tubes</strong></a><strong>” </strong>and if that is indeed the case, those tubes are made of cookies. The modern internet is highly dependent on the storage of innumerable tiny packets of data, often in the form of cookies. By explicitly mentioning cookies, GDPR makes clear that it is intended to apply to almost everything in on the internet. That’s not to say that websites and webapps cannot use cookies, but some form of informed consent on the part of the user must be obtained.</p><p>So what constitutes consent? Be careful on this one, because although it is not a high bar, the regulation cautions that “[s]ilence, pre-ticked boxes or inactivity should not . . . constitute consent,” rather consent should be affirmatively given by “ticking a box when visiting an internet website.”</p><p>Which brings us to you, the lowly developer. Most importantly, rest easy in the knowledge that GDPR does not apply to uses that amount to“purely personal or household activity and thus with no connection to a professional or commercial activity” (see recital 18). So that webapp you showed your mom that asked for her favorite flavor of ice cream is unlikely to land you a €20 million fine. However, if you find yourself working on something destined for wider deployment, it may be a good time to start thinking about your obligations under GDPR.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*6N0jLE5pU_tD467apvRKkg.png" /><figcaption>Example of consent notice found on EUR-Lex</figcaption></figure><p>For a fun evening read, you can check out the <a href="https://eur-lex.europa.eu/legal-content/EN/TXT/HTML/?uri=CELEX:32016R0679&amp;from=EN">full text of GDPR here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f1c982d1154" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sorting Algorithms]]></title>
            <link>https://medium.com/@schulman99/sorting-algorithms-cd138655645b?source=rss-c6ead126e47a------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd138655645b</guid>
            <category><![CDATA[sorting-algorithms]]></category>
            <category><![CDATA[quicksort]]></category>
            <category><![CDATA[bubble-sort]]></category>
            <category><![CDATA[radix-sort]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jon Schulman]]></dc:creator>
            <pubDate>Thu, 13 Sep 2018 12:36:04 GMT</pubDate>
            <atom:updated>2018-09-13T12:42:30.549Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JQzTo8b4ohbDA20W3snmUw.jpeg" /></figure><p>As far as Javascript is concerned, the Sort( ) function is somewhat ambiguous. Javascript itself does not care how sorting happens, typically leaving this ‘decision’ in the hands of the javascript engine. This means that Sort( ) can function differently on different browsers. After I discovered this I decided to take a deeper look at Sort( ), and found myself deep inside the soup of computer science and mathematics that is <strong>Sorting Algorithms</strong>. In this post I’ll be talking about three sorting algorithms: the <strong>radix sort</strong>, the <strong>bubble sort</strong>, and the <strong>quicksort</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*8W3oRUE8B14YmW9h99ifcg.jpeg" /></figure><h3><strong>Radix </strong>Sort</h3><p>One of the earliest sorting algorithms dates back to the 1880s and is attributed to a man named <strong>Herman Hollerith</strong>. Hollerith should be recognized in his capacity as a civil servant working for the U.S. Census Bureau, where the equipment and technologies he invented helped allow the 1890 census to be processed in just 6 years. That may not seem like a big deal, but the 1880 census had taken 8 years to complete, and that was with nearly 13 million fewer citizens to count. It was on the success of his tabulating machines that Hollerith founded a company which eventually became the cornerstone of something called the <strong>International Business Machines Corporation</strong>. You may have heard of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*KKTH2jZwuuTs8QXPZ5qZmQ.png" /></figure><p>That first sorting algorithm was the <strong>Radix sort</strong>. In a traditional radix sort, a set of numbers are progressively reordered beginning with the digits in the ones position. Once the data has been rearranged, the sort then moves to the Tens positions, then the Hundreds, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*8gNwLixVz94c2eO8tw8uNA.png" /></figure><p>The word radix actually derives from the Latin word for “root,” and you can see that reflected in how this sort algorithm begins at the bottom (or root) of each value and works its way up. Note that when the processes is flipped, it is referred to as a most significant digit (MSD) radix sort.</p><p>The radix sort itself is closely tied to its original use in electromechanical tabulating machines, and looking at the drawing above you can almost see the rotors of Hollerith’s 19th century device whirring away as they sort through millions of pieces of data. That said, in 1954 Harold Seward devised an improved style of radix sort to be run on a digital computer.</p><h3>Stable and Not Stable</h3><p>Now is probably a good time to talk about stability in sorting methods. It is important to understand the difference between sorts that are “stable” and sorts that are “not stable,” where “stability” ensures that elements of identical values will maintain their relative position to one another throughout the execution of a sort. Probably the best way to visualize this is to think about sorting a deck of cards. Below we can see that the 5 of ❤s and 5 of ♠s maintain their position relative to each other (e.g., with ❤ on the left) in a stable sort, but may not in an unstable sort. When evaluating sorting methods, it is vital to consider whether a stable sort is needed for your application. A radix sort, for what it’s worth, is a stable sorting method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*pY3ekPN0ZWeiT3lnuzdtuQ.png" /></figure><h3>Bubble Sort</h3><p>Like the radix sort the<strong> Bubble sort </strong>is stable. Though very simple, the bubble sort (invented in 1956), is relatively inefficient because it requires repeated passes over every element in a set of data until the entire set is sorted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*1MiLjMYgr2r2fDORCJn89w.gif" /></figure><p>This type of sort begins by evaluating the very first value against the second. If the first is greater than the second, the values are flipped. The algorithm then compares the second and third values. This pattern is repeated until the end of the dataset is reached, and the process begins again. Given its simplicity, the bubble sort’s strength is the minimal code/instructions needed in its execution.</p><p>One of the big problems with a bubble sort is that if the data is completely backwards, the number of steps needed to sort all of it to completion is roughly the the number of pieces of data squared. While this worst-case scenario is true of a lot of common sorting algorithms, a small bubble sort will take much longer than a small merge sort. But wait, what’s a merge sort…?</p><h3>Merge Sort</h3><p><strong>John von Neumann</strong> is a fascinating historical figure of immeasurable intelligence. He was prolific in his written work, publishing 150 papers over his lifetime, and was instrumental in the development of the explosive lenses used to the create implosion-triggered fusion reactions that were at the heart of the first nuclear weapons.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/267/1*D9v1bDeAQGOrEM0tLzcIwg.gif" /></figure><p>Oh, and in 1945 he invented the <strong>Merge sort</strong>. In a merge sort, a set of numbers is first divided in half, then in half again, then in half again, and so forth until only pairs of numbers are left. Each pair is ordered, then ordered pairs are “merged” into each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*opwN0BhtH4zvPF697fPlow.gif" /></figure><p>Unlike bubble sorts, merge sorts become “faster” over time as sets of numbers become internally sorted. In the chart below, the blue line represents the theoretical number of steps (e.g., time/effort/operations) to complete a bubble sort for a given number of elements, while the red line reflects the number of steps to complete a merge sort of the same size. Note the these are only averages, as the degree to which the data is unsorted to begin with will greatly impact the efficacy of most sort methods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*UQX3osSyyt0vmSOyHYENkQ.png" /></figure><h3>Quicksort</h3><p>So far we been talking about stable sorting methods, but I was curious to see what a not stable sorting method looks like. Enter the <strong>Quicksort, </strong>created in 1959 by <strong>Tony Hoare</strong>. (You can also thank him for the existence of null values, his “billion-dollar mistake” according to his own assessment of the matter).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1asn2YyhkSiDeGZi0--v_w.png" /></figure><p>Like all sorting algorithms, quicksort has its pluses and minuses. Quicksort, like a bubble sort, can be very slow in the worst-case scenario. However, on average and in best-cases, quicksorts tend to be very fast in completing their work. A quicksort starts by selecting a single element called the “pivot.” There are different strategies to selecting a pivot depending on the goals of the sort, and I wont be getting into that here. Suffice to say, the pivot represents the first point of division for this sorting method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*ukxC4fhk0mAb7PmXyTLhAg.gif" /></figure><p>Once a pivot is selected, the elements are recorded so that values less than the pivot are to the left of the pivot, and values greater than the pivot are to the right. The pivot is then considered locked in place, a new pivot is selected, and the process runs again until all elements have been sorted.</p><h3>Conclusion</h3><p>The math and science behind sorting algorithms can intense, and for smaller datasets worrying about how Javascript is going to handle a sort operation is probably not a great use of time. However, as datasets grow in size selecting an appropriate sorting method can substantial effects on the performance of your code, and having a basic understanding of how they work is sure to make you a better developer.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FLyRWppObda4%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DLyRWppObda4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FLyRWppObda4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0540a9313ca1cee7436ec84fda211d9b/href">https://medium.com/media/0540a9313ca1cee7436ec84fda211d9b/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FCq7SMsQBEUw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DCq7SMsQBEUw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FCq7SMsQBEUw%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f84c68b5239f7f7e9f36c8b565733238/href">https://medium.com/media/f84c68b5239f7f7e9f36c8b565733238/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FZRPoEKHXTJg%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DZRPoEKHXTJg&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FZRPoEKHXTJg%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/23a8a024a3c80a7b9bb4906b68475bc3/href">https://medium.com/media/23a8a024a3c80a7b9bb4906b68475bc3/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F8hEyhs3OV1w%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D8hEyhs3OV1w&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F8hEyhs3OV1w%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/999561de8a0f93906a7a80872f75def0/href">https://medium.com/media/999561de8a0f93906a7a80872f75def0/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd138655645b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“The Trouble with #{‘Tribble’.pluralize}”]]></title>
            <link>https://medium.com/@schulman99/the-trouble-with-tribble-pluralize-e5ea18733ee0?source=rss-c6ead126e47a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5ea18733ee0</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Jon Schulman]]></dc:creator>
            <pubDate>Thu, 16 Aug 2018 13:05:52 GMT</pubDate>
            <atom:updated>2018-08-16T13:05:52.895Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IrtRcL7Yod2mcoKDMTM-cw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*9Fro8-IuFtS6w3ON7GxLtw.jpeg" /></figure><p>My introduction to the “magic of Rails” was sullied somewhat by a deeply rooted inability to remember what to name things. More specifically, what to name the file where my Class lives. Even if know the Class name is Tribble, is the model file called <strong>Tribble.rb</strong>? <strong>tribble.rb</strong>?? <strong>Tribbles.rb</strong>?!? <strong>tribbles.rb</strong>?!?!</p><p>My confusion was only further deepened the day I ran into a Class with more than one word in the title. Now I have to (maybe?) make it plural and (maybe?) give it capitalization? Is it CamelCase, snake_case, <strong><br></strong>titlecase? How on earth do I implement a class of <strong>Constitution Class Starships</strong>?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*pZnE4lLfUkIOYfeh4GIb1g.jpeg" /></figure><p>While Rails can make life easier for the developer, that ease comes at the cost of a <a href="https://rubyonrails.org/doctrine/#convention-over-configuration">demandingly specific set of conventions</a> that do not like to be ignored. Because Rails relies heavily on <a href="https://guides.rubyonrails.org/active_record_basics.html">ActiveRecord</a>, understanding what Rails is expecting, and how ActiveRecord is going to get you there is crucial to maintaining sanity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/193/1*Xk4Kmtr6-hSV6iOffGs0QQ.jpeg" /></figure><p>The rules themselves are not difficult, but they can be difficult to keep track of while trying to set up a new project, and failure to play by the rules will rewarded with endlessly entertaining error messages about <a href="https://www.thoughtco.com/nameerror-uninitialized-2907928">uninitialized constants</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3DMhfulwTYtbCcZdPQ8cCQ.png" /></figure><p>To help me navigate these rules, I have put together the samples below that boil-down some common rails-related activities using two classes: Tribbles and Constitution Class Starships.</p><pre>rails new starship-tribble-tracker<br>rails g resource <strong>Tribble<br></strong>rails g resource <strong>ConstitutionClassStarship</strong></pre><p><em>app/controllers/</em><strong><em>tribbles_controller</em></strong><em>.rb</em><br> class <strong>TribblesController</strong> &lt; ApplicationController<br><br><em>app/controllers/</em><strong><em>constitution_class_starships</em></strong><em>_controller.rb</em><br>class <strong>ConstitutionClassStarshipsController</strong> &lt; ApplicationController</p><p><em>app/models/</em><strong><em>tribble</em></strong><em>.rb</em><br>class <strong>Tribble</strong> &lt; ActiveRecord::Base<br> belongs_to :<strong>consitution_class_starship</strong></p><p><em>app/models/</em><strong><em>constitution_class_starship</em></strong><em>.rb</em><br>class <strong>Constitution_Class _Starships</strong> &lt; ActiveRecord::Base<br> has_many :<strong>tribbles</strong></p><p><em>app/views/</em><strong><em>tribbles</em></strong><em>/index.erb<br>app/views/</em><strong><em>constitution_class_starships</em></strong><em>/index.erb</em></p><p><em>config/routes.rb</em></p><pre>resources: :<strong>tribbles</strong>, :<strong>constitution_class_starships</strong></pre><pre>patch ‘<strong>constitution_class_starships</strong>/:id’, to: ‘<strong>constitution_class_starships</strong>#update’</pre><p><em>db/migrate/01_create_</em><strong><em>tribbles</em></strong><em>.rb</em></p><pre>class CreateTribbles &lt; ActiveRecord::Migration<br> def change<br> create_table :<strong>tribbles</strong> do |t|<br> t.string :name<br> t.integer :reproductive_multiplier<br> t.integer :<strong>constitution_class_starship</strong>_id</pre><p><em>db/migrate/02_create_</em><strong><em>constitution_class_starships</em></strong><em>.rb</em></p><pre> class Create<strong>ConstitutionClassStarships</strong> &lt; ActiveRecord::Migration<br> def change<br>   create_table :<strong>constitution_class_starships</strong> do |t|<br>  t.string :name<br>  t.integer :maximum_warp_speed<br>   t.boolean :federation</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yjXGmfYjblw4NODgIAmO1Q.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jk5SN19FapnDWjjvl_u57g.jpeg" /><figcaption>Spaaaaaaace lawyer.</figcaption></figure><p>Language can be a funny thing, and while Rails may run on convention, language certainly does not. Rails applies special rules for handling some — but not all — grammatical oddities with <a href="https://github.com/davidcelis/inflections">ActiveSupport::Inflector</a>. If you are every unsure of how a word may be treated, there is one fool-proof tool that will always point you in the right direction: pluralize.</p><p>Consider the following examples:</p><pre>&#39;woman&#39;.pluralize  #=&gt; &#39;women&#39;</pre><pre>&#39;person&#39;.pluralize  #=&gt;&#39;people&#39;</pre><pre>&#39;mouse&#39;.pluralize  #=&gt; &#39;mice&#39;</pre><pre>&#39;octopus&#39;.pluralize  #=&gt; &#39;octopi&#39;</pre><pre>&#39;guess&#39;.pluralize #=&gt; &#39;guesses&#39;</pre><pre>&#39;madame&#39;.pluralize(:fr) #=&gt; &quot;mesdames&quot;</pre><p>So far, so good. But as you may have guessed, .pluralize does have its limits.</p><pre>&#39;gas&#39;.pluralize  #=&gt; &#39;gas&#39;</pre><pre>&#39;moose&#39;.pluralize #=&gt; &#39;mooses&#39;</pre><pre>&#39;geese&#39;.pluralize #=&gt; &#39;geesees&#39;</pre><pre>&#39;attorney general&#39;.pluralize  #=&gt;&#39;attorney generals&#39;</pre><p>What can be done if you run up against a situation where you really need a word to be pluralized in a certain way? One option is to define your own additional rules using ActiveSupport::Inflector.inflections.</p><pre>ActiveSupport::Inflector.inflections(:en) do |inflect|<br> inflect.singular /(phase)s$/i, ‘\1’<br> inflect.plural /(shel|kni)fe/, ‘\1ves’<br> inflect.irregular ‘foot’, ‘feet’<br> inflect.uncountable %w[money fish]<br>end</pre><p>Just be sure to make any custom rules <em>before </em>running a few dozen <a href="https://guides.rubyonrails.org/generators.html">rails generators</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5ea18733ee0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Horseshoes, Hand Grenades, and Programing]]></title>
            <link>https://medium.com/@schulman99/horseshoes-hand-grenades-and-programing-106fe3280f9e?source=rss-c6ead126e47a------2</link>
            <guid isPermaLink="false">https://medium.com/p/106fe3280f9e</guid>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Jon Schulman]]></dc:creator>
            <pubDate>Thu, 02 Aug 2018 11:29:58 GMT</pubDate>
            <atom:updated>2018-08-02T12:56:28.333Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/158/1*LFEcS4aMuuKw5wUOEJq6YQ.png" /></figure><p>Learning to code is difficult. This is not a new observation, but having attempted to do it about a dozen times in my life, I think I have figured out just <em>why</em> it’s so difficult.</p><p>For most of the things we learn in life, there are ways to initially be bad at them, but still get the job done. The old phrase “close only counts in horseshoes and hand grenades” is of course nonsense, and especially so when we think about our expectations around learning something new. Want to learn to knit? You can start by making raggedy ugly scarves. Want to learn how to draw? How about stretch your legs on some deformed stick figures.</p><p>My initial experiences learning to program were unlike my past experiences. A piece of code typically would either work or not, and I had no deformed stick figure to fall back on.</p><p>A language like Ruby tries to help point you in the right direction with its error messages, but often the new programmer is faced with a simple nil return even after hours of bashing away at the keyboard. As someone who is brand new, that nil fails to convey much other than a gentile pat on the back confirming that just the correct number of ends have been sprinkled into the code to circumvent the dreaded unexpected keyword_end. When starting this journey error messages are scary not because they meant something went wrong — that’s expected — but because it is difficult to know what to do with them.</p><p>Let’s take a look at a fairly simple challenge. Given an array of tasks, how can we print out a message randomly selecting just one of those tasks? We might try the code below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7a1392ee67bb6074198a16cf503e878/href">https://medium.com/media/a7a1392ee67bb6074198a16cf503e878/href</a></iframe><p>It does not take long for an experienced coder to see that this is not going to work. But if you are brand new to this sort of thing, you might be surprised to see your terminal return the following:</p><pre>#=&gt; close.rb:5:in `&lt;main&gt;’: undefined method `tasks’ for main:Object (NoMethodError)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/1*m6o8ynh9ot_ZrFX0AO8zqw.png" /></figure><p>But how can task be an undefined method!? I can see it right there! And what is this main:Object business all about!?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*t4FVNIpMUIF0encUJFXezQ.jpeg" /></figure><p>I’ll be honest with you; you’re unlikely to figure this one just by looking at it. But that’s no reason to quit! Could you tell what was wrong with you car’s motor just by opening the hood? Of course not! You’re going to need to cut it open, and to do that you’re going to need a tool. Fortunately a developer named <a href="https://github.com/banister">John Mair</a> gave us just such a tool → <a href="https://github.com/pry/pry">Pry</a>! Thanks John!</p><p>For the novice developer the true magic of Pry is that it allows the choice of how to fail. If you’re learning to ride a bike you can expect to fall over, but what if you could choose where you were going to fall? What a difference that would make! Pry takes this one step father by letting you test out how the brakes stop without needing to get rolling down a hill. Or how the shifters shift without needing to peddle back up a hill. Or even how the kickstand works without the risk of having the entire bike fall over.</p><p>As a new developer, it is difficult to overstate how crucial this one little tool can be. Without it, you may find yourself fumbling in the dark with no understanding of what you are doing or how it affects your code. Even when your changes work you won’t understand why unless you can isolate all the bits and pieces.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/198/1*h4URZZFESPj0h8nDqpSlsA.png" /></figure><h3>How to get Pry working for you!</h3><p>First you’ll need to make sure that your system has access to Pry by installing it in your terminal. Pry is kind of like a little program built just for Ruby — we call this a “gem”. To install it, run gem install pry in your terminal. Next, you’ll need to make sure that the specific code you’re working on is expecting Pry by including require ‘pry’ at the beginning of your code.</p><h3>Fail where you want to!</h3><p>Let’s revisit the code from earlier that wasn’t working. Again for someone with even a little experience, the problem is obvious. But for a total novice this kind of error can be maddening, with questions like “where did I go wrong?” and “where did I go right?” all swirling around right next to “I’ll never learn this stuff!”</p><p>Let’s take a breath, toss in a Pry, and start to tease out some answers. To do that, we will write binding.pry just above where we want to the program to pause to let us take a look around.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ea92eaf136b9d4d85415bbe7332768f2/href">https://medium.com/media/ea92eaf136b9d4d85415bbe7332768f2/href</a></iframe><p>Recall that in order to use Pry, we need to tell our code to be on the look-out for it, which is why we included require ‘pry’ at the beginning of our script. Because our file is called “close.rb” we can run it by entering ruby close.rb in our terminal (just make sure you are already in the same directory with your file), and the program will pause when it hits the words binding.pry.</p><pre>[1] pry(main)&gt;</pre><p>Your terminal should look pretty similar to what you see above. That pry(main)&gt; indicates that we are inside the Pry. In other words our program has been frozen in time and we now have the opportunity to investigate what’s going on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/144/1*fp7gWh52fOgLXZepQurPdg.png" /></figure><p>It can be good practice to start by confirming that you know what the world looks like at this moment in time. With that in mind, let’s make sure we know what is in our array by calling our array using tasks.</p><p>[1] pry(main)&gt; tasks</p><pre>=&gt; [“playing horseshoes”, “throwing hand grenades”, “baking cakes”, “painting landscapes”, “laying bricks”]</pre><p>Awesome! Now let’s confirm that the rand() method works how we think it should.</p><p>[2] pry(main)&gt; rand(0..4)</p><pre>=&gt; 4</pre><p>[3] pry(main)&gt; rand(0..4)</p><pre>=&gt; 0</pre><p>[4] pry(main)&gt; rand(0..4)</p><pre>=&gt; 1</pre><p>Okay, that looks about right. It’s a little difficult to know for sure, but it seems like rand(0..4) is returning a random number between 0 and 4. So now let’s try checking if we can get a single element — “baking cakes” — out of the tasks array.</p><p>[5] pry(main)&gt; tasks(rand(2))</p><pre>=&gt; NoMethodError: undefined method `tasks’ for main:Object</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/216/1*qMrgy-C0VIcVVR21dT-LFg.jpeg" /></figure><p>That looks like the same error we got when we started. And that is GREAT news because now we know exactly where in our code something is wrong. More importantly for someone who is trying to learn, <strong><em>we also know what parts of our code are working correctly!</em></strong></p><p>It is this ability to fail controllably that permits the new developer to simultaneously understand their missteps while simultaneously internalizing what they are doing right.</p><p>And that is what makes Pry such a powerful tool for learning because by letting us fail in a targeted manner we discover not only what we’re doing wrong, but what we’re doing correctly! With a little targeted internet searching we will discover that out mistake was simply a matter of confusing tasks() for tasks[].</p><h3>Let’s fix this!</h3><p>Right now you are still in your Pry, and there are a couple ways to get back to you regular terminal prompt. You can use exit, but this only goes back one nested level. That might do the trick this time, but as your use of Pry becomes more advance you will find that a single exit won’t always do the trick. So when I know I want to get out of Pry completely, and to avoiding needing to exit multiple times, I like to rely on !!! which will exit the Pry program entirely. It also avoids the risk of franticly typing exit one too many times — potentially logging you out of your terminal session entirely!</p><p>Once you have left the pry, make the changes you need to your code and don’t forget to save! Then try running your code once more.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/03f513a5ccfb977743771fe3333a016c/href">https://medium.com/media/03f513a5ccfb977743771fe3333a016c/href</a></iframe><p>Let’s type ruby close.rb into our console and watch the magic happen.</p><pre>=&gt;  Close only counts when playing horseshoes.</pre><p>ruby close.rb</p><pre>=&gt;  Close only counts when throwing hand grenades.</pre><p>Success!!! Thanks Pry!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/137/1*K2cFBT1XoVicbOFJRNL4qg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=106fe3280f9e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>