<?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>Forem: Bogusdeck</title>
    <description>The latest articles on Forem by Bogusdeck (@bogusdeck).</description>
    <link>https://forem.com/bogusdeck</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%2F1196320%2F6276bcaa-7bb3-4f84-a9d9-5e18178eae0e.png</url>
      <title>Forem: Bogusdeck</title>
      <link>https://forem.com/bogusdeck</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/bogusdeck"/>
    <language>en</language>
    <item>
      <title>MONGOdb 🍃 in python project!</title>
      <dc:creator>Bogusdeck</dc:creator>
      <pubDate>Fri, 26 Jul 2024 11:19:27 +0000</pubDate>
      <link>https://forem.com/bogusdeck/mongodb-in-python-project-he0</link>
      <guid>https://forem.com/bogusdeck/mongodb-in-python-project-he0</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;PyMongo is a Python driver for MongoDB, a popular NoSQL database. MongoDB is a document-oriented database that stores data in flexible, JSON-like documents, and PyMongo allows Python applications to interact with MongoDB.&lt;/p&gt;

&lt;p&gt;With PyMongo, you can perform various database operations, such as inserting, updating, deleting, and querying documents. It provides a convenient and Pythonic way to work with MongoDB, allowing you to use Python data structures and idioms directly.&lt;/p&gt;

&lt;h1&gt;
  
  
  Creating a Database
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Install PyMongo&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;pip&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;pymongo&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Connect to MongoDB&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pymongo&lt;/span&gt;

&lt;span class="c1"&gt;# Connect to MongoDB server (default: localhost, port: 27017)
&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;pymongo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MongoClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mongodb://localhost:27017/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Create or Select a Database&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Create or select a database
&lt;/span&gt;&lt;span class="n"&gt;mydatabase&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mydatabase&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Create  or Select a Collection&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Create or select a collection
&lt;/span&gt;&lt;span class="n"&gt;mycollection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mydatabase&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mycollection&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Sort the Result
&lt;/h1&gt;

&lt;p&gt;Use the &lt;code&gt;sort()&lt;/code&gt; method to sort the result in ascending or descending order.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;sort()&lt;/code&gt; method takes one parameter for "field name" and one parameter for "direction" (ascending is the default direction)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pymongo&lt;/span&gt;

&lt;span class="n"&gt;myclient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pymongo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MongoClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mongodb://localhost:27017/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;mydb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;myclient&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mydatabase&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;mycol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mydb&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;customers&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;mydoc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mycol&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;#for descending .sort("name",-1)
&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;mydoc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Insertion
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Insert Documents&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Insert a single document
&lt;/span&gt;&lt;span class="n"&gt;document&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;John&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;age&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;city&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;New York&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mycollection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;insert_one&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Inserted document ID: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;inserted_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Insert Multiple Documents&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Insert multiple documents
&lt;/span&gt;&lt;span class="n"&gt;documents&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Alice&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;age&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;city&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;San Francisco&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bob&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;age&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;35&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;city&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Los Angeles&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mycollection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;insert_many&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;documents&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Inserted &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;inserted_ids&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; documents&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Deletion
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Delete one document&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Delete a document
&lt;/span&gt;&lt;span class="n"&gt;mycollection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;delete_one&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;John&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Delete multiple documents&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Delete multiple documents
&lt;/span&gt;&lt;span class="n"&gt;mycollection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;delete_many&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;city&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Brooklyn&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Delete all documents in a collections&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mycol&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;delete_many&lt;/span&gt;&lt;span class="p"&gt;({})&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deleted_count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; documents deleted.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Delete a collection&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pymongo&lt;/span&gt;

&lt;span class="n"&gt;myclient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pymongo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MongoClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mongodb://localhost:27017/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;mydb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;myclient&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mydatabase&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;mycol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mydb&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;customers&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;mycol&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;drop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Updation
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Update a single documents&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Update a document
&lt;/span&gt;&lt;span class="n"&gt;mycollection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update_one&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;John&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;$set&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;age&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="p"&gt;}})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;alternate method&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pymongo&lt;/span&gt;

&lt;span class="n"&gt;myclient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pymongo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MongoClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mongodb://localhost:27017/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;mydb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;myclient&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mydatabase&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;mycol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mydb&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;customers&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;myquery&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;address&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Valley 345&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;newvalues&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;$set&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;address&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Canyon 123&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;mycol&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update_one&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;myquery&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newvalues&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;#print "customers" after the update:
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;mycol&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
  &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Update multiple documents&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Update multiple documents
&lt;/span&gt;&lt;span class="n"&gt;mycollection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update_many&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;city&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;New York&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;$set&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;city&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Brooklyn&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Searching a query
&lt;/h1&gt;

&lt;p&gt;To select data from a collection in MongoDB, we can use the &lt;code&gt;find_one()&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;find_one()&lt;/code&gt; method returns the first occurrence in the selection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pymongo&lt;/span&gt;

&lt;span class="n"&gt;myclient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pymongo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MongoClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mongodb://localhost:27017/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;mydb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;myclient&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mydatabase&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;mycol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mydb&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;customers&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mycol&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_one&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To select data from a table in MongoDB, we can also use the &lt;code&gt;find()&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;find()&lt;/code&gt; method returns all occurrences in the selection.&lt;/p&gt;

&lt;p&gt;The first parameter of the &lt;code&gt;find()&lt;/code&gt; method is a query object. In this example we use an empty query object, which selects all documents in the collection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pymongo&lt;/span&gt;

&lt;span class="n"&gt;myclient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pymongo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MongoClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mongodb://localhost:27017/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;mydb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;myclient&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mydatabase&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;mycol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mydb&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;customers&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;mycol&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
  &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;using second parameter in &lt;code&gt;find()&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pymongo&lt;/span&gt;

&lt;span class="n"&gt;myclient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pymongo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MongoClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mongodb://localhost:27017/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;mydb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;myclient&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mydatabase&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;mycol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mydb&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;customers&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;mycol&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({},{&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;_id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;address&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}):&lt;/span&gt;
  &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Filter the result&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When finding documents in a collection, you can filter the result by using a query object.&lt;/p&gt;

&lt;p&gt;The first argument of the &lt;code&gt;find()&lt;/code&gt; method is a query object, and is used to limit the search.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pymongo&lt;/span&gt;

&lt;span class="n"&gt;myclient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pymongo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MongoClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mongodb://localhost:27017/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;mydb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;myclient&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mydatabase&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;mycol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mydb&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;customers&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;myquery&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;address&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Park Lane 38&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;mydoc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mycol&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;myquery&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;mydoc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Advance query&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pymongo&lt;/span&gt;

&lt;span class="n"&gt;myclient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pymongo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MongoClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mongodb://localhost:27017/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;mydb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;myclient&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mydatabase&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;mycol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mydb&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;customers&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;myquery&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;address&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;$gt&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;S&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;mydoc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mycol&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;myquery&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;mydoc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Limit the query result&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pymongo&lt;/span&gt;

