<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Pradeep Gowda</title>
    <description>The latest articles on DEV Community by Pradeep Gowda (@btbytes).</description>
    <link>https://dev.to/btbytes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F49149%2Fc84b504e-f08b-49fb-a363-48d5e7dcc01e.jpeg</url>
      <title>DEV Community: Pradeep Gowda</title>
      <link>https://dev.to/btbytes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/btbytes"/>
    <language>en</language>
    <item>
      <title>tohray - microblogging application in nim</title>
      <dc:creator>Pradeep Gowda</dc:creator>
      <pubDate>Wed, 14 Aug 2024 12:20:21 +0000</pubDate>
      <link>https://dev.to/btbytes/tohray-microblogging-application-in-nim-23kl</link>
      <guid>https://dev.to/btbytes/tohray-microblogging-application-in-nim-23kl</guid>
      <description>&lt;p&gt;&lt;a href="https://kn.wiktionary.org/wiki/%E0%B2%A4%E0%B3%8A%E0%B2%B0%E0%B3%86" rel="noopener noreferrer"&gt;ತೊರೆ&lt;/a&gt;, pronounced "toh-ray" (with a dental 't' sound),&lt;br&gt;
is a microblogging application to capture stream of thoughts inspired by &lt;a href="https://thesephist.com" rel="noopener noreferrer"&gt;Linus Lee&lt;/a&gt;'s &lt;a href="https://stream.thesephist.com" rel="noopener noreferrer"&gt;Stream&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The word ತೊರೆ in &lt;a href="https://en.wikipedia.org/wiki/Kannada" rel="noopener noreferrer"&gt;Kannada&lt;/a&gt; has multiple meanings, but most commonly&lt;br&gt;
as rivulet, forego, divest; which are indeed appropriate description for the intent.&lt;/p&gt;

&lt;p&gt;You can see this in action at &lt;a href="https://tohray.fly.dev" rel="noopener noreferrer"&gt;https://tohray.fly.dev&lt;/a&gt;; the source code is on &lt;a href="https://github.com/btbytes/tohray" rel="noopener noreferrer"&gt;github.com/btbytes/tohray&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Write new posts&lt;/li&gt;
&lt;li&gt;In markdown&lt;/li&gt;
&lt;li&gt;Edit posts&lt;/li&gt;
&lt;li&gt;Delete posts&lt;/li&gt;
&lt;li&gt;Click on the date to see posts written during that &lt;em&gt;month&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Supports multiple users, but I really wrote it for one user.&lt;/li&gt;
&lt;li&gt;You can allow users to sign up by giving them the &lt;code&gt;inviteCode&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Export all the feeds from &lt;code&gt;/export&lt;/code&gt; endpoint.

&lt;ul&gt;
&lt;li&gt;default format is JSON&lt;/li&gt;
&lt;li&gt;append &lt;code&gt;?format=md&lt;/code&gt; to export in markdown format ie., &lt;code&gt;/export?format=md&lt;/code&gt;. The entries are returned with a File Seperator (ASCII 28) after each entry.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Calendar view by month at &lt;code&gt;/calendar&lt;/code&gt; to see all the posts belonging to a month.&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Non-Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;There is no "user management".&lt;/li&gt;
&lt;li&gt;There is no "password reset".&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Technology Details
&lt;/h2&gt;

&lt;p&gt;Linus wrote his &lt;a href="https://github.com/thesephist/stream" rel="noopener noreferrer"&gt;stream app&lt;/a&gt; using a language he created himself - &lt;a href="https://oaklang.org" rel="noopener noreferrer"&gt;Oaklang&lt;/a&gt;.&lt;br&gt;
I wanted an excuse to use Nim for something "useful", so I used Nim, and it was a great experience.&lt;/p&gt;

