<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Siddharth Singh Tanwar</title>
    <description>The latest articles on DEV Community by Siddharth Singh Tanwar (@siddharth_singhtanwar_6a).</description>
    <link>https://dev.to/siddharth_singhtanwar_6a</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%2F1641058%2Ff2745aa4-afa1-49c2-b5ea-3bf0135cc1b4.png</url>
      <title>DEV Community: Siddharth Singh Tanwar</title>
      <link>https://dev.to/siddharth_singhtanwar_6a</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/siddharth_singhtanwar_6a"/>
    <language>en</language>
    <item>
      <title>Creating art similar to 1.2 million pounds worth of painting</title>
      <dc:creator>Siddharth Singh Tanwar</dc:creator>
      <pubDate>Thu, 22 Aug 2024 15:10:21 +0000</pubDate>
      <link>https://dev.to/siddharth_singhtanwar_6a/creating-art-similar-to-12-million-pounds-worth-of-painting-4ef</link>
      <guid>https://dev.to/siddharth_singhtanwar_6a/creating-art-similar-to-12-million-pounds-worth-of-painting-4ef</guid>
      <description>&lt;h2&gt;
  
  
  Recreating a Million-Dollar Damien Hirst Painting Using Python and Turtle Graphics
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Overview
&lt;/h4&gt;

&lt;p&gt;Ever seen art and thought, "Yeah, I could make something similar to that." Well, you are not alone! If you search Damien Hirst's dot paintings online, a similar thought might cross your mind. Today we are going to test this theory using code.&lt;/p&gt;

&lt;h4&gt;
  
  
  Objective
&lt;/h4&gt;

&lt;p&gt;We are trying to create art similar to popular artworks by artist Damien Hirst using Python code and the Turtle graphics library.&lt;/p&gt;

&lt;h3&gt;
  
  
  Inspiration
&lt;/h3&gt;

&lt;p&gt;This blog post is inspired by Angela Yu's Python course.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting up the Environment
&lt;/h3&gt;

&lt;p&gt;We will need Python installed on our system (the latest version is better), Turtle graphics library (which comes pre-installed when you install Python), Colorgram library (which you have to install using pip), and your favorite IDE.&lt;/p&gt;

&lt;h3&gt;
  
  
  Understanding the Art
&lt;/h3&gt;

&lt;p&gt;Hirst's art consists of a pattern of symmetrical color dots of the same size separated by consistent space.&lt;br&gt;
It seems simple enough to mimic. So let's get to it.&lt;/p&gt;
&lt;h3&gt;
  
  
  Coding the Painting
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Creating the Canvas&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#We import the Turtle library and give it an alias as t
import turtle as t

#We create an object of the Turtle class and name it bob
bob = t.Turtle()

#We create a screen that will be our canvas which our turtle (bob)  #will draw the painting on
screen = t.Screen()

#To make the screen persistent we add the following line of code that #makes sure that the screen stays till we click on it.
screen.exitonclick()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Extracting Colors&lt;/strong&gt;:&lt;br&gt;
You can install the &lt;code&gt;colorgram&lt;/code&gt; library from this &lt;a href="https://pypi.org/project/colorgram.py/" rel="noopener noreferrer"&gt;link&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Import the colorgram library
import colorgram

#Make a list that will store the colors extracted from a sample #Damien Hirst painting.
rgb_colors = []

#Extract the colors from the painting. You can choose how many colors #to extract, here 30 is chosen.
colors = colorgram.extract('image.jpg', 30)

#The output is a list of colorgram object of RGB values. We select #the RGB values from them.
for color in colors:
    r = color.rgb.r
    g = color.rgb.g
    b = color.rgb.b
    new_color = (r, g, b)
    rgb_colors.append(new_color)

print(rgb_colors)

#After we get the output, we can select the color list from the #terminal, store them into a variable like below, and comment the #above code.
color_list = [(245, 243, 238), (202, 164, 110), (240, 245, 241), (149, 75, 50), (222, 201, 136), (53, 93, 123), (170, 154, 41), (138, 31, 20), (134, 163, 184), (197, 92, 73), (47, 121, 86), (73, 43, 35), (145, 178, 149), (14, 98, 70), (232, 176, 165), (160, 142, 158), (54, 45, 50), (101, 75, 77), (183, 205, 171), (36, 60, 74), (19, 86, 89), (82, 148, 129), (147, 17, 19), (27, 68, 102), (12, 70, 64), (107, 127, 153), (176, 192, 208), (168, 99, 102)]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Drawing the Patterns&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Importing random module to randomly choose colors from color list
import random

# Since we are using RGB we set the colormode to 255 as there are 0 #to 255 values of RGB.
t.colormode(255)

#For better visualization we speed up the drawing process
bob.speed("fastest")

#by default our pen draws a line, we penup to avoid that
bob.penup()

# Going to an appropriate place in the canvas to draw all the dots in #the visible area
bob.setheading(220)
bob.forward(300)

#Setting the heading in right direction to draw the dots
bob.setheading(0)
number_of_dots = 100

