<?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: ColeDrain</title>
    <description>The latest articles on DEV Community by ColeDrain (@coledrain).</description>
    <link>https://dev.to/coledrain</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%2F376187%2F9202ae99-34d0-4412-92a5-11a38527032d.jpg</url>
      <title>DEV Community: ColeDrain</title>
      <link>https://dev.to/coledrain</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/coledrain"/>
    <language>en</language>
    <item>
      <title>ChatGPT in the Shell</title>
      <dc:creator>ColeDrain</dc:creator>
      <pubDate>Sat, 25 Mar 2023 14:17:37 +0000</pubDate>
      <link>https://dev.to/coledrain/chatgpt-in-the-shell-5g61</link>
      <guid>https://dev.to/coledrain/chatgpt-in-the-shell-5g61</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction:&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Hello there amigo 👋.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In this tutorial, I will show you how to create a CLI app that allows you to interact with ChatGPT from the command line. The app, named "ChatShell", will allow users to ask for shell commands for specific tasks or chat with ChatGPT directly. We'll be using the Go programming language and Cobra CLI library to create our CLI app and the go-openai library to interact with OpenAI's GPT-3 API.&lt;/p&gt;

&lt;p&gt;Please do give a thumbs-up, if this was insightful in any way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go programming language installed (version 1.20.2 or higher)&lt;/li&gt;
&lt;li&gt;Cobra CLI library installed&lt;/li&gt;
&lt;li&gt;go-openai library installed&lt;/li&gt;
&lt;li&gt;Viper library installed (for config and environment vars)&lt;/li&gt;
&lt;li&gt;An OpenAI API key&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;End Goal:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Able to run shell command of form:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chatshell ask &lt;span class="s2"&gt;"how to delete a local branch ?"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chatshell ask &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"when was gpt first built ?"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Steps:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A. Set up the project structure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Create a new directory for the project and navigate to it&lt;/em&gt;&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;&lt;span class="nb"&gt;mkdir &lt;/span&gt;chatshell
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;chatshell
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Initialize a new Go module&lt;/em&gt;&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;go mod init github.com/&lt;span class="o"&gt;{&lt;/span&gt;your_username&lt;span class="o"&gt;}&lt;/span&gt;/chatshell
&lt;span class="c"&gt;# note: replace {your_username} with actual github username&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Install the Cobra CLI library and go-openai library&lt;/em&gt;&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;go &lt;span class="nb"&gt;install &lt;/span&gt;github.com/spf13/cobra-cli@latest
&lt;span class="nv"&gt;$ &lt;/span&gt;go get &lt;span class="nt"&gt;-u&lt;/span&gt; github.com/sashabaranov/go-openai
&lt;span class="nv"&gt;$ &lt;/span&gt;go get github.com/spf13/viper
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;B. Create the CLI app&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;cobra-cli helps generate boilerplates for your cli app automatically, this speeds up development.&lt;/p&gt;

&lt;p&gt;Use the Cobra CLI to generate the basic structure of the CLI app:&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;cobra-cli init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will generate the basic structure of the CLI app, including a main.go file, a cmd directory, and a LICENSE file.&lt;/p&gt;

&lt;p&gt;You can have a look at the code if you're familiar with cobra.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SHkWFtpc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ns4ukqrei74ow5ulwoix.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SHkWFtpc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ns4ukqrei74ow5ulwoix.png" alt="Project Structure" width="790" height="728"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C. Implement the 'ask' command&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once again we will call on our friend (cobra-cli)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cobra-cli add ask
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will generate a file ask.go which will contain the implementation of the 'ask' command. We have to finetune the boilerplate to our need, below is finetuned code well commented for understanding.&lt;/p&gt;

&lt;p&gt;Import necessary packages&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="c"&gt;/*
Copyright © 2023 Ugochukwu Onyebuchi &amp;lt;pyvinci@gmail.com&amp;gt;
*/&lt;/span&gt;
&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;cmd&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"context"&lt;/span&gt;
    &lt;span class="s"&gt;"fmt"&lt;/span&gt;
    &lt;span class="s"&gt;"os"&lt;/span&gt;
    &lt;span class="s"&gt;"runtime"&lt;/span&gt;

    &lt;span class="s"&gt;"github.com/spf13/cobra"&lt;/span&gt;
    &lt;span class="s"&gt;"github.com/spf13/viper"&lt;/span&gt;
    &lt;span class="n"&gt;openai&lt;/span&gt; &lt;span class="s"&gt;"github.com/sashabaranov/go-openai"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next intialize the askCmd&lt;br&gt;
