<?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 Brett Neese on Medium]]></title>
        <description><![CDATA[Stories by Brett Neese on Medium]]></description>
        <link>https://medium.com/@brettneese?source=rss-8ebc3ad4f813------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*wq0wUs_Dwsz3Kv7s.jpeg</url>
            <title>Stories by Brett Neese on Medium</title>
            <link>https://medium.com/@brettneese?source=rss-8ebc3ad4f813------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 00:23:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@brettneese/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[Actor-Based Authentication]]></title>
            <link>https://medium.com/@brettneese/actor-based-authentication-9f8d6fe276c4?source=rss-8ebc3ad4f813------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f8d6fe276c4</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[secrets]]></category>
            <dc:creator><![CDATA[Brett Neese]]></dc:creator>
            <pubDate>Mon, 10 Dec 2018 18:09:32 GMT</pubDate>
            <atom:updated>2018-12-10T18:09:32.469Z</atom:updated>
            <content:encoded><![CDATA[<h4>An Alternative Way To Think About Secrets</h4><p>Secrets are hard because humans are hard. They get leaked to GitHub, they get echo’d out to the console by lazy developers, they get skimmed by attackers. They’re a fundamental weakness in our security infrastructure.</p><p>And yet, secrets are everywhere. API Keys, database credentials, even certificates: all rely on this fundamentally broken authentication system. It’s no longer considered best practice to use single-factor authentication methods to access critical services online and yet underlying all of these sites are single-factor authentication methods (if you’re lucky, maybe you’ve got an IP whitelist.)</p><p>Maybe the problem with secrets… is secrets.</p><p>It’s unfortunately probably not possible get rid of secrets entirely. Legacy systems still rely on them, and there aren’t many great alternatives. Even if a database is configured use client certificates to authenticate, a string has to be passed around somewhere.</p><p>But it is possible to begin to think about them differently; particularly in cloud environments. I’ve been working on systems that begin to think about them differently — that abstract <em>secrets</em> into <em>policies</em>. This is already a fairly common way of understanding secrets, but I asked a few friends what it’s called, and while they understood the pattern, it didn’t appear to have a name. <strong>I call this way of thinking about secrets “actor-based authentication.”</strong></p><p>The idea is that instead of thinking about secrets as text strings, even if that is what they ultimately are, your infrastructure allows you to define to define policies that transparently pull secrets into your application from an external source, ideally by dynamically generating them per connection, based entirely on what the entity/actor — container, service, instance, application, user, etc — that needs the secret is. This way the only level of abstraction that developers or DevSecOps needs to worry about is “X has access to Y with Z permissions.”</p><p>To effectively accomplish actor-based authentication, tooling needs to be written that grabs and injects the credentials into the actor, which can be done in a variety of ways, most commonly through environment variables or a file in a temporary directory. But once it’s built, you stop having to worry about .env files or accidentally leaking secrets, though without dynamic generating secrets, secret skimming is still a concern.</p><p>A great example of actor-based authentication that already exists in the wild at massive scale is <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html">IAM Roles for Amazon EC2</a>. IAM roles for Amazon EC2 allow EC2 instances to gain access to other AWS resources through defining a policy explaining what the services running on the EC2 instance should have access to. The policy language itself defines what the applications running on the instance can and cannot do with what are technically other external services within AWS and that control is enforced by the infrastructure itself and IAM’s policy language is <a href="http://www0.cs.ucl.ac.uk/staff/b.cook/FMCAD18.pdf">provably secure</a>.</p><p>Underneath IAM instance policies, AWS is actually generating and rotating limited-use access key/secret key pairs, but any application on EC2 that uses the AWS SDK doesn’t need to worry about this — it happens automatically and transparently. This is a perfect example of the power of actor-based authentication; developers can focus on “who has access to what and when” instead of “how do I secure this random text string and vary it appropriately across environments.” Other AWS services, such as Lambda, use similar constructs, and Amazon’s own database service, Aurora, <a href="https://aws.amazon.com/about-aws/whats-new/2018/11/amazon-aurora-postgresql-supports-iam-authentication/">can also use IAM roles for user authentication </a>— another great example of actor-based authentication.</p><p>But we don’t have to wait for AWS to write all the tooling. Another example of tooling that allows actor-based authentication <a href="https://github.com/mozilla/node-convict/pull/273">is my PR for </a><a href="https://github.com/mozilla/node-convict/pull/273">node-convict</a> alongside my <a href="https://github.com/HBKEngineering/convict-provider-awsSsm/tree/update-awsssm">AWS Parameter Store provider</a>. For a project I worked on while developing these patterns, we stored all our secrets in the <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-paramstore.html">Parameter Store</a>, under different paths for staging/production/etc. Because we ran on Lambda, we give each of our functions an execution role with a policy that gives them access to only the secrets on the Parameter Store that service needs by cleverly using wildcards and paths.</p><p>For example, a config.js file looks like:</p><pre>var config = {<br>  PRINT_USER: {<br>    doc: &#39;Print server username&#39;,<br>    format: &#39;String&#39;,<br>    env: &#39;PRINT_USER&#39;,<br>    default: &#39;printing&#39;,<br>    providerPath: &#39;/api/&#39; + process.env.STAGE + &#39;/arctokens/PRINT_USER&#39;<br>  },<br>  PRINT_PWD: {<br>    doc: &#39;Print server password&#39;,<br>    format: &#39;String&#39;,<br>    env: &#39;PRINT_PWD&#39;,<br>    default: &#39;null&#39;,<br>    providerPath: &#39;/api/&#39; + process.env.STAGE + &#39;/arctokens/PRINT_PWD&#39;<br>  }<br>};<br><br>var convict = require(&#39;@hbkapps/convict&#39;);<br>convict.configureProvider(require(&#39;@hbkapps/convict-provider-awsssm&#39;));<br>module.exports = convict(config)<br>  .validate()<br>  .getProperties();</pre><p>And the PolicyDocument that allows permission to the Parameter Store looks something like:</p><pre>PolicyDocument:<br>          Version: &#39;2012-10-17&#39;<br> ....<br>            - Effect: &quot;Allow&quot;<br>              Action:<br>                - ssm:GetParametersByPath<br>                - ssm:GetParameters<br>                - ssm:GetParameter<br>              Resource: arn:aws:ssm:*:*:parameter/chartroom/api/${self:custom.stage}/core*<br>            - Effect: &quot;Allow&quot;<br>              Action:<br>                - ssm:GetParametersByPath<br>                - ssm:GetParameters<br>                - ssm:GetParameter<br>              Resource: arn:aws:ssm:*:*:parameter/chartroom/api/${self:custom.stage}/arctokens*</pre><p>Local developers have different roles on AWS and different and thus get different secrets when loading the app locally — actually, they don’t have any access to any of the Parameter Store secrets locally, so node-convict falls back to default values. In different environments, the application’s STAGE is injected into requests to the Parameter Store through interpolating the only variable we set on each Lambda function, the STAGE. And because we deploy our stages separately from each other, we’re able to interpolate the proper STAGE variable into the policy upon deployment — even if an attacker were able to update the STAGE, from “staging” to “production,” for instance, the Lambda function would not have permission to read from the “production” values anyway — it’s set via policy.</p><p>While there is an order of precedence and a mechanism to override parameters using environmental variables, injecting the actual values happens almost magically during application startup and does not rely on managing environmental variables or an .env file. This remains compliant with the <a href="https://12factor.net/config">twelve-factor app</a> because configuration values are stored separately from the code -- just in the Parameter Store instead of the environment -- and are defined declaratively in any given service&#39;s config.js. At the application level, secrets (and all config values) are simply exposed as config.super_secret_db_connection_string. For instance, in pseudocode:</p><pre>var config = require(&quot;./config&quot;);</pre><pre>requestObject = { <br>  username: config.PRINT_USER,                                    <br>  password: config.PRINT_PWD<br>}</pre><pre>request.send(&quot;https://abcd.efg&quot;, requestObject);</pre><p>It’s secrets management based on <em>what you are </em>and <em>what you need</em> not “what random strings are in the environment.” In theory, those values could even be generated uniquely per connection through an isolated proxy with root credentials to the target service, meaning that even if an attacker skims a secret, it’s worthless anyway (I’m working on this.)</p><p>Other tooling could be built to handle different deployment scenarios, such as containers. And tooling could be built to allow for dynamic secrets, using something like Vault. But ultimately under actor-based authentication development tooling and infrastructure should declaratively handle the question of “who has access to what,” not “how do I access this text string.”</p><p>Admittedly, more tooling needs to be built out to handle this pattern effectively, and that will take time and effort to do correctly. What exists so far is very nascent but works very well — it is somewhat transparent to the developer and it Just Works(TM), so this is actually a very exciting approach to an old, boring, and yet surprising hard problem.</p><p>Ultimately, changing the mindset around secrets and credential management through the addition of abstractions to manage access to secrets declaratively as a policy will lead to more secure and easy to manage services and microservices.</p><p><em>Brett Neese wants to help developers and artist build and ship the right things, the right way. He’s currently looking to work with anyone else who shares a passion for making the right thing the easy thing. Learn more at </em><a href="https://brett.neese.rocks/"><em>https://brett.neese.rocks</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f8d6fe276c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[first thoughts on new computers]]></title>
            <link>https://medium.com/@brettneese/i-just-got-back-from-an-incredible-time-at-the-internet-archives-distributed-web-summit-84f89c02d4fc?source=rss-8ebc3ad4f813------2</link>
            <guid isPermaLink="false">https://medium.com/p/84f89c02d4fc</guid>
            <dc:creator><![CDATA[Brett Neese]]></dc:creator>
            <pubDate>Sun, 05 Aug 2018 20:59:04 GMT</pubDate>
            <atom:updated>2018-08-06T15:25:56.033Z</atom:updated>
            <content:encoded><![CDATA[<p>i just got back from an incredible time at the Internet Archive’s <a href="https://decentralizedweb.net/">Decentralized Web Summit</a>.</p><p>i’m still processing and trying to wrap my head around what just happened. i’m sure I’ll have more thoughts here soon. in the meantime, my first thoughts:</p><p>i met a lot of very very interesting people I’d been following for a pretty long time. it was exciting and a bit surreal to me to meet all these wonderful people in person, though they probably never realized it. it was also nice to catch up with old friends working on new ideas.</p><p>what encouraged me most about my time there was that there were so many people, new and old, very interested in this general as-of-yet undefined space of <a href="http://newcomputers.group/">“new computers:”</a> taking a critical look at our industry and deciding that maybe our tools aren’t <em>good enough;</em> that maybe we need <em>new computers.</em></p><p>it may seem strange to bring into dialogue the concept that maybe our tools/machines aren’t yet good enough when there are obviously very glaring and incredibly important political struggles staring us in the face every day. but for us — or, for me, at least — the nexus of those political issues is that our tools have unintended consequences we really ought to think about mitigating, if possible, rather than continue the status quo. we need to disrupt disruption, and protocols are at least one component of that.</p><p>i came into this industry because I wanted to use technology to liberate people, though I maybe didn’t realize it at the time. as a kid, I was fascinated with stories of the Homebrew Computer Club and how the personal computer and networked technology was supposed to augment and empower regular people. as I got older, I studied Sartre, Foucault, and a whole host of feminist/decolonialist literature and took the concept of liberation very seriously.</p><p>lately, though, I’ve felt dismayed with the state of our industry. we’re not empowering people. we’re enslaving them. and worst of all, we’re to blame.</p><p>and the other technologists and engineers I met weren’t interested in these things, and I could never figure out why. [1]</p><p>i thought I was the only one who felt this tension. who want to build a future compatible with the techno-utopian ideals of thinkers past. who still see computers and networked technology as a way to augment the human mind and liberate people, even if it means we need to build new computers to do it.</p><p>my first reaction from the past 4 days is that i’m really glad I’m not the only one thinking about these things, and I’m really glad I had a chance to meet the other people who are.</p><p>[1] lately, I’ve realized there’s a systemic economic reason for this, actually, and I’m quite nuanced here, but that’s the subject for another post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84f89c02d4fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[bad faith, fake news, late capitalism]]></title>
            <link>https://medium.com/@brettneese/bad-faith-fake-news-late-capitalism-3267eb0fade?source=rss-8ebc3ad4f813------2</link>
            <guid isPermaLink="false">https://medium.com/p/3267eb0fade</guid>
            <dc:creator><![CDATA[Brett Neese]]></dc:creator>
            <pubDate>Sun, 29 Jul 2018 21:52:23 GMT</pubDate>
            <atom:updated>2018-07-29T21:52:23.029Z</atom:updated>
            <content:encoded><![CDATA[<p>i was looking through some of my older articles on Medium when I stumbled across this great piece of mine from 2013, and, in particular, this phrase:</p><blockquote>Still, the problem of bullshit on the Internet bothers me. I get physically tense whenever I read blatant fallacies or misleading op-eds. Reading the pundits pundit about punditry can actually induce minor bouts of rage.</blockquote><p>it was written in the brash, adolescent style I would’ve used 5 years ago, and, hopefully, I’ve developed a more mature, nuanced approach since then. but I think it deserves some revisiting, especially in our era of “fake news.”</p><p>firstly, at the time i was primarily concerned with tech journalism most of which is trash, even more so today. now, of course, my concerns are much wider. i think this much and why is obvious.</p><p>secondly, it’s interesting how at the time I lacked the vocabulary to express “good faith” (as opposed to bad faith.) of all the intellectual tools that I’ve developed since, good faith vs bad faith, <a href="http://www.philosophymagazine.com/others/MO_Sartre_BadFaith.html">at least as described by Sartre</a>, is one of the most useful for understanding the problem at hand (and a whole host of others.)</p><p>unlike the Sartre in “Being in Nothingness,” however, or at least unlike a surface reading of Sartre (like the one proposed in <a href="https://www.youtube.com/watch?v=xxrmOHJQRSs">this video</a>, I’m going to go ahead and argue that bad faith is just as prevalent across institutions — systems and concepts can act in bad faith as much as individuals — and in these situations individuals are not acting in bad faith even if the institution or system is.</p><p>the way I’m developing this is essentially: it’s not terribly productive to defame/criticize individual journalists for writing buzzfeed pop quizzes, so long as they’re acting in Good Faith — ie, actually trying to develop themselves as a journalist, and maybe that involves dashing off a few fluffy articles now and then. the fact that they have to do that work is much more of a systemic problem, largely intertwined with the attention economy as it’s developing in late capitalism.</p><p>fake news, as a conceptual framework, actually does act in bad faith — its goal isn’t truth, its goal is political propaganda. again, however, I don’t think I want to criticize the poor saps working for the Internet Research Agency, because again, under late capitalism, they almost certainly have very few other opportunities. the same is true for cable news: journalists can act in good faith, even when the institution itself is incentivized to act in bad faith because of the economics of news. we’re seeing that collision happening [1] right now and its fascinating and concerning, but the problem isn’t journalism: the problem is late capitalism.</p><p>[1] aka as the plot of “The Newsroom”</p><p><a href="http://www.brettneese.xyz/2018/07/29/bad-faith-fake.html">www.brettneese.xyz/2018/07/2...</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3267eb0fade" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[hello world, or, thoughts on using platforms thoughtfully]]></title>
            <link>https://medium.com/@brettneese/hello-world-or-thoughts-on-using-platforms-thoughtfully-acae2ab51d9b?source=rss-8ebc3ad4f813------2</link>
            <guid isPermaLink="false">https://medium.com/p/acae2ab51d9b</guid>
            <dc:creator><![CDATA[Brett Neese]]></dc:creator>
            <pubDate>Sat, 28 Jul 2018 23:07:20 GMT</pubDate>
            <atom:updated>2018-07-28T23:12:33.671Z</atom:updated>
            <content:encoded><![CDATA[<p>i, like many others, have become increasingly concerned about the platformization of the web, and especially social media sites like Facebook and Twitter. to us, they represents something of a “closing off” of what was once open, and have many negative externalities.</p><p>on the other hand, I totally recognize the power that these services provide. that’s why I still continue to use them: giving individual people the power to connect, form communities, and communicate at scale is an incredibly noble mission. i’m actually quite the facebook/twitter apologist, because I’ve seen first hand how transformative interactions on these platforms can be.</p><p>still, even from a pure UX perspective, using platforms (especially Twitter) has gotten incredibly obnoxious and addictive over the past few years. so i did the following:</p><ul><li>unfollowed everyone on Twitter and refollowed them privately on Feedbin, a private RSS reader. no more “you might be interested in” — just the content I want to see. what’s more, I can sort by self-defined tags and create global filter rules, just in case I really don’t want to see what bullshit Trump did today.</li><li>unfollowed most people I was following on Instagram</li><li>shut down some old Tumblrs I had laying around</li><li>installed a News Feed blocker extension for Facebook on both my phone and desktop, and uninstalled the apps. I also have all my Facebook notifications forwarded to a tab/folder on my GMail account, although I still prefer the web interface (without the newsfeed.)</li><li>left every single Facebook group I was in (over 800)</li><li>created my own <a href="https://micro.blog/">micro.blog</a> (aka <a href="https://brettneese.xyz/"><em>this site</em></a>) that cross-posts to Twitter and Medium</li><li>grabbed the downloadable archive, and then ran a tool to delete all my old tweets, and any future tweets older than a week old.</li></ul><p>the last two are actually the most interesting. i still want to share things with people! but the vast majority of the Things to Talk About on Twitter are inherently ephemeral.</p><p>as I develop my art, career and mind, I want to use tools that are open, self-owned, long-term, and that afford general thoughtfulness — if I’m sharing something, I ought to have (and probably do have) some considered feelings about that thing that deserve to be explained in greater than 240 characters (but less than a full-on blog post.)</p><p>and I will still be using Twitter regularly, if unconventionally, especially at conferences and other situations that lend themselves well to an ephemeral medium. it’s just that everything I post directly on Twitter will be swept away back into the void after a week or so, when they don’t matter anymore anyway. anything else worth sharing is worth thinking about and archiving and deserves a tool friendly to that cause [1].</p><p>i know I could do a lot more to encourage myself to really think about and consider things, and collect things for investigation or inspiration later on. tweetstorms, which is how I’ve traditionally organized, longerformish thought, aren’t really the right place for that. i can’t make any guarantees, because I’ve tried out many many tools for this over the course of the past several years to solve similar problems, but mayybbeeee this’ll be the right place for that.</p><p>plus it syndicates to medium and Twitter, so I get that sweet, sweet exposure the platforms provide anyway (not that I care too much about it.)</p><p>[1] fun fact, with the way Twitter’s API works, you can’t look at tweets older than your latest 3200 tweets (even on the website) without downloading the full archive, which is bullshit.</p><p><a href="http://www.brettneese.xyz/2018/07/28/hello-world-or.html">www.brettneese.xyz/2018/07/2...</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=acae2ab51d9b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Internet of Karaoke Machines]]></title>
            <link>https://medium.com/@brettneese/internet-of-karaoke-machines-bcd8f527e6f2?source=rss-8ebc3ad4f813------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcd8f527e6f2</guid>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[art]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[internet-of-things]]></category>
            <dc:creator><![CDATA[Brett Neese]]></dc:creator>
            <pubDate>Thu, 26 Jul 2018 03:46:19 GMT</pubDate>
            <atom:updated>2018-07-26T14:28:38.999Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<h4>How I Got A Retro-Futuristic Thrift Store Find to Run Docker</h4><p>Overt the past few months, for a video installation I’m working on, I’ve been on the hunt for something strange considering it’s 2018: a tiny CRT, ideally greyscale. I hunted thrift stores, dumpsters, eBay, at one point even taking a bunch of buses several hours to check out a film industry rummage sale in Echo Park. No dice.</p><p>One day, however, I found myself poking around at Goodwill when I spotted a portable karaoke machine from 2005 sitting among the various discarded electronics in the back of the store. For the particular project I’m working on, it’s perfect. And it was only $13. (Even better: when I got home, I noticed it had a free DVD of <em>Paul Blart: Mall Cop</em> in the CD tray.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/0*o6Lr-0WrEWMSsYbu" /></figure><p>There was one small problem, though: it’s a <em>karaoke machine</em>, and it definitely does not have any “video-in” ports on the outside. So I grabbed a handful of small computery things I had lying around and drug it to <a href="https://crashspace.org/">CRASH Space</a>, a hackerspace I’m a new member of in Los Angeles, hoping I might be able to liberate the display somehow.</p><p>Much to my surprise, it was incredibly easy to disassemble. Popping the top to get access to the monitor “section” was a simple matter of unscrewing 5 Philips screws, and all the internal wiring was in the form of convenient ribbon cables with header connectors, much like a computer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/0*nbK0Sk-6_Jimrsq4" /></figure><p>I poked around the board with a meter — wearing rubber gloves, of course, considering the CRT is potentially highly energized, even when powered off, and I would prefer not to die — trying to figure out how the display was being driven. I Googled random part names trying to find a schematic, anything, but couldn’t find any information on the insides.</p><p>As I took another look at the board, I suddenly found what I was looking for — much to my surprise, I somehow had missed that the board was literally labeled with a header pin labeled “video in.” <em>This machine was begging to be hacked.</em></p><p>Out of pure curiosity, I quickly pulled out a soldering iron and soldered two pins to the composite video headers on a Raspberry Pi Zero so I could run jumper wire between the “video out” on the Zero and the “video in” on the karaoke machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/0*OiOb4W7fsqz-HGt-" /><figcaption>How nice of them!</figcaption></figure><p>I plugged the whole thing in, and, much to my astonishment, the display sprung to life with the Raspberry Pi’s boot sequence. It even worked the first time!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/0*Rv46RwwRVDI5tQPp" /><figcaption>Success. (The SD card apparently had RetroPi on it, but still, it worked!)</figcaption></figure><p>Since then, I’ve replaced the Zero with a Raspberry Pi 3, because the Zero was a bit under-powered for my taste, and there’s plenty of room in the chassis. Since the big Pi doesn’t have composite headers, my first stab at this involved soldering wires to the bottom of the Pi, but they broke in transit incredibly easily. As the Pi carries video over the third ring of the 3.5mm jack, I found a TRS connector with screw block terminals, which has worked perfectly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7hZMnQWCFPI8w1ol" /></figure><p>I ended up hot-gluing the Pi to the chassis rather than have it awkwardly float around. My first try at this involved me gluing the Pi directly to the chassis… which I definitely wouldn’t recommend (RIP 8GB SD Card). I found a cheap Raspberry Pi case on Amazon and just glued the bottom half to the chassis, and that’s working much better. I then glued the jumper wire going into the board into the header slot so it wouldn’t fall out (thanks to Steve for showing me that trick.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/0*8o2NyQfGsflkbDRL" /></figure><p>I also Dremeled out a small hole in the back for the wires (<a href="https://www.youtube.com/channel/UCHWvlZ6jGmXKYa1w8yRVcbA">thanks to Barb, who makes things</a>, for giving me hand with the Dremel.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7V-g8R9o87vhAT8F" /></figure><p>On the software end, it’s running <a href="https://resin.io/">Resin/Resin OS</a>, which is a really cool Docker orchestration service for IoT devices. This makes it very easy for me manage and push software to the Pi, especially given my goal for it is to be semi-autonomous — I don’t want to have to worry about attaching a keyboard and mouse to it.</p><p>Currently, it’s running a <a href="https://www.screenly.io/ose/">Screenly OSE Docker image</a>, an open source digital signage solution, so I can push videos and websites to it at will. I would dive into how I got Screenly running on the Pi, but all I did was follow this <a href="https://resin.io/blog/deploy-a-digital-signage-application-with-screenly-and-resin/">excellent tutorial</a>. I’m working on giving it cellular data through a USB modem, so it’s always online, even when it’s not connected to my wifi network, and that’ll make it even more autonomous.</p><p>What I plan to do with this will be revealed with time, but for right now I’m pretty happy staring at the strange retro-futuristic object in my kitchen looping <a href="https://en.wikipedia.org/wiki/Meshes_of_the_Afternoon"><em>Meshes of the Afternoon</em></a> on a tiny black and white CRT while I weigh the absurd realization that I connected a karaoke machine to the Internet and it may indeed be one of the strangest machines running Docker in the world.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/0*KmC-ENvGPUBidMKK" /></figure><p><em>PS: I want to do more of this kind of work, potentially professionally. Hit me up at brett@neese.rocks if you’re interested in collaborating, especially</em><a href="https://brett.neese.rocks/"><em> if you need someone good at DevOps/AWS.</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcd8f527e6f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serverless Middleware]]></title>
            <link>https://medium.com/front-end-weekly/serverless-middleware-5a839f906acd?source=rss-8ebc3ad4f813------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a839f906acd</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Brett Neese]]></dc:creator>
            <pubDate>Wed, 31 Jan 2018 21:14:00 GMT</pubDate>
            <atom:updated>2018-01-31T21:16:25.283Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<h4>Dynamic CSS and more at the CloudFront Edge</h4><p>I recently helped my team transition from running our single-page JavaScript application that had been running in a simple Express Docker container to simply Webpacking up and hosting the static assets on S3. This was a big transition for us — without Docker containers, all of the concerns I had as our ops guy over managing our frontend servers simply went away (yay!)</p><p>But there were a few pieces we simply couldn’t do in the browser. One of those pieces was a custom skinning engine we had built that allowed us to white-label our application by injecting custom CSS stylesheets for various users. Before, we ran a bunch of API calls server-side on page render to inject<strong> </strong>custom CSS rules based on some information we had stored in the database. That’s slow, janky, and it won’t work on S3. We thought about doing that work on the client as well, but it’d always be less than ideal as that’s not how browsers are supposed to deal with style information. Another, similar issue we had is that we wanted to be able to redirect users without an authentication token to our authentication service.</p><p>This is where <a href="https://aws.amazon.com/lambda/edge/">Lambda@Edge</a> becomes very useful. Essentially, Lambda@Edge allows you to write Lambda functions that run in response to CloudFront events, modifying headers, responses, etc — anything you might otherwise do in Express-style middleware. In essence, this means it’s possible to write middleware for statically-hosted SPAs that run entirely on CloudFront edges. The only problem is that Lambda@Edge is fairly hard to test locally. Unit tests can solve some of this problem, but it’s also very useful to run all of the “middleware” locally.</p><p>So I came up with a pretty simple solution to this problem: a little npm module I wrote called <a href="https://www.npmjs.com/package/cloudfront-express">cloudfront-express</a>.</p><ul><li><a href="https://www.npmjs.com/package/cloudfront-express">cloudfront-express</a></li><li><a href="https://github.com/brettneese/cloudfront-express">brettneese/cloudfront-express</a></li></ul><p>Basically, this module absracts away most of the logic involved in parsing and sending responses into something that should work in a variety of environments; taking care of most of the implementation details and allowing the developer to focus on business logic. This way, the same &quot;serverless&quot; middleware functions can be invoked locally — by adding them to a local Webpack config.js’s DevServer.setup()— and in production by simply tying it in to the request with Lambda@Edge, and they&#39;ll behave the same way in both places -- developers then know exactly how the middleware affects the request/response cycle, because they can run the middleware right on their machine as if it weren&#39;t a serverless application.</p><h3>An Example Implementation: Dynamic CSS</h3><h4>Background</h4><p>I had already help split out our authentication into it’s own microservice a while ago: basically, the user gets redirected to the authentication service when they try and load the SPA; the authentication service generates a JWT; and the frontend uses that to make backend API calls. I determined that we wanted to use Lambda@Edge to generate a CSS file dynamically on a per-user basis, by simply including a tag that referenced an org.css file to be generated by CloudFront edge, but I really didn&#39;t want to have the Lambda@Edge function making its own set of API calls and wasn&#39;t even entirely sure how to pass user information along to Lambda in the first place.</p><p>Cookies seemed like the obvious answer, but I wasn’t sure a resource requested with the &lt;link&gt; tag actually included cookies in the request. Luckily, a quick experiment proved that link tags will indeed pass along cookie information to the origin server in the request for the CSS file -- and since we can set cookies across domains via JavaScript, that seemed ideal. When the user is redirected from authentication, we just slip in a cookie, and then Lambda@Edge can read it and send down the custom CSS.</p><p>While originally I had planned on simply using the existing JWT we set on the page, I instead opted for modifying our authentication service to return a full user object as a JSON object — complete with a skin property containing the appropriate CSS properties we allow our users to customize, and set <em>that</em> as a cookie. Since the authentication API already has and (obviously) needs a database connection to authenticate the users, this would be much faster than talking to the API in our Lambdas in order to generate this code.*</p><h4>Implementation</h4><p>There were no existing patterns for Lambda@Edge functions beyond some basic AWS docs, so I created one — and then used the same pattern for both the redirect function and the dynamic CSS function, and will probably do something very similar for any future “middleware” functions we build. You can see both of our examples <a href="https://github.com/brettneese/cloudfront-express/tree/master/examples">here</a>; but line-by-line, the patterns looks something like:</p><pre>module.exports.pathPattern = () =&gt; {<br>    return &#39;*org.css*&#39;;<br>};</pre><p>First, I export a PathPattern. The reason for this is so that the development middleware and the CloudFront &quot;middleware&quot; are both using the same route patterns: in fact, in our serverless.yml, I literally use this PathPattern to configure the CloudFront CacheBehavior, and it also gets used in the dev server middleware configuration as well:</p><pre>// serverless.yml<br>PathPattern: ${file(./serverless/dynamic-css/index.js):pathPattern}</pre><pre>// webpack.config.js<br><br>app.use(<br>    serverlessDynamicCss.pathPattern(),<br>    serverlessDynamicCss.middleware<br>);</pre><p>I should caution that CloudFront’s CacheBehavior PathPattern property and Express’s paths work and act quite a bit differently (in terms of wildcards and the like), but they’re compatible enough for our use case, and I plan to only do things that are supported by both backends.</p><p>Then,</p><pre>function populateResponse(req){<br>    let response = {};<br><br>    response.status = 200;<br>    response.headers = {<br>        &#39;Cache-Control&#39;: &#39;no-cache&#39;,<br>        &#39;Content-Type&#39;: &#39;text/css&#39;,<br>        &#39;Content-Encoding&#39;: &#39;UTF-8&#39;<br>    };<br>    response.body = generateCss(req);<br><br>    return response;<br>}</pre><p>all of our Lambda@Edge functions have this populateResponse function. Basically it takes an Express or Express-like (in the case of Lambda@Edge) request object and returns a somewhat generic response object, which then eventually gets fed into either Lambda@Edge&#39;s callback, or as an Express response depending on environment.</p><p>That happens at the bottom:</p><pre>// lambda<br>module.exports.handler = (event, context, callback) =&gt; {<br><br>    const response = populateResponse(cloudfrontExpress.fromCf(event));<br>    <br>    callback(null, cloudfrontExpress.toCf(response));<br>};<br><br>// express<br>module.exports.middleware = (req, res, next) =&gt; {<br><br>    const response = populateResponse(req);<br><br>    cloudfrontExpress.sendExpressResponse(response, req, res, next);<br>};</pre><p>This sets up the behavior for the two environments: Lambda calls the “handler” function, while Express calls the “middleware” function. I’ll detail what happens in the cloudfront-express module in a future post, but the tl;dr version is that those functions, respectively, take both Express and Lambda requests and responses and abstract them into a simple generic object. That way, you can, for instance, set response.status or read request.headers and it&#39;ll work the same both places.</p><p>I thought about encapsulating this even further and simply having one entrypoint, but this was a case where we decided that it was probably better to have less magic.</p><h4>Conclusion</h4><p>That’s basically all you need to write a Lambda@Edge-powered serverless “middleware” for a Webpacked SPA. I won’t go into deployment details in this post, but I rely on the <a href="https://serverless.com/">Serverless Framework</a> to do much of the heavy lifting.</p><p>The essential lesson from this project is for maximum developer productivity when using Lambda@Edge, <em>don’t</em> mix implementation details with business logic (as is done in literally all of AWS’s examples). Use cloudFrontExpress -- or your own library -- to abstract business logic away and allow you to run the same code both locally development environment and in the cloud.</p><p><a href="https://www.npmjs.com/package/cloudfront-express">cloudfront-express</a></p><p>Even though it’s a bit abstracted and confusing at first, Lambda@Edge allows for incredibly powerful “server”-side “middleware”, rather than baking this code into a special server which requires a lot of maintenance. Deploying a SPA like I did on S3 makes deployment and iteration a breeze, it’s incredibly fast, and nearly infinitely scalable without any work on my end as an ops guy — <em>and</em>, with Lambda@Edge, I can still manage to get the advantages of server rendering. Plus, it is totally possible to easily cache the results of your middleware functions on CloudFront itself — right at the edge; the next step for us, for instance, is figuring out how to server-render some of our data components on Lambda@Edge to speed up page load.</p><p>For a frontend application, Lambda@Edge gives you the best of both worlds — the simplicity of a static webpage, and the power of middleware — and the pattern I devised and explained above has made it very easy for our team to build and deploy solutions like these.</p><p><em>Brett Neese is a DevOps engineer at </em><a href="https://hbkengineering.com/"><em>HBK Engineering</em></a><em>, where he helps cloud GIS solutions for the civil engineering industry, helping make cities smarter and more connected. You can contact him at brett@neese.rocks.</em></p><p>* While this does mean it’d be trivial for someone to man-in-the-middle their own user object and edit their skin on the frontend, this wasn&#39;t a problem we are particularly worried about since it&#39;s entirely visual and not exposing any sensitive information. It also means a little bit of extra overhead on each request, but ultimately the convenience and speed of this new system trumps any extra roundtrip bits that are needed to complete a page-load.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a839f906acd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/front-end-weekly/serverless-middleware-5a839f906acd">Serverless Middleware</a> was originally published in <a href="https://medium.com/front-end-weekly">Frontend Weekly</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Messiah-AWS]]></title>
            <link>https://medium.com/@brettneese/messiah-aws-5f428f0d043?source=rss-8ebc3ad4f813------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f428f0d043</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Brett Neese]]></dc:creator>
            <pubDate>Mon, 22 Jan 2018 22:32:11 GMT</pubDate>
            <atom:updated>2018-01-22T22:42:19.394Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cl-MLJENwKfoLSwRKL2WOA.jpeg" /><figcaption><a href="https://en.wikipedia.org/wiki/Messiah_(Handel)">The chapel of the London’s Foundling Hospital, where regular charity performances of Handel’s Messiah were held.</a></figcaption></figure><h4>Easy, vendor-agnostic serverless JSON APIs in native Go on top of AWS Lambda/API Gateway</h4><h4>Introduction</h4><p>One week ago today, <a href="https://aws.amazon.com/blogs/compute/announcing-go-support-for-aws-lambda/">AWS Lambda announced official support for Go 1.x</a>. This was very exciting news for our team, which had already been working on migrating our last API to officially run on Lambda (it had been running in a hacky way under <a href="https://twitter.com/tjholowaychuk">@tjholowaychuk</a>’s<a href="https://github.com/apex/up">up</a>but this wasn’t sufficient for our needs and we needed access to provision CloudFormation resources directly.)</p><p>In order to leverage this new support, we quickly decided to split up our endpoints — which had been one, large, monolithic package tied together by a <em>main.go</em>, which did all the routing — into their own packages.</p><p>So, for instance, we might have a user APIs, which has an <em>endpoints/password/reset</em> package, or a <em>endpoints/users/create</em> package. That way these can be built and even deployed orthogonally from each other (in theory) even though the share the same repository. This is how we structure our other Lambda APIs in Node.js, and it’s quite nice. Go’s package system is much better than Node’s, which makes this even easier. (I’ll talk more about the tooling that make this possible in a future post. Things get weird but in a good way.)</p><p>But there was a problem — namely, if we were going to split our endpoints into their own function, we would need need to update a bunch of files (ie, all our existing endpoint handlers). We didn’t want to do this and end up with the same problem we were currently facing and be tied too directly into the <a href="https://github.com/aws/aws-lambda-go">aws-lambda-go</a>types — even though we love Lambda and <a href="https://aws.amazon.com/api-gateway/">API Gateway</a>, it’s never a good idea to mix implementation with business logic (a mistake which I decided we had already made by causing each endpoint handler to directly implement the ServeHTTP function.)</p><p><a href="https://github.com/brettneese/messiah-aws"><strong>So I created a simple (it’s literally 88 lines) abstraction around </strong></a><a href="https://github.com/brettneese/messiah-aws"><strong>aws-lambda-go, called <em>messiah-aws</em>.</strong></a></p><p>The cool thing about Messiah is that is both a pattern — ie, a collection of generic types — and an implementation (through aws-lambda-go). We wanted the ability, if we desired, to simply replace the messiah-awspackage with a package that implements the API of another backend provider — even a simply net/http&#39;s ServeHTTP. This keeps our handlers very cleanly operated from our backend. Functions should not care where they are, they should simply do the work.</p><h4>Implementing Messiah-AWS</h4><p>Implementing <a href="https://github.com/brettneese/messiah-aws">Messiah-AWS</a> is very simple. Messiah simply defines a couple of generic types that are an abstraction over the ones defined by the aws-lambda-go , and provides some convenience fields to help with automatically marshalling and marshalling JSON data in and out of the request/response cycle, so the endpoints don’t need to do that.</p><p>Specifically, as of this writing, those are:</p><pre>type Request struct {<br>	Context *context.Context<br>	events.APIGatewayProxyRequestContext<br>	events.APIGatewayProxyRequest // all the properties from the request<br>	RequestData map[string]interface{} // Messiah attempts to un-JSONify the body and put it into a map. If it can&#39;t, you will need to access the data from `Request.body`<br>}</pre><p>and</p><pre>Messiah.Response {<br> Headers      map[string]string // sets the headers on the response<br> StatusCode   int // sets the status code on the response<br> ResponseData interface{} // attempts to JSONify whatever it gets passed and sets it to the body. If it can’t, it stringifies it.<br>}</pre><p>Let’s say you have an endpoint you want to transform into Messiah. I’ll use the example from the GitHub repo, the status endpoint. It simply returns the name and version of the API, which are set by a struct of strings. Not terribly useful on Lambda, perhaps, but a nice clean example.</p><h4>Before</h4><p>Before <a href="https://github.com/brettneese/messiah-aws">messiah-aws</a>, we had a Status endpoint handler that looked something like:</p><pre># /endpoints/status.go<br><br>package endpoints<br><br>import (<br>	&quot;encoding/json&quot;<br>	&quot;net/http&quot;<br><br>	&quot;hbkauth-api/config&quot;<br>)<br><br>// StatusInfo stores a summary of information for the health check endpoint.<br>type StatusInfo struct {<br>	Version string `json:&quot;version&quot;`<br>	Name    string `json:&quot;name&quot;`<br>}<br><br>// StatusHandler is the handler for health checks.<br>type StatusHandler struct {<br>	Status config.StatusInfo<br>}<br><br>// ServeHTTP serves requests to the health check endpoint.<br>func (handler StatusHandler) ServeHTTP(res http.ResponseWriter, req *http.Request) {<br>	res.Header().Set(&quot;Content-Type&quot;, &quot;application/json; charset=utf-8&quot;)<br>	res.WriteHeader(http.StatusOK)<br>	json.NewEncoder(res).Encode(handler.Status)<br>}</pre><p>Then, in the root of the repository, we would’ve had something like this:</p><pre>// /main.go<br><br>package blah<br><br>import (<br>	&quot;github.com/blah/config&quot;<br><br>	&quot;log&quot;<br>	&quot;net/http&quot;<br>	&quot;strconv&quot;<br><br>	&quot;github.com/gorilla/mux&quot;<br>)<br><br>// StatusInfo stores a summary of information for the health check endpoint.<br>type StatusInfo struct {<br>	Version string `json:&quot;version&quot;`<br>	Name    string `json:&quot;name&quot;`<br>}<br><br>var version = &quot;1.0.0&quot;<br>var name = &quot;Messiah Example API&quot;<br><br>func main() {<br>	status := config.GetStatus()<br><br>	statusHandler := endpoints.StatusHandler{<br>		Status: status,<br>	}<br><br>	router := mux.NewRouter()<br><br>	router.Handle(&quot;/status.json&quot;, statusHandler)<br><br>	log.Fatal(http.ListenAndServe(&quot;:&quot;+strconv.Itoa(status.Port), router))<br>}</pre><p>The key thing here is that we’ve got ServeHTTP spammed all over the place. We’re directly tied into anything that implements the `ServeHTTP` function signature, and it’s hard to change that without updating all the functions. When I update this code to use Messiah, we’ll no longer be stuck in this paradigm. (I did think about abstracting over <em>net/http</em>. That seemed unnecessary and overly complex, though might be the subject of a future project.)</p><p>The config package itself looks like this. It doesn’t change between versions:</p><pre>// config/config.go<br><br>package config<br><br>// StatusInfo stores a summary of information for the health check endpoint.<br>type StatusInfo struct {<br>	Version string `json:&quot;version&quot;`<br>	Name    string `json:&quot;name&quot;`<br>}<br><br>var version = &quot;1.0.0&quot;<br>var name = &quot;Messiah Example API&quot;<br><br>// GetStatus derives the system status<br>func GetStatus() StatusInfo {<br>	status := StatusInfo{<br>		Version: version,<br>		Name:    name,<br>	}<br><br>	return status<br>}</pre><h4>After Messiah-AWS</h4><p>Messiah simplifying things a bit by making things much more generic. While Messiah currently only speaks to AWS (hence <a href="https://github.com/brettneese/messiah-aws">messiah-</a><a href="https://github.com/brettneese/messiah-aws"><em>aws</em></a>), it’d totally be possible to replace the <a href="https://github.com/brettneese/messiah-aws">messiah-aws</a>package with another Messiahor Messiah-like package that implements Messiah’s generic types. (At some point, as an experiment, I’m actually going to write one that starts an HTTP server using <em>net/http</em>.)</p><p>After messiah-aws, our code looks more like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1fa62541b335b1e671509e1d08b43536/href">https://medium.com/media/1fa62541b335b1e671509e1d08b43536/href</a></iframe><p>Instead of writing to http.ResponseWriter, the handler function simply returns a Messiah.Responseobject with the appropriate properties. <br>Then, in the main()function, I initialize that handler and pass it into messiah.Start()which eventually transforms the handler and pumps it into <em>aws-lambda-go</em>’slambda.Start() function. As mentioned above, for added convenience, Messiah also handles properly marshaling the messiah.Response.ResponseData property into a JSON response, and the properties from the request in the the messiah.Request.RequestData map.</p><p>And because I embed the types defined in the aws-lambda-gopackage into the Messiah request and response types, I can even theoretically do something like:</p><pre>res := Messiah.Response{<br> StatusCode:              http.StatusOK,<br> ResponseData:            $someBinaryObject,<br> APIGatewayProxyResponse: events.APIGatewayProxyResponse{<br>                                  IsBase64Encoded: true,<br> },</pre><pre>return res</pre><p>Or any of the other fields, current or future, defined on the aws-lambda-go struct that I haven’t already abstracted over, although the only one that doesn’t have an abstraction currently is “IsBase64Encoded” — though if you needed to skip the JSONification on the <em>ResponseData</em> property you could set APIGatewayProxyResponse.Body directly and not set the ResponseData property at all.</p><p>I also have access to every property on the events.APIGatewayProxyRequest object directly, such as req.Headers, and I can do whatever I want with them in my handlers. (For future implementations of the <em>Messiah</em> pattern which may not share the same structure, I suggest mapping from the properties of the events.APIGatewayProxyRequest struct.)</p><p>And that’s about it! The config package didn’t have to change at all — all we had to do was move some code around, copy the initialization code out of main.go and put it into the new endpoint’s main() function, as well as update our function signatures slightly. Another advantage of this pattern is that our tests are much simpler: we simply need to mock the messiah.Request and Messiah.Responsetypes and check the response object from calling the handler. This is much easier than dealing with ServeHTTP.</p><p><strong>What about routing?</strong></p><p>Currently, API Gateway handles all of our routing. Instead of declaring our routing patterns in the main.go using <a href="https://github.com/gorilla/mux">Gorilla/mux</a>, we simply declare them in our SAM template and let API Gateway handle routing. I’ll go over more about how this works in a future post. This currently means that yes, using this structure, every API route is its own package. That works for all our projects but it might not work for yours. However, it seems possible to simply a implement a Mux or Mux-like routing package in our endpoint packages themselves.</p><p><strong>What if I already have structs defined for my API requests?</strong></p><p>Using this pattern, we ran into an issue where we already had structs defined for our incoming request data, such as api.AuthenticationRequest. It looked something like:</p><pre><br>type AuthenticationRequest struct {<br> Username string `json:”username”`<br> Password string `json:”password”`<br> Scope string `json:”scope”`<br>}<br></pre><p>To cast an incoming RequestData map into that struct, we simply did something like this, utilizing the <a href="https://github.com/mitchellh/mapstructure">mapstructure</a> package:</p><pre>var apiRequest api.AuthenticationRequest</pre><pre>parseErr := mapstructure.Decode(req.RequestData, &amp;apiRequest)</pre><pre>if parseErr != nil {<br> panic(parseErr)<br>}</pre><h4>Conclusion</h4><p>And that’s it. Messiah-AWS makes it very easy to make simple APIs on Lambda and API Gateway. I look forward to seeing how our team — and hopefully others — adopts the Messiah pattern to build generic, vendor-agnostic APIS on top of Lambda and API Gateway in Go.</p><p>In a future piece, I will go over some deployment tips and tricks as we as a more complex example.</p><p>In the meantime, if you found <a href="https://github.com/brettneese/messiah-aws"><em>Messiah-AWS</em></a> or this tutorial useful, please feel free to star the project on GitHub and smash that clap button below. You can also follow me on GitHub to see what else I’m up to, or send me an <a href="/service/mailto:brett@neese.rocks">email</a>.</p><p><strong>Acknowledgements</strong></p><p><em>Thanks to my teammate </em><a href="https://github.com/mnaughto/"><em>Mike Naughton</em></a><em> for helping me write an early prototype of Messiah-AWS.</em></p><p><em>Brett Neese is a DevOps engineer at </em><a href="https://hbkengineering.com/"><em>HBK Engineering</em></a><em>, where he works on writing internal tools for GIS data collection and mapping. He can be reached at &lt;brett@neese.rocks&gt;</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f428f0d043" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[there is a seeming contradiction in the ethics of tech between power and liberty.]]></title>
            <link>https://medium.com/@brettneese/there-is-a-seeming-contradiction-in-the-ethics-of-tech-between-power-and-liberty-86a568391b9a?source=rss-8ebc3ad4f813------2</link>
            <guid isPermaLink="false">https://medium.com/p/86a568391b9a</guid>
            <category><![CDATA[philosophy]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Brett Neese]]></dc:creator>
            <pubDate>Sat, 22 Jul 2017 01:05:49 GMT</pubDate>
            <atom:updated>2017-07-22T01:07:07.179Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<p>there is a seeming contradiction in the ethics of tech between power and liberty.</p><p>if we are to take a heiddegerian(?) or foucauldian approach to technological ethics, we are to see that technology is an object of power: that is to say, an object created or used at the hands of or in pursuit of power has a moral distinction. therefore it is possible and grounded to say something such as “that’s a bad invention,” or that is “an immoral weapon.”</p><p>at face value this seems quite silly. but it’s easy to see how some one who invents a weapon might feel a sense of guilt or perhaps joy at the disaster before them. those are real, grounded emotions that point to some semblance of morality. but how to consider intent? for instance, there is no possibility that the creator or creators of a disastrous or “bad” technology could have foreseen it’s dangers. they might not even know what they’re building or why. it does not feel appropriate to place blame or guilt upon them.</p><p>in fact, unintended consequences are rather inevitable — and it is very the much case that it even with undesired consequences comes enhanced possibility: in other words, a technology can be both liberatory and oppressive. a classic utilitarian approach would be to weigh the good against the bad, but, at the very least, this calculus seem near impossible, as it requires foresight, an possibility whose impossibility trends toward infinite. even if the body and the mechanics of the earth are naturally and mechanistically determined, probability theory suggests that every possible outcome and every possible model is a mere chance, dependent on such an infinite of possibilities that it is effectively an impossibility itself.</p><p>thus both neither utilitarian perspective nor one with rooted in understanding dynamics of power is appropriate here.</p><p>i can imagine a third model speckled with hints of sartre and mill — one that suggests maybe all technology is good simply because it expands the realm of individual possibility. if the ultimate goal of humans endeavors ought to be striving towards freedom, then technology is ultimately and only. even the most disastrous technology would be morally good simply because invention is the bosom of possibility: the most terrible and wondrous possibilities.</p><p>these views feel so utterly opposed and yet wonderfully attractive: perhaps the issue with these approaches is to place the individual human subject under the realm of power and the the technologic object under the realm of possibility. this is not a complete separation: it is one that is ultimately connected under a framework through which the question of what makes a technology good or bad is via addressing both the question of power and liberation: separating the power embedded in both the human subject and technological object from it’s material mechanistic composition. then we can say such things as that is both a bad and good invention. this is not merely utilitarianism all over again: it is to say the question of good vs bad is ultimately rooted in power, and the question of power is separate from the question of possibility. asking “is it a good technology” is to ask multiple questions with multiple perhaps opposing answers.</p><p>that does allow for the possibility of us placing blame or guilt on an inventor: either through abusing their level of power, or through ignorantly refusing to acknowledge the systems of power they find themselves situated. intent (and non-intent, as non intent is ultimately intent) matters, in other words. but that applies for every individual human on a merely and ultimately individual level. this means it is also possible to create moral technology through expressing intent, for the expression of intent is a manifestation and realization of the individual moral ethic.</p><p>therefore it is imperative that one strives towards morality and individual freedom even if forced under a framework that seeks to oppress.it is not merely enough to think moral: one must act moral and strive towards morality. in other words: salvation through practice, as the christians among us might say.</p><p>this can be done in the form of speech or through other human forms, for all speech spoke with intent is the expression of individual freedom. freedom is not opposed to biological determinism for freedom is rooted in expanding the realm of possibility continuously. that means of course acknowledging and contending with power constantly. this practice is the ultimate art of humanity even as it contends with itself as to what that means.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86a568391b9a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hack: Update Slack from Google Calendar]]></title>
            <link>https://medium.com/@brettneese/hack-update-slack-from-google-calendar-5fca7643b033?source=rss-8ebc3ad4f813------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fca7643b033</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[slack]]></category>
            <category><![CDATA[lifehacks]]></category>
            <category><![CDATA[hacks]]></category>
            <category><![CDATA[ifttt]]></category>
            <dc:creator><![CDATA[Brett Neese]]></dc:creator>
            <pubDate>Sat, 11 Feb 2017 01:11:45 GMT</pubDate>
            <atom:updated>2017-02-11T01:11:45.690Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<p>I’m one of those people who’s always moving around, but who religiously keeps a calendar so they know where to go and when. I can’t really expect to keep my coworkers to keep track of my movements when I hardly can and constantly redirecting them to my calendar when I disappear randomly has become increasingly annoying. Plus, when I go home I really want to escape from work, and Slack’s Do Not Disturb settings aren’t terribly customizable, something I’ve been whining about for years (at least they finally have DND now!)</p><p>Poking around, I realized this afternoon that Slack provides a full Web API using standard Web RPC methods — and that said API doesn’t even require any particularly fancy authentication (a test token is sufficient), meaning I could trigger updates to Slack directly using <a href="https://ifttt.com/maker">IFTTT’s Maker Channel</a>.</p><p>That means I can use the <a href="https://ifttt.com/google_calendar">Google Calendar channel</a> to skim custom metadata in my Google Calendar events and update Slack as needed.</p><p>When IFTTT finds that an event with a custom tag starts, the <a href="https://api.slack.com/methods/users.profile.set">users.profile.set</a> method updates my last name on Slack like so, appending the event name and the location to my Slack profile:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*Y3H3AD3sjzQxx1pLNCRE5A.png" /><figcaption>There’s a 35-character limit, but all my events fit nicely in that.</figcaption></figure><p>I could also update many of Slack’s fields or custom fields, but they’re not as prominent in the Slack UI, so sticking it there seemed like a good idea. This is actually <em>really</em> easy to configure, and it doesn’t even require writing code.</p><p>First I added custom metadata to the events on my calendar:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*w4FnCOkK0EuSVHILWXpsxw.png" /><figcaption>The Google Calendar channel can search event descriptions, so I can stuff custom metadata here.</figcaption></figure><p>On the IFTTT side, it’s a simple as creating a new Applet, choosing the Google Calendar service and the “Event from Search Starts” trigger. I added that trigger phrase as part of the trigger field:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*6OnYvKZ-AkTpaHTp8jfKJQ.png" /></figure><p>and then selected the Maker service as the target, and “Make A Web Request” as the action. Completing the action fields is as simple as taking the URL from Slack’s API tester…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*rmHI394E1K7LyIynkoGnuA.png" /><figcaption>No, that’s not actually my token.</figcaption></figure><p>…pasting it in the “URL” field, and replacing the “(event)” after the last name with the appropriate custom ingredients:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*nTbx1PrL0uB_0SrlGhRIAw.png" /><figcaption>Make sure to URL escape the field!</figcaption></figure><p>The other fields aren’t even necessary.</p><p>I did the same thing for a whole host of fields and events to turn on and off my Do Not Disturb when I’m at home and to update my presence in Slack when I’m in transit. Here’s the full list of Applets I wired up:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OdrTuznlpjkqx5IUL584XQ.png" /></figure><p>I just wish Slack had custom away/here messages because it was useful for AIM and it’s still useful today.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fca7643b033" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Whole Foods, Mexican Markets, Donald Trump and You]]></title>
            <link>https://medium.com/@brettneese/whole-foods-mexican-markets-donald-trump-and-you-d0f79f0bab08?source=rss-8ebc3ad4f813------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0f79f0bab08</guid>
            <category><![CDATA[mexico]]></category>
            <category><![CDATA[capitalism]]></category>
            <category><![CDATA[philosophy]]></category>
            <category><![CDATA[food]]></category>
            <dc:creator><![CDATA[Brett Neese]]></dc:creator>
            <pubDate>Wed, 08 Feb 2017 05:46:56 GMT</pubDate>
            <atom:updated>2017-02-08T05:49:44.921Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<p>I’m currently sitting in the Chicago Lincoln Park Whole Foods at the corner of Sheffield and Fullerton avenues — two blocks from the heart of DePaul University’s adorably quaint Lincoln Park campus. This Whole Foods is clearly designed specifically to appeal to DePaul’s student population. It has just the right blend of humility and bougieness for the “I’m a gluten-free-organic poor college student” crowd. For reference: its pet name on campus is “Whole Paycheck;” everyone knows that Whole Foods is expensive and overtly preppy. Yet (or because of this) throngs of students still shop here every day.</p><p>I’m one of them, actually: on days when I have class, I’ve been known to visit multiple times per day. Take-out from Whole Foods is often the only thing that could remotely be identified as “food” I’ll eat that day. It’s always just short of terrible — the pizza is cold, or the (expensive) sandwiches fall apart on my lap, leaving me looking like a two-year-old with a spaghetti problem. Yet I savor the meals I’ve eaten at Whole Foods. I look forward to escaping class and running to the automated kiosk, and — with a few taps and what I can only assume is dark magic that happens behind the counter — completely devouring a Chicken Bad Boy five minutes later — and then, of course, rushing right back to my work.</p><p>So sitting here in the Red Star Bar — the epitome of the Whole Foods appeal of convenience <em>and</em> class; slowly drinking — perhaps even slow enough to venture into <em>enjoying</em> — a $3 can of beer while I slowly devour my Chicken Bad Boy — this is a new experience for me. Yet, it’s not a strange one: after all, the appeal of Whole Foods is one that is grounded on a false sense of familiarity. “We always feature local beer on tap” a sign behind the bar loudly declares; suggesting a vibe of “see kids, we’re local just like you!”</p><p>Of course, when you’re here, you’re not supposed to question the fact that you’re <em>drinking beer at a bar in a grocery store.</em> It isn’t supposed to be strange that there’s an advertisement for a storewide wine tasting event. Or that there’s a community board filled with local announcements. Or the calendar — yes, a calendar — of Events at Whole Foods (one can only wonder what kind of Event is special enough to make Whole Foods a Destination).</p><p>No, just “sip, savor, shop.” And shop you will. In the aesthetic universe of Whole Foods — with its cutesy signs, it’s old-timey focus on events and “local food” — Whole Foods is constructing a very specific narrative: one which, like other spaces of late capitalism — Starbucks is another particularly egregious example — uses specific aesthetic elements to posit itself not merely as a commercial space, but as a commodified community space.</p><p>Whole Foods is a suburban wet dream: it’s the repackaging and up-selling of the neighborhood community ideal in a cute, convenient, little package. Within spaces like Whole Foods, what grounds the foundation of the polis: daily interactions with diverse others who inhabit one’s public space; have been transformed into a package to be bought and sold within the bounds of a private space just like another box of Cheerios. This creates a space that renegotiates our relationships with others; transforming deep connection and debate into a series of merely transactional interactions. It should surprise no one that the deepest human interactions within the aisles of Whole Foods are actually mediated through smartphones. It’s not a revolutionary troupe to lambast “filter bubbles,” but what is interesting here is in the way private spaces like Whole Foods embrace a certain kind of dystopian liberal reality: Whole Foods is a space designed for comfort, for convenience, and for alienating — or at the very least, filtering and mediating — essential human interaction.</p><p>This is dangerous, because the commodification of community space is an act of de-politicization, and it is only natural that said de-politicization coincides with the spaces around food. Humans have for our entire existence, gathered around food. There is perhaps nothing more human (and certainly nothing more essential) than eating. Our social spaces are innately tied to our food acquisition and consumption spaces.</p><p>This is not the space for exploring the history of humans and food: I will merely mention that I think a strong argument could be that there is nothing more essentially political than food and the systems around acquiring food. In this light, “who makes food, how food is made, and who eats good food” is actually the central question in our politics. From hunters-and-gatherers to feudal systems to modern neoliberal capitalist systems of control and alienation — this is the critical struggle to fulfill the primal human necessity that is our need and desire to nourish ourselves. Thus to speak of food is precisely to speak of politics.</p><p>In <em>Walden</em>, Henry David Thoreau also pondered Western society’s relationship to food. Chapter one of <em>Walden</em> contains an account of what he ate and how he ate while in his cabin in the woods; mostly, as “simple a diet as the animals;” his narrative spewing a parable that stemmed from a rejection of the systems of food production and focused on self-sufficiency. Thoreau’s journey is one of returning to simple consumption away from the alienation that was prevalent even during his time. Capitalism works to strip us from the process of production; Thoreau wanted to attempt a return to that state prior to alienation; finding that, for instance, it is perhaps possible that we labor more for our meals through capitalism than it would be if we directly tended for our own diets.</p><p>Thoreau also uses this part of his novel to point towards the ways in which the ways we obtain goods quietly shape us into a complicit consumer of unnecessary tastes. Far before <em>Super Size Me</em>, Thoreau is realizing that, for instance, even a staple like salt isn’t terribly critical: <a href="http://thoreau.eserver.org/walden1d.html">“I do not think the Indians ever troubled themselves to go after it,”</a> he notes. This is a prescient realization for Thoreau: think of the amount of destruction, violence and exploitation undertaken in pursuit of a rather unnecessary staple throughout human history. Thoreau’s response to de-politicization in this text is to bring it upon himself to produce and thus understand his own food.</p><p>However, in doing so, Thoreau falls into a similar trap of liberal depoliticization as the average Whole Foods consumer. Thoreau willing neglects the conditions which enable him to remove himself from society in the first place (for instance, his cabin was on land owned by Ralph Waldo Emerson). To his credit, Thoreau’s story isn’t as much a negation of politics as much as it is an <em>ignorance</em> of politics, because politics necessarily concerns itself with the human-among-society. Written in a pre-industrial America, Thoreau simply couldn’t imagine the alienated processes of food production in today’s technocapitalist dystopia.</p><p>But his story precisely represents the liberal American desire towards self-reliance that is ever-enshrined in our capitalist institutions, such as Whole Foods, the latest product in a long process of alienating the populace from this politics in the spirit of consumption. From its inception, the capitalist monster captured the systems of food production and violently separated the consumer from the politics of food. The classical left-wing question of “where does your food come from,” of course, is not a new one; it would not take long for one to find many a book or documentary about the horrid systems of food production in this country; this is a meme that has been pushed by environmental activists and hippies for decades.</p><p>The Whole Foods Promise<strong>™</strong>, however, is that it is focused on selling the solution to these very concerns to “enlightened” consumers who refuse to believe that they (and thus Whole Foods) are exactly the problem. It is performative environmentalism at it’s finest. Whole Foods can never be the solution to neoliberal environmental degradation, but it can certainly <em>sell</em> itself on suggesting that it’s the solution to that problem.</p><p>The key to truly understand how Whole Foods is able to accomplish this feat is to unpack the mechanisms through which Whole Foods operates this trickery: namely, by constructing a certain kitsch aesthetic that appeals to preppy college kids and suburban moms alike. I’m tempted to relate the experience of shopping at Whole Foods to the “dehumanized” vision that sociologist Erich Fromm paints in chapter two of his 1968 work <em>The Revolution Of Hope.</em> Fromm, following other Marxists, was incredibly concerned with the automation of humans in the name of corporate profit. What Fromm forgot in his study, however, is that perhaps a <em>fully</em> realized maximally efficient space isn’t necessarily the most <em>automated</em> space. Humans, at least in the year 2017, still don’t entirely feel comfortable interacting primarily with machines. They want the efficiency, but they want the humanity, too.</p><p>Whole Foods is essentially a Frommian <em>dehumanized</em> space, yet it is completely aware of this potential for discomfort and makes <em>just enough</em> concessions to allow the consumer to feel “natural” in this space. The wide aisles harken towards efficiency: just convenient enough that the shopper can mechanically go about their shopping duties, yet attractive enough to beckon the unassuming consumer towards impulse purchases. Many aisles feature sample jars with food for purchase. Walking through Whole Foods is an experience of extreme cleanliness. Not just sanitary cleanliness — though I dare the reader to attempt to find a splotch of dust on the floor at their local Whole Foods — but <em>aesthetic</em> cleanliness. The signs are painted on chalkboards — clearly intended to project a sense of homely wholesomeness; the lines on the words evoke a friendly messiness and yet are drawn to an aesthetic perfection. They’re so perfect that it’s hard, actually, to write about the perfect imperfection evident at Whole Foods: the space feels as if it is designed to evade analysis. Perhaps it was. This is, after all, the way kitsch works: its art which is constructed precisely to be consumed, not studied or understood.</p><p>Fromm pictured our institutions by 2000 to tend towards a fully automated and thus maximally efficient systems. What actually happened was much worse. Though certain organizations are indeed testing fully automated stores — just pick up and go — historic attempts at this have been unsuccessful for one simple reason: consumers, store managers report, don’t feel <em>comfortable</em> interacting with automated checkout machines. Whole Foods is no doubt aware of this discomfort. Since the goal is to maximize profit, <em>just enough</em> workers pace the floor to pop any feelings of alienation; but any relationship with another human at Whole Foods is merely transactional in nature — after all, robots aren’t necessary when you can teach people to act like them. “We’re not some megalithic remote corporation,” — the space beckons — here, you can get “fine foods — made to order.”</p><p>In Mexico, there are two distinct kinds of public markets: the fixed <em>mercados</em> — <a href="https://en.wikipedia.org/wiki/Popular_fixed_markets_in_Mexico">of which there are over 300 throughout Mexico City alone which house over 70,000 vendors</a> — or the rotating <em>tianguis</em>; open air bazzaars which often take over entire neighborhoods on certain days of the week (there are over 1000 of those in Mexico City) — this, of course, is not counting the shop vendors who flood street corners daily and the vendors who drive around town literally selling vegetables out of the back of a truck.</p><p>When I first arrived in Mexico in 2014, I had thought I would be annoyed by the number of markets and stalls littering the street: after all, it is challenging enough to escape from the capitalist rat race of unnecessary goods and commodities in America; and I had fled the States to escape just that. I, however, quickly noticed something strange: in spite of language and cultural barriers, I was actually far more comfortable in a Mexican <em>mercado</em> than I have ever been in a Whole Foods.</p><p>In spite of ostensibly striving towards the same mission: providing a space for consumers to buy good, fresh food and other items — a Mexican <em>mercado</em> is the polar opposite of Whole Foods. It’s not a clean place — though fairly airy, many floors filled with hundreds of vendors selling everything from tomatoes to cacti to pork to pinatas can quickly overwhelm the nose: and that’s before the tiny restaurants in the middle of the market light up their grills. Vendors shout at passersby, attempting to entice them to shop at <em>their</em> stand. Hand-written signs on bright neon poster board advertise prices specials. Fruits, vegetables, and goods of all colors piled high on carts attack the eye from all directions in spite of the dim lighting. Shopkeepers can be seen diligently adding up prices on calculators — or in their head — and write transaction logs in paper notebooks.</p><p>The Mexican <em>mercado</em> is, and has always been, the heart of Mexican life. In smaller towns, it is often placed right off the town square — and often, that market has been doing business right where it stands since even before Spain wreaked havoc across Mexico. Everyone from kids to parents to abuelos (Mexican grandmas) to restauranteurs source a good portion of their food here: in spite of the prevalence of Walmarts and 7–11’s across the Mexican landscape, fully 65% of foodstuffs in Mexico are sold in a <em>mercado</em>.</p><p>Rather than distancing themselves from their history and their relationships with one another, Mexico has continually embraced their history, traditions, and values and thus their politics every day. A grocery store would not be on a list of tourist attractions anywhere in America; a Mexican mercado is a must-see. And it’s not just food: in larger cities and Mexico City especially, markets are the source for all kinds of home-goods and items from electronics to shoes to quinceanera dresses to live animals to — I’m told if I look closely — guns, passports, and drugs, other counterfeit goods.</p><p>Walking around the La Lagunilla <em>tianguis</em>, which pops up on Sunday mornings around the northern La Lagunilla market and sprawls for tens of blocks, I was greeted by people roaming around with converted grocery carts selling grilled corn (grilled right on a metal plate draped across the shopping cart; the main part filled with charcoal) and mixed drinks (the cups are pre-rimmed, filled with ice, and placed in the baby section of the cart, while the main part of the cart acts as a giant cooler for bottles of beer, lemonade, and Coke.) Lagunilla is equal parts antique market as it is book store; equal parts used electronics market as it is furniture market. It is entirely possible — if one knows what one is looking for — to find rare and valuable artifacts from throughout history on the cheap. Celebrities shop these streets hoping to find rare and interesting items to use to outfit their homes; children enjoy the many Mexican candies offered by the vendors; teenagers buy counterfeit movies for pennies; parents and grandparents buy meat, seafood, and vegetables to cook for the next week.</p><p>These aren’t small markets, either: in fact, they make the giant Walmart they just build in your backyard look like a tiny <em>abarrotes</em> (Mexican bodega.) La Central de Abasto in Iztapalapa — the eastern borough of Mexico City — <a href="https://www.lonelyplanet.com/mexico/mexico-city/travel-tips-and-articles/mexico-citys-best-markets-2">is 1.5 square miles large and sells 300 tons of goods daily</a>; all in cash. Shopping here feels not at all like buying or shopping and not even like trading — but bartering. Daily life in Mexico is about relationships, not transactions.</p><p>This culture permeates Mexico at every corner — even outside of the fixed markets, stands of all kinds fill the streets. And not just taco or torta stands: if there is any way it can be sold in a cart on a street corner, it will be — I have even seen pop-up shacks selling haircuts and cutting keys. I bought the backpack I use today off of some guy on a street corner two blocks from my apartment for $20. Sure, Mexico has its share of Walmarts and supermarkets: in fact, one of the largest chains of grocery stores in Mexico, Superama, is actually owned by Walmart. I will absolutely admit that — too unfamiliar with markets and wanting a quick item I have bought towels and flip-flops, and, after mine caught some rain, even a cheap laptop at a Mexican Walmart.</p><p>But, as the Chilean Poet Pablo Neruda once remarked, “Mexico is in its markets.” This is in stark contrast to the Whole Foodsian or Amazonian vision of automating the process of obtaining one’s necessary items: in Chicago I very often will have Amazon simply deliver most of my goods. That’s not possible in quite the same way in Mexico. Transactions can be automated; relationships cannot.</p><p>I don’t want to suggest that Mexico is a kind of anti-capitalist fantasy land: that somehow “striving to be more like Mexico,” would magically force American technocapitalism out of it’s institutionally-enforced transactional political insularity. Nothing could be further from the truth. For one, of course, a relational — rather than a transactional — system is one strife with what Americans would call corruption. Nor do I mean to suggest that there is nothing that remotely equates to the Mexican markets: if you know where to look in America, this mercantile spirit is alive and well in our farmer’s markets, pop up shops, and fairs. I grew up in the cornfields of Iowa — during the harvesting season, I remember my family driving by random trucks and stands by the highway to pick up the freshest grown corn around.</p><p>In fact, the so-called “middle America,” is probably much closer to the Mexican relationship and tradition-based structures of commerce than the urban and suburban structures of transactions and automation. Iowans pride themselves on helping their neighbors out; it takes a village of friends and enemies alike to raze a burned down barn. But this spirit is disappearing, and it is disappearing as a function of our alienating political relationships with each other. Whole Foods doesn’t want you to know your neighbors or really know your food. It wants you to obey and transact. The rest is mere illusion in pursuit of this aim.</p><p>It may seem as if this simply is because it seems like it’s not possible to scale an economy — indeed, an entire culture built on relationships. But Mexico City is the largest city in the Western Hemisphere — and Mexico’s central valley is one of the largest urban areas outside Asia. It is also one of the most historic and traditional. Perhaps in a post-Trump America — filled with plenty of fluffy discourse about “safe spaces,” “gig economies,” “automation,” “filter bubbles” and other technocratic consequences of political alienation driven by liberal ideologies of self-reliance and individualism — what is needed is to call into question that assumption. Maybe relationship-based cultures — really, communitarian cultures — are, indeed, preferable to liberal technocapitalist ones, even at scale. And these systems may not even be as opposed to the flavors of capitalism at work in the United States as it initially seems.</p><p>Plenty of ink has been spilled about the failure of the Democratic Party in the election of 2016 to embrace or even listen to “middle America.” Plenty more documentaries have been filmed criticizing our fast food restaurant and factory farms. Tons of people — from Thoreau to Fromm to Slavoj Žižek have written treatises bemoaning liberal alienated technocapitalism. Very few have offered a terribly pragmatic road to an alternative. Why not start with revolutionizing the spaces around food?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0f79f0bab08" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>