#drawing dots of size 20 at a distance of 50 from each other of a #random color from the color list. After every 10 dots we go the next #line
for dots in range(1, number_of_dots + 1):
    bob.dot(20, random.choice(color_list))
    bob.forward(50)

    if dots % 10 == 0:
        bob.setheading(90)
        bob.forward(50)
        bob.setheading(180)
        bob.forward(500)
        bob.setheading(0)

#hiding our drawing pen
bob.hideturtle()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Enhancements
&lt;/h3&gt;

&lt;p&gt;Now there various Hirst's paintings to choose from and we can extract any number of colors from them so feel free to try out for yourself and see what kind of artwork you can come up with!&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Overall it is a fun project and shows how easy it is to create something real from just the fundamentals of a programming language.&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>sideprojects</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Understanding the -u Flag in Git: Simplify Your Workflow</title>
      <dc:creator>Siddharth Singh Tanwar</dc:creator>
      <pubDate>Thu, 01 Aug 2024 14:15:08 +0000</pubDate>
      <link>https://dev.to/siddharth_singhtanwar_6a/understanding-the-u-flag-in-git-simplify-your-workflow-1bmb</link>
      <guid>https://dev.to/siddharth_singhtanwar_6a/understanding-the-u-flag-in-git-simplify-your-workflow-1bmb</guid>
      <description>&lt;p&gt;As developers, efficiency and clarity in our workflows can make a significant difference. One Git command that helps streamline our processes is &lt;code&gt;git push -u origin main&lt;/code&gt;. This blog post'll explore what the &lt;code&gt;-u&lt;/code&gt; flag does and how it simplifies future Git operations.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Does the &lt;code&gt;-u&lt;/code&gt; Flag Do?
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;-u&lt;/code&gt; flag in the git push command stands for &lt;code&gt;--set-upstream&lt;/code&gt;. When you use &lt;code&gt;git push -u origin main&lt;/code&gt;, it does two primary things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pushes the Local Branch to the Remote Repository&lt;/strong&gt;: Just like a regular git push origin main, this command pushes your local main branch to the main branch on the remote repository named origin.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Sets the Upstream Branch&lt;/strong&gt;: It establishes a tracking relationship between your local branch and the remote branch. This means Git now knows which remote branch your local branch is linked to, making future interactions with this branch more straightforward.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why is Setting the Upstream Branch Important?
&lt;/h2&gt;

&lt;p&gt;By setting the upstream branch, you simplify future Git commands. Without this, you would need to specify the remote branch every time you pull or push. After setting the upstream, you can use shorter commands, saving time and reducing the potential for errors.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example Workflow
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Push with Upstream Set:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git push -u origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Future Pushes:
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;git push&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pull Changes:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git pull
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By using the &lt;code&gt;-u&lt;/code&gt; flag, future &lt;code&gt;git push&lt;/code&gt; and &lt;code&gt;git pull&lt;/code&gt; commands will automatically reference the main branch on the origin remote, simplifying your workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checking Upstream Branch
&lt;/h2&gt;

&lt;p&gt;You can see which upstream branch is set for your local branches with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git branch -vv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command provides a detailed view of all your local branches, their upstream branches, and their tracking status.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Incorporating the &lt;code&gt;-u&lt;/code&gt; flag into your Git workflow is a small change that can have a big impact on efficiency. By setting the upstream branch, you streamline your commands and ensure a smoother, more intuitive interaction with your Git repository.&lt;/p&gt;

&lt;p&gt;Try it out next time you push a branch for the first time, and enjoy a more efficient Git experience!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Supercharge Your Terminal: Display Git Branch in Your Bash Prompt</title>
      <dc:creator>Siddharth Singh Tanwar</dc:creator>
      <pubDate>Tue, 30 Jul 2024 17:20:48 +0000</pubDate>
      <link>https://dev.to/siddharth_singhtanwar_6a/supercharge-your-terminal-display-git-branch-in-your-bash-prompt-4816</link>
      <guid>https://dev.to/siddharth_singhtanwar_6a/supercharge-your-terminal-display-git-branch-in-your-bash-prompt-4816</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;As developers, we spend a significant amount of time in our terminal, navigating through projects and managing Git repositories. One common pitfall is forgetting which Git branch we're currently working on, leading to potential mistakes or confusion. What if your terminal could always remind you of your current Git branch? In this post, we'll walk through a simple yet powerful customization of your bash prompt that will do just that.&lt;/p&gt;

&lt;h2&gt;
  
  
  What We'll Achieve
&lt;/h2&gt;

&lt;p&gt;Before: username@hostname:$&lt;br&gt;
After: username@hostname:/project (main)$&lt;/p&gt;

&lt;p&gt;By the end of this tutorial, your bash prompt will automatically display your current Git branch when you're in a Git repository. This small change can significantly improve your workflow, reducing the need for frequent git branch commands and helping prevent accidental commits to the wrong branch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before we begin, ensure you have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bash shell (default on most Linux distributions and macOS)&lt;/li&gt;
&lt;li&gt;Git installed&lt;/li&gt;
&lt;li&gt;Basic familiarity with editing configuration files&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step-by-Step Guide
&lt;/h2&gt;