Use: a short description of how to use the ask command, in our case we expect ask to be followed by a text in quotes&lt;br&gt;
Short: a short description of the ask command&lt;br&gt;
Long: a longer description&lt;br&gt;
Args: we specify we only want one argument, which is a text in quotes&lt;br&gt;
Run: we specify the function to be called, this function will handle the business logic.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="c"&gt;// askCmd represents the ask command&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;askCmd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;cobra&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Command&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Use&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;   &lt;span class="s"&gt;"ask [text]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Short&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"ask ChatGPT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Long&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;  &lt;span class="s"&gt;`ask is used to ask for shell commands for a particular task`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Args&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;  &lt;span class="n"&gt;cobra&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ExactArgs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;runAsk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;// authToken holds your openai auth key&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;authToken&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="c"&gt;// initial operations&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;init&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c"&gt;// add the ask command to root&lt;/span&gt;
    &lt;span class="n"&gt;rootCmd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddCommand&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;askCmd&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c"&gt;// add flag to enable chat mode&lt;/span&gt;
    &lt;span class="n"&gt;askCmd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PersistentFlags&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BoolP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"chat"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"c"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Chat with ChatGPT"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c"&gt;// Read the auth token from a configuration file&lt;/span&gt;
    &lt;span class="n"&gt;viper&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SetConfigName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"config"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;viper&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddConfigPath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"$HOME/.chatshell"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;viper&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddConfigPath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;`%USERPROFILE%/.chatshell`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;viper&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SetEnvPrefix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"OPENAI"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;viper&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AutomaticEnv&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

        &lt;span class="c"&gt;// Handle missing config file or auth token&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;viper&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ReadInConfig&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;authToken&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;viper&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GetString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"OPENAI_AUTH_TOKEN"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Error reading configuration file: %v&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;authToken&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Error: OPENAI_AUTH_TOKEN environment variable not set"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&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;The prompt I use is a bit large: but for much correctness I get the osType using &lt;code&gt;runtime.GOOS&lt;/code&gt; and SHELL type using &lt;code&gt;os.Getenv("SHELL")&lt;/code&gt;, this will help ChatGPT give reasonable shell commands of the relevant OS, we don't want shell commands for mac whilst we are using windows.. and it also responds with "Sorry I can't seem to find a command for that", if it can find a command for your prompt. It took a while to get a good prompt as this, it's an iterative process..&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="c"&gt;// Call OpenAI and prints response&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;runAsk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cmd&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;cobra&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Command&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;openai&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;authToken&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;osType&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;runtime&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GOOS&lt;/span&gt;
    &lt;span class="n"&gt;shell&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"SHELL"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;

    &lt;span class="n"&gt;chatMode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Flags&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GetBool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"chat"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c"&gt;// We use the state of the flag to determine the context&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;chatMode&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Sprintf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;`You are a very helpful shell assistant that gives users only shell commands to achieve a task, just give out only the shell command(s), and nothing else, no preamble, greetings or explanation please, just the shell command. When you can't find a command for a query/prompt/greeting respond strictly with "Sorry I can't seem to find a command for that". Start now: "%v in %v os using %v shell"`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;osType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;shell&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="c"&gt;// Get ChatGPT Response&lt;/span&gt;
    &lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CreateChatCompletion&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Background&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
        &lt;span class="n"&gt;openai&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ChatCompletionRequest&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;openai&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GPT3Dot5Turbo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;Messages&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;openai&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ChatCompletionMessage&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="n"&gt;Role&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;openai&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ChatMessageRoleUser&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="n"&gt;Content&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;content&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;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"ChatCompletion error: %v&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Choices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Message&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Content&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;&lt;strong&gt;D. Update the configuration file&lt;/strong&gt;&lt;br&gt;