&lt;p&gt;Nim is a fast, and friendly language that is statically typed, while looking like Python in Syntax.&lt;br&gt;
It compiles the source code into C (or C++, or Javascript), which allows the programs written in it&lt;br&gt;
to be very fast, small, and quite portable.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Programming Language: &lt;a href="https://nim-lang.org" rel="noopener noreferrer"&gt;Nim&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Framework: &lt;a href="https://planety.github.io/prologue/" rel="noopener noreferrer"&gt;Prologue&lt;/a&gt;, which in turn uses &lt;a href="https://github.com/karaxnim/karax" rel="noopener noreferrer"&gt;Karax&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Database: SQLite&lt;/li&gt;
&lt;li&gt;CSS: &lt;a href="https://terminalcss.xyz" rel="noopener noreferrer"&gt;Terminal&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Cloud: Tested on &lt;a href="https://fly.io" rel="noopener noreferrer"&gt;https://fly.io&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Editor: eh.. didn't know you cared, but it was written on &lt;a href="https://zed.dev" rel="noopener noreferrer"&gt;Zed&lt;/a&gt; which has decent support
for editing Nim with &lt;code&gt;nimlangserver&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Programming Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;views.nim&lt;/code&gt; file way too long, but I'm not ashamed of it. It's app I wrote for myself, and it
fits into myhead perfectly fine.&lt;/li&gt;
&lt;li&gt;The decision to compile secrets into the binary was made after realizing that managing secrets in
the environment, &lt;code&gt;.env&lt;/code&gt; files, &lt;code&gt;consts.nim&lt;/code&gt; .. multiple places is just busy work. Not how I would write
a "production" application.. but this is a "hobby" application. And, whatever makes me happy to keep
writing code will remain.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Clone this directory&lt;/li&gt;
&lt;li&gt;Have &lt;a href="////nim-lang.org"&gt;nim&lt;/a&gt; installed on your computer&lt;/li&gt;
&lt;li&gt;copy &lt;code&gt;example-consts.nim&lt;/code&gt; to &lt;code&gt;consts.nim&lt;/code&gt; and &lt;strong&gt;set the variables&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;NOTE: The config is compiled into the binary. There is no "config file"&lt;/li&gt;
&lt;li&gt;Compile the app with &lt;code&gt;$ nim compile toray.nim&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Launch the program with &lt;code&gt;./tohray&lt;/code&gt;, and the program will start on port &lt;code&gt;:8080&lt;/code&gt; - &lt;a href="http://localhost:8080" rel="noopener noreferrer"&gt;http://localhost:8080&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Go to &lt;a href="http://localhost:8080/register" rel="noopener noreferrer"&gt;http://localhost:8080/register&lt;/a&gt; (not visible on the web page itself)&lt;/li&gt;
&lt;li&gt;Use the &lt;code&gt;inviteCode&lt;/code&gt; you set in &lt;code&gt;consts.nim&lt;/code&gt; along with your name and password&lt;/li&gt;
&lt;li&gt;Click on &lt;code&gt;Write&lt;/code&gt; to start writing. I recomment writing a post with slug &lt;code&gt;about&lt;/code&gt; so that the &lt;code&gt;about&lt;/code&gt; link on the top nav actually goes to the about page.&lt;/li&gt;
&lt;li&gt;The data is stored in a &lt;code&gt;sqlite&lt;/code&gt; databse given in the &lt;code&gt;consts.nim&lt;/code&gt; file&lt;/li&gt;
&lt;li&gt;NOTE: if you want to see how the blog looks with some entries in it, you can run &lt;code&gt;sqlite3 tohray.db &amp;lt; test.sql&lt;/code&gt; to see some &lt;code&gt;lorem ipsum&lt;/code&gt; content.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installation on fly.io
&lt;/h2&gt;