&lt;span class="n"&gt;myclient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pymongo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MongoClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mongodb://localhost:27017/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;mydb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;myclient&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mydatabase&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;mycol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mydb&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;customers&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;myresult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mycol&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;#print the result:
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;myresult&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Setup for flask with tailwind project</title>
      <dc:creator>Bogusdeck</dc:creator>
      <pubDate>Tue, 12 Mar 2024 15:06:44 +0000</pubDate>
      <link>https://forem.com/bogusdeck/setup-for-flask-with-tailwind-project-420e</link>
      <guid>https://forem.com/bogusdeck/setup-for-flask-with-tailwind-project-420e</guid>
      <description>&lt;h1&gt;
  
  
  how to setup tailwind css with flask app
&lt;/h1&gt;

&lt;p&gt;status: ✏️ Draft&lt;br&gt;
categories: Coding, Javascript, flask, python, webdev&lt;br&gt;
published: 12/03/2024&lt;br&gt;
Author: tanish vashisth&lt;br&gt;
route: tutorial&lt;/p&gt;

&lt;p&gt;Simplicity is the cornerstone of efficient web development. In this blog post, we'll explore the seamless integration of Flask, a lightweight Python web framework, with Tailwind CSS, a utility-first CSS framework. By combining these two powerful tools, developers can effortlessly create sleek and responsive web applications with minimal setup. Join us as we unveil the essentials of setting up a Flask and Tailwind project, empowering you to embark on your web development journey with ease and finesse.&lt;/p&gt;