For all this to work you will need your OPENAI_AUTH_TOKEN set.&lt;br&gt;
Remember, we set viper to look for a config file that should contain our OPENAI_AUTH_TOKEN&lt;/p&gt;

&lt;p&gt;Create a new directory called .chatshell in your home directory (on Windows, use %USERPROFILE% instead of $HOME):&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;&lt;span class="nb"&gt;mkdir&lt;/span&gt; ~/.chatshell
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a new file called config.json in the .chatshell directory and add your OpenAI API key as the value for the OPENAI_AUTH_TOKEN variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"OPENAI_AUTH_TOKEN"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"your_api_key_here"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;E. Build the CLI app&lt;/strong&gt;&lt;br&gt;
Navigate to the project's root directory and build the app:&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;go build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create an executable binary called 'chatshell'.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;F. Use the ChatShell CLI app&lt;/strong&gt;&lt;br&gt;
Run the chatshell binary and provide a task description as an argument:&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;./chatshell ask &lt;span class="s2"&gt;"how to delete a local branch ?"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;output: git branch &lt;span class="nt"&gt;-d&lt;/span&gt; &amp;lt;branch_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The app will then interact with ChatGPT and return the shell command for the given task. &lt;/p&gt;

&lt;p&gt;You can also use the -c flag to chat with ChatGPT directly:&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;./chatshell ask &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"When was gpt first built?"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;output: GPT &lt;span class="o"&gt;(&lt;/span&gt;Generative Pre-trained Transformer&lt;span class="o"&gt;)&lt;/span&gt; was first introduced by OpenAI &lt;span class="k"&gt;in &lt;/span&gt;June 2018
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Conclusion:&lt;/p&gt;

&lt;p&gt;In this tutorial, we saw how to create a Conda CLI app that interacts with ChatGPT from the command line. The ChatShell app can be used to obtain shell commands for specific tasks or chat with ChatGPT directly. Feel free to explore the provided code and the go-openai library to extend the functionality of the app or adapt it to your needs.&lt;/p&gt;

&lt;p&gt;Repository: &lt;a href="https://github.com/ColeDrain/chatshell"&gt;https://github.com/ColeDrain/chatshell&lt;/a&gt;&lt;/p&gt;

</description>
      <category>openai</category>
      <category>chatgpt</category>
      <category>go</category>
      <category>cli</category>
    </item>
    <item>
      <title>Search Videos/Audios Easily</title>
      <dc:creator>ColeDrain</dc:creator>
      <pubDate>Tue, 25 Oct 2022 12:44:53 +0000</pubDate>
      <link>https://dev.to/coledrain/search-videosaudios-easily-2ifg</link>
      <guid>https://dev.to/coledrain/search-videosaudios-easily-2ifg</guid>
      <description>&lt;p&gt;A while back I had the issue of figuring out where a particular thing was said in a video or audio, so I thought "was it possible to search a video/audio ?".&lt;/p&gt;

&lt;p&gt;I knew what the steps would look like (Transcribe -&amp;gt; Parse/Search Transcripts), but it was kinda hard to get really good accuracy on transcription, no that wasn't really the problem, the problem was I needed an open source STT model I could easily iterate upon freely and also wrap my head around, I tried some cloud STT/ASR's but I lacked that freedom. Then came OpenAI with Whisper, the accuracy is really good even with the tiny.en model, then another issue I had was deploying the model and creating a UI for interaction, then came Streamlit, it was really fun creating with Streamlit's widgets and then deploying on Streamlit cloud, smooth as butter.&lt;/p&gt;

