<?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 Buckminster Waldorf on Medium]]></title>
        <description><![CDATA[Stories by Buckminster Waldorf on Medium]]></description>
        <link>https://medium.com/@DisjectaMembra?source=rss-28a375a0055b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*j3CPOQOiUsFEjwlgv22hbg.jpeg</url>
            <title>Stories by Buckminster Waldorf on Medium</title>
            <link>https://medium.com/@DisjectaMembra?source=rss-28a375a0055b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 07:10:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@DisjectaMembra/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[Tweaking Your New Mechanical Keyboard]]></title>
            <link>https://medium.com/@DisjectaMembra/tweaking-your-new-mechanical-keyboard-6b057283c09c?source=rss-28a375a0055b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b057283c09c</guid>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[mechanical-keyboards]]></category>
            <dc:creator><![CDATA[Buckminster Waldorf]]></dc:creator>
            <pubDate>Thu, 11 Aug 2016 20:15:40 GMT</pubDate>
            <atom:updated>2016-08-11T23:01:26.659Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’re like me, a dude in his late thirties who still remembers his first computer (Apple IIe, technically my dad’s computer) and that cool click-clack-ity sound it made, you might appreciate that what’s old is new again.</p><p>Suffice it to say, like a lot developers in the last few years, I’ve become interested in the tactile satisfaction and usability of mechanical keyboards.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xn_tb2Hx7vFiGDAR8ikfkg.jpeg" /></figure><p><em>An old Apple IIe which came with a really noisy, awesome mechanical keyboard (the only keyboard option for the first few decades of home computing).</em></p><p>Anyway, I can’t exactly remember exactly how I first came upon the idea of getting a mechanical keyboard — I think it was this <a href="https://www.quora.com/What-is-the-best-keyboard-for-a-programmer">guy’s post on quora</a> where he had included a picture of an awesome, custom built, mechanical keyboard, which looked something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*juBqiqCpMsjg45KHBiVJTw.jpeg" /><figcaption>This is a WhiteFox 65% keyboard which was recently part of a <a href="https://www.massdrop.com/buy/the-whitefox-keyboard">Massdrop</a>. You can read more about this <a href="https://input.club/whitefox">keyboard here</a>.</figcaption></figure><p>In any event, rather than waiting for the Massdrop order to fill up, I searched around for a solid, cool-looking mechanical keyboard that was also Apple-compatible without too much tinkering. It didn’t take much Googling before I happened upon this baby:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LJ7foTXjq0D80l_oHBJHug.jpeg" /><figcaption>Nixeus Moda Pro</figcaption></figure><p>At right around $80 USD, the <a href="http://www.nixeus.com/product/moda-pro-mechanical-keyboard/">Nixeus Moda Pro</a> is as affordable as it is well-built. You can get all the details here, but the first question is of course:</p><p><em>“Will it work on my Mac? And if ‘yes’, how much screwing around will I have to do before I feel at home on it?”</em></p><p>The answer is pretty much “yes” and “not too much”, respectively.</p><p>Here’s how it works:</p><p><strong>Step 1.</strong> Once you get your Moda Pro unsheathed and presented to the world, there’s a little plastic packet with a few Apple keys and a black plastic tool that looks like a ring a villain would wear. It’s pretty intuitive, just slide the prongs under the Windows key and the two alt keys and replace those with the two Apple cms keys and the one Option key they give you. You’re just making your Moda Pro key look like your current Apple keyboard here, although it’s not going to be a perfect match. Here’s how mine looks now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tyWSj-r0QoscImCcBx75Ag.jpeg" /><figcaption>PC keys I popped off using the black tool in the middle</figcaption></figure><p>Ok, so it’s not a total match to an Apple keyboard as you can see, even after you replace the option and cmd keys. The media keys up top basically work the same as the player and volume keys on a standard Apple keyboard, you just have to use the Fn key to the right of the space bar:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ID3m7eJlQ13658KmIugBRg.jpeg" /></figure><p>The main thing though is that you won’t have an Option key to the right of the right-side Command key, as you would normally with a standard Apple keyboard. Just a little heads up so you won’t be surprised.</p><p>Ok, so now on to how you actually configure this thing.</p><p><strong>Step 2.</strong> <a href="https://pqrs.org/osx/karabiner/index.html.en">Download and install Karabiner,</a> an open source and well-supported keyboard customizer application for OSX.</p><p><strong>Step 3.</strong> Once you have Karabiner installed (and no conflicting keyboard mappers installed, which Karabiner will alert you to), you actually leave Karabiner alone for a second and go right to Systems Preferences. There you go: Keyboard &gt; Modifier Keys &gt; In the dropdown Select Keyboard menu select “USB Gaming Keyboard” and set up the Cmd and Option keys properly like so (basically swapping Option and Cmd, due to how your Mac will initially see the Moda Pro layout):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*gEtq0sigtsLtiVirffEP6g.jpeg" /><figcaption>Swapping Option and Command layout in Keyboard Preferences.</figcaption></figure><p>That’s actually most of the work. But you’ll notice that the Cmd on the right side still doesn’t work, even though it’s being activated when you press it, according to Keyboard Preferences Show Keyboard Layout viewer it’s still being registered as an Option key. Here’s where Karabiner comes in.</p><p><strong>Step 4. </strong>Find Karabiner in your Applications folder, open it, and you’ll see this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bwLP3fgKFkEck76-HqkWVw.jpeg" /><figcaption>Karabiner Preferences with the keyboard mapping listed via XML</figcaption></figure><p>Scroll down or search until you find Change Option_R Key (Right Option):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0bL__qPGTJXFSqTv6r8igQ.jpeg" /></figure><p>Once you’ve found <strong>Change Option_R Key (Right Option)</strong>, expand it with the arrow icon and check the box that says <strong>Option_R to Command_R</strong>. This will now register the right-side Cmd key properly as a Cmd key and not an Option key.</p><p>So the only catch with this is that you have to let Karabiner run in the background the entire time you user your Mac with this keyboard. It will load an icon in the menu bar and pretty much stay out of the way after that, but just another heads up.</p><p>That’s it. Enjoy your new mechanical keyboard!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b057283c09c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Groking Python decorators: a beginner’s guide (cont’d…)]]></title>
            <link>https://medium.com/@DisjectaMembra/groking-python-decorators-a-beginner-s-guide-cont-d-489a7aaaf006?source=rss-28a375a0055b------2</link>
            <guid isPermaLink="false">https://medium.com/p/489a7aaaf006</guid>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Buckminster Waldorf]]></dc:creator>
            <pubDate>Sat, 16 Jan 2016 04:56:33 GMT</pubDate>
            <atom:updated>2016-01-16T05:17:49.490Z</atom:updated>
            <content:encoded><![CDATA[<p>Following up here on <a href="https://medium.com/@DisjectaMembra/groking-python-decorators-a-beginner-s-guide-be2bce3c85be#.36p6uj6l4">the other post</a> that attempts to breakdown Python decorators for the neophyte student of Python.</p><p>In the previous post we saw how decorators can be used to alter the functionality of the function it decorates:</p><pre>def p_decorate(func):<br>   def func_wrapper(*args, **kwargs):<br>       return &quot;&lt;p&gt;{0}&lt;/p&gt;&quot;.format(func(*args, **kwargs))<br>   return func_wrapper</pre><pre>@p_decorate<br>def get_text(name):<br>   return &quot;lorem ipsum, {0} dolor sit amet&quot;.format(name)</pre><pre>print get_text(&quot;chip&quot;)</pre><pre># get_text(&quot;chip&quot;) outputs:<br># &lt;p&gt;Outputs lorem ipsum, chip dolor sit amet&lt;/p&gt;</pre><p>But what happens when the decorator takes an argument itself?</p><p>You might say “wait, isn’t that what a decorator does in the first place?”</p><p>Well yes, that’s true, but here’s what I mean:</p><pre>def decorator_factory(enter_message, exit_message):<br><br>    def simple_decorator(f):<br>        def wrapper():<br>            print enter_message<br>            f()<br>            print exit_message<br>        return wrapper<br>    return simple_decorator</pre><pre>@decorator_factory(&quot;Start&quot;, &quot;End&quot;)<br>def hello():<br>    print &quot;Hello World&quot;</pre><p>Notice how <strong>decorator_factory(“Start”, “End”)</strong> already has arguments being passed to it as it’s also decorating <strong>def hello()</strong> ?</p><p>This code will output:</p><pre>Start<br>Hello World<br>End<br>None</pre><p>What’s happening here? Well, think about this:</p><pre>@decorator_factory(...)<br>def hello():<br>    ...</pre><p>Is equivalent to:</p><pre>def hello():<br>    ...<br><br>hello = decorator_factory(...)(hello)</pre><p>Which is, of course, equivalent to:</p><pre>def hello():<br>    ...<br><br>decorator = decorator_factory(...)<br>hello = decorator(hello)</pre><p>So remember how decorators are functions that return other functions? Well, that’s what is happening here except the function that’s actually acting as the decorator function, <strong>simple_decorator(f)</strong>, is one-level deeper in a function before being called vs what we have with <strong>p_decorate(func) </strong>where the function used with <strong>@</strong> is actually getting the function it decorates as its argument and is getting called immediately.</p><pre>def decorator_factory(enter_message, exit_message):<br><br>    def simple_decorator(f):<br>        def wrapper():<br>            print enter_message<br>            f()<br>            print exit_message<br>        return wrapper<br>    return simple_decorator</pre><p>Just keep in mind how the code executes here in terms of how Python goes over the function definitions first, with each function returning the function it wraps around, calling it, then returning the next one:</p><p><strong>@decorator_factory(“Start”, “End”)</strong> calls <strong>decorator_factory</strong> with “Start” and “End” passed as arguments, then <strong>simple_decorator</strong> is returned which calls <strong>def simple_decorator(f)</strong> where <strong>f </strong>is actually the function we decorated, <strong>hello(), </strong>then<strong> simple_decorator() </strong>returns the<strong> wrapper() </strong>function, which is printing the two strings passed to <strong>decoratory_factory()</strong> and outputting the what is returned by the <strong>hello()</strong> function (the string “Hello World”)</p><p>If you want to follow how this whole thing is executed on the stack and look at the frames, <a href="http://www.pythontutor.com/visualize.html#code=def+decorator_factory(enter_message,+exit_message%29%3A%0A++++def+simple_decorator(f%29%3A%0A++++++++def+wrapper(%29%3A%0A++++++++++++print+enter_message%0A++++++++++++f(%29%0A++++++++++++print+exit_message%0A++++++++return+wrapper%0A++++return+simple_decorator%0A%0A%0A%40decorator_factory(%22Start%22,+%22End%22%29%0Adef+hello(%29%3A%0A++++print+%22Hello+World%22%0A%0Ahello+%3D+hello(%29%0Aprint+hello&amp;mode=display&amp;origin=opt-frontend.js&amp;cumulative=true&amp;heapPrimitives=true&amp;textReferences=false&amp;py=2&amp;rawInputLstJSON=%5B%5D&amp;curInstr=0">check it out here</a>.</p><p>So in conclusion, when you have something like:</p><pre>@decorator_factory(&quot;Start&quot;, &quot;End&quot;)<br>def hello():<br>    print &quot;Hello World&quot;</pre><p>The function:</p><pre>@decorator_factory(&quot;Start&quot;, &quot;End&quot;)</pre><p>is really a function factory that returns another function and it’s <em>THAT </em>function that is actually decorating the function we’ve decorated (decorating/augmenting/altering the return value of that function).</p><p>This is just how Python works with a decorator that you’re passing arguments to, so to reiterate:</p><pre>@decorator_factory(&quot;Start&quot;, &quot;End&quot;)<br>def hello():<br>    ...</pre><p>is equivalent to:</p><pre>def hello():<br>    ...<br><br>hello = decorator_factory(&quot;Start&quot;, &quot;End&quot;)(hello)</pre><p>which of course is equivalent to:</p><pre>def hello():<br>    ...<br><br>decorator = decorator_factory(&quot;Start&quot;, &quot;End&quot;)<br>hello = simple_decorator(hello)</pre><p>So if we didn’t want “Start” and “End” (for whatever reason) in this particular setup, we’d just use:</p><pre>@simple_decorator<br>def hello():<br>    ...</pre><p>You see this a lot if, for example, you’re using <a href="http://flask.pocoo.org/">Flask</a>, usually in your views file:</p><pre>@app.route(&quot;/api/post&quot;, methods=[&quot;GET&quot;])<br>@decorators.accept(&quot;application/json&quot;)<br>def posts_get():<br>    ...<br>  return Response(data, 200, mimetype=&quot;application/json&quot;)</pre><p>Here we’re decorating the function <strong>post_get() </strong>responsible for displaying something on a page with a routing decorator and a decorator responsible for making sure the client has an Accept header that can handle JSON.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=489a7aaaf006" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Groking Python decorators: a beginner’s guide]]></title>
            <link>https://medium.com/@DisjectaMembra/groking-python-decorators-a-beginner-s-guide-be2bce3c85be?source=rss-28a375a0055b------2</link>
            <guid isPermaLink="false">https://medium.com/p/be2bce3c85be</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Buckminster Waldorf]]></dc:creator>
            <pubDate>Fri, 15 Jan 2016 19:48:20 GMT</pubDate>
            <atom:updated>2016-04-14T15:37:40.381Z</atom:updated>
            <content:encoded><![CDATA[<p>I was recently asked by a friend to explain how Python decorators work. By any estimation, decorators are one of those slippery object oriented programming concepts that, understandably, takes the unfamiliar more than just a minute to fully understand.</p><p>(Before you read further, this post assumes you have a basic understanding of how functions, variable scope, and <strong>*args</strong> and <strong>**kwargs </strong>work).</p><p>Consider the following code:</p><pre>def p_decorate(func):<br>   def func_wrapper(*args, **kwargs):<br>       return &quot;&lt;p&gt;{0}&lt;/p&gt;&quot;.format(func(*args, **kwargs))<br>   return func_wrapper</pre><pre>@p_decorate<br>def get_text(name):<br>   return &quot;lorem ipsum, {0} dolor sit amet&quot;.format(name)</pre><pre><br>print get_text(&quot;chip&quot;)</pre><pre># get_text(&quot;chip&quot;) outputs:<br># &lt;p&gt;Outputs lorem ipsum, chip dolor sit amet&lt;/p&gt;<br></pre><p>Ok, so what’s happening here?</p><p>First off, we need to get some clarity on just exactly what a decorator is:</p><p><em>A decorator is any callable Python object that is used to modify a function, method or class definition. A decorator is passed the original object being defined and returns a modified object, which is then bound to the name in the definition. Python decorators were inspired in part by </em><a href="https://en.wikipedia.org/wiki/Java_annotation"><em>Java annotations</em></a><em>, and have a similar syntax; the decorator syntax is pure </em><a href="https://en.wikipedia.org/wiki/Syntactic_sugar"><em>syntactic sugar</em></a><em>, using @ as the keyword.</em></p><p>So we can boil that down even further by saying simply that: a decorator is just a function that takes another function and returns a new (decorated or changed) function.</p><p>This is different from what a beginner normally is used to seeing, wherein a function is a thing that returns a value, a final result. A decorator doesn’t return a final return value “end product” but instead returns a new, augmented function, that is then used to complete a task. If we think of functions like little machines, then a decorator is like a factory that takes in little machines, makes alterations, and then returns the altered machine to the user for further use.</p><p>So in our code above, the first weird thing you see is the <strong>@p_decorate</strong></p><p>The use of the <strong>@</strong> symbol is just syntactic sugar and means the same thing as if we were to write this instead:</p><pre>my_get_text = p_decorate(get_text)</pre><p>So, just to be clear, without the <strong>@ </strong>symbol, the code above could be written just as easily (but not Pythonically) as this:</p><pre>def get_text(name):<br>   return &quot;lorem ipsum, {0} dolor sit amet&quot;.format(name)<br><br>def p_decorate(func):<br>   def func_wrapper(*args, **kwargs):<br>       return &quot;&lt;p&gt;{0}&lt;/p&gt;&quot;.format(func(*args, **kwargs))<br>   return func_wrapper<br><br>my_get_text = p_decorate(get_text)<br><br>print my_get_text(&quot;chip&quot;)<br></pre><p>Ok, so back to the original code at the top of the post with the @ symbol.</p><p>Let’s break this down:</p><p>The function we’re decorating, or augmenting the functionality of, is<strong> get_text(name). </strong>This is a<strong> </strong>pretty simple function that we pass a string to as the argument and it returns a new string with the name inserted into the Latin text: <strong>“lorem ipsum, chip dolor sit amet”</strong>.</p><p>Our decorator function is <strong>p_decorate(func)</strong> and you should note its construction:</p><pre>def p_decorate(func):<br>   def func_wrapper(*args, **kwargs):<br>       return &quot;&lt;p&gt;{0}&lt;/p&gt;&quot;.format(func(*args, **kwargs))<br>   return func_wrapper</pre><p>The <strong>p_decorate(func)</strong> has a nested or inner function inside of it called <strong>func_wrapper()</strong> which takes <strong>*args</strong> and <strong>**kwargs</strong> (more on that in a minute).</p><p>Think of the decorator <strong>p_decorate() </strong>as a “function factory” which exists to house/create/and most importantly <em>return</em> <em>another</em> <em>function. </em>What is that other function? It’s<em> </em>the altered version of the function that was decorated. How the decorated function, in this case <strong>get_text(name)</strong>, get’s ‘decorated’ or altered is via the inner or nested function <em>inside</em> of <strong>p_decorate()</strong> called <strong>func_wrapper()</strong>, which is (as its name suggests) a function wrapper, because it ‘wraps’ around another function. That function, is of course, the decorated function <strong>get_text()</strong>.</p><p>Inside of the function wrapper <strong>func_wrapper(*args, **kwargs)</strong> we can see that we’re returning the value returned by <strong>func(*args, **kwargs)</strong> (which is a string) inserted into the html paragraph tags <strong>“&lt;p&gt;{0}&lt;/p&gt;”.</strong></p><p>Note that <strong>func(*args, **kwargs) </strong>is actually <strong>get_text(“chip”), </strong>this is crucial, keep in mind everything in Python is an object and all we’ve done here is pass one function into another function.</p><p>Confused? Remember:</p><pre>@p_decorate<br>def get_text(name):<br>....</pre><pre>#is the same as saying:</pre><pre>my_get_text = p_decorate(get_text) <br></pre><p>So you can see, we’re passing to <strong>p_decorate(func)</strong> the <strong>get_text(name)</strong> function. So inside of <strong>p_decorate(func)</strong> just keep in mind that <strong>func == get_text(name). </strong>Just a bit of syntactical groking housekeeping there, but it’s worth pointing out.</p><p>But what else is happening inside of <strong>p_decorate(func)</strong>? Well, it’s the most important concept to understand about decorators: what<strong> p_decorate(func) </strong>is actually returning to the global namespace of the script is NOT a value but ANOTHER FUNCTION! Again, this is what decorators do:</p><pre>def p_decorate(func):<br>    def func_wrapper(*args, **kwargs):<br>        return &quot;&lt;p&gt;{0}&lt;/p&gt;&quot;.format(func(*args, **kwargs))<br>    return func_wrapper</pre><p>Look at the code above: <strong>p_decorate(func)</strong> is returning the <strong>func_wrapper </strong>function object back to the global namespace!!! What is <strong>func_wrapper </strong>after all? Well, it’s essentially our <strong>get_text(name)</strong> function with some added functionality (the <strong>&lt;p&gt;</strong> tag formatting)!</p><p>So when we do <strong>print get_text(“chip”)</strong> what we’re <em>actually</em> calling — because we decorated <strong>def get_text(“chip”)</strong> with <strong>@p_decorate </strong>—<strong> </strong>is <strong>func_wrapper(“chip”)</strong>.</p><p>Let that sink in for a minute.</p><p>Again:</p><pre>@p_decorate<br>def get_text(name):<br>....</pre><pre>#is the same as saying:</pre><pre>my_get_text = p_decorate(get_text)</pre><p>So our decorated <strong>get_text(name)</strong> function has actually become <strong>func_wrapper(name)</strong> simply by decorating <strong>get_text(name)</strong>.</p><p>A few things to note:</p><p>There’s an important concept at work within <strong>p_decorate(func)</strong> called closure. Without getting too off track here, it’s important to make mention of this phenomenon in Python.</p><p>Basically A CLOSURE is a function object that remembers values in enclosing scopes regardless of whether those scopes are still present in memory. Python supports a feature called <strong>function closures</strong> which means that inner functions (like our <strong>func_wrapper(*args, **kwargs)</strong>) defined in non-global scope remember what their enclosing namespaces (the namespace or scope “owned” by <strong>p_decorate(func)</strong>) looked like <strong>at definition time</strong>.</p><p>This can be seen by looking at the <strong>func_closure</strong> attribute of our inner function which contains the variables in the enclosing scopes:</p><pre>...</pre><pre>my_get_text = p_decorate(get_text)</pre><pre>print my_get_text.func_closure<br># this print statement would return something like this:<br># (&lt;cell at 0x108de92b8: function object at 0x1089296e0&gt;,)</pre><p>But don’t worry about all that for now.</p><p>The other important thing here is: why are we using <strong>*args</strong> and <strong>**kwargs</strong> in our <strong>func_wrapper()</strong> function?</p><p>In order for <strong>func_wrapper()</strong> to be as useful and flexible as possible we’d like it to accept any kind of arguments that could possibly be thrown its way, right? That’s why we’re using <strong>*args</strong> and <strong>**kwargs </strong>— it’s just good practice to make our decorator function as flexible as possible, which means that we’d prefer to not hard-code arguments into it, so that way we can use it all over the place in our code and get the same functionality without having to go back and tweak it every time.</p><p>Things can get a little more complicated with the use of functools module or if you have a decorator with an argument. I’ll try to follow up on that with another post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be2bce3c85be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Non-ASCII error due to #comment line? WTF]]></title>
            <link>https://medium.com/@DisjectaMembra/non-ascii-error-due-to-comment-line-wtf-de50dedd0644?source=rss-28a375a0055b------2</link>
            <guid isPermaLink="false">https://medium.com/p/de50dedd0644</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[autodidacticism]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Buckminster Waldorf]]></dc:creator>
            <pubDate>Sat, 24 Oct 2015 03:26:33 GMT</pubDate>
            <atom:updated>2015-10-25T02:39:31.098Z</atom:updated>
            <content:encoded><![CDATA[<p>Really quick post, someone out there might find this helpful…</p><p>Have you ever gotten that annoying Non-ASCII error when you try and execute a Python script, but the error message keeps pointing to a line that’s commented out? You keep trying different things, double check that you have:</p><blockquote>#!/usr/bin/python</blockquote><blockquote># -*- coding: ‘utf-8’ -*-</blockquote><p>…but still no dice. You keep getting:</p><blockquote>File “your_script.py”, line 29</blockquote><blockquote>SyntaxError: Non-ASCII character ‘\xe2’ in file your_script.py on line 29, but no encoding declared; see <a href="http://python.org/dev/peps/pep-0263/">http://python.org/dev/peps/pep-0263/</a> for details</blockquote><p>Well, here’s a really simple way to find out the offending character. Open up the Python interpreter in the directory where the file in question lives, and try the following:</p><pre>with open(&quot;your_script.py&quot;) as fp:<br>    for i, line in enumerate(fp):<br>        if &quot;\xe2&quot; in line:<br>            print i, repr(line)</pre><p>This will return the string with the actual location of the offending character or characters. For example, you might get something like this:</p><blockquote>28 ‘#The association object pattern is a variant on many-to-many: it\xe2\x80\x99s used when your association table contains additional columns beyond those which are foreign keys to the left and right tables. Instead of using the secondary argument, you map a new class directly to the association table.\n’</blockquote><p>See those <strong>\xe2\x80\x99</strong> ? That’s the apostrophe in ‘it’s’ in the comment there. Got rid of it, then I was back in business.</p><p>Why this error occurred in the first place is for another time, maybe I’ll attempt to open up that Pandora’s Box of encoding later.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de50dedd0644" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Admission to the Rabbit Hole — part 1]]></title>
            <link>https://medium.com/@DisjectaMembra/admission-to-the-rabbit-hole-681760f9107e?source=rss-28a375a0055b------2</link>
            <guid isPermaLink="false">https://medium.com/p/681760f9107e</guid>
            <category><![CDATA[autodidacticism]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Buckminster Waldorf]]></dc:creator>
            <pubDate>Mon, 14 Sep 2015 01:17:46 GMT</pubDate>
            <atom:updated>2015-10-21T15:10:31.170Z</atom:updated>
            <content:encoded><![CDATA[<p>Problem solving for the nascent developer is often like an exercise in self-recursion: you diligently chip away at a problem with a simulacra of unsuccessful attempts, wrapping yourself up into an increasingly tangled mess of momentarily/seemingly clever approaches until you finally roll to a dead stop, hitting the wall. And it’s right at that moment that you begin untangling yourself from your feeble attempts, to finally arrive at a simple, intuitive solution, which usually resembles your first attempt (more precisely, your first attempt done correctly).</p><p><em>“I don’t always use recursion, but when I do use recursion, I use recursion, recursively when using recursion…”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*9aGi53H4lB6E8orPrw8LRg.jpeg" /><figcaption>recursive visualization to refresh your memory</figcaption></figure><p>Here’s how I’m using this (loose) recursion simile:</p><p><strong>The Winding Phase</strong>: the task at hand calls you (you’re the function) and every attempt you make as you flail around trying this approach, the next one, and then the next one, get’s put on the “<a href="https://en.wikipedia.org/wiki/Call_stack">call stack</a>” — which you can think of as the place in your brain where all your earnest attempts go (thanks for bearing with me on this simile).</p><p><strong>The Terminating Base (or Exit) Condition</strong>: This is the point at which you hit the wall with the maximum number of attempts your personality or childhood or patience will allow. And it occurs to you that maybe, just maybe, you need to go back and take another look…because maybe, just maybe, you missed something.</p><p><strong>The Unwinding Phase</strong>: Here’s when you barf out all your previous attempts, you delete them (or if you’re a little obsessive, comment them out) from your code, until you arrive back at something that looks very much like your first inclination and solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*93IMb9o4wmBFMVmMcfQDpg.jpeg" /></figure><p>So how does this happen? I/we/you/the nascent developer takes the inevitable long and winding trip down the ‘ol coding rabbit hole.</p><p>This coding rabbit hole is fraught with multiple dead ends, erroneous cul de sacs with non-solutions that suck up hours of effort, darkened collapsing tunnels that you navigate through, feeling the walls as you glance at fruitless Google search results…Every few hours you find yourself bypassing the undersexed and spiteful Stackoverflow trolls (here’s a pithy take on <a href="https://medium.com/@johnslegers/the-decline-of-stack-overflow-7cb69faa575d">Stackoverflow</a>, which is still, in all fairness, a useful resource merely as a massive repository of problem solving) who gleefully label your question as a duplicate post so that they can link back to their selected answer on a several-years-old post featuring deprecated module versions, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*JlNV_iWHCNJ-_EcJcjnauQ.jpeg" /><figcaption>Typical Stackoverflow overlord</figcaption></figure><p>Ok, so enough rambling bullshit. The next post will be an actual example of my recursive trip down the rabbit hole. It will culminate in a tiny Python script that allows you to grab all video objects from a Facebook page and pass a DELETE request to their API (built by people on the Autism spectrum, for people on the Autism spectrum).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=681760f9107e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>