&lt;p&gt;a. Editing the .bashrc file&lt;br&gt;
Open your .bashrc file in a text editor:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;nano ~/.bashrc&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;b. Adding the parse_git_branch function&lt;br&gt;
Add this function to your .bashrc:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;parse_git_branch() {&lt;br&gt;
    git branch 2&amp;gt; /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;c. Modifying the PS1 variable&lt;br&gt;
Find your PS1 definition and modify it to include the Git branch information:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;if [ "$color_prompt" = yes ]; then&lt;br&gt;
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[33m\]$(parse_git_branch)\[\033[00m\]\$ '&lt;br&gt;
else&lt;br&gt;
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '&lt;br&gt;
fi&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;d. Applying the changes&lt;br&gt;
Save the file and run:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;source ~/.bashrc&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How It Works
&lt;/h2&gt;

&lt;p&gt;The parse_git_branch function:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Runs git branch to get the list of branches&lt;/li&gt;
&lt;li&gt;Uses sed to filter and format the output, showing only the current branch name in parentheses&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The PS1 string:&lt;br&gt;
&lt;code&gt;\u@\h:&lt;/code&gt; Displays username@hostname&lt;br&gt;
&lt;code&gt;\w:&lt;/code&gt; Shows the current working directory&lt;br&gt;
&lt;code&gt;$(parse_git_branch):&lt;/code&gt; Calls our function to display the Git branch&lt;br&gt;
Color codes (e.g., [\033[01;32m]) add visual distinction to different parts of the prompt&lt;/p&gt;

&lt;h2&gt;
  
  
  Customization Options
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Change colors by modifying the color codes in PS1&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add Git status information by extending the parse_git_branch function&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Include other Git information like the number of staged/unstaged files&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If changes don't appear, ensure you've sourced .bashrc or opened a new terminal &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check for syntax errors in your .bashrc file&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify that Git is installed and accessible from your PATH&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This simple bash prompt customization can significantly enhance your development workflow. By always knowing which Git branch you're on, you can work more confidently and efficiently. I encourage you to customize your prompt further to suit your needs and workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Bash manual: Advanced prompt customization&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Git documentation: Working with branches &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bash scripting tutorials for more advanced prompt modifications &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By implementing this customization, you're taking a small but significant step towards a more informative and efficient development environment. &lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>git</category>
      <category>terminal</category>
      <category>linux</category>
      <category>bash</category>
    </item>
    <item>
      <title>A list of lists in Python</title>
      <dc:creator>Siddharth Singh Tanwar</dc:creator>
      <pubDate>Sun, 14 Jul 2024 05:30:20 +0000</pubDate>
      <link>https://dev.to/siddharth_singhtanwar_6a/a-list-of-lists-in-python-20e1</link>
      <guid>https://dev.to/siddharth_singhtanwar_6a/a-list-of-lists-in-python-20e1</guid>
      <description>&lt;p&gt;&lt;strong&gt;Python Tip: Creating a List of Lists&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When creating a list of lists in Python, it's important to understand how list multiplication works.&lt;/p&gt;

&lt;p&gt;Using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;m = [[]] * 7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;creates seven references to the same list. Modifying one list will affect all others because they reference the same object.&lt;/p&gt;

&lt;p&gt;Instead, use list comprehension to ensure each list is independent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;m = [[] for _ in range(7)]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This way, each empty list in 'm' is a separate object, avoiding unwanted side effects.&lt;/p&gt;

</description>
      <category>learnpython</category>
      <category>coding</category>
      <category>programming</category>
    </item>
    <item>
      <title>Concurrency: Letting all cook!</title>
      <dc:creator>Siddharth Singh Tanwar</dc:creator>
      <pubDate>Wed, 19 Jun 2024 11:42:02 +0000</pubDate>
      <link>https://dev.to/siddharth_singhtanwar_6a/concurrency-letting-all-cook-4np8</link>
      <guid>https://dev.to/siddharth_singhtanwar_6a/concurrency-letting-all-cook-4np8</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for &lt;a href="https://dev.to/challenges/cs"&gt;DEV Computer Science Challenge v24.06.12: One Byte Explainer&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Explainer
&lt;/h2&gt;

&lt;p&gt;Imagine a kitchen with multiple chefs cooking different dishes simultaneously. Each chef (thread) works on their tasks, but they need to share the stove (resource) without bumping into each other (race conditions). This efficient cooking dance is concurrency!&lt;/p&gt;

&lt;h2&gt;
  
  
  Additional Context
&lt;/h2&gt;

&lt;p&gt;Concurrency is an important but difficult to understand concept when you first come across it. If we try to understand it using an analogy, it gets somewhat easier. A lot of concepts connected to it like race conditions and deadlock also become easier to understand.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>cschallenge</category>
      <category>computerscience</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