&lt;p&gt;Finally, I came up with this: &lt;a href="https://searchmedia.streamlitapp.com/"&gt;&lt;strong&gt;Search Media Web App&lt;/strong&gt;&lt;/a&gt;, I'm curious what people think about this, I really don't know what to think of it, but I'm glad I was able to solve a problem I had, so send in your feedbacks or just try it out..&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ColeDrain/SearchMedia"&gt;Github Repo&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/openai/whisper"&gt;Whisper Repo&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/K67LzX5GPJE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>showdev</category>
      <category>python</category>
      <category>streamlit</category>
    </item>
    <item>
      <title>ML-Zoomcamp Series (wk 2)</title>
      <dc:creator>ColeDrain</dc:creator>
      <pubDate>Tue, 20 Sep 2022 00:31:30 +0000</pubDate>
      <link>https://dev.to/coledrain/ml-zoomcamp-series-wk-2-514d</link>
      <guid>https://dev.to/coledrain/ml-zoomcamp-series-wk-2-514d</guid>
      <description>&lt;p&gt;Hello there, this is week 2 on my Machine Learning journey with ML-Zoomcamp, well this week was pretty choked up, but I still made time to go through the content, here are some things we did this week..&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;We were introduced to a real world problem, that involved predicting the price of a car.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;First, we had to gather, access and clean the data to make it good for the ML model.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Explored the dataset visually through graphs and chart to spot outliers and understand the distribution of target variable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We then split the dataset into Train, Validate and Tests sets.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Linear regression model is a very popular model for predicting the price of a numerical quantity or variable, we used this, and we implemented the linear regression model with numpy.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>machinelearning</category>
      <category>datascience</category>
      <category>python</category>
      <category>mlzoomcamp</category>
    </item>
    <item>
      <title>ML-Zoomcamp Series</title>
      <dc:creator>ColeDrain</dc:creator>
      <pubDate>Mon, 12 Sep 2022 08:03:22 +0000</pubDate>
      <link>https://dev.to/coledrain/ml-zoomcamp-series-153l</link>
      <guid>https://dev.to/coledrain/ml-zoomcamp-series-153l</guid>
      <description>&lt;p&gt;I Recently joined &lt;a href="https://github.com/alexeygrigorev/mlbookcamp-code/tree/master/course-zoomcamp"&gt;ML Zoomcamp&lt;/a&gt; to build my ML skills.&lt;/p&gt;

&lt;p&gt;These are some things I have learnt, I hope you could learn something too.&lt;/p&gt;

&lt;p&gt;Week 1:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;What's Machine Learning ?&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Machine learning is the ability of machines to pick patterns from data and its features, and use the patterns to make predictions to new data.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;g(x) ≂ y&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;ML VS Rule-Based Systems(RBS)&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;RBS systems involve you identifying every possible scenario and creating a rule for such, this is a very tedious process and is very limited and time-consuming, these rules can instead be used as features to a ML model. The model is trained on a collected data with these features.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Supervised ML&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this type of ML, a model is trained on features (x) and their corresponding target variable (y) or labels.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CRISP-DM&lt;/strong&gt; (Cross Industry Standard Process for Data Mining)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CRISP is a methodology for organizing ML projects, it's been around for a while now, old but still used. It consists of 6 major steps as shown below..&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wmg1maGh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hky0zkzt5wpneqrqzu5f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wmg1maGh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hky0zkzt5wpneqrqzu5f.png" alt="The CRISP-DM workflow" width="880" height="535"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Model Comparison Problem&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When comparing models in your evaluation, be careful, as models can get lucky, so it's advisable to also perform validation and test on each of the models you're comparing to make the best choice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Train -&amp;gt; Validate -&amp;gt; Test&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Also had a numpy, pandas and linear algebra refresher. Then was given an assignment to reinforce all this.&lt;/p&gt;

&lt;p&gt;You can also follow via this repo &lt;a href="https://github.com/ColeDrain/ml-zoomcamp"&gt;Ugo's ML Zoomcamp&lt;/a&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>datascience</category>
      <category>python</category>
      <category>mlzoomcamp</category>
    </item>
    <item>
      <title>Starting an Internship at HNG - My Goals Checklist</title>
      <dc:creator>ColeDrain</dc:creator>
      <pubDate>Sun, 15 Aug 2021 13:58:09 +0000</pubDate>
      <link>https://dev.to/coledrain/starting-an-internship-at-hng-my-goals-checklist-2e50</link>
      <guid>https://dev.to/coledrain/starting-an-internship-at-hng-my-goals-checklist-2e50</guid>
      <description>&lt;p&gt;Hello devs , one thing I have learnt in my dev journey is the importance of having a goal, so this is me documenting my journey through the HNG internship. &lt;/p&gt;

