Christos Margiolis: engineering Christos Margiolis http://margiolis.net/tags/engineering/ In defense of the Old Web http://margiolis.net/w/oldweb/ Wed, 17 Aug 2022 00:00:00 +1200 <p>The internet has reached the point where almost everything has been concertrated in just a few platforms. This is both opposed to the original idea of a decentralized and free internet, and is also used as a <a href="http://margiolis.net/w/socialmedia">tool for control</a>, since the flow of information is &ldquo;managed&rdquo; only by a handful of companies.</p> <p>My rather romanticized proposal is that we should make an attempt return to the old ways of the internet (1990s-2000s) &mdash; when personal websites and small communities were thriving &mdash; not because of nostalgia, but because it espoused better values and promoted creativity, despite its problems (spam, malware, bad security practices, unencrypted traffic). This might very well be a pipe dream at this point, but I think it would be great to at least see the existing movement attracting more people than it already does.</p> <p>I was initially working on a full article explaining my viewpoint in depth, but the following articles express them better than I could ever have:</p> <ul> <li><a href="https://neustadt.fr/essays/against-a-user-hostile-web/">Against an Increasingly User-Hostile Web</a></li> <li><a href="https://neustadt.fr/essays/the-small-web/">Rediscovering the Small Web</a></li> <li><a href="https://benhoyt.com/writings/the-small-web-is-beautiful/">The small web is beautiful</a></li> <li><a href="https://webdirections.org/blog/the-website-obesity-crisis/">The Website Obesity Crisis</a></li> </ul> <p>So, how can you be part of the small web? To start off, you need:</p> <ul> <li><a href="https://landchad.net/basic/domain/">A domain name</a>.</li> <li>Somewhere to host your website/service. I rent a <a href="https://vultr.com">Vultr</a> VPS with the cheapest plan available, which is more than enough for my needs, but you can even do self-hosting at home if you want. If you do rent from Vultr, you can <a href="https://landchad.net/basic/server/">follow this guide</a>.</li> <li>To <a href="https://landchad.net/basic/dns/">connect the domain name with the server</a>, so that your website can be reached.</li> <li>A stable and secure operating system for servers, such as <a href="https://openbsd.org">OpenBSD</a>.</li> </ul> <p>A list of guides I&rsquo;ve written:</p> <ul> <li><a href="http://margiolis.net/w/openbsd_web">Set up an OpenBSD web server</a>.</li> <li><a href="http://margiolis.net/w/rss">Create an RSS feed for your website</a>.</li> <li><a href="http://margiolis.net/w/rsync">Edit files locally and upload them to the server</a>.</li> <li><a href="http://margiolis.net/w/openbsd_git">Set up an OpenBSD Git server</a> with a mimimal <a href="http://margiolis.net/w/stagit_frontend">web frontend</a>.</li> </ul> <p>To make finding other websites easier, have a <a href="http://margiolis.net/links">links page</a>, and consider being part of a <a href="https://en.wikipedia.org/wiki/Webring">webring</a>.</p> <p>The tools you choose to manage your website depend on personal preference and needs, but I firmly believe that because building a website is not rocket science, and because <a href="https://idlewords.com/talks/website_obesity.htm">the web has been getting severely bloated</a> you don&rsquo;t need anything more than a few command line utilities, a text editor, and perhaps a <a href="https://staticsitegenerators.net/">static site generator</a>. Modern web frameworks tend to cause more headaches than actually improve workflow, so I&rsquo;ll refrain from recommending them. I like writing articles in <a href="https://daringfireball.net/projects/markdown/basics">Markdown</a>, and using <a href="https://gohugo.io/">Hugo</a> for static site generation and templating.</p> RSS: Advantages and usage http://margiolis.net/w/rss/ Fri, 27 May 2022 00:00:00 +1200 <p><a href="https://en.wikipedia.org/wiki/RSS">RSS (Really Simple Syndication)</a> is a standardized protocol for creating and sharing web feeds. An RSS feed is an XML file consisting of entries, each of them usually corresponding to an article. Programs called &ldquo;RSS aggregators&rdquo;, parse these files and provide a nice display where you can nagivate through each entry as if it were a news feed. This is a very convenient way to &ldquo;follow&rdquo; websites because all you have to do is grab their RSS URL, add it to your aggregator, and read the articles once it parses the feed.</p> <p><img src="http://margiolis.net/rss.png" alt=""></p> <p>On the website owner&rsquo;s end, a new entry needs to be added whenever a new article is published. The entry usually includes a short summary of the article, or as is the case for my website, the whole article, so that you can read it all through your RSS reader.</p> <h2 id="why-bother">Why bother</h2> <p>RSS is an open protocol, it&rsquo;s decentralized, and very simple both in terms of parsing and maintaining. Because RSS is such a simple protocol, it can adapt to everyone&rsquo;s workflow. There are RSS readers for Android, Windows, UNIX, web browsers, email clients, etc.</p> <p>Apart from the technical advantages RSS provides, it&rsquo;s also a great way to have a personal, uncensored feed, following only the websites you want &mdash; even YouTube channels and Twitter accounts &mdash; without ads and additional noise and distractions.</p> <p>I personally use <a href="https://codemadness.org/sfeed-simple-feed-parser.html">sfeed</a> as an RSS reader, because I like the extensibility it offers. I&rsquo;ve written <a href="https://ftp.margiolis.net/patch/sfeed_bookmarks.diff">a small patch for sfeed_curses(1)</a>, so that you can bookmark feed entry URLs to a predefined file. I use this mostly to queue videos and podcasts and then stream them through <a href="https://mpv.io/">mpv</a> using <a href="https://git.sr.ht/~crm/scripts/tree/master/item/vdq">a very simple script I created</a>, which, all it does is read the &ldquo;queue&rdquo; file and pipe the URLs to mpv.</p> <h2 id="how-to-create-and-maintain-an-rss-feed">How to create and maintain an RSS feed</h2> <p>Below is a very basic RSS feed. Inside the <code>&lt;channel&gt;</code> tags is the whole feed, and inside <code>&lt;item&gt;</code> is each individual entry. The rest of the tags are pretty self-explanatory, if not, feel free to <a href="https://www.rssboard.org/rss-specification">read the specification</a>. The article/summary is placed inside <code>&lt;description&gt;</code> &mdash; that can be in plain text or <a href="https://www.rssboard.org/rss-encoding-examples">encoded HTML</a>:</p> <pre tabindex="0"><code>&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34; ?&gt; &lt;rss version=&#34;2.0&#34;&gt; &lt;channel&gt; &lt;title&gt;Example Org&lt;/title&gt; &lt;description&gt;Example Org&#39;s RSS feed&lt;/description&gt; &lt;link&gt;http://www.example.org/rss.xml&lt;/link&gt; &lt;item&gt; &lt;title&gt;Example entry&lt;/title&gt; &lt;link&gt;http://www.example.org/blog/post.html&lt;/link&gt; &lt;pubDate&gt;Sun, 06 Sep 2009 16:20:00 +0000&lt;/pubDate&gt; &lt;description&gt; Here is some text containing an interesting description. &lt;/description&gt; &lt;/item&gt; &lt;/channel&gt; &lt;/rss&gt; </code></pre><p>To create a new entry, you can either handwrite it in the XML file yourself, make a script or small program to do it automatically, or use some existing tool. I prefer to use my own script, since it&rsquo;s a dead simple thing to do.</p> <p>To share the feed, simply add the URL to your website and tell people to subscribe to it. For example, my website&rsquo;s RSS feed can be obtained from <a href="http://margiolis.net/w/rss.xml">https://margiolis.net/w/rss.xml</a>.</p> <h2 id="rss-for-youtube-and-social-media">RSS for YouTube and social media</h2> <p>Even though they purposefully make it hard to find, so that you can stay on their platform, YouTube, Twitter, Reddit, and other services, offer RSS feeds, and even if they don&rsquo;t, there are ways you can generate one.</p> <h3 id="youtube">YouTube</h3> <p>Go to the channel&rsquo;s home page, right-click and click on &ldquo;Page source&rdquo; and search for <code>channelId&quot; content</code>. Copy the hash inside <code>content=&quot;&quot;</code> and append it to the following URL (replace <code>hash</code>):</p> <pre tabindex="0"><code>https://www.youtube.com/feeds/videos.xml?channel_id=hash </code></pre><h3 id="github">GitHub</h3> <p>You can get an RSS feed for each new commit that happens in a given branch. Replace <code>username</code>, <code>repo</code> and <code>branch</code> with the correct values:</p> <pre tabindex="0"><code>https://github.com/username/repo/commits/branch.atom </code></pre><h3 id="twitter">Twitter</h3> <p>Twitter does not actually offer RSS feeds anymore, but there is a proxy site for Twitter called <a href="https://nitter.ca/">nitter</a> that does. Replace <code>username</code> with the account&rsquo;s username you want to follow:</p> <pre tabindex="0"><code>https://nitter.net/username/rss </code></pre><h3 id="reddit">Reddit</h3> <p>Each subreddit has an RSS feed under this URL (replace <code>subreddit</code>):</p> <pre tabindex="0"><code>https://www.reddit.com/r/subreddit.rss </code></pre><h3 id="facebook-and-others">Facebook and others</h3> <p>There&rsquo;s a nice program called <a href="https://rss-bridge.github.io/rss-bridge/">RSS-Bridge</a> that can generate RSS feeds for websites which don&rsquo;t have one. RSS-Bridge is installed and run on your server, but there are <a href="https://www.srss.nl/">public instances you can use</a>.</p> Why reinvent the wheel http://margiolis.net/w/reinvent_wheel/ Fri, 25 Mar 2022 00:00:00 +1200 <p>I&rsquo;ve got a few reasons for &ldquo;reinventing the wheel&rdquo;, some personal and some practical:</p> <ul> <li>I&rsquo;m curious and want to know how things really work.</li> <li>I like DIY from scratch projects.</li> <li>Bottom-up learning is valuable.</li> <li>There are things that are fundamentally flawed and need to be done again from scratch.</li> <li>Existing tools don&rsquo;t always match the criteria for your specific task and/or introduce too much complexity.</li> <li>Because there&rsquo;s already a way to do something, it doesn&rsquo;t mean it&rsquo;s the right way to do it.</li> </ul> <p>Some of the greatest innovations have in fact been a reinvention of the wheel, because what already existed at the time wasn&rsquo;t good enough. Imagine someone telling James Watt he shouldn&rsquo;t waste his time reinventing the wheel. Improving what already exists means we have stable foundations and better tools to work with in the future. The wheel itself has been reinvented multiple times, hence we don&rsquo;t use Bronze Age wheels anymore.</p> <p><img src="http://margiolis.net/files/wheel.jpg" alt=""></p> <p>A good example in the software world of why sometimes reinventing the wheel is a good idea is UNIX vs Windows. UNIX was written from scratch to replace Multics which had serious flaws, so they ended up with a new and clean system, built right from the bottom-up. They reinvented the wheel and made huge innovations in the process. Windows on the other hand, is built on top of MS-DOS which even at the time was a mess, so what Microsoft is left with is an OS which up to this day is overly complicated, because of fundamental design flaws that cannot be fixed unless they do away with the whole thing and start from scratch. Instead, they are coming up with half-assed solutions and add complexity to the system with each update.</p> <p>Then there&rsquo;s quality and efficiency. Writing your own tools means they can be tailored to perform a specific task perfectly &mdash; something a big generalized framework or piece of software can&rsquo;t do in many cases. We tend to ignore the improvements better software can bring in the long term and instead spend time fighting with not-so-great tools and also rely on the power of modern hardware to cope for our mediocre solutions (see modern web tools or the web in general).</p> <p>So, am I proposing that we&rsquo;d be better off writing machine code and building our own programs for everything? Absolutely not. What I AM saying though, is that instead of being allergic to reinventing the wheel, we can start to see the merits in it, without overdoing it. This approach is benefecial to our personal improvement as engineers, which means an improvement in software as a whole. Just as you learn any other skill by mastering and understanding the basics, programming has to be understood from the bottom-up, not the opposite way. There&rsquo;s no point in knowing all kinds of fancy frameworks if all you see are black boxes, or cannot even implement a linked list if asked to. After all, it&rsquo;s a fact that software is getting worse.</p> <p>And to save myself from sounding ignorant, <strong>there are cases where reinventing the wheel is a problem</strong>, namely:</p> <ul> <li>Companies rolling their own proprietary solutions for everything, and ending up creating protocols and programs, which are arguably worse, expensive, harder to maintain, <em>and</em> incompatible with existing software.</li> <li>People who like to reinvent the wheel for the sake of just having &ldquo;their own&rdquo; version of something, even when there actually <em>is</em> good software out there that covers their needs just as well.</li> </ul> <p>Knowing how things really work will enable you to trace bugs easier, write/design more performant software, and overall know what the hell you&rsquo;re doing. And that can only be achieved by, sometimes, reinventing the wheel. Nothing can teach you what getting your hands dirty will.</p> <p><a href="https://medium.com/codex/dont-reinvent-the-wheel-and-other-web-developer-cop-outs-ed9dc4d6c9e3">A related article I found funny.</a></p> Email-driven Git workflow http://margiolis.net/w/email_git/ Sun, 16 Jan 2022 00:00:00 +1200 <p>Basic Git configuration (in case you haven&rsquo;t already done that):</p> <pre tabindex="0"><code>$ git config --global user.email you@example.org $ git config --global user.name &#34;Your Name&#34; </code></pre><p>Git email configuration:</p> <pre tabindex="0"><code>$ git config --global sendemail.smtpserver your_mail_server $ git config --global sendemail.smtpuser you@example.org $ git config --global sendemail.smtpserverport your_smtp_port $ git config --global sendemail.smtpencryption your_encryption_type </code></pre><h2 id="examples">Examples</h2> <p>Apply a patch (or simply make a commit) and send it to a mailing list:</p> <pre tabindex="0"><code>$ git am &lt; some_patch $ git send-email --to=list@example.org HEAD^ </code></pre><p>Fix last commit and send it:</p> <pre tabindex="0"><code>$ git commit -a --amend $ git send-email --annotate -v2 HEAD^ </code></pre><p>Send 3 last commits (see <a href="https://git-scm.com/book/en/v2/Git-Tools-Revision-Selection">Revision Selection</a> for more info on the notation):</p> <pre tabindex="0"><code>$ git send-email HEAD~3 </code></pre><p>Send the last commit to list@example.org and make the subject look like &ldquo;<code>[reponame][PATCH] commitmsg</code>&rdquo;. This is useful for sending patches to mailing lists or programmers with multiple projects:</p> <pre tabindex="0"><code>$ git send-email --subject-prefix=&#34;${PWD##*/}][PATCH&#34; \ --to=list@example.org -1 </code></pre><p><a href="https://linux.die.net/man/1/git-send-email">git-send-email(1)</a> manual page. Simple as that. None of that fork &amp; pull request crap.</p> <h2 id="further-reading">Further reading</h2> <ol> <li><a href="https://begriffs.com/posts/2018-06-05-mailing-list-vs-github.html">Mailing lists vs GitHub</a></li> <li><a href="https://web.archive.org/web/20180522180815/https://dpc.pw/blog/2017/08/youre-using-git-wrong/">You&rsquo;re using Git wrong</a></li> <li><a href="https://drewdevault.com/2018/07/02/Email-driven-git.html">The advantages of an email-driven Git workflow</a></li> </ol>