<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ndamulelo Nemakhavhani on Medium]]></title>
        <description><![CDATA[Stories by Ndamulelo Nemakhavhani on Medium]]></description>
        <link>https://medium.com/@ndamulelo?source=rss-622c04212996------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*spwh851F90MhSqGZt0VwZw.png</url>
            <title>Stories by Ndamulelo Nemakhavhani on Medium</title>
            <link>https://medium.com/@ndamulelo?source=rss-622c04212996------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 22:54:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ndamulelo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[pydrizzle-orm (alpha): Python Schema Definitions with Drizzle-Style Migrations]]></title>
            <link>https://ndamulelo.medium.com/pydrizzle-orm-alpha-python-schema-definitions-with-drizzle-style-migrations-b06b98cba193?source=rss-622c04212996------2</link>
            <guid isPermaLink="false">https://medium.com/p/b06b98cba193</guid>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[drizzleorm]]></category>
            <category><![CDATA[relational-databases]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Ndamulelo Nemakhavhani]]></dc:creator>
            <pubDate>Sat, 14 Mar 2026 07:43:28 GMT</pubDate>
            <atom:updated>2026-03-14T07:43:28.321Z</atom:updated>
            <content:encoded><![CDATA[<p>Database migrations in Python have long been dominated by <strong>Alembic</strong>. It works — but I personally always encounter the same frustrations:</p><ul><li>Configuration overhead that demands more attention than the schema changes themselves</li><li>Unreliable autogenerate output</li><li>Too many moving parts for my taster</li></ul><blockquote><strong>Disclaimer</strong>: This is a very opinionated article. If Alembic already feels effortless to you, you can safely skip this one.</blockquote><p>Meanwhile, the JavaScript ecosystem produced <strong>drizzle-kit</strong> — a migration engine that deterministically diffs schemas and generates clean, readable SQL. The catch is obvious: it expects <strong>TypeScript input</strong>, which makes it inaccessible to most Python projects.</p><blockquote><strong>pydrizzle-orm</strong> is an attempt to bridge that gap.</blockquote><p>You define your database schema in <strong>Python</strong>, the tool converts it to <strong>Drizzle-compatible TypeScript</strong>, and then delegates to <strong>drizzle-kit</strong> for schema diffing and migration generation.</p><p>The result: <strong>versioned SQL migration files</strong> that can be reviewed, committed, and applied consistently across environments.</p><h3>How It Works</h3><p>The workflow is intentionally simple.</p><pre>pip install pydrizzle-orm</pre><p>Initialize the project:</p><pre>pydrizzle-orm init</pre><p>Generate TypeScript schema files for Drizzle:</p><pre>pydrizzle-orm generate</pre><p>Create versioned SQL migration files:</p><pre>pydrizzle-orm migrate</pre><p>Apply migrations to your database:</p><pre>pydrizzle-orm push</pre><h3>Three Ways to Define Your Schema</h3><p>Not every project starts from scratch. pydrizzle-orm supports <strong>three schema input modes</strong>.</p><h3>1. Native DSL</h3><p>Schemas are defined using a lightweight Python DSL that maps directly to PostgreSQL types.</p><pre>from pydrizzle_orm import pg_table, text, timestamp, uuid, index</pre><pre>users = pg_table(<br>    &quot;users&quot;,<br>    id=uuid().primary_key().default_random(),<br>    email=text().not_null().unique(),<br>    name=text().not_null(),<br>    created_at=timestamp().default_now().not_null(),<br>    indexes=[index(&quot;users_email_idx&quot;).on(&quot;email&quot;)],<br>)</pre><p><strong><em>NOTE</em>: pydrizzle-orm is migrations-only.</strong></p><p>Use any query layer you prefer:</p><ul><li>Raw SQL</li><li>SQLAlchemy Core</li><li>asyncpg</li><li>or any other database client</li></ul><h3>2. SQLAlchemy Introspection</h3><p>Point the tool at existing SQLAlchemy models and it will <strong>read them directly</strong>.<br>No rewriting required.</p><pre>[pydrizzle]<br>out_dir = &quot;.pydrizzle&quot;<br><br>[pydrizzle.modes.sqlalchemy]<br>schema = &quot;myapp.models&quot;<br>schema_type = &quot;sqlalchemy&quot;</pre><h3>3. TypeScript Pass-Through</h3><p>If you already have <strong>Drizzle </strong><strong>.ts schema files</strong>—for example in a full-stack monorepo—you can use them as-is.</p><p><strong>Versioned SQL migration files generated and managed using </strong><a href="https://orm.drizzle.team/docs/kit-overview"><strong>drizzle-kit</strong></a><strong>.</strong></p><h3>Project Links</h3><p>GitHub<br><a href="https://github.com/ndamulelonemakh/pydrizzle-orm">https://github.com/ndamulelonemakh/pydrizzle-orm</a></p><p>PyPI<br><a href="https://pypi.org/project/pydrizzle-orm/">https://pypi.org/project/pydrizzle-orm/</a></p><p><a href="https://github.com/ndamulelonemakh/pydrizzle-orm/tree/main/docs/example">Example Project</a>.</p><p><strong><em>pydrizzle-orm is open source. your feedback and contributions are welcome.</em></strong> 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b06b98cba193" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Debug C++ in VsCode]]></title>
            <link>https://ndamulelo.medium.com/how-to-debug-c-in-vscode-2530d0266e78?source=rss-622c04212996------2</link>
            <guid isPermaLink="false">https://medium.com/p/2530d0266e78</guid>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[cpp]]></category>
            <category><![CDATA[wsl]]></category>
            <dc:creator><![CDATA[Ndamulelo Nemakhavhani]]></dc:creator>
            <pubDate>Sat, 02 Oct 2021 10:18:17 GMT</pubDate>
            <atom:updated>2021-10-02T10:18:17.953Z</atom:updated>
            <content:encoded><![CDATA[<p>Debugging a project with multiple source files on Linux. For more info checkout the <a href="https://code.visualstudio.com/docs/cpp/config-linux">official vscode guide </a>.</p><pre>This code was tested on Ubuntu 18.04 running on WSL</pre><p>task.json</p><pre>{</pre><pre>&quot;tasks&quot;: [</pre><pre>{</pre><pre>&quot;type&quot;: &quot;cppbuild&quot;,</pre><pre>&quot;label&quot;: &quot;C/C++: g++ build active file&quot;,</pre><pre>&quot;command&quot;: &quot;/usr/bin/g++&quot;,</pre><pre>&quot;args&quot;: [</pre><pre>&quot;-g&quot;,</pre><pre><strong>&quot;*.cpp&quot;</strong>,</pre><pre>&quot;-o&quot;,</pre><pre>&quot;${fileDirname}/${fileBasenameNoExtension}&quot;</pre><pre>],</pre><pre>&quot;options&quot;: {</pre><pre>&quot;cwd&quot;: &quot;${fileDirname}&quot;</pre><pre>},</pre><pre>&quot;problemMatcher&quot;: [</pre><pre>&quot;$gcc&quot;</pre><pre>],</pre><pre>&quot;group&quot;: {</pre><pre>&quot;kind&quot;: &quot;build&quot;,</pre><pre>&quot;isDefault&quot;: true</pre><pre>},</pre><pre>&quot;detail&quot;: &quot;Task generated by Debugger.&quot;</pre><pre>}</pre><pre>],</pre><pre>&quot;version&quot;: &quot;2.0.0&quot;</pre><pre>}</pre><h3>Make sure that you start the debugger from the main source file!!!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2530d0266e78" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Install Pandoc on Ubuntu]]></title>
            <link>https://ndamulelo.medium.com/install-pandoc-on-ubuntu-9cd9991735a2?source=rss-622c04212996------2</link>
            <guid isPermaLink="false">https://medium.com/p/9cd9991735a2</guid>
            <category><![CDATA[pandoc]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[nbconvert]]></category>
            <category><![CDATA[jupyter-notebook]]></category>
            <dc:creator><![CDATA[Ndamulelo Nemakhavhani]]></dc:creator>
            <pubDate>Mon, 28 Jun 2021 12:21:12 GMT</pubDate>
            <atom:updated>2021-06-28T12:24:41.297Z</atom:updated>
            <content:encoded><![CDATA[<p>Simple instructions for installing the latest version of <a href="https://pandoc.org/">pandoc </a>on Ubuntu</p><blockquote>This commands were tested on Ubuntu 18.04 on WSL2. They should work the same way in other ubuntu distributions as well.</blockquote><pre># Make sure to remove all previous versions</pre><pre>sudo apt-get purge --auto-remove pandoc</pre><pre># Download the latest version of pandoc from <a href="https://github.com/jgm/pandoc/releases">github</a>(Update version as required)</pre><pre>wget https://github.com/jgm/pandoc/releases/download/<a href="https://github.com/jgm/pandoc/releases/tag/2.14.0.3">2.14.0.3</a>/<a href="https://github.com/jgm/pandoc/releases/download/2.14.0.3/pandoc-2.14.0.3-1-amd64.deb">pandoc-2.14.0.3-1-amd64.deb</a></pre><pre># Install<br>sudo dpkg -i <a href="https://github.com/jgm/pandoc/releases/download/2.14.0.3/pandoc-2.14.0.3-1-amd64.deb">pandoc-2.14.0.3-1-amd64.deb</a></pre><pre><br># Check installation</pre><pre>pandoc -v</pre><p>You can find the latest release from the <a href="https://github.com/jgm/pandoc/releases">official pandoc github repo</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9cd9991735a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[.NET 5 Hello World]]></title>
            <link>https://ndamulelo.medium.com/net-5-hello-world-2bb13a856973?source=rss-622c04212996------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bb13a856973</guid>
            <category><![CDATA[dotnet-5]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[csharp]]></category>
            <dc:creator><![CDATA[Ndamulelo Nemakhavhani]]></dc:creator>
            <pubDate>Wed, 11 Nov 2020 12:23:33 GMT</pubDate>
            <atom:updated>2020-11-11T12:23:33.378Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Net 5 is finally here! <a href="https://devblogs.microsoft.com/dotnet/announcing-net-5-0/">Official announcement</a>.</blockquote><p>Let’s test it out by writing the famous <a href="https://en.wikipedia.org/wiki/%22Hello,_World!%22_program">Hello word</a> console app.</p><h3>Getting started</h3><ul><li>Download <a href="https://visualstudio.microsoft.com/">Visual studio 16.8</a></li><li>Create a new .Net core application</li><li>Open your project settings file and change the target framework to .Net 5 as illustrated below:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*rdVeHJ9gYGb0dR7h8eollg.png" /><figcaption>.Net 5 Console app example</figcaption></figure><ul><li>Add this code to <em>Program.cs</em></li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6076e95ee7bb2c01768e651c698bc3a5/href">https://medium.com/media/6076e95ee7bb2c01768e651c698bc3a5/href</a></iframe><ul><li>Now go ahead and run this masterpiece!</li><li>You can read more about .Net 5 and C#9 <a href="https://devblogs.microsoft.com/dotnet/welcome-to-c-9-0/">here</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bb13a856973" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pipenv for dummies]]></title>
            <link>https://ndamulelo.medium.com/pipenv-for-dummies-e7eb4f89d9fc?source=rss-622c04212996------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7eb4f89d9fc</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pipenv]]></category>
            <category><![CDATA[virtual-environment]]></category>
            <category><![CDATA[pip]]></category>
            <dc:creator><![CDATA[Ndamulelo Nemakhavhani]]></dc:creator>
            <pubDate>Sun, 26 Jul 2020 09:12:29 GMT</pubDate>
            <atom:updated>2020-07-26T09:12:29.252Z</atom:updated>
            <content:encoded><![CDATA[<p>Easy way to manage <a href="https://realpython.com/python-virtual-environments-a-primer/">python virtual environments</a>.</p><h4>Pre-requisites</h4><ul><li>Python 3.x or Python 2.7.x</li><li><a href="https://pypi.org/project/pip/">pip</a> (Python package installer)</li></ul><h3>1. Installation</h3><ul><li>Use pip to install pipenv</li></ul><pre>$ python -m pip install --upgrade pipenv</pre><pre>$ pipenv --version  # Verify installation</pre><h3>2. Create a new pipenv project</h3><ul><li>There are multiple ways to create projects using pipenv. Examples:</li></ul><pre># i. Creates new project using the latest version of python 2x or 3x</pre><pre>$ pipenv --two<br>$ pipenv --three</pre><pre><br># ii. Using a specific python version<br>$ pipenv --python 3.6.5</pre><pre><br># iii. Specify a path where python is installed<br>$ pipenv --python /path/to/python</pre><h3>3. Manage project dependencies</h3><ul><li>The project dependencies are stored inside the <a href="https://pipenv.pypa.io/en/latest/basics/#example-pipfile-pipfile-lock">Pipfile</a></li><li>Example:</li></ul><pre>$ pipenv install requests</pre><ul><li>It’s also possible to install dependencies that will be used in the development environment <strong>only</strong>.</li><li>Example:</li></ul><pre>$ pipenv install --dev pytest</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*UFLb_Q-d90XFzpEdGy4ChA.png" /><figcaption><a href="https://pipenv.pypa.io/en/latest/basics/#example-pipfile-pipfile-lock">Example Pipfile</a></figcaption></figure><h3>References</h3><ul><li><strong><em>pipenv — help</em></strong><em> </em>(Run from the command line)</li><li><a href="https://pipenv.pypa.io/en/latest/#install-pipenv-today">Official pipenv documentation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7eb4f89d9fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[VirtualBox Networking Modes]]></title>
            <link>https://ndamulelo.medium.com/virtualbox-networking-modes-17ff1480fcfd?source=rss-622c04212996------2</link>
            <guid isPermaLink="false">https://medium.com/p/17ff1480fcfd</guid>
            <category><![CDATA[virtualbox]]></category>
            <category><![CDATA[virtual-machine]]></category>
            <category><![CDATA[vagrant]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[Ndamulelo Nemakhavhani]]></dc:creator>
            <pubDate>Sun, 07 Jun 2020 13:12:25 GMT</pubDate>
            <atom:updated>2020-06-07T13:40:39.040Z</atom:updated>
            <content:encoded><![CDATA[<p>A brief comparison of networking modes in <a href="https://www.virtualbox.org/">Oracle Virtualbox</a>.</p><h3>NAT</h3><ul><li><a href="https://en.wikipedia.org/wiki/Network_address_translation">NAT</a>(Network Address Translation) mode is the <strong>default mode</strong> when you spin up a new virtual machine(<a href="https://en.wikipedia.org/wiki/Virtual_machine">vm</a>) on virtual box.</li><li>This mode allows the <a href="https://en.wikipedia.org/wiki/Virtual_machine">vm </a>to <strong>communicate with the ‘internet’</strong> by using the <strong>host machine</strong> as a <a href="https://en.wikipedia.org/wiki/Proxy_server"><strong>proxy</strong></a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*Gs8R3ScZTlO3JKFsw9QqUA.jpeg" /><figcaption>Figure 1: Virtualbox default networking mode</figcaption></figure><ul><li>Communication to the vm can be made by configuring <strong>port forwarding </strong>through the vritualbox GUI or a CLI tool such as <a href="https://www.vagrantup.com/">Vagrant</a>.</li></ul><pre># Example (using vagrant):</pre><pre>config.vm.network &quot;forwarded_port&quot;, guest: 22, host: 2222</pre><ul><li>This means all traffic to port 2222 on the host will be forwarded to port 22 of the vm.</li></ul><h3>NAT Network</h3><ul><li>Instead of creating a virtual NAT engine for each vm, Virtualbox creates one NAT engine is used for all <a href="https://en.wikipedia.org/wiki/Virtual_machine">vms </a>as illustrated below:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LoTbj6oF-QGgOoy2.png" /><figcaption>Source: <a href="https://www.nakivo.com/blog/virtualbox-network-setting-guide/">VirtualBox Network Settings: Complete Guide</a></figcaption></figure><ul><li>As it is shown above, the vms can communicate to each other and as well as the ‘internet’.</li></ul><h3>Internal or Private Network</h3><ul><li>This mode allows the vms to be completely isolated from the host and the ‘internet’.</li><li>That is unlike NAT network mode, communication only occurs among the <a href="https://en.wikipedia.org/wiki/Virtual_machine">vms </a>connected to the internal network.</li></ul><h3>Host Only Network</h3><ul><li>In this mode, a V<strong>irtual Ethernet adapter </strong>is used to allow the host and the <a href="https://en.wikipedia.org/wiki/Virtual_machine"><strong>vms </strong></a><strong>to communicate directly</strong>.</li><li>The vms cannot communicate with any external network in this mode</li></ul><h3>Hybrid or Bridge Network</h3><ul><li>In this mode the vm acts as a physical device connected to your network</li><li>Basically, this is similar to buying a new computer and connecting it to your home or office network.</li></ul><h3>References</h3><ul><li><a href="https://www.nakivo.com/blog/virtualbox-network-setting-guide/">VirtualBox Network Settings: Complete Guide</a></li><li><a href="https://www.youtube.com/watch?v=cDF4X7RmV4Qhttps://www.youtube.com/watch?v=cDF4X7RmV4Q">VirtualBox Networking (NAT &amp; Port Forwarding, Bridged, Internal, Host-Only)</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17ff1480fcfd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Log Levels Using A Practical Example]]></title>
            <link>https://ndamulelo.medium.com/understanding-log-levels-using-a-practical-example-ac0b9814eba2?source=rss-622c04212996------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac0b9814eba2</guid>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[loglevel]]></category>
            <category><![CDATA[logging-level]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Ndamulelo Nemakhavhani]]></dc:creator>
            <pubDate>Wed, 03 Jun 2020 08:58:47 GMT</pubDate>
            <atom:updated>2020-06-03T08:58:47.513Z</atom:updated>
            <content:encoded><![CDATA[<p>Example: Say you have an authentication API, that receives a JSON request to register a new user.</p><p>How would you log events that occur in the end-to-end new user registration process? Here’s how <strong>I</strong> would do it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*15nTmNAYU60KBOjJdpxHLQ.jpeg" /></figure><ul><li>The arrows represent the setting on your logger instance</li><li>For example, if you set the level to DEBUG, you will see all the logs in your logs.</li><li>If you set it to warn, you will only see warning, error and fatal logs. Assuming you are using a single logging instance(i.e. All logs go to a single log file)</li></ul><h4>Using multiple loggers</h4><ul><li>If you use multiple logging instances, you can set each logger to have different levels.</li><li>That is, you can group all the fatal errors in one file, and set alerts according to your specific needs.</li></ul><h4>Using Logging Levels Effectively</h4><ul><li><strong>FATAL</strong> — “Logs that describe an <strong>unrecoverable</strong> application or <strong>system crash</strong>, or a catastrophic failure that requires immediate attention” — <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.loglevel?view=dotnet-plat-ext-3.1"><em>LogLevel Enum</em></a></li><li><strong>ERROR</strong> — “Logs that highlight when the <strong>current flow</strong> of execution is <strong>stopped due to a failure</strong>. These should indicate a failure in the current activity, not an application-wide failure.” — <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.loglevel?view=dotnet-plat-ext-3.1"><em>LogLevel Enum</em></a></li><li><strong>WARN</strong> — “Logs that highlight an abnormal or unexpected event in the application flow, but do not otherwise cause the application execution to stop.” — <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.loglevel?view=dotnet-plat-ext-3.1"><em>LogLevel Enum</em></a></li><li><strong>INFO</strong> — Logs that track the general flow of the application.</li><li><strong>DEBUG</strong> —”Logs that are used for interactive investigation during development. These logs should primarily contain information useful for debugging and have no long-term value.” — <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.loglevel?view=dotnet-plat-ext-3.1"><em>LogLevel Enum</em></a></li></ul><h3>Reference</h3><ul><li><a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.loglevel?view=dotnet-plat-ext-3.1">https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.loglevel?view=dotnet-plat-ext-3.1</a></li><li>Happy to know what you think in the comments. Thanks for reading.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac0b9814eba2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pyinstaller | Converting python scripts into executables]]></title>
            <link>https://ndamulelo.medium.com/pyinstaller-converting-python-scripts-into-executables-3ac3e878d13c?source=rss-622c04212996------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ac3e878d13c</guid>
            <category><![CDATA[pyinstaller]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Ndamulelo Nemakhavhani]]></dc:creator>
            <pubDate>Sat, 18 Apr 2020 20:05:00 GMT</pubDate>
            <atom:updated>2020-04-18T20:05:00.037Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*MxnczG7VKSiF_54GHTuUfw.jpeg" /></figure><p><strong>Reference</strong>: <a href="https://www.pyinstaller.org/">pyinstaller home</a></p><blockquote>Question: How do you go from<strong> python myscript.py -verbose</strong> to just <strong>myscrpt -verbose</strong>? Follow along to find out!</blockquote><h4>Before we begin</h4><ol><li>Install the required packages</li></ol><pre>$ pip install --upgrade pyinstaller</pre><p>2. Add the python scripts folder to the system path if you have not done so already</p><h3>The basics</h3><ol><li>Basic usage</li></ol><pre>$ pyinstaller &lt;your-script&gt;.py</pre><pre># output(s):<br># &lt;your-script&gt;.spec - Default settings used to generate exe<br># build/ - Build artifacts e.g. build logs<br># dist/ - contains <strong>&lt;your-script&gt;.exe</strong> + python dependencies</pre><p>2. Useful options</p><ul><li><strong>— name</strong> | Specify the name of the generated executable</li><li><strong>— onefile</strong> | Bundle all binary artifacts into one executable file</li><li><strong>— distpath</strong> | Customize the output directory of the generated executable</li><li><strong>-y</strong> or <strong>— no-confirm</strong> | Replace dist_path contents without asking for confirmation</li><li><strong>— exclude-module</strong> | Ignore modules not required to make the executable</li></ul><pre># example:<br>$ pyinstaller --exclude-module pytest ex.py</pre><ul><li><strong>— paths</strong> | Specify additional import folders</li><li><strong>— add-data</strong> | Include any additional data file e.g. config.xml</li><li><strong>— add-binary</strong> | Include additional binary data files</li><li><a href="https://pyinstaller.readthedocs.io/en/stable/usage.html#options">More info</a>.</li></ul><p>3. Using the spec file to specify build options</p><ul><li>As an alternative to specifying multiple command line options, you can use a spec file to generated your executable</li></ul><pre># Example:</pre><pre>$ pyinstaller &lt;your_script&gt;.spec</pre><ul><li>Here is an example of a spec file you might use:</li></ul><pre># -*- mode: python ; coding: utf-8 -*-<br><br>block_cipher = None<br><br><br>a = Analysis([&#39;src1.py&#39;, &#39;src2.py&#39;],<br>             pathex=[&#39;root_path\&#39;, &#39;extra_pythonpath\&#39;],<br>             binaries=[],<br>             datas=[],<br>             hiddenimports=[],<br>             hookspath=[],<br>             runtime_hooks=[],<br>             excludes=[],<br>             win_no_prefer_redirects=False,<br>             win_private_assemblies=False,<br>             cipher=block_cipher,<br>             noarchive=False)<br>pyz = PYZ(a.pure, a.zipped_data,<br>             cipher=block_cipher)<br>exe = EXE(pyz,<br>          a.scripts,<br>          [],<br>          exclude_binaries=True,<br>          name=&#39;pybuildselector&#39;,<br>          debug=False,<br>          bootloader_ignore_signals=False,<br>          strip=False,<br>          upx=True,<br>          console=True )<br>coll = COLLECT(exe,<br>               a.binaries,<br>               a.zipfiles,<br>               a.datas,<br>               strip=False,<br>               upx=True,<br>               upx_exclude=[],<br>               name=&#39;pybuildselector&#39;)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ac3e878d13c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Convert a Python Script into an executable]]></title>
            <link>https://ndamulelo.medium.com/convert-a-python-script-into-an-executable-a61cde190105?source=rss-622c04212996------2</link>
            <guid isPermaLink="false">https://medium.com/p/a61cde190105</guid>
            <category><![CDATA[argparse]]></category>
            <category><![CDATA[pyinstaller]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[psutil]]></category>
            <dc:creator><![CDATA[Ndamulelo Nemakhavhani]]></dc:creator>
            <pubDate>Sat, 18 Apr 2020 17:07:21 GMT</pubDate>
            <atom:updated>2020-04-18T19:51:48.353Z</atom:updated>
            <content:encoded><![CDATA[<p>This simple guide will show you how you can use <strong>pyinstaller</strong> and <a href="https://docs.python.org/3/library/argparse.html"><strong>argparse</strong></a> to create a simple console application with python.</p><h4>Required tools</h4><ul><li>Python 3.x (with pip)</li><li>Python code editor e.g. <a href="https://www.jetbrains.com/pycharm/download/">Pycharm</a></li><li><a href="https://pypi.org/project/psutil/">psutil</a></li></ul><pre>$ pip install --upgrade psutil</pre><ul><li><a href="https://www.pyinstaller.org/">pyinstaller</a></li></ul><pre>$ pip install --upgrade pyinstaller</pre><blockquote>Lets try this out by creating a simple console app that will list processes or applications that are currently running on your <strong>PC</strong>.</blockquote><ol><li>Create a python script named <em>proclist.py</em></li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/659b5d2b459c800838c1149f9384afa1/href">https://medium.com/media/659b5d2b459c800838c1149f9384afa1/href</a></iframe><ul><li>We use <em>psutil.process_iter([‘pid’, ‘name’]) </em>to get a list of all processes running on a machine</li><li>The argparse ibrary allows the user of our script to specify a limit on the number of processes with print to the console.</li><li>At this point we can distribute out script as a .py file and any user with python installed on their machine will be able to use our app.</li></ul><h4>Lets take it a step further</h4><pre># We want the user to run the app as follows</pre><pre>$ proclist --limit 9</pre><pre># instead of,</pre><pre>$ python proclist.py --limit 9</pre><p>2. Create an executable using pyinstaller</p><ul><li>Inside the directory where you script is located, run</li></ul><pre>$ pyinstaller --name proclist --onefile proclist.py</pre><ul><li>This will create an executable inside <strong>distpath</strong> directory name <em>proclist.exe</em></li><li>At this point we can proceed to run our standalone executable as follows:</li></ul><pre>$ cd dist<br>$ proclist --limit 10</pre><ul><li>You should see an output similar to this:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/361/1*sDodBMdskjj4nHz8JnOlnw.png" /><figcaption>Sample output from running proclist — limit 10</figcaption></figure><h3>Closing remarks</h3><ul><li>You can go ahead and add the generated executable to the system path so that it can be executed from any location in the command line shell.</li><li>You might also want to explore the <a href="https://docs.python.org/3/library/argparse.html"><strong>argparse</strong></a> library further to see if you can add more functionality to our simple application. e.g. List 5 applications with the highest cpu usage in the last 5 minutes.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a61cde190105" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vagrant CLI Reference]]></title>
            <link>https://ndamulelo.medium.com/vagrant-cli-reference-ad95def8e39e?source=rss-622c04212996------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad95def8e39e</guid>
            <category><![CDATA[cli]]></category>
            <category><![CDATA[vagrant]]></category>
            <dc:creator><![CDATA[Ndamulelo Nemakhavhani]]></dc:creator>
            <pubDate>Sat, 04 Apr 2020 12:36:28 GMT</pubDate>
            <atom:updated>2020-04-04T12:36:28.669Z</atom:updated>
            <content:encoded><![CDATA[<h4>Useful commands you will need when using vagrant</h4><blockquote><strong>Before we begin</strong>: Make sure vagrant is installed in your machine and added to the path. To verify, run <strong>vagrant -v</strong> and make sure you get a version number of the vagrant version installed on your machine.</blockquote><p><strong>Reference: </strong><a href="https://www.vagrantup.com/docs">Vagrant Official Docs</a></p><h4>TOP 10</h4><ol><li><em>vagrant init</em></li></ol><ul><li>Initialize a new vagrant environment by creating a new Vagrantfile if it does not already exist.</li></ul><pre># Syntax: vagrant init [name [url]]<br># name = name of the box to create i.e. config.vm.box<br># url = url to download the box from<br># Example:</pre><pre>$ vagrant init my-company-box https://boxes/example.box</pre><p><em>2. vagrant up</em></p><pre># Syntax: <em>vagrant up [name|id]</em></pre><pre># name = Name of the box/machine defined in the Vagrantfile<br># id = Unique identifier for any known machine found by running vagrant global-status</pre><ul><li>By default, vagrant uses VirtualBox as a virtualization provider. This can be changed as follows: <em>$ vagran up —provider &lt;provider-name&gt;</em></li></ul><pre># example:<br>$ vagrant up --provider=docker</pre><p>3.<em> vagrant halt</em></p><ul><li>Used to shutdown the virtual machine</li></ul><pre># Syntax: <em>vagrant halt[name|id]<br># Example:</em></pre><pre># vagrant halt -f</pre><ul><li>The option -<strong>f </strong>will force the machine to shutdown,similar to how you unplug power from your PC if its taking ages to shut down.</li></ul><p>4.<em> vagrant suspend</em></p><ul><li>In simple terms , this is similar to the sleep action on your PC.</li></ul><pre># Syntax: <em>vagrant suspend [name|id]</em></pre><pre># Resume the machine to the previous state by running:<br>$<em> vagrant resume</em></pre><p><em>5. vagrant destroy</em></p><ul><li>Removes all the resources consumed when bringing up the current box</li><li>Similar to Reset To Factory Defaults on modern PCs.</li><li>Note that this does not remove the actual box from the host machine</li></ul><pre># Syntax: <em>vagrant destroy [name|id]</em></pre><p>6. <em>vagrant global-status</em></p><ul><li>Shows information about all vagrant environments on your host machine</li></ul><p>7. <em>vagrant ssh</em></p><pre># Syntax: <em>vagrant ssh [name|id] [-- extra_ssh_args]</em><br># If not name or id is specified vagrant will use the default vagrant machine currently running <br># e.g. <em>vagrant ssh</em> is equivalent to <em>vagrant ssh default</em></pre><p>8.<em> vagrant port</em></p><ul><li>List all port mappings between the current virtual machine and the host machine</li></ul><pre># Syntax: vagrant port [name|id]</pre><p>9.<em> vagrant package</em></p><ul><li>This command packages your box into a re-usable box that can be shared with other developers</li></ul><pre># Syntax: vagrant package [name|id]</pre><p>10.<em> vagrant reload</em></p><ul><li>Typically run after configuration changes are made to the Vagrant file.</li><li>It is essentially the same as running vagrant halt followed by vagrant up.</li></ul><p>If at any point you are unsure how to use any vagrant command you can use the built in <a href="https://www.vagrantup.com/docs/cli/">CLI</a> help option as follows.</p><pre>// Syntax: vagrant &lt;command-name&gt; -h</pre><pre>// Example:<br>$ vagrant up -h</pre><p>To be continued…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad95def8e39e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>