&lt;p&gt;A quick one about HNG, HNG is a virtual internship operated by Zuri, that helps devs scale their career with real world experience.&lt;/p&gt;

&lt;p&gt;I believe setting goals for any journey, can help you appreciate how far you've gone at the end.&lt;/p&gt;

&lt;p&gt;I would love to push myself a bit, so I'm participating in 3 tracks: Backend, Frontend and Mobile. I know it's gonna be tough, but I believe I can do this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My Goals include:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create meaningful connections with other developers.&lt;/li&gt;
&lt;li&gt;Improve my tolerance to pressure.&lt;/li&gt;
&lt;li&gt;Improve my current know-how in the back-end, front-end and mobile stack by learning from mentors.&lt;/li&gt;
&lt;li&gt;Create projects confidently from start to finish.&lt;/li&gt;
&lt;li&gt;Learn how to work with a team(never have).&lt;/li&gt;
&lt;li&gt;Gain real world experience&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I will be back here again to see how well I did.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Wish me luck&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For more details on HNG visit &lt;a href="https://internship.zuri.team"&gt;Zuri Internship&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Plus:&lt;/strong&gt;&lt;br&gt;
Some Resources to Help Beginners&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://www.figma.com/resources/learn-design/"&gt;Learn to design with Figma&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.github.com/en/get-started/quickstart/set-up-git"&gt;Learn how to use Git&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.w3schools.com/html/html_intro.asp"&gt;Learn about HTML&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.python.org/3/tutorial/"&gt;Learn Python from the docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://golang.org/doc/tutorial/getting-started"&gt;Getting Started with Go&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.android.com/courses/android-basics-kotlin/unit-1"&gt;Build Mobile Apps with Kotlin&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>Chatting Via the Command Line (ssh)</title>
      <dc:creator>ColeDrain</dc:creator>
      <pubDate>Wed, 07 Jul 2021 16:33:43 +0000</pubDate>
      <link>https://dev.to/coledrain/imagine-chatting-via-the-command-line-5d4h</link>
      <guid>https://dev.to/coledrain/imagine-chatting-via-the-command-line-5d4h</guid>
      <description>&lt;p&gt;Hello devs, trust you're doing great. &lt;/p&gt;

&lt;p&gt;I came across this cool repository on GitHub Made by Ishan Goel.&lt;/p&gt;

&lt;p&gt;It's called Devzat&lt;/p&gt;

&lt;p&gt;Devzat is chat over SSH: &lt;a href="//github.com/quackduck/devzat"&gt;devzat&lt;/a&gt; (GitHub Link).&lt;br&gt;
Because there's SSH apps on all platforms, even on mobile, you can join from anywhere.&lt;/p&gt;

&lt;p&gt;To use, just open your command prompt and run this command:&lt;br&gt;
&lt;code&gt;ssh devzat.hackclub.com&lt;/code&gt;&lt;br&gt;
make sure you're connected to the internet, of course.&lt;/p&gt;

&lt;p&gt;Run cmds to see a list of commands.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interesting features:&lt;/strong&gt;&lt;br&gt;
• Rooms! Run cd to see all rooms and use cd #foo to join a new room.&lt;br&gt;
• Markdown support! Tables, headers, italics and everything. Just use \n in place of newlines.&lt;br&gt;
• Code syntax highlighting. Use Markdown fences to send code. Run eg-code to see an example.&lt;br&gt;
• Direct messages! Send a quick DM using =user  or stay in DMs by running cd @user.&lt;br&gt;
• Timezone support, use tz Continent/City to set your timezone.&lt;br&gt;
• Built in Tic Tac Toe and Hangman! Run tic or hang  to start new games.&lt;br&gt;
• Emoji replacements! 🚀 =&amp;gt;  (like on Slack and Discord)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Devs this is cool, come try it out, and drop your feedback.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ssh</category>
      <category>go</category>
      <category>showdev</category>
    </item>
    <item>
      <title>How I ran Django on my android phone ❌💻</title>
      <dc:creator>ColeDrain</dc:creator>
      <pubDate>Wed, 02 Sep 2020 11:54:48 +0000</pubDate>
      <link>https://dev.to/coledrain/how-i-ran-django-on-my-android-phone-k4a</link>
      <guid>https://dev.to/coledrain/how-i-ran-django-on-my-android-phone-k4a</guid>
      <description>&lt;h2&gt;
  
  
  How I ran Django on my android phone...