&lt;p&gt;I wrote this so that I can run it &lt;code&gt;fly.io&lt;/code&gt;.  Study the &lt;code&gt;Dockerfile&lt;/code&gt; and &lt;code&gt;fly.toml&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Observe how I copy &lt;code&gt;fly-consts.nim&lt;/code&gt; to &lt;code&gt;consts.nim&lt;/code&gt; in the &lt;code&gt;Dockerfile&lt;/code&gt;. This allows you to have a&lt;br&gt;
local copy (on the computer) with the secrets etc, but will be compiled into the binary on deployment.&lt;/p&gt;

&lt;p&gt;To create the volume where the database is stored (&lt;code&gt;/mnt/db&lt;/code&gt; in &lt;code&gt;fly.toml&lt;/code&gt;), you have to use this&lt;br&gt;
command: &lt;code&gt;fly volumes create db -r atl&lt;/code&gt;. Here, &lt;code&gt;atl&lt;/code&gt; stands for Atlanta, where I launched the app.&lt;br&gt;
The app and the volume should be in the same zone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Todo
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[x] Export all the posts in a JSON file (and markdown)&lt;/li&gt;
&lt;li&gt;[x] Add a calendar view&lt;/li&gt;
&lt;li&gt;[x] Edit Posts. &lt;del&gt;Don't hold your breath&lt;/del&gt;
&lt;/li&gt;
&lt;li&gt;[x] Add calendar and export links&lt;/li&gt;
&lt;li&gt;[x] RSS Feed&lt;/li&gt;
&lt;li&gt;[ ] Fix Broken Search&lt;/li&gt;
&lt;li&gt;[ ] Fix "Next Page" and "Previous Page" navigation&lt;/li&gt;
&lt;li&gt;[ ] Implement &lt;code&gt;/import&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Deploy on other PaaS platforms like unicraft etc.&lt;/li&gt;
&lt;li&gt;[ ] Make a static build of this docker image. Currently, it is using a full sized Ubuntu Normal image. bleh.&lt;/li&gt;
&lt;li&gt;[ ] Make it &lt;a href="https://github.com/godofredoninja/simply/pull/150" rel="noopener noreferrer"&gt;Apple podcast compatible&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>nim</category>
      <category>webdev</category>
      <category>fly</category>
    </item>
    <item>
      <title>Fun with your Amazon order history</title>
      <dc:creator>Pradeep Gowda</dc:creator>
      <pubDate>Tue, 11 Sep 2018 02:11:28 +0000</pubDate>
      <link>https://dev.to/btbytes/fun-with-your-amazon-order-history-jdg</link>
      <guid>https://dev.to/btbytes/fun-with-your-amazon-order-history-jdg</guid>
      <description>&lt;h2&gt;
  
  
  Querying Amazon Purchase data
&lt;/h2&gt;