&lt;p&gt;Setting up a Flask project with Tailwind CSS involves several steps. Here's a basic guide to get you started:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Install Flask :&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;First, you need to have Flask installed. You can install it via pip:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;Flask
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Create a Flask project directory :&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;Create a directory for your Flask project.&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Initialize a virtual environment&lt;/strong&gt; (optional but recommended) &lt;strong&gt;:&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Navigate to your project directory and create a virtual environment to isolate your project dependencies.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 &lt;span class="nt"&gt;-m&lt;/span&gt; venv venv
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Activate the virtual environment :&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On Windows:
&lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.venv\Scripts\activate
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- On macOS/Linux:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```
source venv/bin/activate
```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Start an npm project :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We need this to automatically compile our tailwindcss file to make sure only the tailwind classes we are using are included in the output.css file&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Initialize Tailwind CSS :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Initialize Tailwind CSS in your project directory. This will create a &lt;code&gt;tailwind.config.js&lt;/code&gt; file and a &lt;code&gt;tailwind.css&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx i tailwindcss
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;now we need to initialise tailwindcss&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx tailwindcss init
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Add content in tailwind.config.js :&lt;/strong&gt; &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;we need to add the path of our templates files inside tailwind.config.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="cm"&gt;/** @type {import('tailwindcss').Config} **/&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./templates/*.html&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="na"&gt;extend&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="na"&gt;plugins&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;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create input.css file&lt;/strong&gt; &lt;strong&gt;:&lt;/strong&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now create a CSS file which will contain the base code of tailwindcss.&lt;/p&gt;

&lt;p&gt;create the file inside &lt;strong&gt;“/static/css/input.css”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Enter the following code inside input.css&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;components&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;utilities&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Start the build process&lt;/strong&gt; &lt;strong&gt;:&lt;/strong&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We will now run a command that will take the input.css file as input and generate the output CSS which will only contain the tailwind classes required by our html files&lt;/p&gt;

&lt;p&gt;now run this command on a new terminal :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;npx&lt;/span&gt; &lt;span class="nt"&gt;tailwindcss&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="o"&gt;./&lt;/span&gt;&lt;span class="nt"&gt;static&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nt"&gt;css&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nt"&gt;input&lt;/span&gt;&lt;span class="nc"&gt;.css&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="o"&gt;./&lt;/span&gt;&lt;span class="nt"&gt;static&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nt"&gt;css&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nt"&gt;output&lt;/span&gt;&lt;span class="nc"&gt;.css&lt;/span&gt; &lt;span class="nt"&gt;--watch&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Add the output.css&lt;/strong&gt; &lt;strong&gt;:&lt;/strong&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This command instructs Tailwind to create an "output.css" file containing only the utility classes utilized within the HTML files located in your "templates" folder. You can then include the generated file "./static/css/output.css" in your HTML files using the specified command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"{{url_for('static',filename='css/output.css')}}"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Test your project :&lt;/strong&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Add the below code inside the index.html file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"UTF-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1.0"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"{{url_for('static',filename='css/output.css')}}"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Document&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"bg-red-600"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        background is red
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create &lt;a href="http://app.py" rel="noopener noreferrer"&gt;app.py&lt;/a&gt; file in your root directory :&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;from flask import Flask, render_template

app = Flask(__name__)

@app.route("/")
def hello_world():
    return render_template("index.html")

app.run(debug=True)
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Run the flask app:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python main.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now, you should have a Flask project set up with Tailwind CSS integrated. Access your Flask application in a web browser by navigating to &lt;code&gt;http://localhost:5000/&lt;/code&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to change the apperance of your terminal</title>
      <dc:creator>Bogusdeck</dc:creator>
      <pubDate>Wed, 20 Dec 2023 11:44:15 +0000</pubDate>
      <link>https://forem.com/bogusdeck/bored-with-your-old-terminal-3l68</link>
      <guid>https://forem.com/bogusdeck/bored-with-your-old-terminal-3l68</guid>
      <description>&lt;h2&gt;
  
  
  Kitty Terminal Configuration
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbf2sce83u755997dxp8q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbf2sce83u755997dxp8q.png" alt="SS" width="800" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Prome-theus/Kitty-dotfiles/blob/main/screenshot-compressed.gif" rel="noopener noreferrer"&gt;more screenshot&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This repository contains my personal configuration for the Kitty terminal emulator, tailored to enhance my development workflow and make the terminal experience more enjoyable. Kitty is a fast, feature-rich, GPU-accelerated terminal emulator.&lt;/p&gt;

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

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Install Kitty Terminal:&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you haven't installed Kitty yet, follow the &lt;a href="https://sw.kovidgoyal.net/kitty/#id4" rel="noopener noreferrer"&gt;official installation instructions&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Clone this Repository:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   git clone https://github.com/Prome-theus/Kitty-dotfiles
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Copy Configuration Files:&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Navigate to the cloned directory and copy the configuration files to the appropriate locations:&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="nb"&gt;cp &lt;/span&gt;kitty.conf ~/.config/kitty/
   &lt;span class="nb"&gt;cp &lt;/span&gt;tanish.omp.json ~/.config/kitty
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Restart Kitty Terminal:&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Restart the Kitty terminal for the changes to take effect.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Install OMP(OH_MY_POSH):&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://ohmyposh.dev/docs/installation/linux" rel="noopener noreferrer"&gt;installation guide OMP&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;for arch linux :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   yay &lt;span class="nt"&gt;-S&lt;/span&gt; oh-my-posh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;for windows&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="n"&gt;winget&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;JanDeDobbeleer.OhMyPosh&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-s&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;winget&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Install fonts:(optional)&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://github.com/ryanoasis/nerd-fonts/releases/download/v3.1.1/VictorMono.zip" rel="noopener noreferrer"&gt;VictorMono Nerd Font.&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Activate Oh-my-posh :&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   oh-my-posh init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;than install font&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   oh-my-posh font &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;select VictorMono nerd font&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Copy the config files:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;cp&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; config.fish ~/.config/fish/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Enjoy using the Kitty terminal with this configuration! If you find it helpful, don't forget to give it a star. Happy coding! 🚀&lt;/p&gt;

</description>
      <category>linux</category>
      <category>programming</category>
      <category>productivity</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>EASY GIT</title>
      <dc:creator>Bogusdeck</dc:creator>
      <pubDate>Fri, 15 Dec 2023 11:26:57 +0000</pubDate>
      <link>https://forem.com/bogusdeck/easy-git-1gg5</link>
      <guid>https://forem.com/bogusdeck/easy-git-1gg5</guid>
      <description>&lt;h1&gt;
  
  
  Git Cheat Sheet: A Quick Reference Guide
&lt;/h1&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;git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.name &lt;span class="s2"&gt;"Your Name"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Assign Your Email
&lt;/h3&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;git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.email xyz@domain.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Initialization
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Initialize Git in Your Folder
&lt;/h3&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;git init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Show Git Status
&lt;/h3&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;git status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Basic Commands
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Add File to Staging Area
&lt;/h3&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;git add index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Commit File
&lt;/h3&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;git commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Commit with Message
&lt;/h3&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;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Added more HTMLs"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Send All Files to Staging Area
&lt;/h3&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;git add &lt;span class="nt"&gt;-A&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Recover File or Match Last Commit
&lt;/h3&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;git checkout index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Recover All Files
&lt;/h3&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;git checkout &lt;span class="nt"&gt;-f&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Viewing Commits
&lt;/h2&gt;

&lt;h3&gt;
  
  
  View Commit Log
&lt;/h3&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;git log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Filter Commit Log
&lt;/h3&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;git log &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;number of commits&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Comparisons
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Working Tree and Staging Area
&lt;/h3&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;git diff
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Compare Last Commit to Staging Area
&lt;/h3&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;git diff &lt;span class="nt"&gt;--staged&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Advanced Committing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Commit All Files Directly
&lt;/h3&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;git commit &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Skipped staging area and fixed"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Remove File from Directory and Staging Area
&lt;/h3&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;git &lt;span class="nb"&gt;rm &lt;/span&gt;about.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Remove File from Staging Area
&lt;/h3&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;git &lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;--cached&lt;/span&gt; about.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Show Staging and Working Tree Status
&lt;/h3&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;git status &lt;span class="nt"&gt;-s&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Remote Repositories
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Add Remote Repo (Origin)
&lt;/h3&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;git remote add origin https://github.com/Prome-theus/CSES.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Get Remote Repo Links
&lt;/h3&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;git remote &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Push to Remote Repo (Origin - Master Branch)
&lt;/h3&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;git push origin master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Change Remote Repo URL
&lt;/h3&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;git remote set-url origin git@github.com:Prome-theus/CSES.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Push to Remote Repo with Default Branch Set
&lt;/h3&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;git push &lt;span class="nt"&gt;-u&lt;/span&gt; origin master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Clone a Repository
&lt;/h3&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;git clone &lt;span class="o"&gt;{&lt;/span&gt;url&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Branching
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Create a New Branch
&lt;/h3&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;git branch feature1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Show All Branches
&lt;/h3&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;git branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Switch Branch
&lt;/h3&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;git checkout feature1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Merge Branch to Master
&lt;/h3&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;git merge feature1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create and Switch to a New Branch
&lt;/h3&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;git checkout &lt;span class="nt"&gt;-b&lt;/span&gt; htmlcodes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Git Ignore
&lt;/h2&gt;

&lt;p&gt;Create a &lt;code&gt;.gitignore&lt;/code&gt; file in your directory to specify files you want to ignore in the repository.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mylogs.log
*.log
/mylogs.log
ignore/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember to add and commit the &lt;code&gt;.gitignore&lt;/code&gt; file to your repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  Branching Note
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;master&lt;/code&gt; branch is typically considered the main branch.&lt;/p&gt;

&lt;p&gt;This cheat sheet covers essential Git commands, but feel free to explore more features and options in the &lt;a href="https://education.github.com/git-cheat-sheet-education.pdf" rel="noopener noreferrer"&gt;official Git cheatsheet&lt;/a&gt;. Happy coding!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Django 5.0 is here</title>
      <dc:creator>Bogusdeck</dc:creator>
      <pubDate>Thu, 07 Dec 2023 04:24:38 +0000</pubDate>
      <link>https://forem.com/bogusdeck/django-50-is-here-1kpg</link>
      <guid>https://forem.com/bogusdeck/django-50-is-here-1kpg</guid>
      <description>&lt;p&gt;Django 5.0 is released 🎉🎉🎉&lt;/p&gt;

&lt;p&gt;Lot of exiting changes to DjangoORM and more..&lt;/p&gt;

&lt;p&gt;Let's take a brief look at what's new.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Generated fields&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The new GeneratedField enables the creation of database-generated fields, where values are automatically computed by the database itself based on other fields (and indexable too). For example, if you have &lt;code&gt;first_name&lt;/code&gt; and &lt;code&gt;last_name&lt;/code&gt; fields, you can use a GeneratedField to create a full_name property that is a combination of the two, allowing the database to handle the generation process.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Database-computed default values&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This was the last significant obstacle to fully representing the structure of Django models in the database schema. In Django versions prior to 5.0, the only option for setting a default value for a field was through Field.default, and it was calculated on the Python side, not in the database. The new Field.db_default option addresses this limitation by allowing the creation of default values directly in the database schema, providing a valuable improvement for consistency&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Form field group rendering&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The new concept of form field group rendering makes field rendering simpler and more reusable. Now you can use &lt;code&gt;filed.as_field_group&lt;/code&gt; to render separate fields without any inconsistencies.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Host your website locally to show everyone</title>
      <dc:creator>Bogusdeck</dc:creator>
      <pubDate>Tue, 05 Dec 2023 03:12:07 +0000</pubDate>
      <link>https://forem.com/bogusdeck/host-your-website-locally-to-show-everyone-41od</link>
      <guid>https://forem.com/bogusdeck/host-your-website-locally-to-show-everyone-41od</guid>
      <description>&lt;p&gt;Have you ever wanted to share a website you're developing on your local machine with someone else? Or perhaps you need to demo a project to a client or a colleague without deploying it to a public server? This is where &lt;code&gt;LocalTunnel&lt;/code&gt; comes to the rescue. In this guide, we'll walk through the steps of using &lt;code&gt;LocalTunnel&lt;/code&gt; to expose your locally hosted website to the internet, making it accessible to anyone, anywhere&lt;/p&gt;

&lt;h2&gt;
  
  
  What is LocalTunnel?
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;LocalTunnel&lt;/code&gt; is a powerful tool that allows you to expose your local development server to the internet. It creates a secure tunnel to a public URL, enabling others to access your locally hosted website as if it were live on the web.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's Setup
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Install nodejs and npm in your system&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;For Windows and mac OS&lt;br&gt;
&lt;a href="https://nodejs.org/en/download/" rel="noopener noreferrer"&gt;nodejs.org&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For Linux&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Ubuntu/debian&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;nodejs npm
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Arch linux&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;pacman &lt;span class="nt"&gt;-S&lt;/span&gt; nodejs npm
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Install local tunnel&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Open your terminal and run the following command to install localtunnel globally&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; localtunnel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy2ofq81dfdlux4j7zzdx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy2ofq81dfdlux4j7zzdx.png" alt="localtunnel install image" width="800" height="235"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Start your Local Server&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;start your application or website on local development server&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw9yl9m9czqnhvne76sf1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw9yl9m9czqnhvne76sf1.png" alt="server start image" width="800" height="173"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Use localtunnel&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In your Terminal , run the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lt &lt;span class="nt"&gt;--port&lt;/span&gt; &amp;lt;your_local_port&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example &lt;br&gt;
if website or application is hosted on local host i.e port 3000&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lt &lt;span class="nt"&gt;--port&lt;/span&gt; 3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flhjnu81bhi6l5971r42h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flhjnu81bhi6l5971r42h.png" alt="localport" width="800" height="301"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;LocalTunnel will generate a unique URL which you can share with others to access your locally hosted website&lt;/p&gt;

&lt;h2&gt;
  
  
  Some advance options
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Custom Subdomain&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lt &lt;span class="nt"&gt;--port&lt;/span&gt; &amp;lt;your_local_port&amp;gt; &lt;span class="nt"&gt;--subdomain&lt;/span&gt; &amp;lt;your_custom_subdomain&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4gpj33o2g9z11sd5790p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4gpj33o2g9z11sd5790p.png" alt="subdomain" width="800" height="295"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Allowing specific hostnames&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lt &lt;span class="nt"&gt;--port&lt;/span&gt; &amp;lt;your_local_port&amp;gt; &lt;span class="nt"&gt;--host&lt;/span&gt; &amp;lt;allowed_hostname&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Setting Maximum Connections&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lt &lt;span class="nt"&gt;--port&lt;/span&gt; &amp;lt;your_local_port&amp;gt; &lt;span class="nt"&gt;--max-conn&lt;/span&gt; 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Specifying Base Domain&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lt &lt;span class="nt"&gt;--port&lt;/span&gt; &amp;lt;your_local_port&amp;gt; &lt;span class="nt"&gt;--domain&lt;/span&gt; &amp;lt;your_domain&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💡 Be mindful when using LocalTunnel, as it's convenient but may pose security risks. Avoid exposing sensitive information, and make certain your local server is secure, preventing any inadvertent exposure of confidential data to the public.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>node</category>
      <category>tutorial</category>
      <category>javascript</category>
    </item>
    <item>
      <title>MongoDB learning Guide</title>
      <dc:creator>Bogusdeck</dc:creator>
      <pubDate>Sat, 02 Dec 2023 12:31:03 +0000</pubDate>
      <link>https://forem.com/bogusdeck/mongodb-learning-guide-4848</link>
      <guid>https://forem.com/bogusdeck/mongodb-learning-guide-4848</guid>
      <description>&lt;p&gt;Certainly! If you're creating tutorial notes on MongoDB, you might want to cover a broader range of topics. Here's an outline for creating tutorial notes:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Introduction to MongoDB
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;What is MongoDB?&lt;/li&gt;
&lt;li&gt;How does MongoDB differ from traditional relational databases?&lt;/li&gt;
&lt;li&gt;Key features and advantages of MongoDB.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Installation and Setup
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Downloading and installing MongoDB.&lt;/li&gt;
&lt;li&gt;Starting and stopping the MongoDB server.&lt;/li&gt;
&lt;li&gt;Connecting to MongoDB through the shell.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Basic MongoDB Concepts
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Databases and Collections.&lt;/li&gt;
&lt;li&gt;BSON (Binary JSON) format.&lt;/li&gt;
&lt;li&gt;Documents and Fields.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. CRUD Operations
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Creating a Database.&lt;/li&gt;
&lt;li&gt;Creating Collections.&lt;/li&gt;
&lt;li&gt;Inserting Documents.&lt;/li&gt;
&lt;li&gt;Querying Documents.&lt;/li&gt;
&lt;li&gt;Updating Documents.&lt;/li&gt;
&lt;li&gt;Deleting Documents.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. Data Modeling
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Schemaless design.&lt;/li&gt;
&lt;li&gt;Embedding vs. Referencing.&lt;/li&gt;
&lt;li&gt;Design considerations for various use cases.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. Indexing
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Importance of indexes.&lt;/li&gt;
&lt;li&gt;Creating and managing indexes.&lt;/li&gt;
&lt;li&gt;Index types and their impact on performance.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  7. Aggregation Framework
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Introduction to the Aggregation Framework.&lt;/li&gt;
&lt;li&gt;Pipeline stages for data transformation.&lt;/li&gt;
&lt;li&gt;Aggregation operators.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  8. Working with Date and Time
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Date and time data types.&lt;/li&gt;
&lt;li&gt;Date and time operators and functions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  9. Security
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Authentication and Authorization.&lt;/li&gt;
&lt;li&gt;User roles and privileges.&lt;/li&gt;
&lt;li&gt;Best practices for securing MongoDB.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  10. Scaling and Sharding
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Horizontal scaling with sharding.&lt;/li&gt;
&lt;li&gt;Sharding strategies.&lt;/li&gt;
&lt;li&gt;Monitoring and managing a sharded cluster.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  11. Backing Up and Restoring
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Database backup strategies.&lt;/li&gt;
&lt;li&gt;Restoring data from backups.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  12. Using MongoDB with Programming Languages
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;MongoDB drivers for various programming languages.&lt;/li&gt;
&lt;li&gt;Connecting and interacting with MongoDB in a programming language (e.g., Python, Node.js).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  13. Case Studies and Best Practices
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Real-world examples of MongoDB implementations.&lt;/li&gt;
&lt;li&gt;Best practices for optimal performance.&lt;/li&gt;
&lt;li&gt;Common pitfalls and how to avoid them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  14. Advanced Topics
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Transactions in MongoDB.&lt;/li&gt;
&lt;li&gt;Geospatial data and queries.&lt;/li&gt;
&lt;li&gt;Full-text search.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  15. Resources and Further Learning
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;MongoDB official documentation.&lt;/li&gt;
&lt;li&gt;Online courses and tutorials.&lt;/li&gt;
&lt;li&gt;Community forums and support.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Additional Tips:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Include code examples and snippets for each concept.&lt;/li&gt;
&lt;li&gt;Provide exercises or challenges for hands-on practice.&lt;/li&gt;
&lt;li&gt;Use visuals like diagrams or charts to explain complex concepts.&lt;/li&gt;
&lt;li&gt;Regularly update your tutorial notes to keep them current with the latest MongoDB features and best practices.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Enjoy Mongo!&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>webdev</category>
      <category>database</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Use Spotify made for Developers</title>
      <dc:creator>Bogusdeck</dc:creator>
      <pubDate>Fri, 01 Dec 2023 19:35:03 +0000</pubDate>
      <link>https://forem.com/bogusdeck/using-spotify-made-for-developers-d28</link>
      <guid>https://forem.com/bogusdeck/using-spotify-made-for-developers-d28</guid>
      <description>&lt;p&gt;Launch Spotify directly from your terminal for a streamlined experience without the need for a resource-intensive browser tab or desktop application. Just follow these straightforward steps, and you'll be enjoying your music in no time.&lt;/p&gt;

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

&lt;p&gt;To install the spotify-tui client from Rigellute/spotify-tui&lt;br&gt;
github repository or you can use different methods depending on your OS{macOS, Arch linux}&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For MAC installation&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install spotify-tui
brew install spotifyd
brew services start spotifyd
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For arch linux&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yay -S spotify-tui
yay -S spotifyd
&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;we also need to install Spotifyd, a lightweight Unix daemon, you’ll get a fully-featured terminal application that connects to your Spotify Premium account.&lt;/p&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%2Fuploads%2Farticles%2Fzecf2s93n8fp3pot171w.png" 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%2Fuploads%2Farticles%2Fzecf2s93n8fp3pot171w.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuration
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Create a configuration file
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;~/.config/spotifyd/spotifyd.conf:&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[global]
# Your Spotify account name.
username = "{your spotify username}"

# Your Spotify account password.
password = "Launch Spotify directly from your terminal for a streamlined experience without the need for a resource-intensive browser tab or desktop application. Just follow these straightforward steps, and you'll be enjoying your music in no time.

## Installation
To install the spotify-tui client from Rigellute/spotify-tui
github repository or you can use different methods depending on your OS{macOS, Arch linux}

&amp;gt; For MAC installation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;brew install spotify-tui&lt;br&gt;
brew install spotifyd&lt;br&gt;
brew services start spotifyd&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; For arch linux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;yay -S spotify-tui&lt;br&gt;
yay -S spotifyd&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
we also need to install Spotifyd, a lightweight Unix daemon, you’ll get a fully-featured terminal application that connects to your Spotify Premium account.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zecf2s93n8fp3pot171w.png)

## Configuration
### Create a configuration file
`~/.config/spotifyd/spotifyd.conf:`

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

&lt;/div&gt;

&lt;p&gt;[global]&lt;/p&gt;

&lt;h1&gt;
  
  
  Your Spotify account name.
&lt;/h1&gt;

&lt;p&gt;username = "{your spotify username}"&lt;/p&gt;

&lt;h1&gt;
  
  
  Your Spotify account password.
&lt;/h1&gt;

&lt;p&gt;password = "Launch Spotify directly from your terminal for a streamlined experience without the need for a resource-intensive browser tab or desktop application. Just follow these straightforward steps, and you'll be enjoying your music in no time.&lt;/p&gt;

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

&lt;p&gt;To install the spotify-tui client from Rigellute/spotify-tui&lt;br&gt;
github repository or you can use different methods depending on your OS{macOS, Arch linux}&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For MAC installation&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install spotify-tui
brew install spotifyd
brew services start spotifyd
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For arch linux&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yay -S spotify-tui
yay -S spotifyd
&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;we also need to install Spotifyd, a lightweight Unix daemon, you’ll get a fully-featured terminal application that connects to your Spotify Premium account.&lt;/p&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%2Fuploads%2Farticles%2Fzecf2s93n8fp3pot171w.png" 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%2Fuploads%2Farticles%2Fzecf2s93n8fp3pot171w.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuration
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Create a configuration file
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;~/.config/spotifyd/spotifyd.conf:&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[global]
# Your Spotify account name.
username = "{your spotify username}"

# Your Spotify account password.
password = "Launch Spotify directly from your terminal for a streamlined experience without the need for a resource-intensive browser tab or desktop application. Just follow these straightforward steps, and you'll be enjoying your music in no time.

## Installation
To install the spotify-tui client from Rigellute/spotify-tui
github repository or you can use different methods depending on your OS{macOS, Arch linux}

&amp;gt; For MAC installation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;brew install spotify-tui&lt;br&gt;
brew install spotifyd&lt;br&gt;
brew services start spotifyd&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; For arch linux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;yay -S spotify-tui&lt;br&gt;
yay -S spotifyd&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
we also need to install Spotifyd, a lightweight Unix daemon, you’ll get a fully-featured terminal application that connects to your Spotify Premium account.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zecf2s93n8fp3pot171w.png)

## Configuration
### Create a configuration file 
`~/.config/spotifyd/spotifyd.conf:`

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

&lt;/div&gt;

&lt;p&gt;[global]&lt;/p&gt;

&lt;h1&gt;
  
  
  Your Spotify account name.
&lt;/h1&gt;

&lt;p&gt;username = "{your spotify username}"&lt;/p&gt;

&lt;h1&gt;
  
  
  Your Spotify account password.
&lt;/h1&gt;

&lt;p&gt;password = "Launch Spotify directly from your terminal for a streamlined experience without the need for a resource-intensive browser tab or desktop application. Just follow these straightforward steps, and you'll be enjoying your music in no time.&lt;/p&gt;

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

&lt;p&gt;To install the spotify-tui client from Rigellute/spotify-tui&lt;br&gt;
github repository or you can use different methods depending on your OS{macOS, Arch linux}&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For MAC installation&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install spotify-tui
brew install spotifyd
brew services start spotifyd
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For arch linux&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yay -S spotify-tui
yay -S spotifyd
&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;we also need to install Spotifyd, a lightweight Unix daemon, you’ll get a fully-featured terminal application that connects to your Spotify Premium account.&lt;/p&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%2Fuploads%2Farticles%2Fzecf2s93n8fp3pot171w.png" 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%2Fuploads%2Farticles%2Fzecf2s93n8fp3pot171w.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuration
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Create a configuration file
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;~/.config/spotifyd/spotifyd.conf:&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[global]
# Your Spotify account name.
username = "{your spotify username}"

# Your Spotify account password.
password = "pass spotify/spotifyd"

use_keyring = true
use_mpris = true
dbus_type = "session"
backend = "alsa" # use portaudio for macOS [homebrew]
device = "alsa_audio_device"  # omit for macOS
audio_format = "S16"
control = "alsa_audio_device"  # omit for macOS
mixer = "PCM"  # omit for macOS
volume_controller = "alsa"  # use softvol for macOS
on_song_change_hook = "command_to_run_on_playback_events"
device_name = "spotifyd"
bitrate = 320
cache_path = ""/Users/&amp;lt;your Username&amp;gt;/.cache/spotifyd"
max_cache_size = 1000000000
no_audio_cache = true
initial_volume = "90"
volume_normalisation = true
normalisation_pregain = -10
autoplay = true
zeroconf_port = 1234
proxy = "http://proxy.example.org:8080"
audio_dongle.
device_type = "computer"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;fill your username, password and your system username in username, password and cache_path respectively&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a systemd user script
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~/.config/systemd/user/spotifyd.service:&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Unit]&lt;br&gt;
Description=A spotify playing daemon&lt;br&gt;
Documentation=&lt;a href="https://github.com/Spotifyd/spotifyd" rel="noopener noreferrer"&gt;https://github.com/Spotifyd/spotifyd&lt;/a&gt;&lt;br&gt;
Wants=sound.target&lt;br&gt;
After=sound.target&lt;br&gt;
Wants=network-online.target&lt;br&gt;
After=network-online.target

&lt;p&gt;[Service]&lt;br&gt;
ExecStart=/usr/bin/spotifyd --no-daemon&lt;br&gt;
Restart=always&lt;br&gt;
RestartSec=12&lt;/p&gt;

&lt;p&gt;[Install]&lt;br&gt;
WantedBy=default.target&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Then enable and start the script&lt;br&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;systemctl --user enable spotifyd --now&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Connecting to Spotify API
&lt;/h2&gt;

&lt;p&gt;To connect Spotify-tui to Spotify's API for music playback and track searching, follow these steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Visit the Spotify dashboard.&lt;/li&gt;
&lt;li&gt;Create a new app to obtain your Client ID and Client Secret.&lt;/li&gt;
&lt;li&gt;Edit app settings and add &lt;code&gt;http://localhost:8888/callback&lt;/code&gt; as a Redirect URI.&lt;/li&gt;
&lt;li&gt;Save settings and return to the terminal.&lt;/li&gt;
&lt;li&gt;Run "spt" and enter your Client ID and Client Secret when prompted.&lt;/li&gt;
&lt;li&gt;Confirm the default port (8888) or input a custom port.&lt;/li&gt;
&lt;li&gt;You'll be redirected to Spotify for permission.&lt;/li&gt;
&lt;li&gt;After approval, the redirect URL is automatically parsed.&lt;/li&gt;
&lt;li&gt;If the local web server fails, copy the URL from the blank page and paste it into the terminal prompt.&lt;/li&gt;
&lt;li&gt;You're now ready to use spotify-tui! 🎉&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After you’ve run spt for the first time, you’ll find a configuration file under &lt;code&gt;~/.config/spotify-tui/client.yml&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Connect with spotifyd
&lt;/h3&gt;

&lt;p&gt;Make sure that spotifyd.service is running:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;systemctl --user status spotifyd.service&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, run &lt;code&gt;spt&lt;/code&gt; in terminal and select any song&lt;br&gt;
and press ENTER&lt;/p&gt;

&lt;p&gt;If Spotify TUI indicates it can't find a device, press 'd', and the CLI will display the available Spotifyd clients. Select the appropriate one by pressing 'Enter'.&lt;/p&gt;

&lt;p&gt;Now it should Work.&lt;/p&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%2Fuploads%2Farticles%2F3wu7yxdlk6dcvz8i0vov.png" 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%2Fuploads%2Farticles%2F3wu7yxdlk6dcvz8i0vov.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enjoy Listening&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;use_keyring = true&lt;br&gt;
use_mpris = true&lt;br&gt;
dbus_type = "session"&lt;br&gt;
backend = "alsa" # use portaudio for macOS [homebrew]&lt;br&gt;
device = "alsa_audio_device"  # omit for macOS&lt;br&gt;
audio_format = "S16"&lt;br&gt;
control = "alsa_audio_device"  # omit for macOS&lt;br&gt;
mixer = "PCM"  # omit for macOS&lt;br&gt;
volume_controller = "alsa"  # use softvol for macOS&lt;br&gt;
on_song_change_hook = "command_to_run_on_playback_events"&lt;br&gt;
device_name = "spotifyd"&lt;br&gt;
bitrate = 320&lt;br&gt;
cache_path = ""/Users/&amp;lt;your Username&amp;gt;/.cache/spotifyd"&lt;br&gt;
max_cache_size = 1000000000&lt;br&gt;
no_audio_cache = true&lt;br&gt;
initial_volume = "90"&lt;br&gt;
volume_normalisation = true&lt;br&gt;
normalisation_pregain = -10&lt;br&gt;
autoplay = true&lt;br&gt;
zeroconf_port = 1234&lt;br&gt;
proxy = "&lt;a href="http://proxy.example.org:8080" rel="noopener noreferrer"&gt;http://proxy.example.org:8080&lt;/a&gt;"&lt;br&gt;
audio_dongle.&lt;br&gt;
device_type = "computer"&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Create a systemd user script&lt;br&gt;
&lt;/h3&gt;
&lt;br&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~/.config/systemd/user/spotifyd.service:&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Unit]&lt;br&gt;
Description=A spotify playing daemon&lt;br&gt;
Documentation=&lt;a href="https://github.com/Spotifyd/spotifyd" rel="noopener noreferrer"&gt;https://github.com/Spotifyd/spotifyd&lt;/a&gt;&lt;br&gt;
Wants=sound.target&lt;br&gt;
After=sound.target&lt;br&gt;
Wants=network-online.target&lt;br&gt;
After=network-online.target

&lt;p&gt;[Service]&lt;br&gt;
ExecStart=/usr/bin/spotifyd --no-daemon&lt;br&gt;
Restart=always&lt;br&gt;
RestartSec=12&lt;/p&gt;

&lt;p&gt;[Install]&lt;br&gt;
WantedBy=default.target&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Then enable and start the script&lt;br&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;systemctl --user enable spotifyd --now&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Connecting to Spotify API
&lt;/h2&gt;

&lt;p&gt;To connect Spotify-tui to Spotify's API for music playback and track searching, follow these steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Visit the Spotify dashboard.&lt;/li&gt;
&lt;li&gt;Create a new app to obtain your Client ID and Client Secret.&lt;/li&gt;
&lt;li&gt;Edit app settings and add &lt;code&gt;http://localhost:8888/callback&lt;/code&gt; as a Redirect URI.&lt;/li&gt;
&lt;li&gt;Save settings and return to the terminal.&lt;/li&gt;
&lt;li&gt;Run "spt" and enter your Client ID and Client Secret when prompted.&lt;/li&gt;
&lt;li&gt;Confirm the default port (8888) or input a custom port.&lt;/li&gt;
&lt;li&gt;You'll be redirected to Spotify for permission.&lt;/li&gt;
&lt;li&gt;After approval, the redirect URL is automatically parsed.&lt;/li&gt;
&lt;li&gt;If the local web server fails, copy the URL from the blank page and paste it into the terminal prompt.&lt;/li&gt;
&lt;li&gt;You're now ready to use spotify-tui! 🎉&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After you’ve run spt for the first time, you’ll find a configuration file under &lt;code&gt;~/.config/spotify-tui/client.yml&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Connect with spotifyd
&lt;/h3&gt;

&lt;p&gt;Make sure that spotifyd.service is running:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;systemctl --user status spotifyd.service&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, run &lt;code&gt;spt&lt;/code&gt; in terminal and select any song&lt;br&gt;
and press ENTER&lt;/p&gt;

&lt;p&gt;If Spotify TUI indicates it can't find a device, press 'd', and the CLI will display the available Spotifyd clients. Select the appropriate one by pressing 'Enter'.&lt;/p&gt;

&lt;p&gt;Now it should Work.&lt;/p&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%2Fuploads%2Farticles%2F3wu7yxdlk6dcvz8i0vov.png" 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%2Fuploads%2Farticles%2F3wu7yxdlk6dcvz8i0vov.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enjoy Listening&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;use_keyring = true&lt;br&gt;
use_mpris = true&lt;br&gt;
dbus_type = "session"&lt;br&gt;
backend = "alsa" # use portaudio for macOS [homebrew]&lt;br&gt;
device = "alsa_audio_device"  # omit for macOS&lt;br&gt;
audio_format = "S16"&lt;br&gt;
control = "alsa_audio_device"  # omit for macOS&lt;br&gt;
mixer = "PCM"  # omit for macOS&lt;br&gt;
volume_controller = "alsa"  # use softvol for macOS&lt;br&gt;
on_song_change_hook = "command_to_run_on_playback_events"&lt;br&gt;
device_name = "spotifyd"&lt;br&gt;
bitrate = 320&lt;br&gt;
cache_path = ""/Users/&amp;lt;your Username&amp;gt;/.cache/spotifyd"&lt;br&gt;
max_cache_size = 1000000000&lt;br&gt;
no_audio_cache = true&lt;br&gt;
initial_volume = "90"&lt;br&gt;
volume_normalisation = true&lt;br&gt;
normalisation_pregain = -10&lt;br&gt;
autoplay = true&lt;br&gt;
zeroconf_port = 1234&lt;br&gt;
proxy = "&lt;a href="http://proxy.example.org:8080" rel="noopener noreferrer"&gt;http://proxy.example.org:8080&lt;/a&gt;"&lt;br&gt;
audio_dongle.&lt;br&gt;
device_type = "computer"&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Create a systemd user script&lt;br&gt;
&lt;/h3&gt;
&lt;br&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~/.config/systemd/user/spotifyd.service:&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Unit]&lt;br&gt;
Description=A spotify playing daemon&lt;br&gt;
Documentation=&lt;a href="https://github.com/Spotifyd/spotifyd" rel="noopener noreferrer"&gt;https://github.com/Spotifyd/spotifyd&lt;/a&gt;&lt;br&gt;
Wants=sound.target&lt;br&gt;
After=sound.target&lt;br&gt;
Wants=network-online.target&lt;br&gt;
After=network-online.target

&lt;p&gt;[Service]&lt;br&gt;
ExecStart=/usr/bin/spotifyd --no-daemon&lt;br&gt;
Restart=always&lt;br&gt;
RestartSec=12&lt;/p&gt;

&lt;p&gt;[Install]&lt;br&gt;
WantedBy=default.target&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Then enable and start the script&lt;br&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;systemctl --user enable spotifyd --now&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Connecting to Spotify API
&lt;/h2&gt;

&lt;p&gt;To connect Spotify-tui to Spotify's API for music playback and track searching, follow these steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Visit the Spotify dashboard.&lt;/li&gt;
&lt;li&gt;Create a new app to obtain your Client ID and Client Secret.&lt;/li&gt;
&lt;li&gt;Edit app settings and add &lt;code&gt;http://localhost:8888/callback&lt;/code&gt; as a Redirect URI.&lt;/li&gt;
&lt;li&gt;Save settings and return to the terminal.&lt;/li&gt;
&lt;li&gt;Run "spt" and enter your Client ID and Client Secret when prompted.&lt;/li&gt;
&lt;li&gt;Confirm the default port (8888) or input a custom port.&lt;/li&gt;
&lt;li&gt;You'll be redirected to Spotify for permission.&lt;/li&gt;
&lt;li&gt;After approval, the redirect URL is automatically parsed.&lt;/li&gt;
&lt;li&gt;If the local web server fails, copy the URL from the blank page and paste it into the terminal prompt.&lt;/li&gt;
&lt;li&gt;You're now ready to use spotify-tui! 🎉&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After you’ve run spt for the first time, you’ll find a configuration file under &lt;code&gt;~/.config/spotify-tui/client.yml&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Connect with spotifyd
&lt;/h3&gt;

&lt;p&gt;Make sure that spotifyd.service is running:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;systemctl --user status spotifyd.service&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, run &lt;code&gt;spt&lt;/code&gt; in terminal and select any song&lt;br&gt;
and press ENTER&lt;/p&gt;

&lt;p&gt;If Spotify TUI indicates it can't find a device, press 'd', and the CLI will display the available Spotifyd clients. Select the appropriate one by pressing 'Enter'.&lt;/p&gt;

&lt;p&gt;Now it should Work.&lt;/p&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%2Fuploads%2Farticles%2F3wu7yxdlk6dcvz8i0vov.png" 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%2Fuploads%2Farticles%2F3wu7yxdlk6dcvz8i0vov.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enjoy Listening&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;use_keyring = true&lt;br&gt;
use_mpris = true&lt;br&gt;
dbus_type = "session"&lt;br&gt;
backend = "alsa" # use portaudio for macOS [homebrew]&lt;br&gt;
device = "alsa_audio_device"  # omit for macOS&lt;br&gt;
audio_format = "S16"&lt;br&gt;
control = "alsa_audio_device"  # omit for macOS&lt;br&gt;
mixer = "PCM"  # omit for macOS&lt;br&gt;
volume_controller = "alsa"  # use softvol for macOS&lt;br&gt;
on_song_change_hook = "command_to_run_on_playback_events"&lt;br&gt;
device_name = "spotifyd"&lt;br&gt;
bitrate = 320&lt;br&gt;
cache_path = ""/Users/&amp;lt;your Username&amp;gt;/.cache/spotifyd"&lt;br&gt;
max_cache_size = 1000000000&lt;br&gt;
no_audio_cache = true&lt;br&gt;
initial_volume = "90"&lt;br&gt;
volume_normalisation = true&lt;br&gt;
normalisation_pregain = -10&lt;br&gt;
autoplay = true&lt;br&gt;
zeroconf_port = 1234&lt;br&gt;
proxy = "&lt;a href="http://proxy.example.org:8080" rel="noopener noreferrer"&gt;http://proxy.example.org:8080&lt;/a&gt;"&lt;br&gt;
audio_dongle.&lt;br&gt;
device_type = "computer"&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Create a systemd user script&lt;br&gt;
&lt;/h3&gt;
&lt;br&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~/.config/systemd/user/spotifyd.service:&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Unit]&lt;br&gt;
Description=A spotify playing daemon&lt;br&gt;
Documentation=&lt;a href="https://github.com/Spotifyd/spotifyd" rel="noopener noreferrer"&gt;https://github.com/Spotifyd/spotifyd&lt;/a&gt;&lt;br&gt;
Wants=sound.target&lt;br&gt;
After=sound.target&lt;br&gt;
Wants=network-online.target&lt;br&gt;
After=network-online.target

&lt;p&gt;[Service]&lt;br&gt;
ExecStart=/usr/bin/spotifyd --no-daemon&lt;br&gt;
Restart=always&lt;br&gt;
RestartSec=12&lt;/p&gt;

&lt;p&gt;[Install]&lt;br&gt;
WantedBy=default.target&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Then enable and start the script&lt;br&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;systemctl --user enable spotifyd --now&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Connecting to Spotify API
&lt;/h2&gt;

&lt;p&gt;To connect Spotify-tui to Spotify's API for music playback and track searching, follow these steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Visit the Spotify dashboard.&lt;/li&gt;
&lt;li&gt;Create a new app to obtain your Client ID and Client Secret.&lt;/li&gt;
&lt;li&gt;Edit app settings and add &lt;code&gt;http://localhost:8888/callback&lt;/code&gt; as a Redirect URI.&lt;/li&gt;
&lt;li&gt;Save settings and return to the terminal.&lt;/li&gt;
&lt;li&gt;Run "spt" and enter your Client ID and Client Secret when prompted.&lt;/li&gt;
&lt;li&gt;Confirm the default port (8888) or input a custom port.&lt;/li&gt;
&lt;li&gt;You'll be redirected to Spotify for permission.&lt;/li&gt;
&lt;li&gt;After approval, the redirect URL is automatically parsed.&lt;/li&gt;
&lt;li&gt;If the local web server fails, copy the URL from the blank page and paste it into the terminal prompt.&lt;/li&gt;
&lt;li&gt;You're now ready to use spotify-tui! 🎉&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After you’ve run spt for the first time, you’ll find a configuration file under &lt;code&gt;~/.config/spotify-tui/client.yml&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Connect with spotifyd
&lt;/h3&gt;

&lt;p&gt;Make sure that spotifyd.service is running:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;systemctl --user status spotifyd.service&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, run &lt;code&gt;spt&lt;/code&gt; in terminal and select any song&lt;br&gt;
and press ENTER&lt;/p&gt;

&lt;p&gt;If Spotify TUI indicates it can't find a device, press 'd', and the CLI will display the available Spotifyd clients. Select the appropriate one by pressing 'Enter'.&lt;/p&gt;

&lt;p&gt;Now it should Work.&lt;/p&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%2Fuploads%2Farticles%2F3wu7yxdlk6dcvz8i0vov.png" 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%2Fuploads%2Farticles%2F3wu7yxdlk6dcvz8i0vov.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enjoy Listening&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;use_keyring = true&lt;br&gt;
use_mpris = true&lt;br&gt;
dbus_type = "session"&lt;br&gt;
backend = "alsa" # use portaudio for macOS [homebrew]&lt;br&gt;
device = "alsa_audio_device"  # omit for macOS&lt;br&gt;
audio_format = "S16"&lt;br&gt;
control = "alsa_audio_device"  # omit for macOS&lt;br&gt;
mixer = "PCM"  # omit for macOS&lt;br&gt;
volume_controller = "alsa"  # use softvol for macOS&lt;br&gt;
on_song_change_hook = "command_to_run_on_playback_events"&lt;br&gt;
device_name = "spotifyd"&lt;br&gt;
bitrate = 320&lt;br&gt;
cache_path = ""/Users/&amp;lt;your Username&amp;gt;/.cache/spotifyd"&lt;br&gt;
max_cache_size = 1000000000&lt;br&gt;
no_audio_cache = true&lt;br&gt;
initial_volume = "90"&lt;br&gt;
volume_normalisation = true&lt;br&gt;
normalisation_pregain = -10&lt;br&gt;
autoplay = true&lt;br&gt;
zeroconf_port = 1234&lt;br&gt;
proxy = "&lt;a href="http://proxy.example.org:8080" rel="noopener noreferrer"&gt;http://proxy.example.org:8080&lt;/a&gt;"&lt;br&gt;
audio_dongle.&lt;br&gt;
device_type = "computer"&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Create a systemd user script&lt;br&gt;
&lt;/h3&gt;
&lt;br&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~/.config/systemd/user/spotifyd.service:&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Unit]&lt;br&gt;
Description=A spotify playing daemon&lt;br&gt;
Documentation=&lt;a href="https://github.com/Spotifyd/spotifyd" rel="noopener noreferrer"&gt;https://github.com/Spotifyd/spotifyd&lt;/a&gt;&lt;br&gt;
Wants=sound.target&lt;br&gt;
After=sound.target&lt;br&gt;
Wants=network-online.target&lt;br&gt;
After=network-online.target

&lt;p&gt;[Service]&lt;br&gt;
ExecStart=/usr/bin/spotifyd --no-daemon&lt;br&gt;
Restart=always&lt;br&gt;
RestartSec=12&lt;/p&gt;

&lt;p&gt;[Install]&lt;br&gt;
WantedBy=default.target&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Then enable and start the script&lt;br&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;systemctl --user enable spotifyd --now&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Connecting to Spotify API
&lt;/h2&gt;

&lt;p&gt;To connect Spotify-tui to Spotify's API for music playback and track searching, follow these steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Visit the Spotify dashboard.&lt;/li&gt;
&lt;li&gt;Create a new app to obtain your Client ID and Client Secret.&lt;/li&gt;
&lt;li&gt;Edit app settings and add &lt;code&gt;http://localhost:8888/callback&lt;/code&gt; as a Redirect URI.&lt;/li&gt;
&lt;li&gt;Save settings and return to the terminal.&lt;/li&gt;
&lt;li&gt;Run "spt" and enter your Client ID and Client Secret when prompted.&lt;/li&gt;
&lt;li&gt;Confirm the default port (8888) or input a custom port.&lt;/li&gt;
&lt;li&gt;You'll be redirected to Spotify for permission.&lt;/li&gt;
&lt;li&gt;After approval, the redirect URL is automatically parsed.&lt;/li&gt;
&lt;li&gt;If the local web server fails, copy the URL from the blank page and paste it into the terminal prompt.&lt;/li&gt;
&lt;li&gt;You're now ready to use spotify-tui! 🎉&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After you’ve run spt for the first time, you’ll find a configuration file under &lt;code&gt;~/.config/spotify-tui/client.yml&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Connect with spotifyd
&lt;/h3&gt;

&lt;p&gt;Make sure that spotifyd.service is running:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;systemctl --user status spotifyd.service&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, run &lt;code&gt;spt&lt;/code&gt; in terminal and select any song&lt;br&gt;
and press ENTER&lt;/p&gt;

&lt;p&gt;If Spotify TUI indicates it can't find a device, press 'd', and the CLI will display the available Spotifyd clients. Select the appropriate one by pressing 'Enter'.&lt;/p&gt;

&lt;p&gt;Now it should Work.&lt;/p&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%2Fuploads%2Farticles%2F3wu7yxdlk6dcvz8i0vov.png" 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%2Fuploads%2Farticles%2F3wu7yxdlk6dcvz8i0vov.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enjoy Listening&lt;/p&gt;

</description>
      <category>linux</category>
      <category>archlinux</category>
      <category>spotify</category>
      <category>terminal</category>
    </item>
  </channel>
</rss>