&lt;/h2&gt;

&lt;p&gt;Yeah, it seems weird coding with your phone, but right now I don't have an option, so if you are like me or you just fancy the idea, you can also do this. This is not an introduction to Django tutorial but how to work on Django with your android.&lt;/p&gt;




&lt;p&gt;First we need something like a Linux terminal(or CLI) for android. Lucky for us, there is a terminal emulator on Google play store called Termux, so head to playstore and install it.&lt;br&gt;
Link:&lt;a href="https://play.google.com/store/apps/details?id=com.termux" rel="noopener noreferrer"&gt;termux&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Okay, so you have installed it, what next?&lt;br&gt;
So basically you can do whatever you could do on a Linux terminal now with this app(create directories, move files, change directory). This is how Termux looks like.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F63160yviulhadk0ut1as.jpg" alt="Alt Text"&gt;
&lt;/h2&gt;

&lt;p&gt;So let's roll in. Enter this command to view where Termux saves your files.&lt;/p&gt;

&lt;h4&gt;
  
  
  $ pwd
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F90dcxddspy67gaikwtd1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F90dcxddspy67gaikwtd1.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
So that's where Termux saves your files, but the problem is you can't access that folder because of safety issues.&lt;/p&gt;

&lt;p&gt;So to be able to access your files..&lt;br&gt;
run this command&lt;/p&gt;

&lt;h4&gt;
  
  
  $ termux-setup-storage
&lt;/h4&gt;

&lt;p&gt;And allow permission to storage in the popup shown.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fc2v89svlzaqub7ojqj75.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fc2v89svlzaqub7ojqj75.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Now change directory to your internal shared storage by running this command.&lt;/p&gt;

&lt;h4&gt;
  
  
  $ cd /sdcard
&lt;/h4&gt;

&lt;p&gt;N:B this command doesn't point to your external SD card but your internal SD card(storage).&lt;/p&gt;




&lt;p&gt;Then let's create a folder to store our Django projects, let's call it django_projects. &lt;br&gt;
So run this command.&lt;/p&gt;

&lt;h4&gt;
  
  
  $ mkdir django_projects
&lt;/h4&gt;

&lt;h4&gt;
  
  
  $ cd django_projects
&lt;/h4&gt;




&lt;p&gt;Now let's install python&lt;br&gt;
To install python, run this&lt;/p&gt;

&lt;h4&gt;
  
  
  $ pkg install python
&lt;/h4&gt;

&lt;p&gt;To check if python is installed, run the python command to enter python console.&lt;/p&gt;

&lt;h4&gt;
  
  
  $ python
&lt;/h4&gt;

&lt;p&gt;N:B Use ctrl + z to exit the terminal. Termux app comes with a ctrl key.&lt;/p&gt;




&lt;p&gt;Let's create a project called mysite&lt;br&gt;
So still in that django_projects, run this commands.&lt;/p&gt;

&lt;h4&gt;
  
  
  $ mkdir mysite
&lt;/h4&gt;

&lt;h4&gt;
  
  
  $ cd mysite
&lt;/h4&gt;

&lt;p&gt;We need a virtual environment to avoid dependencies clash. So let's install a virtual environment, run this command.&lt;/p&gt;

&lt;h4&gt;
  
  
  $ pip install virtualenv
&lt;/h4&gt;

&lt;p&gt;After installing it, run&lt;/p&gt;

&lt;h4&gt;
  
  
  $ virtualenv venv
&lt;/h4&gt;

&lt;p&gt;to create a virtual environment.. Then activate the virtual environment by running (note the full stop)&lt;/p&gt;

&lt;h4&gt;
  
  
  $ . venv/bin/activate
&lt;/h4&gt;




&lt;p&gt;Now we have a virtual environment, let's install Django. run..&lt;/p&gt;