&lt;p&gt;Create an order history report using &lt;a href="https://www.amazon.com/gp/help/customer/display.html?nodeId=200131240" rel="noopener noreferrer"&gt;instructions here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Load CSV into &lt;a href="https://www.sqlite.org/index.html" rel="noopener noreferrer"&gt;SQLite&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sqlite&amp;gt; .mode csv
sqlite&amp;gt; .import ./01-Jan-2009_to_11-Sep-2018.csv orders
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Table schema&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sqlite&amp;gt; .sch
CREATE TABLE orders(
  "Order Date" TEXT,
  "Order ID" TEXT,
  "Title" TEXT,
  "Category" TEXT,
  "ASIN/ISBN" TEXT,
  "UNSPSC Code" TEXT,
  "Website" TEXT,
  "Release Date" TEXT,
  "Condition" TEXT,
  "Seller" TEXT,
  "Seller Credentials" TEXT,
  "List Price Per Unit" TEXT,
  "Purchase Price Per Unit" TEXT,
  "Quantity" TEXT,
  "Payment Instrument Type" TEXT,
  "Purchase Order Number" TEXT,
  "PO Line Number" TEXT,
  "Ordering Customer Email" TEXT,
  "Shipment Date" TEXT,
  "Shipping Address Name" TEXT,
  "Shipping Address Street 1" TEXT,
  "Shipping Address Street 2" TEXT,
  "Shipping Address City" TEXT,
  "Shipping Address State" TEXT,
  "Shipping Address Zip" TEXT,
  "Order Status" TEXT,
  "Carrier Name &amp;amp; Tracking Number" TEXT,
  "Item Subtotal" TEXT,
  "Item Subtotal Tax" TEXT,
  "Item Total" TEXT,
  "Tax Exemption Applied" TEXT,
  "Tax Exemption Type" TEXT,
  "Exemption Opt-Out" TEXT,
  "Buyer Name" TEXT,
  "Currency" TEXT,
  "Group Name" TEXT
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Simple query for all the books (the ISBNs do not start with letter &lt;code&gt;B&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;sqlite&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="nv"&gt;"Order Date"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;"Title"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;"ASIN/ISBN"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;"Purchase Price Per Unit"&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt; &lt;span class="k"&gt;where&lt;/span&gt; &lt;span class="nv"&gt;"ASIN/ISBN"&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;LIKE&lt;/span&gt; &lt;span class="nv"&gt;"B%"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Total money spent on Books:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;sqlite&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="k"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;CAST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;"QUANTITY"&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="nb"&gt;DECIMAL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;CAST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SUBSTR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;"Purchase Price Per Unit"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="nb"&gt;DECIMAL&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt; &lt;span class="k"&gt;where&lt;/span&gt; &lt;span class="nv"&gt;"ASIN/ISBN"&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;LIKE&lt;/span&gt; &lt;span class="nv"&gt;"B%"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>amazon</category>
      <category>sql</category>
      <category>sqlite</category>
      <category>csv</category>
    </item>
    <item>
      <title>c9x edit</title>
      <dc:creator>Pradeep Gowda</dc:creator>
      <pubDate>Wed, 13 Jun 2018 19:55:01 +0000</pubDate>
      <link>https://dev.to/btbytes/c9x-edit--i8n</link>
      <guid>https://dev.to/btbytes/c9x-edit--i8n</guid>
      <description>&lt;p&gt;In order to compile &lt;a href="http://c9x.me/edit/" rel="noopener noreferrer"&gt;c9x edit&lt;/a&gt; on a Mac, you will have to do the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig
make
./obj/edit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;this will launch the &lt;code&gt;ed&lt;/code&gt; window using X11 (XQuartz).&lt;/p&gt;

</description>
      <category>editor</category>
      <category>x11</category>
      <category>macosx</category>
    </item>
    <item>
      <title>You don't need no stinking projects [dub version]</title>
      <dc:creator>Pradeep Gowda</dc:creator>
      <pubDate>Fri, 16 Feb 2018 20:03:16 +0000</pubDate>
      <link>https://dev.to/btbytes/you-dont-need-no-stinking-projects-dub-version--476c</link>
      <guid>https://dev.to/btbytes/you-dont-need-no-stinking-projects-dub-version--476c</guid>
      <description>&lt;p&gt;Let's say you want to build an application that you know will fit in a single file. Many of the scripting/automation programs fall in this category. However, the program depends on a third-party library. You think you may need to setup a "project", and you start thinking "maybe I can just use Python for this". But then still you are left with the task of (globally) installing the package using pip or creating a &lt;code&gt;virtualenv&lt;/code&gt;. And if you have to "ship" this program, you are left with no choice but to ship with a dependency management tool (ie., &lt;code&gt;requirements.txt&lt;/code&gt; or a &lt;code&gt;Pipfile&lt;/code&gt;). With D, (specifically &lt;code&gt;dub&lt;/code&gt;), you can have your cake and eat it too.&lt;/p&gt;

&lt;p&gt;Show me the code!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight d"&gt;&lt;code&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="p"&gt;!/&lt;/span&gt;&lt;span class="n"&gt;usr&lt;/span&gt;&lt;span class="p"&gt;/&lt;/span&gt;&lt;span class="n"&gt;bin&lt;/span&gt;&lt;span class="p"&gt;/&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt; &lt;span class="n"&gt;dub&lt;/span&gt;
&lt;span class="cm"&gt;/+ dub.sdl:
    name "allthepythons"
    dependency "d-glob" version="~&amp;gt;0.3.0"
+/&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stdio&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;glob&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;glob&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entry&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;glob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/usr/local/bin/python*"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;writefln&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"%s"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above program, you are using a third-party library called &lt;a href="https://code.dlang.org/packages/d-glob" rel="noopener noreferrer"&gt;glob-d&lt;/a&gt; (you might argue, "with python, you don't have use a third-party library for this, hah!". Bear with me here, this is after all a made-up example!).&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;#!/usr/bin/env dub&lt;/code&gt; hashbang tells the shell to use D's &lt;code&gt;dub&lt;/code&gt; &lt;a href="https://code.dlang.org/getting_started" rel="noopener noreferrer"&gt;package manager&lt;/a&gt;, to run the code that follows.&lt;/p&gt;

&lt;p&gt;The comment section enclosed in &lt;code&gt;/+ +/&lt;/code&gt; is a special section meant for &lt;code&gt;dub&lt;/code&gt;, that informs what this single-file package is called (&lt;code&gt;allthepythons&lt;/code&gt;) and what dependencies it has (&lt;code&gt;d-glob&lt;/code&gt;). Dub supports two data definition languages by default -- &lt;a href="https://code.dlang.org/package-format?lang=json" rel="noopener noreferrer"&gt;json&lt;/a&gt; and &lt;a href="https://code.dlang.org/package-format?lang=sdl" rel="noopener noreferrer"&gt;sdl&lt;/a&gt;. I used &lt;code&gt;sdl&lt;/code&gt; here, because it is easy on the eyes.&lt;/p&gt;

&lt;p&gt;Rest of the code is easy to understand, that needs no special explanation.&lt;/p&gt;

&lt;p&gt;Running the script is straight-forward:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;./allthepythons.d

/usr/local/bin/python2
/usr/local/bin/python3
... truncated ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is &lt;em&gt;excellent&lt;/em&gt; for developing, testing and scripting. However, what if you need to deploy a binary to a machine that a) does not have dub installed? and/or b) does not have an internet connection to automatically download packages from the internet? (for say, security considerations). Converting the above file to a binary is easy-peasy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;dub build &lt;span class="nt"&gt;--single&lt;/span&gt; allthepythons.d
Performing &lt;span class="s2"&gt;"debug"&lt;/span&gt; build using dmd &lt;span class="k"&gt;for &lt;/span&gt;x86_64.
d-glob 0.3.0: target &lt;span class="k"&gt;for &lt;/span&gt;configuration &lt;span class="s2"&gt;"default"&lt;/span&gt; is up to date.
allthepythons ~master: building configuration &lt;span class="s2"&gt;"application"&lt;/span&gt;...
Linking...
To force a rebuild of up-to-date targets, run again with &lt;span class="nt"&gt;--force&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will end up with a binary named &lt;code&gt;allthepythons&lt;/code&gt; that can then be deployed easily.&lt;/p&gt;

&lt;p&gt;Note: In order to produce a "release" binary, add &lt;code&gt;--build=release&lt;/code&gt; to the &lt;code&gt;dub build&lt;/code&gt; command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dub build &lt;span class="nt"&gt;--build&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;release &lt;span class="nt"&gt;--single&lt;/span&gt; allthepythons.d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thanks to &lt;a href="https://www.reddit.com/user/aravindavk" rel="noopener noreferrer"&gt;Aravinda K&lt;/a&gt; on Reddit for pointing it out!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Viva la D!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/btbytes/608a52b705b403df73c13bfe2a8ca718" rel="noopener noreferrer"&gt;source code on gist.github.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>dlang</category>
      <category>d</category>
    </item>
  </channel>
</rss>
