{"@attributes":{"version":"2.0"},"channel":{"title":"Kay Lyon, computer genius extraordinaire","description":"Writing about tech and social issues mainly.","link":"https:\/\/killtheradio.net\/","pubDate":"Tue, 01 Dec 2026 00:31:15 +0000","lastBuildDate":"Tue, 01 Dec 2026 00:31:15 +0000","generator":"Jekyll v4.0.1","item":[{"title":"Stamp protocol: a p2p identity system","description":"<p>If you follow my work much, you\u2019ll know I\u2019m working on <a href=\"https:\/\/basisproject.net\/\">Basis, a project with the end goal of supporting a post-capitalist economy.<\/a> I recently decided to move from the theory of the project into a more concrete implementation. But how? A few years back, I would have reached for blockchain tech but I\u2019ve recently become increasingly suspicious of blockchains as a means for building distributed systems. Their reliance on global consensus means I have to \u201cagree\u201d that a transaction between a fisherman and a street vendor in a coastal town somewhere in Italy is valid\u2026in truth, I don\u2019t give a shit. Let them figure it out. It doesn\u2019t scale and it never will. Blockchains are the ultimate rule-by-committee system where every decision has to be ratified by every participant. Kind of useless for anything beyond banks clearing transfers or dicks scamming idiots with NFTs.<\/p>\n\n<p>So the next choice is some kind of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Peer-to-peer\">p2p system<\/a>. If constructed properly, these systems can scale almost infinitely. However, control mechanisms need to be in place. If some actions in a p2p network protocol are not allowed, who makes sure they aren\u2019t happening? Projects like <a href=\"https:\/\/www.holochain.org\/\">Holochain<\/a> try to solve this, and have made decent headway in doing so. In fact, I\u2019ve long followed the Holochain project and been interested in using it for Basis or even <a href=\"https:\/\/turtlapp.com\/\">Turtl<\/a>.<\/p>\n\n<p>One thing that just bugs me about Holochain \u2013 and every other p2p system I\u2019ve run into \u2013 is that your <em>identity<\/em> in the system is tied to a single cryptographic key. This key is <em>you<\/em>: and if the key is lost, \u201cyou\u201d no longer exist in the system. This doesn\u2019t end here, though. The \u201cyou\u201d key is generated once on one of your devices and forever after lives just on that device with no built-in way to sync it to your other devices. This means there\u2019s a different \u201cyou\u201d on your phone, laptop, etc.<\/p>\n\n<p>Identity in p2p systems has always been an afterthought.<\/p>\n\n<h2 id=\"stamp-was-born\">Stamp was born<\/h2>\n\n<p>I originally thought of Stamp as a way to cryptographically provide personal identity within a network. It\u2019s much like <a href=\"https:\/\/en.wikipedia.org\/wiki\/Pretty_Good_Privacy\">PGP<\/a> in that it works by using cryptographic keys as mechanisms for managing the identity. You can make claims, and others in the system can \u201cstamp\u201d (verify) your claims by signing them. This creates what\u2019s known as a \u201cweb of trust.\u201d If I trust Joe, and Joe stamps Jill\u2019s identity, I can now extend a bit of trust to Jill.<\/p>\n\n<div class=\"center padded\">\n    <img src=\"\/images\/uploads\/stamp-logo.svg\" alt=\"Stamp protocol logo\" \/>\n<\/div>\n\n<p>Stamp differs from existing key-based identity systems in a few ways, however. It allows creating claims that can be automatically verified, such as the ownership of a domain or URL. It allows claims to be named, opening the door for discovery in other distributed systems (ie, maybe I have an \u201cactivitypub\u201d URL claim that points to my Mastodon account).<\/p>\n\n<p>Another difference is identities in Stamp are not singular objects, but rather collections of \u201ctransactions\u201d that are issued by the owner. These transactions link back to previous transactions, creating what\u2019s known as a directed acyclic graph (DAG). This structure allows for auditability, versioning, and easy verification.<\/p>\n\n<h2 id=\"identity-management\">Identity management<\/h2>\n\n<p>Of all the differences between Stamp and other identity systems, the most important is that a Stamp identity is not controlled by a single key. Instead, identities have a set of \u201cadmin\u201d keys that are assigned abilities using what are known as \u201cpolicies.\u201d Effectively, a policy is a set of permissions granted to a key or set of keys, allowing those keys to perform certain actions if they are used in the correct combinations.<\/p>\n\n<p>But why the complexity? Because it opens the door for another paradigm: group management of identities. Now instead of having to build a permissioning system around a singular key that allows someone in a group to create a signature on behalf of an identity, Stamp incorporates the permissioning system directly in the protocol. Policies can grant keys <em>outside of the identity<\/em> the ability to perform actions within the identity, so before Jill can sign a purchase order on behalf of the company, she needs to get approval from Ted in accounting.<\/p>\n\n<p>It doesn\u2019t stop at group management, though! One of the most significant problems with existing identity systems is that because they are managed by a single key, if that key is lost then the identity is useless. Stamp solves this: the policy system allows you to specify a recovery mechanism for your identity. You can set up a policy that says \u201cmy spouse, brother, and any one of three friends can sign a key replacement transaction\u201d and if you get the correct signatures, you regain access to your identity again. Not bad.<\/p>\n\n<h2 id=\"syncing-and-storage\">Syncing and storage<\/h2>\n\n<p>Instead of forcing an identity to live on one device and making someone run a bunch of ugly CLI commands in a terminal to move their key to another device, Stamp has built-in private identity syncing for your devices. Although not part of the core identity protocol, the project itself has a layer for keeping your identity synced between your devices.<\/p>\n\n<p>Included in this syncing, which is accomplished by setting up a p2p network, is public storage of published identities. So ditch those broken GPG key servers\u2026from now on, you only have to look in one place for published identities, and if you\u2019ve got an internet connection, you can look up an identity.<\/p>\n\n<h2 id=\"identity-in-p2p-systems\">Identity in p2p systems<\/h2>\n\n<p>Ok so I\u2019ve been blathering on and on about this great new identity system. What\u2019s it good for, actually? Remember how I mentioned a Stamp identity is a collection of transactions? Well, turns out, it can issue transactions for things other than just ones that modify the identity.<\/p>\n\n<p>In fact, Stamp can issue any kind of custom transaction in the same envelope that lets any system that can speak \u201cStamp\u201d verify that the transaction is valid (when I say \u201cvalid\u201d I mean that the transaction is signed by the key(s) required to issue it via the policy system). This means that a Stamp identity can act as a multisig system for issuing transactions <em>in other p2p systems<\/em>. In effect, p2p systems no longer have to build a concept of identity because Stamp is handling it all for them.<\/p>\n\n<p>The ability to perform multisig external operations is instrumental for <a href=\"https:\/\/basisproject.net\/\">Basis<\/a> because much of the protocol relies on the ability for groups of people to act as singular economic entities.<\/p>\n\n<h2 id=\"whats-next\">What\u2019s next?<\/h2>\n\n<p>The Stamp core protocol is mostly complete at this point. I\u2019m currently working on the network layer of the system: private syncing and publishing. Private syncing is being built in mind with other systems in mind: the next version of <a href=\"https:\/\/turtlapp.com\/\">Turtl<\/a> is going to be a p2p system and I\u2019m trying to generalize things in Stamp\u2019s networking layer enough to support Turtl\u2019s need for person-to-person sharing.<\/p>\n\n<p>Basis has somewhat different requirements though: in effect, groups in Basis have cost allowances that they need to keep their costs under. If they make an order that increases their costs past their allowance, the transaction creating that order is invalid. How do we enforce this effectively? This is a topic of thought for me, and likely involves some sort of federated verification network within the larger p2p system. This is one of those places people reach for a blockchain, and rightly so, however I\u2019d like Basis to be able to run more than 10 transactions a minute so an alternative is needed.<\/p>\n\n","pubDate":"Tue, 12 Dec 2023 00:00:00 +0000","link":"https:\/\/killtheradio.net\/technology\/stamp-protocol\/","guid":"https:\/\/killtheradio.net\/technology\/stamp-protocol\/","category":["identity","p2p","Technology"]},{"title":"The property \"ownership\" myth (and other thoughts on socialization)","description":"<p>It was getting dark, and starting to rain. You needed a place to stay. Not just for the night, but a place to call your own after living under other people\u2019s roofs for so long. You\u2019re tired of moving, tired of the journey. You want to put down roots.<\/p>\n\n<p>By strange coincidence, a stranger approaches you and says \u201cSee that house over there? I\u2019ll sell you the house and the property it\u2019s on for $50K.\u201d You have the money, you\u2019ve saved up for a long time. You agree.<\/p>\n\n<p>\u201cThere\u2019s just one or two more things,\u201d says the stranger. \u201cYou can\u2019t make significant modifications to the property without asking me first.\u201d It seems reasonable, so you agree. \u201cAny large-scale projects you wish to do on the property must be cleared by me,\u201d stated the stranger. \u201cAnd lastly, at any point, if I ever need the property for something, I can take it back from you, and if I do this I will pay market value\u2026but you cannot refuse.\u201d It struck you as odd, but you agree and buy the property.<\/p>\n\n<p>Do you own it?<\/p>\n\n<h2 id=\"property-ownership-in-the-united-states\">Property ownership in the United States\u2026<\/h2>\n\n<p>\u2026is a myth. Nobody owns (land\/\u201dreal\u201d) property. What people own is a title of use of property, but the property itself is jointly owned between cities, counties, states, and the nation. I\u2019ve had this argument several times with many people, and none of them can reconcile \u201cownership\u201d with the fact that:<\/p>\n\n<ul>\n  <li>You often need to get government approval to modify an existing structure on property<\/li>\n  <li>You need government approval for large-scale projects on property (building any kind of large structure, digging a mine, etc)<\/li>\n  <li>Most importantly, the government can take your property away from you via Eminent Domain whenever it deems it necessary (you being compensated is irrelevant to the fact that you have no choice)<\/li>\n<\/ul>\n\n<p>You <em>do not own<\/em> the property you \u201cown\u201d but rather own a title of use, and that title comes with various restrictions. If you can prove me wrong, please feel free to comment below, but to my understanding, if someone gives you something but has the ability to take it away from you at any point, you do not own it.<\/p>\n\n<p>It gets interesting with things like a civil suit in which being on the losing end means some amount of your assets being seized. Did you own those assets to begin with? It\u2019s an interesting question, but ultimately I would say you <em>did<\/em> own those assets, but through some form of wrongdoing via your own action\/inaction lost access to them, via some socially-mandated set of rules that come along with social or economic interaction with other people.<\/p>\n\n<p>That said, the fact that you can lose your property <em>without wrongdoing<\/em> and <em>just because the government wants it<\/em>, to me, points to the fact that the property was not yours to begin with.<\/p>\n\n<h2 id=\"why-does-this-matter\">Why does this matter?<\/h2>\n\n<p>This matters because given that property is not owned individually, it follows that property is socialized. In the context of a market system, it means that when you buy\/sell property, you\u2019re really just selling the title for use of the property, not the property itself.<\/p>\n\n<p>So when talking about socialization of productive property or housing, nothing regarding ownership changes materially: the ownership of property is already socialized! What changes is the mediation of the use of property. What this mediation looks like without markets and how it works is another very interesting but complex set of ideas (which are outside the scope of this post).<\/p>\n\n<p>However, the next time someone says that socialization of property is totalitarian or \u201cdoesn\u2019t work\u201d or some such nonsense, tell them that all property is <em>already<\/em> socialized and ownership is a myth.<\/p>\n\n","pubDate":"Fri, 10 Apr 2020 00:00:00 +0000","link":"https:\/\/killtheradio.net\/economics\/property-ownership-myth\/","guid":"https:\/\/killtheradio.net\/economics\/property-ownership-myth\/","category":["economics","capitalism","socialism","property","economics"]},{"title":"The Five Components of Economic Systems: A discovery through explorations of Socialism","description":"<p><em>As an opening note, I\u2019d like to mention that while I came to the conclusions discussed in this post while researching what a \u201csocialist mode of production\u201d would look like, I\u2019m attempting to the best of my abilities to not argue for one system or another. Rather, my goal is to share my findings on how economics can be broken down.<\/em><\/p>\n\n<hr \/>\n\n<p>It was December 2018. I had recently read through a forum discussion about <a href=\"https:\/\/en.wikipedia.org\/wiki\/Basic_income\">Universal Basic Income<\/a>, an idea I supported at the time. One of the comments mentioned how socialists view UBI as a band-aid fix.<\/p>\n\n<p>\u201cWait,\u201d I thought. \u201cIsn\u2019t UBI a form of socialism?\u201d I realized that even though my past 18 year old self had donned the label <em>anarcho-communist<\/em>, I didn\u2019t actually know what that meant, other than \u201cthings should, like, be more equal.\u201d I had left anarcho-communism behind in my 20s when I came to the realization that capitalism <em>does work<\/em> and became a supporter of it. But for some reason, when this last December rolled by, I connected with my old self again. You see, I have a problem. An addiction. I need to know how things work. It\u2019s why I know a several forms of assembly language. It\u2019s why I have a drawer full of deconstructed electronic components. I can remember my dad tell me as a kid: \u201cDon\u2019t take this apart!\u201d. And now I needed to know what socialism meant; to deconstruct it and understand it. In our culture, the things we most attribute to socialism (state capitalism and welfare capitalism) have nothing to do with socialism. So what is it?<\/p>\n\n<p>Then it started. A strange manic episode which seemed to come from nowhere. For weeks, I was waking up after only four or five hours of sleep. I would open my eyes, the sky would still be dark, and I was exhausted, but my head was racing. I used my early mornings to my advantage: reading papers, researching economic theory, architecting systems, thinking through methods and incentives. I swam through ideas like I had woken up at the bottom of a lake and needed air: libertarian socialism, central planning, free association, market socialism, common ownership, democratic socialism, communism, syndicalism, social dividends, collectivist anarchism. Marx, Kropotkin, Cockshott. USSR, China, Cuba, South America, the Spanish Civil War. A raging torrent of information, history, and theory. I found a <a href=\"https:\/\/www.reddit.com\/r\/CapitalismVSocialism\/\">subreddit where people argue bitterly about economics<\/a>. I talked with people and I fought with people, socialists and capitalists alike. I formed opinions. I talked more. I fought more. I asked questions. I reshaped all my opinions. Then I did it all again.<\/p>\n\n<p>The whole time, I was working on a project that would be the ultimate conclusion of my findings (which I will publish at a later date). This work has ushered me into a deeper understanding of how things are organized and how the pieces of economics all fit together.<\/p>\n\n<h2 id=\"the-five-components-of-economic-systems\">The five components of economic systems<\/h2>\n\n<p>I ultimately found that there are five main components that describe an economic system. Because these are not apparently obvious, I thought it would be helpful to document my observations:<\/p>\n\n<ul>\n  <li><strong>Ownership<\/strong>. This is the crux of the capitalism vs socialism debate. Capitalism necessitates private ownership of the means of production. Socialism is the social ownership thereof. This means capitalism simpler: anything can be privately owned. Socialism is a bit more complicated, because it makes a distinction between <em>private<\/em> property (factories and stuff) and <em>personal<\/em> property (your hat, your Roomba, your toothbrush). This distinction is lost on many people (aka the \u201cyou want to take my toothbrush\u201d problem).<\/li>\n  <li><strong>Organization<\/strong>. Is the economy completely decentralized and self-organizing? Or is there one entity that plans every input and output down to meticulous detail? It\u2019s important to note that the former is attributed to capitalism, and the latter to socialism. This is mainly because most Marxist-Leninist states employed central planning for their economic system. But central planning is not socialism\u2026social ownership of productive property is. It\u2019s possible to have privately-owned production with heavy central planning (for instance, Nazi Germany). It\u2019s possible, in theory, to have socially-owned productive instruments with a small (or no) government. We also have central planning in the United States (NASA, farm subsidies, etc).<\/li>\n  <li><strong>Costs\/valuation<\/strong>. Valuation can be done with prices guided by market forces, which is the mode we\u2019re all used to because it\u2019s how capitalism does things. However, there are more methods of valuation. There\u2019s the Marxian value theory in which a thing is valued at the average amount of labor it took to build it. There is in-kind valuation, where all possible aspects of costs are tracked for a particular item (for instance, the labor that went into it, how much of each raw material, externalities if possible, etc). It\u2019s important to note that cost and value are different: there is some intersection between the two, but value might ignore a cost like pollution, and cost might not take into account how something is valued to a particular individual.<\/li>\n  <li><strong>Exchange<\/strong>. What medium do productive entities use to exchange? Money is the most prevalent one. There are other ideas, though, such as the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Free_association_(Marxism_and_anarchism)\">free association of producers<\/a>, where exchange happens freely\u2026producers order things from other producers in order to meet some social need. If using central planning, exchange would look like an internal transfer might look at a large corporation.<\/li>\n  <li><strong>Distribution<\/strong>. Who gets what? If using a money system, those with money buy what they want. If using gift economics, distribution might be a function of reputation. If labor vouchers, distribution is a function of hours worked (and possibly the social value of that labor). In some systems, distribution is need-based (\u201cto each according to their needs\u201d\u2026I realize this is loosely defined). Distribution could be ration based as well: each person gets a daily allowance of resources they can consume. It\u2019s important to note that the distribution mechanism is also what puts downward pressure on resource consumption <em>and<\/em> incentivizes higher levels of efficiency in the productive process: producers must make things in such a way that those who want those things can afford them.<\/li>\n<\/ul>\n\n<p>In theory, some of these parts can be swapped out for another. Also, few of these categories are binary: you can have some mix of public\/private ownership, or some mix of decentralized\/central planning. However, note that money can be used in a number of these economic components. This is a beautiful selling point of moneyed capitalism, but also what makes it hard to pick the above concepts apart: it\u2019s simple. Anyone can own anything, and valuation\/exchange\/distribution are all based on money.<\/p>\n\n<p>Also, notice we\u2019re missing the authoritarian aspect here completely. This is on purpose. Economics and authoritarianism are completely separate topics, as much as people like to lump them in together. It\u2019s possible to have a totalitarian government with privately-owned production. It\u2019s possible to have a tiny government with social ownership of production.<\/p>\n\n<p>Let\u2019s clarify some ideas.<\/p>\n\n<h3 id=\"ownership\">Ownership<\/h3>\n\n<p>I\u2019d like to talk about the concept of ownership. I think it\u2019s important to mention because it\u2019s a deep topic of debate between proponents of socialism. What does it mean to have \u201ccommon ownership over the means of production?\u201d What even are the \u201cmeans of production?\u201d<\/p>\n\n<p>For the productive instruments to be socially owned, there are a number of different ideas. First, the most common understanding is state ownership. This is tricky, though. If the state is representative of the people in it, then by the state owning the means of production, the people do as well. However, if a state is authoritarian such that the citizens have very little control, then the productive instruments are not held in common, but rather owned by oligarchs. This is in contrast with more anarchist ideas, in which ownership of means of production is <em>directly<\/em> social, as in, not proxied through a state (or perhaps, in the libertarian case, owned by a municipality) and use thereof is determined cooperatively.<\/p>\n\n<p>Then, there\u2019s the \u201cmeans of production\u201d themselves. There are as many definitions of this as there are socialists, but one common theme I\u2019ve seen over and over would be large capital assets: raw materials\/resources, productive land (farms), factories, warehouses, office buildings, air\/sea ports, large machinery, and intellectual property. Essentially, anything that\u2019s used <em>exclusively<\/em> for productive purposes would be a target for social ownership. It would be <em>possible<\/em> to socialize laptops and toothbrushes and things of that nature, but it likely would not be very effective at all.<\/p>\n\n<p>Lastly, let\u2019s talk companies themselves. Socialism necessitates abolishing private ownership of companies. What does this mean, though? Does the state own all companies? Do the employees? The answer is it depends. In some models (such as central planning), yes, the state would own, or at least orchestrate, all companies. In other systems, companies would be self-determined and would be state-agnostic. It\u2019s important to note that just because the <em>means<\/em> of production are socialized doesn\u2019t mean that the companies using those means of production need to be socialized as well.<\/p>\n\n<h3 id=\"organization\">Organization<\/h3>\n\n<p>Another important topic is how the economy is organized. It\u2019s often thought that decentralized organization cannot work without prices\/profits. I\u2019d like to demonstrate that as theoretically false.<\/p>\n\n<p>If you have a transparent system that allows orders between productive entities (for instance, some kind of blockchain), demand can be measured directly by looking at the order list. Instead of, then, using price signals to determine supply levels, supply can be matched directly to demand.<\/p>\n\n<p>In other words, money is a <em>method<\/em> of exchange between productive entities, but it\u2019s not <em>the only<\/em> method of exchange. Organization is as much about communication of needs as it is about a means of exchange: if needs can be communicated directly, then distributed production can be enabled, no matter what valuation system (or system of exchange) is used.<\/p>\n\n<hr \/>\n\n<p>That wraps things up. I hope reading this was as illuminating to you as it was for me to discover it.<\/p>\n\n","pubDate":"Fri, 13 Sep 2019 00:00:00 +0000","link":"https:\/\/killtheradio.net\/economics\/components-of-economics\/","guid":"https:\/\/killtheradio.net\/economics\/components-of-economics\/","category":["economics","capitalism","socialism","distribution","value","economics"]},{"title":"The mystification of pricing","description":"<p>Pricing is an important economic tool. How much things cost, and <a href=\"https:\/\/en.wikipedia.org\/wiki\/Socialist_calculation_debate\">how much things should cost<\/a>, has been a subject of debate between economists for a long time. However, there\u2019s one part of pricing I\u2019d like to dissect. It\u2019s the aspect of mystification.<\/p>\n\n<p>When I buy a product, it sends a signal. It\u2019s essentially an economic feedback mechanism that says \u201cI value this product as much or more than the price that it is being sold for.\u201d This signal is transmitted back to the producer (sometimes over many hops of the economic network because usually you buy a product from a distributor, not directly from the manufacturer). However, the producer does not know <em>why<\/em> I bought it.<\/p>\n\n<p>The price takes into account many different factors: the inputs to production required to make the product, the wages of the people producing it, the marketing budget to convince people to buy it, the costs of compliance with regulations, the need to pay back interest on loans acquired for startup capital, shipping costs, etc etc. There are likely thousands upon thousands of factors that are bundled into the price of a product.<\/p>\n\n<p>The problem is, we don\u2019t know what they are. When I buy something, I am saying \u201cI like this for some reason\u201d and that\u2019s the only <em>economic<\/em> signal the producer receives. I can call them and say \u201cHey, I love your peanut butter because it tastes better than others\u201d and companies will certainly encourage this, but there is no economic feedback mechanism other than the purchase itself.<\/p>\n\n<p>So, if labor costs $5, the inputs to production cost $3, marketing is $1, and the owner of the company wants a profit of $3, that\u2019s <code class=\"highlighter-rouge\">5 + 3 + 1 + 3 = 12<\/code>. Now, as a consumer, how do I tell how much the labor cost for this product? Or how much profit was made? It\u2019s impossible. You can only find one by knowing all of the others.<\/p>\n\n<p>Why is this a problem? It\u2019s a problem because people encourage voting with capital. They encourage spending based on beliefs. But, there\u2019s no economic feedback mechanism in place to vote for <em>just one<\/em> of the factors of the price of a product.<\/p>\n\n<p>Imagine if you had deconstructed pricing for every product. Instead of $5.99 it had $0.03 in environmental compliance, $0.50 in marketing, $1.00 in wages (with a breakdown of labor-hours averaged per-worker), $0.60 in productive inputs (and each input had a deconstructed price as well), $1.67 in equipment maintenance, $0.98 for reinvestment in the company, and $1.21 in profit for the owners.<\/p>\n\n<p>Now, pricing is demystified. You can buy a product produced by people who are paid well, or buy products that are made from products made by people who are paid well. You can buy a product that spends more in order to care for the environment. You can buy products that value profit less.<\/p>\n\n<p>Would this not be a a requirement of voting with your dollar?<\/p>\n\n<hr \/>\n\n<p>This thought experiment came out of discussions I\u2019ve have around an economic model I\u2019m working on. One of the ideas I\u2019m interested in is wages being decided democratically based on a set of attributes: social need, skill\/training required, stress level, danger, etc. Essentially, each attribute would be a value between 0 and 1, and the average of all the attribute values multiplied by a maximum wage would be someone\u2019s hourly wage. A productivity attribute could be applied to each person such that their occupational wage goes from being fixed to being a range instead, and this productivity rate would be decided by the worker (if self-employed) or the members of their company. The wage attributes would be decided regionally (per-city\/county).<\/p>\n\n<p>In essence, you give every industry-occupation pair a score and use it to determine the range of wages a person can have. After that, you let the pricing system take over. The purpose here is for society to make a conscious decision on \u201cwhat this job is worth.\u201d My theory is that the economy would be shaped very differently if people were given a direct choice. Want smarter children? Raise the need for the education industry and for the teacher occupation. Too many tech dorks on scooters? Lower the social need for computer programmers. Making wages a conscious decision of the members of the community allows them to shape their own economy, without having to deal with the wildly inaccurate pricing system and the feedback loops of the market.<\/p>\n\n<p>Should a pro football player be paid 500x more than a teacher? I\u2019m willing to bet that if you asked every single person in the United States this question, the answer would overwhelmingly be \u201cno.\u201d Why, then, does the market enforce these patterns?<\/p>\n\n<p>After discussions, this idea of democratically setting wages was met with some resistance. It was argued that the market already does allow democratization of wages. People <em>do<\/em> vote for salaries already, and they do it via the products and services they buy. However, after some thinking, I realized this isn\u2019t true. People certainly enforce economic patterns via their spending, but the truth is that, even if they <em>did<\/em> want to alter their spending to shape the economy according to their desires, they simply <em>do not have the information they need to do so<\/em>.<\/p>\n\n<p>This is because of the mystification of pricing.<\/p>\n\n<hr \/>\n\n<h2 id=\"update---feb-12-2020\">UPDATE - Feb 12, 2020<\/h2>\n\n<p>It\u2019s important to note that I\u2019ve since abandoned the idea of democratically-decided wages. While the idea was made in good faith, I couldn\u2019t solve for things like<\/p>\n\n<ul>\n  <li>On call\/emergency hour rate hikes. Sure, my day rate is $100\/hr, but if you need me at 3am on the weekend, it\u2019s $200\/hr<\/li>\n  <li>Scale. What does a musician make for performing gigs? What if they are playing shows for 1000+ people?<\/li>\n  <li>Distributed decision making. My skills might be highly valued, and forcing a wage on someone when their time is worth more (both to them and the other party) is needlessly authoritarian. Shouldn\u2019t the level of stress, danger, need, training, etc be decided by <em>me<\/em> and not the general population, who knows jack shit about my job?<\/li>\n<\/ul>\n\n<p>I believe all of the problems that might be solved by democratic wages would actually be better handled by democratic workspaces (worker-owned companies) and free association. Not only that, but an excessive amount of beureaucracy is removed (no need to vote just to set wages). While I still support a profitless economy, it should work within the confines of workers being able to negotiate their own wages.<\/p>\n\n<p>The other stuff I wrote about pricing in the post still stands, however.<\/p>\n\n","pubDate":"Tue, 02 Apr 2019 00:00:00 +0000","link":"https:\/\/killtheradio.net\/economics\/the-mystification-of-pricing\/","guid":"https:\/\/killtheradio.net\/economics\/the-mystification-of-pricing\/","category":["economics","wealth","capital","pricing","wages","economics"]},{"title":"How to really save Net Neutrality","description":"<p>Net Neutrality is a hot topic in the United States. On the one hand, you have\npeople claiming that government should stay out of the internet. On the other\nhand, you have people claiming that the internet is much too important to\nleave in the hands of a few immense telecoms.<\/p>\n\n<h2 id=\"what-is-net-neutrality\">What is Net Neutrality?<\/h2>\n\n<p>Net Neutrality is fairly simple. There are many people who will tell you it\u2019s\nthe \u201cgovernment controlling the internet\u201d or \u201cObamacare for the internet.\u201d This\nis useless propraganda.<\/p>\n\n<p><em>Net Neutrality is the idea that all traffic is treated the same<\/em>, regardless of\nits source or destination. From the college student looking at cat photos to the\ngovernment contractor submitting plans for a new missle prototype: if it\u2019s going\nover the internet, the packets carrying the information are treated the same.<\/p>\n\n<p>That\u2019s it.<\/p>\n\n<p>Why is this important? Well, Comcast has a service, Stream, that competes with\nNetflix. There are two ways to make money by sidestepping Net Neutrality:\nComcast can tell Netflix \u201cpay us a buttload of money every year or we\u2019ll make\nsure your little streaming service is unusably slow for our customers.\u201d Netflix\nnow has to pony up or lose a large segment of paying customers. On the flipside,\nComcast can throttle Netflix and start marketing their Stream service so their\ncustomers will more naturally flock away from Netflix.<\/p>\n\n<p>That\u2019s one example. There are a number of things telecoms can do if Net\nNeutrality is not enforced:<\/p>\n\n<ul>\n  <li>Throttle competing services<\/li>\n  <li>Sell tiered internet plans:\n    <ul>\n      <li>$50 for Basic (Google, Facebook, Twitter)<\/li>\n      <li>$70 for Premium (Basic + CSS, Fox, and 12 other news websites)<\/li>\n      <li>$120 for Platinum (all websites)<\/li>\n    <\/ul>\n  <\/li>\n  <li>Block websites outright.<\/li>\n<\/ul>\n\n<p>Looks bleak.<\/p>\n\n<p>The principals of Net Neutrality are clearly pro-consumer. Having equal access\nto all information on the internet without any kind of gatekeeper forcing you\ninto various acceptable pathways is what our country is about: open exchange of\nideas.<\/p>\n\n<p>So why don\u2019t telecoms enforce Net Neutrality?<\/p>\n\n<h2 id=\"the-problems-with-the-internet-in-the-us\">The problem(s) with the internet in the US<\/h2>\n\n<p>Most big telecoms abhor Net Neutrality as they see it as a barrier to their \nprofit margins. They don\u2019t want to treat traffic equally, going so far as to say\nit hinders their free speech.<\/p>\n\n<p>But won\u2019t the free market solve this problem? The answer is \u201cnot really.\u201d The\nfree market, as it exists in its current climate, <em>has<\/em> solved this problem. We\nare already looking at the solution: A handful of large players, dividing up\nservice areas on gentleman\u2019s agreements, effectively self-enforcing a\none-company-per-area monopoly for any given town. In essense, there is no choice\nin ISP, other than to move to another town.<\/p>\n\n<p>Another problem is that given that these companies act as gateways to the\nworld\u2019s online information, they are given cash infusions by various governments\nin order to expand their networks. <a href=\"http:\/\/irregulators.org\/bookofbrokenpromises\/\">These expansions either don\u2019t happen at\nall or if they do, are miniscule compared to the promises made<\/a>.<\/p>\n\n<p>In the cases where people decide their town should build fiber lines that are\ntruly owned by the public, the telecoms will <a href=\"http:\/\/www.latimes.com\/business\/hiltzik\/la-fi-hiltzik-cable-municipal-broadband-20160812-snap-story.html\">file suit and run propaganda\ncampaigns in the towns<\/a>\nin order to fight what is essentially free-market competition (with a\nmunicipality entering the market as a competitor).<\/p>\n\n<h3 id=\"summary\">Summary:<\/h3>\n<ul>\n  <li>Telecoms are monopolies in the US. There is no \u201cchoice\u201d in most locations.<\/li>\n  <li>Telecoms block any competitive choice through collusion or through passing\nlegislation blocking municipal broadband.<\/li>\n  <li>The people of the US have invested billions in telecom infrastructure, but\nare told we have no choice when deciding the flow of information through the\nnetworks we\u2019ve invested in.<\/li>\n<\/ul>\n\n<h2 id=\"the-solution-municipal-fiber\">The solution: Municipal fiber<\/h2>\n\n<p>Net Neutrality has been ping-ponging in the FCC for a while now. Things were\nlooking good with Wheeler in charge. Now things look dark with Pai. If there is\na decisive win either way, the battle will move to congress. Telecoms are\npouring money by the truckload into their anti-Net Neutrality campaigns. At the\nsame time there are a vocal group of people fighting to protect NN.<\/p>\n\n<p>The battle will rage tirelessly for years to come unless we change our methods.<\/p>\n\n<p><strong>We need to move the battle out of the federal government and into local\nmunicipalities.<\/strong> We need to crush the telecoms with public infrastructure. We\nneed fiber in our towns, and LTE towers in our rural areas, all publically owned\nand operated. Then we can rent out the infrastructure to whoever wants to\ncompete on it.<\/p>\n\n<p>This creates a level playing field for true competition, while putting the\nsupporting infrastructure where it belongs: in the hands of the public. We have\nmunicipal roads. We have municipal water. We have, in many places, municipal\npower.<\/p>\n\n<p><strong>It\u2019s time for municipal fiber.<\/strong><\/p>\n\n<p>This will end the stranglehold telecoms have on our information. It allows the\nfree market to solve the issue of Net Neutrality through competition, making it\nsomething that no longer needs regulatory protection.<\/p>\n\n<p>The Net Neutrality activists win. The free market fundamentalists win. The only\nlosers are the entrenched powers that are squeezing your wallet while tightening\ntheir grip on the flow of information.<\/p>\n\n<p>Talk to your city\/county\/state representatives about municipal fiber.<\/p>\n\n","pubDate":"Fri, 27 Oct 2017 00:00:00 +0000","link":"https:\/\/killtheradio.net\/technology\/how-to-really-save-net-neutrality\/","guid":"https:\/\/killtheradio.net\/technology\/how-to-really-save-net-neutrality\/","category":["net neutrality","internet","free speech","Technology"]},{"title":"Debug comments (or how to save your sanity using git)","description":"<p>A lot of times when I\u2019m programming, I need to write a few lines of code that\ntest what I\u2019m working on. This can be a top-level function call, a few log\nentries, etc. Much to my dismay, I tended to end up with this debug code\ncommitted to git.<\/p>\n\n<p>I decided I <a href=\"https:\/\/www.youtube.com\/watch?v=7wqWyLb8Vvo\">wasn\u2019t going to take it anymore<\/a>.<\/p>\n\n<h2 id=\"gits-pre-commit-hook-to-the-rescue\">Git\u2019s pre-commit hook to the rescue<\/h2>\n\n<p>Now, whenever I add one of these lines, I mark it with a special comment:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-javascript\" data-lang=\"javascript\"><span class=\"nx\">console<\/span><span class=\"p\">.<\/span><span class=\"nx\">log<\/span><span class=\"p\">(<\/span><span class=\"dl\">'<\/span><span class=\"s1\">the value is: <\/span><span class=\"dl\">'<\/span><span class=\"p\">,<\/span> <span class=\"nx\">val<\/span><span class=\"p\">);<\/span>     <span class=\"c1\">\/\/ gee, sure hope i don't commit this<\/span><\/code><\/pre><\/figure>\n\n<p>becomes<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-javascript\" data-lang=\"javascript\"><span class=\"c1\">\/\/ DEBUG: remove this log entry<\/span>\n<span class=\"nx\">console<\/span><span class=\"p\">.<\/span><span class=\"nx\">log<\/span><span class=\"p\">(<\/span><span class=\"dl\">'<\/span><span class=\"s1\">the value is: <\/span><span class=\"dl\">'<\/span><span class=\"p\">,<\/span> <span class=\"nx\">val<\/span><span class=\"p\">);<\/span><\/code><\/pre><\/figure>\n\n<p>Then in my pre-commit hook, I symlink a script that checks for <code class=\"highlighter-rouge\">DEBUG<\/code> comments\nin various languages for that repo:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-bash\" data-lang=\"bash\"><span class=\"c\">#!\/bin\/sh<\/span>\n\n<span class=\"nv\">DEBUG<\/span><span class=\"o\">=<\/span><span class=\"s2\">\"\"<\/span>\n<span class=\"k\">function <\/span>add_to_debug <span class=\"o\">{<\/span>\n\t<span class=\"nv\">filetype<\/span><span class=\"o\">=<\/span><span class=\"nv\">$1<\/span>\n\t<span class=\"nv\">comment<\/span><span class=\"o\">=<\/span><span class=\"nv\">$2<\/span>\n\n\t<span class=\"nv\">next<\/span><span class=\"o\">=<\/span><span class=\"si\">$(<\/span>\n\t\tgit diff <span class=\"se\">\\<\/span>\n\t\t\t<span class=\"nt\">--cached<\/span> <span class=\"se\">\\<\/span>\n\t\t\t<span class=\"nt\">--name-only<\/span> <span class=\"se\">\\<\/span>\n\t\t\t<span class=\"nt\">-G<\/span><span class=\"s2\">\"<\/span><span class=\"k\">${<\/span><span class=\"nv\">comment<\/span><span class=\"k\">}<\/span><span class=\"s2\">[ ]*DEBUG\"<\/span> <span class=\"se\">\\<\/span>\n\t\t\t<span class=\"nt\">--<\/span> <span class=\"s2\">\"*.<\/span><span class=\"k\">${<\/span><span class=\"nv\">filetype<\/span><span class=\"k\">}<\/span><span class=\"s2\">\"<\/span>\n\t<span class=\"si\">)<\/span>\n\t<span class=\"nv\">DEBUG<\/span><span class=\"o\">=<\/span><span class=\"s2\">\"<\/span><span class=\"k\">${<\/span><span class=\"nv\">DEBUG<\/span><span class=\"k\">}${<\/span><span class=\"nv\">next<\/span><span class=\"k\">}<\/span><span class=\"s2\">\"<\/span>\n<span class=\"o\">}<\/span>\n\nadd_to_debug <span class=\"s1\">'js'<\/span> <span class=\"s1\">'\/\/'<\/span>\nadd_to_debug <span class=\"s1\">'rs'<\/span> <span class=\"s1\">'\/\/'<\/span>\nadd_to_debug <span class=\"s1\">'html'<\/span> <span class=\"s1\">'&lt;!--'<\/span>\nadd_to_debug <span class=\"s1\">'lisp'<\/span> <span class=\"s1\">';'<\/span>\nadd_to_debug <span class=\"s1\">'sh'<\/span> <span class=\"s1\">'#'<\/span>\nadd_to_debug <span class=\"s1\">'hbs'<\/span> <span class=\"s1\">'{{!--'<\/span>\n\n<span class=\"k\">if<\/span> <span class=\"o\">[<\/span> <span class=\"s2\">\"<\/span><span class=\"k\">${<\/span><span class=\"nv\">DEBUG<\/span><span class=\"k\">}<\/span><span class=\"s2\">\"<\/span> <span class=\"o\">!=<\/span> <span class=\"s2\">\"\"<\/span> <span class=\"o\">]<\/span><span class=\"p\">;<\/span> <span class=\"k\">then\n\t<\/span><span class=\"nb\">echo\n\techo<\/span> <span class=\"s2\">\"Please address the DEBUG comments in following files before committing:\"<\/span>\n\t<span class=\"nb\">echo\n\techo<\/span> <span class=\"s2\">\"<\/span><span class=\"k\">${<\/span><span class=\"nv\">DEBUG<\/span><span class=\"k\">}<\/span><span class=\"s2\">\"<\/span> | <span class=\"nb\">sed<\/span> <span class=\"s1\">'s\/^\/  \/'<\/span>\n\t<span class=\"nb\">exit <\/span>1\n<span class=\"k\">fi<\/span><\/code><\/pre><\/figure>\n\n<p>Using this, trying to commit any code that has DEBUG comments will fail with the\noutput:<\/p>\n\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>Please address the DEBUG comments in following files before committing:\n\n  user.js\n<\/code><\/pre><\/div><\/div>\n\n<p>This forces going back in and cleaning up your code before committing it.\nWicked.<\/p>\n\n<h2 id=\"get-it-yourself\">Get it yourself<\/h2>\n\n<p><a href=\"https:\/\/github.com\/orthecreedence\/git-debug-hook\">Grab the pre-commit hook off my Github<\/a>\nto END THE SUFFERING and stop committing your debug code.<\/p>\n\n","pubDate":"Wed, 01 Feb 2017 00:00:00 +0000","link":"https:\/\/killtheradio.net\/technology\/debug-comments-or-how-to-save-your-sanity-using-git\/","guid":"https:\/\/killtheradio.net\/technology\/debug-comments-or-how-to-save-your-sanity-using-git\/","category":["git","programming","Technology"]},{"title":"Ansible: included handlers not running in v2.x","description":"<p>I\u2019ll keep this short. I recently installed Ansible 2.0 to manage the <a href=\"https:\/\/turtl.it\">Turtl<\/a>\nservers. However, once I ran some of the roles I used in the old version, my\nhandlers were not running.<\/p>\n\n<p>For instance:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-yaml\" data-lang=\"yaml\"><span class=\"c1\"># roles\/rethinkdb\/tasks\/main.yml<\/span>\n\n<span class=\"pi\">-<\/span> <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s\">copy rethinkdb monitrc file<\/span>\n  <span class=\"na\">template<\/span><span class=\"pi\">:<\/span> <span class=\"s\">src=monit.j2 dest=\/etc\/monit.d\/rethinkdb<\/span>\n  <span class=\"na\">notify<\/span><span class=\"pi\">:<\/span> <span class=\"s\">restart monit<\/span><\/code><\/pre><\/figure>\n\n<figure class=\"highlight\"><pre><code class=\"language-yaml\" data-lang=\"yaml\"><span class=\"c1\"># roles\/rethinkdb\/handlers\/main.yml<\/span>\n\n<span class=\"pi\">-<\/span> <span class=\"s\">include roles\/monit\/handlers\/main.yml<\/span><\/code><\/pre><\/figure>\n\n<figure class=\"highlight\"><pre><code class=\"language-yaml\" data-lang=\"yaml\"><span class=\"c1\"># roles\/monit\/handlers\/main.yml<\/span>\n\n<span class=\"pi\">-<\/span> <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s\">restart monit<\/span>\n  <span class=\"na\">command<\/span><span class=\"pi\">:<\/span> <span class=\"s\">\/etc\/rc.d\/rc.monit restart<\/span><\/code><\/pre><\/figure>\n\n<p>Note that in Ansible &lt;= 1.8, when the monitrc file gets copied over, it would\nrun the <code class=\"highlighter-rouge\">restart monit<\/code> handler. In 2.0, no such luck.<\/p>\n\n<h2 id=\"the-fix\">The fix<\/h2>\n\n<p>I found <a href=\"https:\/\/github.com\/ansible\/ansible\/issues\/13485\">this github discussion<\/a>\nwhich led to <a href=\"https:\/\/groups.google.com\/forum\/#!topic\/ansible-devel\/9aJaoVeRdOg\">this google groups post<\/a>\nwhich says to put this in <strong>ansible.cfg<\/strong>:<\/p>\n\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>[defaults]\n...\ntask_includes_static = yes\nhandler_includes_static = yes\n<\/code><\/pre><\/div><\/div>\n\n<p>This makes includes pre-process instead of being loaded dynamically. I don\u2019t\n<em>really<\/em> know what that means but I do know it fixed the issue. It breaks\nlooping, but I don\u2019t even use any loops in ansible tasks, so<\/p>\n\n<p class=\"lead\"><img src=\"\/images\/uploads\/dr_scurvy.png\" width=\"720\" height=\"400\" alt=\"Do whatever you want, you little weasel. I don't care. I DON'T CARE.\" \/><\/p>\n\n","pubDate":"Sun, 05 Jun 2016 00:00:00 +0000","link":"https:\/\/killtheradio.net\/technology\/ansible-included-handlers-not-running\/","guid":"https:\/\/killtheradio.net\/technology\/ansible-included-handlers-not-running\/","category":["ansible","servers","debugging","Technology"]},{"title":"SSH public key fix","description":"<p>So once in a while I\u2019ll run into a problem where I can log into a server via SSH\nas one user via public key, and taking the <code class=\"highlighter-rouge\">authorized_keys<\/code> keys and dumping\nit into another user\u2019s <code class=\"highlighter-rouge\">.ssh\/<\/code> folder doesn\u2019t work.<\/p>\n\n<p>There are a few things you can try.<\/p>\n\n<h2 id=\"permissions\">Permissions<\/h2>\n\n<p>Try this:<\/p>\n\n<div class=\"language-bash highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nb\">chmod <\/span>0700 .ssh\/\n<span class=\"nb\">chmod <\/span>0600 .ssh\/authorized_keys\n<span class=\"nb\">sudo chown<\/span> <span class=\"nt\">-R<\/span> myuser:mygroup .ssh\/\n<\/code><\/pre><\/div><\/div>\n\n<p>That should fix it 99% of the time.<\/p>\n\n<h2 id=\"locked-account\">Locked account<\/h2>\n\n<p>Tonight I had an issue where the permissions were all perfect\u2026checked, double\nchecked, and yes they were fine.<\/p>\n\n<p>So after poking at it for an hour (instead of smartly checking the logs) I\ndecided to check the logs. I saw this error:<\/p>\n\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>Nov 23 05:26:46 localhost sshd[1146]: User deploy not allowed because account is locked\nNov 23 05:26:46 localhost sshd[1146]: input_userauth_request: invalid user deploy [preauth]\n<\/code><\/pre><\/div><\/div>\n\n<p>Huh? I looked it up, and apparently an account can become locked if its password\nis too short or insecure. So I did<\/p>\n\n<div class=\"language-bash highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nb\">sudo <\/span>passwd deploy\n<\/code><\/pre><\/div><\/div>\n\n<p>Changed the password to something longer, and it worked!<\/p>\n\n<p>Have any more tips on fixing SSH login issues? Let us know in the comments\nbelow.<\/p>\n\n","pubDate":"Sun, 22 Nov 2015 00:00:00 +0000","link":"https:\/\/killtheradio.net\/technology\/ssh-public-key-fix\/","guid":"https:\/\/killtheradio.net\/technology\/ssh-public-key-fix\/","category":["ssh","debugging","Technology"]},{"title":"Nginx returns error on file upload","description":"<p>I love Nginx and have never had a problem with it. Until now.<\/p>\n\n<p><a href=\"https:\/\/turtl.it\">Turtl, the private Evernote alternative<\/a>, allows uploading\nfiles securely. However, after switching to a new server on <a href=\"https:\/\/www.linode.com\/?r=15d5d2323910d69794b93ed02cd7d43b2f68d8c5\">Linode<\/a>,\nuploads broke for files over 10K. The server was returning a 404.<\/p>\n\n<p>I finally managed to reproduce the problem in cURL, and to my surprise, the\nrequests were getting stopped by Nginx. All other requests were going through\nfine, and the error only happened when uploading a file of 10240 bytes or more.<\/p>\n\n<p>First thing I though was that Nginx v1.8.0 had a bug. Nobody on the internet\nseemed to have this problem. So I installed v1.9.4. Now the server returned a\n500 error instead of a 404. Still no answer to <em>why<\/em>.<\/p>\n\n<p>I finally found it: playing with <code class=\"highlighter-rouge\">client_body_buffer_size<\/code> seemed to change the\nthreshold for which files would trigger the error and which wouldn\u2019t, but\nultimately the error was still there. Then I read about how Nginx uses\ntemporary files to store body data. I checked that folder (in my case\n<code class=\"highlighter-rouge\">\/var\/lib\/nginx\/client_body<\/code>) and the folder was writeable by the <code class=\"highlighter-rouge\">nginx<\/code> user,\nhowever the parent folder <code class=\"highlighter-rouge\">\/var\/lib\/nginx<\/code> was owned by <code class=\"highlighter-rouge\">root:root<\/code> and was set\nto <code class=\"highlighter-rouge\">0700<\/code>. I set <code class=\"highlighter-rouge\">\/var\/lib\/nginx<\/code> to be readable\/writable by user <code class=\"highlighter-rouge\">nginx<\/code>, and\nit all started working.<\/p>\n\n<h2 id=\"check-your-permissions\">Check your permissions<\/h2>\n\n<p>So, check your folder permissions. Nginx wasn\u2019t returning any useful errors\n(first a 404, which I\u2019m assuming was a bug fixed in a later version) then a 500\nerror. It\u2019s important to note that after switching to v1.9.4, the Permission\nDenied error <em>did<\/em> show up in the error log, but at that point I had already\ndecided the logs were useless (v1.8.0 silently ignored the problem).<\/p>\n\n<h2 id=\"another-problem\">Another problem<\/h2>\n\n<p>This is an edit! Shortly after I applied the above fix, I started getting\nanother error. My backend was getting the requests, but the entire request was\nbeing buffered by Nginx before being proxied. This is annoying to me because the\nbackend is async and is made to stream large uploads.<\/p>\n\n<p>After some research, I found the fix (I put this in the backend proxy\u2019s\n<code class=\"highlighter-rouge\">location<\/code> block:<\/p>\n\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>proxy_request_buffering off;\n<\/code><\/pre><\/div><\/div>\n\n<p>This tells Nginx to just stream the request to the backend (exactly what I want).<\/p>\n\n","pubDate":"Sat, 05 Sep 2015 00:00:00 +0000","link":"https:\/\/killtheradio.net\/technology\/nginx-returns-error-on-file-upload\/","guid":"https:\/\/killtheradio.net\/technology\/nginx-returns-error-on-file-upload\/","category":["nginx","debugging","software","Technology"]},{"title":"Turtl's new syncing architecture","description":"<p>For those of you just joining us, I\u2019m working on an app called <a href=\"https:\/\/turtl.it\">Turtl, a secure\nEvernote alternative<\/a>. Turtl is an open-source note taking app\nwith client-side encryption which also allows private collaboration. Think like\na private Evernote with a self-hosted option (sorry, no OCR yet =]).<\/p>\n\n<p>Turtl\u2019s version 0.5 (the current version) has syncing, but it was never designed to support offline\nmode, and requires clients to be online to use Turtl. The newest upcoming\nrelease supports fully offline mode (except for a few things like login,\npassword changes, etc). This post will attempt to describe how syncing in the\nnew version of Turtl works.<\/p>\n\n<p>Let\u2019s jump right in.<\/p>\n\n<h2 id=\"client-ids-or-the-cid\">Client IDs (or the \u201ccid\u201d)<\/h2>\n\n<p>Each object having a globally unique ID that can be client-generated makes\nsyncing painless. We do this using a few methods, some of which are actually\nborrowed from <a href=\"http:\/\/docs.mongodb.org\/manual\/reference\/object-id\/\">MongoDB\u2019s Object ID schema<\/a>.<\/p>\n\n<p>Every client that runs the Turtl app creates and saves a client hash if it\ndoesn\u2019t have one. This hash is a SHA256 hash of some (cryptographically secure)\nrandom data (current time + random uuid).<\/p>\n\n<p>This client hash is then baked into every id of every object created from then on.\nTurtl uses the <a href=\"https:\/\/lyonbros.github.io\/composer.js\/\">composer.js<\/a> framework\n(somewhat similar to Backbone) which gives every object a unique ID (\u201ccid\u201d) when\ncreated. Turtl replaces Composer\u2019s cid generator with its own that creates IDs\nlike so:<\/p>\n\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>12 bytes hex timestamp | 64 bytes client hash | 4 bytes hex counter\n<\/code><\/pre><\/div><\/div>\n\n<p>For example, the cid<\/p>\n\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>014edc2d6580b57a77385cbd40673483b27964658af1204fcf3b7b859adfcb90f8b8955215970012\n<\/code><\/pre><\/div><\/div>\n\n<p>breaks down as:<\/p>\n\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code> timestamp    client hash                                                      counter\n------------|----------------------------------------------------------------|--------\n014edc2d6580 b57a77385cbd40673483b27964658af1204fcf3b7b859adfcb90f8b895521597 0012\n |                                    |                                        |\n |- 1438213039488                     |- unique hash                           |- 18\n<\/code><\/pre><\/div><\/div>\n\n<p>The timestamp is a <code class=\"highlighter-rouge\">new Date().getTime()<\/code> value (with leading 0s to support\nlonger times eventually). The client hash we already went over, and the counter\nis a value tracked in-memory that increments each time a cid is generated. The\ncounter has a max value of 65535, meaning that the only way a client can produce\na duplicate cid is by creating 65,535,001 objects in one second. We have some\ndevoted users, but even for them creating 65M notes in a second would be\ndifficult.<\/p>\n\n<p>So, the timestamp, client hash, and counter ensure that each cid created is\nunique not just to the client, but globally within the app as well (unless two\nclients create the same client hash somehow, but this is implausible).<\/p>\n\n<p>What this means is that we can create objects endlessly in any client, each with\na unique cid, use those cids as primary keys in our database, and never have a\ncollision.<\/p>\n\n<p>This is important because we can create data in the client, and not need server\nintervention or creation of IDs. A client can be offline for two weeks and then\nsync all of its changes the next time it connects without problems and without\nneeding a server to validate its object\u2019s IDs.<\/p>\n\n<p>Using this scheme for generating client-side IDs has not only made offline mode\npossible, but has greatly simplified the syncing codebase in general. Also,\nhaving a timestamp at the beginning of the cid makes it sortable by order of\ncreation, a nice perk.<\/p>\n\n<h2 id=\"queuing-and-bulk-syncing\">Queuing and bulk syncing<\/h2>\n\n<p>Let\u2019s say you add a note in Turtl. First, the note data is encrypted\n(serialized). The result of that encryption is shoved into the local DB\n(IndexedDB) <em>and<\/em> the encrypted note data is also saved into an outgoing sync\ntable (also IndexedDB). The sync system is alerted \u201chey, there are outgoing\nchanges in the sync table\u201d and if, after a short period, no more outgoing sync\nevents are triggered, the sync system takes <em>all<\/em> pending outgoing sync records\nand sends them to a bulk sync API endpoint (in order).<\/p>\n\n<p>The API processes each one, going down the list of items and updating the\nchanged data. It\u2019s important to note that Turtl doesn\u2019t support deltas! It only\npasses full objects, and replaces those objects when any one piece has changed.<\/p>\n\n<p>For each successful outgoing sync item that the API processes, it returns a\nsuccess entry in the response, with the corresponding <em>local<\/em> outgoing sync ID\n(which was passed in). This allows the client to say \u201cthis one succeeded, remove\nit from the outgoing sync table\u201d on a granular basis, retrying entries that\nfailed automatically on the next outgoing sync.<\/p>\n\n<p>Here\u2019s an example of a sync sent to the API:<\/p>\n\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>[\n    {id: 3, type: 'note', action: 'add', data: { &lt;encrypted note data&gt; }}\n]\n<\/code><\/pre><\/div><\/div>\n\n<p>and a response:<\/p>\n\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>{\n    success: [\n        {id: 3, sync_ids: ['5c219', '5c218']}\n    ]\n}\n<\/code><\/pre><\/div><\/div>\n\n<p>We can see that sync item \u201c3\u201d was successfully updated in the API, which allows\nus to remove that entry from our local outgoing sync table. The API also returns\nserver-side generate sync IDs for the records it creates in its syncing log. We\nuse these IDs passed back to <em>ignore<\/em> incoming changes from the API when incoming\nsyncs come in later so we don\u2019t double-apply data changes.<\/p>\n\n<h3 id=\"why-not-use-deltas\">Why not use deltas?<\/h3>\n\n<p>Wouldn\u2019t it be better to pass diffs\/deltas around than full objects? If two\npeople edit the same note in a shared board at the same time, then the\nlast-write-wins architecture would overwrite data!<\/p>\n\n<p>Yes, diffs would be wonderful. However, consider this: at some point, an object\nwould be an original, and a set of diffs. It would have to be collapsed back\ninto the main object, and because the main object <em>and<\/em> the diffs would be\nclient-encrypted, the server has no way of doing this.<\/p>\n\n<p>What this means is that the clients would not only have to sync notes\/boards\/etc\nbut also the diffs for all those objects, and collapse the diffs into the main\nobject then <em>save the full object back to the server<\/em>.<\/p>\n\n<p>To be clear, this is entirely possible. However, I\u2019d much rather get the\nwhole-object syncing working perfectly before adding additional complexity of\ndiff collapsing as well.<\/p>\n\n<h2 id=\"polling-for-changes\">Polling for changes<\/h2>\n\n<p>Whenever data changes in the API, a log entry is created in the API\u2019s \u201csync\u201d\ntable, describing what was changed and who it affects. This is also the place\nwhere, in the future, we might store diffs\/deltas for changes.<\/p>\n\n<p>When the client asks for changes, at does so using a sequential ID, saying \u201chey,\nget me everything affecting my profile that happened after &lt;last sync id&gt;\u201d.<\/p>\n\n<p>The client uses long-polling to check for incoming changes (either to one\u2019s own\nprofile or to shared resources). This means that the API call used holds the\nconnection open until either a) a certain amount of time passes or b) new sync\nrecords come in.<\/p>\n\n<p>The API uses <a href=\"http:\/\/rethinkdb.com\/docs\/changefeeds\/javascript\/\">RethinkDB\u2019s changefeeds<\/a>\nto detect new data by watching the API\u2019s sync table. This means that changes\ncoming in are very fast (usually within a second of being logged in the API).\nRethinkDB\u2019s changefeeds are terrific, and eliminate the need to poll your\ndatabase endlessly. They collapse changes up to one second, meaning it doesn\u2019t\nreturn immediately after a new sync record comes in, it waits a second for more\nrecords. This is mainly because syncs happen in bulk and it\u2019s easier to wait a\nbit for a few of them than make five API calls.<\/p>\n\n<p>For each sync record that comes in, it\u2019s linked against the actual data stored\nin the corresponding table (so a sync record describing an edited note will pull\nout that note, in its current form, from the \u201cnotes\u201d table). Each sync record is\nthen handed back to the client, in order of occurence, so it can be applied to\nthe local profile.<\/p>\n\n<p>The result is that changes to a local profile are applied to all connected\nclients within a few seconds. This also works for shared boards, which are\nincluded in the sync record searches when polling for changes.<\/p>\n\n<h2 id=\"file-handling\">File handling<\/h2>\n\n<p>Files are synced separately from everything else. This is mainly because they\ncan\u2019t just be shoved into the incoming\/outgoing sync records due to their\npotential size.<\/p>\n\n<p>Instead, the following happens:<\/p>\n\n<h3 id=\"outgoing-syncs-client---api\">Outgoing syncs (client -&gt; API)<\/h3>\n\n<p>Then a new file is attached to a note and saved, a \u201cfile\u201d sync item is created\nand passed into the ougoing sync queue <em>without the content body<\/em>. Keep in mind\nthat at this point, the file contents are already safe (in encrypted binary\nform) in the files table of the local DB. The sync system notices the outgoing\nfile sync record (sans file body) and pulls it aside. Once the normal sync has\ncompleted, the sync system adds the file record(s) it found to a file upload\nqueue (after which the outgoing \u201cfile\u201d sync record is removed). The upload queue\n(using <a href=\"https:\/\/github.com\/orthecreedence\/hustle\">Hustle<\/a>) grabs the encrypted\nfile contents from the local files table uploads it to the API\u2019s attachement\nendpoint.<\/p>\n\n<p>Attaching a file to a note creates a \u201cfile\u201d sync record in the API, which alerts\nclients that there\u2019s a file change on that note they should download.<\/p>\n\n<p>It\u2019s important to note that file uploads happen after all other syncs in that\nbulk request are handled, which means that the note will always exist before the\nfile even starts uploading.<\/p>\n\n<p>Encrypted file contents are stored on S3.<\/p>\n\n<h3 id=\"incoming-syncs-api---client\">Incoming syncs (API -&gt; client)<\/h3>\n\n<p>When the client sees an incoming \u201cfile\u201d sync come through, much like with outgoing\nfile syncs, it pulls the record aside and adds it to a file download queue instead\nof processing it normally. The download queue grabs the file via the note\nattachment API call and, once downloaded, saves it into the local files database\ntable.<\/p>\n\n<p>After this is all done, if the note that the file is attached to is in memory\n(decrypted and in the user\u2019s profile) it is notified of the new file contents\nand will re-render itself. In the case of an image attachment, a preview is\ngenerated and displayed via a Blob URL.<\/p>\n\n<h2 id=\"whats-not-in-offline-mode\">What\u2019s not in offline mode?<\/h2>\n\n<p>All actions work in offline mode, except for a few that require server approval:<\/p>\n\n<ul>\n  <li>login (requires checking your auth against the API\u2019s auth database)<\/li>\n  <li>joining (creating an account)<\/li>\n  <li>creating a persona (requires a connection to see if the email is already taken)<\/li>\n  <li>changing your password<\/li>\n  <li>deleting your account<\/li>\n<\/ul>\n\n<h2 id=\"whats-next\">What\u2019s next?<\/h2>\n\n<p>It\u2019s worth mentioning that after v0.6 launches (which will include an Android\napp), there will be a \u201cSync\u201d interface in the app that shows you what\u2019s waiting\nto be synced out, as well as file uploads\/downloads that are active\/pending.<\/p>\n\n<p>For now, you\u2019ll just have to trust that things are working ok in the background\nwhile I find the time to build such an interface =].<\/p>\n\n","pubDate":"Wed, 29 Jul 2015 00:00:00 +0000","link":"https:\/\/killtheradio.net\/technology\/turtls-new-syncing-architecture\/","guid":"https:\/\/killtheradio.net\/technology\/turtls-new-syncing-architecture\/","category":["turtl","security","rethinkdb","software","scalability","Technology"]}]}}