&lt;h4&gt;
  
  
  $ pip install Django
&lt;/h4&gt;

&lt;p&gt;Okay, so Django is installed in our venv, let's create a Django project. run..&lt;/p&gt;

&lt;h4&gt;
  
  
  $ django-admin startproject hello .
&lt;/h4&gt;

&lt;p&gt;(note the full stop)&lt;/p&gt;

&lt;p&gt;Then let's run migrations..&lt;/p&gt;

&lt;h4&gt;
  
  
  $ python manage.py migrate
&lt;/h4&gt;

&lt;p&gt;You can then run the server..&lt;/p&gt;

&lt;h4&gt;
  
  
  $ python manage.py runserver
&lt;/h4&gt;

&lt;p&gt;voilà, go to your phone browser and open &lt;a href="http://127.0.0.1:8000" rel="noopener noreferrer"&gt;http://127.0.0.1:8000&lt;/a&gt; and you should see this.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fpziu4sk2ocsraijhpecv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fpziu4sk2ocsraijhpecv.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can always view your files by going to your file manager and searching for django_projects folder.&lt;/p&gt;

&lt;p&gt;Feel free to indulge me, if any issues.&lt;/p&gt;

</description>
      <category>django</category>
      <category>android</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Social Authentication or Not?</title>
      <dc:creator>ColeDrain</dc:creator>
      <pubDate>Sun, 05 Jul 2020 13:03:13 +0000</pubDate>
      <link>https://dev.to/coledrain/social-authentication-or-not-2mao</link>
      <guid>https://dev.to/coledrain/social-authentication-or-not-2mao</guid>
      <description>&lt;p&gt;Good day devs.&lt;/p&gt;

&lt;p&gt;I have been thinking about this, and I want to know what you think, or your experience with it.&lt;/p&gt;

&lt;p&gt;I basically want to create a user authentication system, do you think social Authentication is okay or should I do a basic registration-&amp;gt;login flow. I am mindful of issues that may arise in the future.&lt;/p&gt;

&lt;p&gt;Thanks, I would really love to hear from anyone.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>webdev</category>
      <category>security</category>
    </item>
    <item>
      <title>Wanna Start a Journey Into Tech Writing, get in here.</title>
      <dc:creator>ColeDrain</dc:creator>
      <pubDate>Sat, 13 Jun 2020 10:02:04 +0000</pubDate>
      <link>https://dev.to/coledrain/wanna-start-a-journey-into-tech-writing-get-in-here-g45</link>
      <guid>https://dev.to/coledrain/wanna-start-a-journey-into-tech-writing-get-in-here-g45</guid>
      <description>&lt;p&gt;One thing I found out is, some times it becomes hard to start something, when you see so many people that are 'big names' or experts in that field you want to enter. It's like a standard is already set, and you feel what's the need of even starting.&lt;/p&gt;

&lt;p&gt;You forget that those people ahead always had a beginning, and like you they likely had people ahead of them.&lt;br&gt;
So friend don't be afraid to start, just do it.&lt;/p&gt;

&lt;p&gt;Some Useful Tips for Tech Writers&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Have the interest &amp;amp; Choose a Niche&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This cannot be overemphasized, else you wane out in the journey, choose a niche you find interest in or are curious about.&lt;br&gt;
There could be so many things that drive your passion for writing, but overall let it be that "you are delivering a great content to the world" that people will enjoy.&lt;br&gt;
There are many areas in tech you can write about, though it's possible to be a 'Jack of All Trade', but I wouldn't recommend this for someone still new to writing in the tech world.&lt;/p&gt;

&lt;p&gt;If you find choosing a niche difficult:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can check out what others are writing about, along the line  you may get inspired. &lt;/li&gt;
&lt;li&gt;You can also write about your learning journey no matter what level you are in, it will help others.&lt;/li&gt;
&lt;li&gt;You could also choose a niche based on what's trending, what people are searching about, just go to Google Trends, you will see what people are searching about.&lt;/li&gt;
&lt;li&gt;Some technologies that people are not so clear about, you can do research, then break it down in a clearer way to people. and many more.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Have mentors or (people who also write)&lt;/strong&gt;&lt;br&gt;
On dev.to for example, you can follow writers who you enjoy reading their content or are also in your niche. You could also have a mentor who will guide you, there are a lot of good writers out there who you could learn one or two from.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do your research well&lt;/strong&gt;&lt;br&gt;
When writing have it at the back of your mind, that people are definitely gonna read your content, and it would be bad if your content contains error or it's outdated, it may be frustrating on the reader's end.&lt;br&gt;
Your content is what always brings the user back, if you want to make content that brings readers back then do your research well. Remember &lt;em&gt;great writers are also great readers&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Other tips:&lt;br&gt;
&lt;strong&gt;Be specific&lt;/strong&gt;- let's say you are writing a tutorial for Django developers, specify the technologies and tools you are using, it will prevent some 'banging of the keyboard moment'.&lt;br&gt;
&lt;strong&gt;Feedback&lt;/strong&gt;- You can always ask for feedback and do well to help readers who are confused about something in your content. I have seen many contents on the web that lack this, they just drop content for the readers and that's it.&lt;br&gt;
&lt;strong&gt;Keep Yourself updated&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Last, the ocean you see today was formed by yesterday's little drop, add a little drop daily and you will be surprised at the ocean you form, write as much as possible and enjoy yourself.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This post first appeared on &lt;a href="//ugoayo.pythonanywhere.com"&gt;ugoayo.pythonanywhere.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>writing</category>
      <category>career</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Web Monetization API, What you need to know. Short and concise.</title>
      <dc:creator>ColeDrain</dc:creator>
      <pubDate>Fri, 12 Jun 2020 22:32:54 +0000</pubDate>
      <link>https://dev.to/coledrain/web-monetization-api-what-you-need-to-know-short-and-concise-2em9</link>
      <guid>https://dev.to/coledrain/web-monetization-api-what-you-need-to-know-short-and-concise-2em9</guid>
      <description>&lt;p&gt;&lt;strong&gt;Web monetization&lt;/strong&gt; in layman terms is making money from traffic to your websites, as easy as that. Most websites do this through:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Pay Per Click PPC&lt;/em&gt;- get paid when an ad is clicked by site visitors&lt;br&gt;
&lt;em&gt;Cost Per Impression CPI&lt;/em&gt;- get paid when an ad is displayed and viewed by site visitors.&lt;/p&gt;

&lt;p&gt;So basically the existing ways of making money from your website involved putting ads on your website, and truthfully ads atimes are very annoying, your privacy is invaded, user experience is diminished for example why will an ad cover the content of a web page you are reading, it's so annoying.&lt;/p&gt;

&lt;p&gt;A new standard of making money on the web is being advocated, it is called the Web Monetization API. Web monetization API seeks to solve the problems of present monetization schemes, that is no ads, no invasion of privacy, the user enjoys the website, and the website owner still earns.&lt;br&gt;
From &lt;a href="//webmonetization.org"&gt;webmonetization.com&lt;/a&gt;, web monetization API is a JavaScript Browser API which allows the creation of a payment stream from the user agent to the website, the payment occurs in real time. Just by adding a line of code to your website or specifying a streaming channel to earn.&lt;/p&gt;

&lt;p&gt;How it works:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The website or website owner needs a wallet to receive payments.&lt;/li&gt;
&lt;li&gt;User/ Website visitor needs a wallet to send payments.&lt;/li&gt;
&lt;li&gt;The browser initiates payment in the background.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Chrome and Firefox browser support it as an extension.&lt;br&gt;
Puma browser supports it totally.&lt;/p&gt;

&lt;p&gt;So a future without annoying ads and privacy thieves may be possible. Keep this in mind.&lt;/p&gt;

&lt;p&gt;Check out the following for more gist:&lt;br&gt;
&lt;a href="//webmonetization.org"&gt;webmonetization.org&lt;/a&gt;&lt;br&gt;
&lt;a href="//coil.com"&gt;coil.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This post first appeared on &lt;a href="//ugoayo.pythonanywhere.com"&gt;ugoayo.pythonanywhere.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webmonetization</category>
      <category>javascript</category>
      <category>api</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
