<?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: Ruheza, NS</title>
    <description>The latest articles on DEV Community by Ruheza, NS (@maen).</description>
    <link>https://dev.to/maen</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%2F543016%2F2ddbd010-2a5e-4ebe-8a7e-363417f5ef5d.jpg</url>
      <title>DEV Community: Ruheza, NS</title>
      <link>https://dev.to/maen</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/maen"/>
    <language>en</language>
    <item>
      <title>Story of SSRF from Stored XSS in PDF generator application</title>
      <dc:creator>Ruheza, NS</dc:creator>
      <pubDate>Tue, 19 Dec 2023 16:18:39 +0000</pubDate>
      <link>https://dev.to/maen/story-of-ssrf-from-stored-xss-in-pdf-generator-application-70h</link>
      <guid>https://dev.to/maen/story-of-ssrf-from-stored-xss-in-pdf-generator-application-70h</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;PDF generator libraries, particularly those implemented using JavaScript, often face vulnerabilities to cross-site scripting (XSS) attacks, posing a challenge to the security of web applications. One primary reason for this lies in the dynamic nature of JavaScript itself. Many PDF generator libraries heavily rely on client-side scripting to manipulate and generate PDFs, allowing attackers to exploit vulnerabilities in the code. In this write-up, I will show you how I exploited the server side issue (SSRF) from the front-end interface (XSS)&lt;/p&gt;

&lt;h2&gt;
  
  
  The finding
&lt;/h2&gt;

&lt;p&gt;Basically, the application helps you to generate invoice online by just filling in the data and download the pdf file of it.&lt;/p&gt;

&lt;p&gt;I started by doing a recon on the target to identify few things including the stack used to build this application (well, Wappalyzer plus review the minified client code on the browser) and the cloud used to deploy this application (which was AWS).&lt;/p&gt;

&lt;p&gt;Story short, instead of filling intended fields and data, i tried to add JS code to see if the code will be interpreted and executed (XSS). &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%2F6rnndcjt2ezhga9s9vhf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6rnndcjt2ezhga9s9vhf.jpg" alt="Passing a simple code with script tag"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Surprisingly, the app responded with the output of my JS code &lt;code&gt;&amp;lt;script&amp;gt;document.write(document.domain)&amp;lt;/script&amp;gt;&lt;/code&gt; printing the domain name of the application. Now we have our stored XSS. A journey to increase an impact ...&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%2Fpqimaq4idx70r1f30yoo.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpqimaq4idx70r1f30yoo.jpg" alt="Domain name got printed on the pdf as redacted.com"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next i wanted to try if i can exploit any server side issue (stealing cookies wasn't enough for me) for that i tried to use iframe, testing if the application can fetch resources remotely. Since i've already knew that AWS is used, i tried to fetch internal meta-data of the instance with &lt;code&gt;&amp;lt;iframe src="http://169.254.169.254/latest/meta-data/"&amp;gt;&lt;/code&gt; &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%2Fzrw136981j8ldp8f7yu9.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzrw136981j8ldp8f7yu9.jpg" alt=" SSRF towards AWS instance "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As how i was expecting, the application gave me what i requested ...&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%2Fidjj2cwknbqm7fxacn6x.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%2Fidjj2cwknbqm7fxacn6x.png" alt=" SSRF successfully "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Up to this point as an attacker, you can do alot on this application. I chose to read access keys of the this server so that i can completely take over the server. In AWS cloud-world, if you can have "Access Key ID" and "Secret Access Key" then you can run command remotely in the server and even play around with some connected services. I wanted this!&lt;/p&gt;

&lt;p&gt;First in order to know and read these credentials, you must know the IAM role used in this particular instance. So i added &lt;code&gt;&amp;lt;iframe src="http://169.254.169.254/latest/meta-data/iam/security-credentials/"&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I got the IAM role and next step was just to append it on the same endpoint so that we can read these credentials.&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%2Fyt2xeeb8w94xyosb42cp.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyt2xeeb8w94xyosb42cp.jpg" alt="Game over "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Voila! Now we have a full control of the instance remotely.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final thought
&lt;/h2&gt;

&lt;p&gt;As we have seen above, the integration of third-party libraries in PDF generators can introduce additional vulnerabilities. Although this is most known issue and well fixed in most of the JS libraries but some libraries especially new ones are still prone to this kind of attacks.&lt;/p&gt;

&lt;p&gt;It is advised to double check the library you want to use in your application and ensure that it is free-from pursing issues result to XSS. Also sanitization should always be implemented on all input fields and forms as a preventive measure.&lt;/p&gt;

&lt;p&gt;Disclaimer: The researched target mentioned (anonymized) in this write-up was successful patched and remediated. Kudos to the team!&lt;/p&gt;

&lt;p&gt;Originally wrote this article &lt;a href="https://maen08.hashnode.dev/story-of-ssrf-from-stored-xss-in-pdf-generator-application" rel="noopener noreferrer"&gt;here&lt;/a&gt;  Thanks for reading !&lt;/p&gt;

</description>
      <category>ssrf</category>
      <category>websecurity</category>
      <category>javascriptlibraries</category>
      <category>xss</category>
    </item>
    <item>
      <title>Send Linux commands to a remote PC(or server) from WhatsApp</title>
      <dc:creator>Ruheza, NS</dc:creator>
      <pubDate>Sat, 05 Feb 2022 15:37:14 +0000</pubDate>
      <link>https://dev.to/maen/send-linux-commands-to-a-remote-pcor-server-from-whatsapp-gi9</link>
      <guid>https://dev.to/maen/send-linux-commands-to-a-remote-pcor-server-from-whatsapp-gi9</guid>
      <description>&lt;h3&gt;
  
  
  Inspiration
&lt;/h3&gt;

&lt;p&gt;Some years back, I wanted to link two systems talking to each other through Linux commands. It was just a project out of curiosity, and wasn't even a serious one. I didn't know &lt;a href="https://www.twilio.com/"&gt;Twilio&lt;/a&gt; or &lt;a href="https://www.plivo.com/"&gt;Plivo&lt;/a&gt; or any other platform related. I tried to die hard, but guess what! it was hard indeed :) I learnt about Twilio and built many other related projects. You can do the same, or even start building your very own next Twilio. Yes! It's possible. Hell, yess !&lt;/p&gt;

&lt;p&gt;You can learn from this project, going further and building something tremendous! From the concept of this project (of-course you need to improve and add few other things) you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deploy your docker replicas just by sending WhatsApp text&lt;/li&gt;
&lt;li&gt;You can monitor your IoT devices remotely&lt;/li&gt;
&lt;li&gt;Send commands to your K8's engine for some orchestration processes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In fact you can do a lot, the sky is not a limit :) Let's set up our project.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup a project in Twilio
&lt;/h3&gt;

&lt;p&gt;In this article, we will focus more on how to interact these technologies and accomplish what we want. Our focus won't be more on Twilio.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;To setup a sandbox and obtain a WhatsApp number (sender id) follow this &lt;a href="https://www.twilio.com/docs/whatsapp/sandbox"&gt;link&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Obtain &lt;code&gt;ACCOUNT_SID&lt;/code&gt; and &lt;code&gt;AUTH_TOKEN&lt;/code&gt; from the platform. Click &lt;a href="https://www.twilio.com/blog/better-twilio-authentication-csharp-twilio-api-keys"&gt;here&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now let's proceed with the project.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Flow of our project
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XYeVEGWG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1641558621593/iUrIZm_di.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XYeVEGWG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1641558621593/iUrIZm_di.jpeg" alt="architecture flow(3).jpg" width="800" height="728"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Building a server in Python
&lt;/h3&gt;

&lt;p&gt;Now that we have already setup our project in Twilio platform and obtained &lt;code&gt;ACCOUNT_SID&lt;/code&gt; and &lt;code&gt;AUTH_TOKEN&lt;/code&gt; its time to build our server. We will use Flask for this project.&lt;/p&gt;

&lt;p&gt;Create a file, name it &lt;code&gt;command.py&lt;/code&gt;. This is the file where we will write our server-side application to and establish a connection between the machine (which will receive the commands) and WhatsApp through Twilio.&lt;/p&gt;

&lt;p&gt;Install the required packages and make them available in the &lt;code&gt;requirements.txt&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pip install flask, twilio
$ pip freeze &amp;gt; requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the file &lt;code&gt;command.py&lt;/code&gt; import the libraries:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os
from flask import Flask, request
from twilio.twiml.messaging_response import MessagingResponse

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

&lt;/div&gt;



&lt;p&gt;From the import, &lt;code&gt;Flask&lt;/code&gt; will help us to setup the server, &lt;code&gt;request&lt;/code&gt; will enable us to send requests from WhatsApp via the Twilio sandbox to this server we're building. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;MessagingResponse&lt;/code&gt;&lt;br&gt;
 is the Twilio Python class whose object helps to manage responses, that is incoming and outgoing messages or even calls. In short, &lt;code&gt;MessagingResponse&lt;/code&gt; helps to starts the &lt;a href="https://www.twilio.com/docs/glossary/what-is-twilio-markup-language-twiml"&gt;TwiML&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will use &lt;code&gt;os&lt;/code&gt; to make our WhatsApp text be excuted on the remote terminal (can be your remote Linux machine or the Server) as Linux commands (not just text).&lt;/p&gt;

&lt;p&gt;Now lets write our first function to handle incomming commands sent from a phone (via WhatsApp) to the Twilio number we obtained early.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@app.route("/command", methods=['GET', 'POST'])
def command():
    # get the message body which sent to the Twilio number
    body = request.values.get('Body', None)
    # Start our TwiML response
    resp = MessagingResponse()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now &lt;code&gt;MessagingResponse&lt;/code&gt; is well set, we can listen to the response coming to our Twilio number obtained. We can receive and process the message sent from any WhatsApp number (ofcourse, sent to our Twilio number). We can now start the chat, receive the commands and run them on the terminal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Determine the right reply for this message
    if body == 'command':
        resp.message('What command do you want to run on your machine?')

    # You can send any command
    elif body == 'init 0':
        resp.message('Shutting down your machine...')
        os.system('init 0')

    elif body != 'command':
        os.system(body)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's the &lt;code&gt;command.py&lt;/code&gt; file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from flask import Flask, request, redirect
from twilio.twiml.messaging_response import MessagingResponse
import os
from decouple import config

app = Flask(__name__)

@app.route("/")
def home():
    # Just to make sure if flask server runs successfully
    return 'Hello, the server is running...'

@app.route("/command", methods=['GET', 'POST'])
def command():
     """
        Send a dynamic reply to an incoming text message
        Get the message the user sent our Twilio number
     """
    body = request.values.get('Body', None)
    # Start our TwiML response
    resp = MessagingResponse()

    if body == 'command':
        resp.message('What command do you want to run on your machine?')
    # You can send any command
    elif body == 'init 0':
        resp.message('Shutting down your machine...')
        os.system('init 0')
    elif body != 'command':
        os.system(body)
    return str(resp)

if __name__ == "__main__":
    # Run the script on port 5000
    app.run(debug=True, host='0.0.0.0', port='5000')

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Send linux commands from your WhatsApp
&lt;/h3&gt;

&lt;p&gt;Finally, we need to send commands and let them be processed by our server. But the server is currently running on localhost. We need to expose the server publicly and use its url as callback url in the Twilio platform. You can choose to deploy the app and continue, but for now i will use &lt;a href="https://ngrok.com/"&gt;Ngrok&lt;/a&gt; for this task. Make sure you install &lt;strong&gt;ngrok&lt;/strong&gt; before continue.&lt;/p&gt;

&lt;p&gt;On the terminal, run this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ngrok http 5000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running this command will expose port 5000 which is the same port where our server is running. Ngrok will return a url (a link) of our running server. Copy this url and fill in the Twilio platform in your project console as a &lt;code&gt;callback url&lt;/code&gt;.  Check this example below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZGBgPoQ6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1641566429289/KZaqRTmIjA.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZGBgPoQ6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1641566429289/KZaqRTmIjA.jpeg" alt="sandbox.jpg" width="800" height="290"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you followed all instructions up to now, then you're on the right track and ready to start sending commands from your WhatsApp. &lt;/p&gt;

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

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/maen08/remote-terminal-control"&gt;Source code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.twilio.com/docs/libraries/python"&gt;Twilio Sandbox docs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Posted &lt;a href="https://maenblog.tech/send-linux-commands-to-a-remote-pcor-server-from-whatsapp"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>twiliohackathon</category>
      <category>twilio</category>
      <category>linux</category>
    </item>
    <item>
      <title>Using Tuya Link SDK to build water level monitoring system.</title>
      <dc:creator>Ruheza, NS</dc:creator>
      <pubDate>Tue, 04 Jan 2022 05:22:22 +0000</pubDate>
      <link>https://dev.to/maen/using-tuya-link-sdk-to-build-water-level-monitoring-system-ocm</link>
      <guid>https://dev.to/maen/using-tuya-link-sdk-to-build-water-level-monitoring-system-ocm</guid>
      <description>&lt;h2&gt;
  
  
  Hardware devices required
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Raspberry Pi&lt;/li&gt;
&lt;li&gt;Ultrasonic sensor&lt;/li&gt;
&lt;li&gt;Jumper wires&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Software required
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Tuya IoT platform&lt;/li&gt;
&lt;li&gt;Link SDK python package&lt;/li&gt;
&lt;li&gt;Tuya Smart app (mobile app)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Getting started with Tuya IoT platform
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Create an account in the platform.
&lt;/h3&gt;

&lt;p&gt;If you already have an account, go on login &lt;a href="https://auth.tuya.com/?_source=f8ce204fc51d1a7082c9e80206711660" rel="noopener noreferrer"&gt;here&lt;/a&gt; or if you don't have an account, then create one in this &lt;a href="https://auth.tuya.com/?_source=f8ce204fc51d1a7082c9e80206711660" rel="noopener noreferrer"&gt;link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you are registered or login successfully, then you'll see this dashboard:&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1640774667217%2FoIe2FMj6U.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1640774667217%2FoIe2FMj6U.png" alt="008.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then open  &lt;strong&gt;Product&lt;/strong&gt; &amp;gt; &lt;strong&gt;Development&lt;/strong&gt; &amp;gt; &lt;strong&gt;Create&lt;/strong&gt; then scroll down and you'll see &lt;strong&gt;Can't find the category?&lt;/strong&gt; in the left bottom corner. Open up and fill the information like below then &lt;strong&gt;Create&lt;/strong&gt;:&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1639814305995%2FnKoYZNW86.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1639814305995%2FnKoYZNW86.png" alt="004.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By creating the Product we mean, the project which will exist in the Tuya platform to receive data from the sensors and monitored remotely from the phone or your PC. The information we filled in the platform tries to mimic our hardware devices which we will use in the circuit.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create custom functions
&lt;/h3&gt;

&lt;p&gt;Here we specify some metrics about the sensor (Ultrasonic sensor) so as it may link correctly as how we want it to be. These metrics including, &lt;code&gt;Data Point (DP)&lt;/code&gt;, &lt;code&gt;Identifier&lt;/code&gt;,&lt;code&gt;Data Transfer Type&lt;/code&gt;, &lt;code&gt;Data Type&lt;/code&gt; and &lt;code&gt;Value&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Open up our &lt;strong&gt;Product&lt;/strong&gt; and then click ** Function Definition**  &amp;gt; &lt;strong&gt;Custom Function&lt;/strong&gt; &amp;gt; &lt;strong&gt;Add&lt;/strong&gt;, you'll see the form to fill the metrics above. Go ahead and fill like this:&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1639815308278%2FYmDrzqGfSm.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1639815308278%2FYmDrzqGfSm.png" alt="005.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Obtain credentials for your project
&lt;/h3&gt;

&lt;p&gt;Credentials which are needed in &lt;code&gt;tuyalinksdk&lt;/code&gt; are &lt;code&gt;PID&lt;/code&gt;, &lt;code&gt;AUTHKEY&lt;/code&gt; and &lt;code&gt;UUID&lt;/code&gt;. Once you create a Product in the platform, you automatically obtain the PID (aka, Product ID).&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1639816092846%2F1hJhzi5YO.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1639816092846%2F1hJhzi5YO.png" alt="006.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But for AUTKEY and UUID, you'll have to apply for a license. The license comes with these two credentials. Follow these steps to get the license. Navigate to &lt;strong&gt;Purchase&lt;/strong&gt; &amp;gt; &lt;strong&gt;Material &amp;amp; License&lt;/strong&gt; then click &lt;strong&gt;Buy Now&lt;/strong&gt; the &lt;strong&gt;Generic License&lt;/strong&gt; 2 free licenses for each developer account, you need to buy when you use up.&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1639817006071%2F9bobxx7tZ.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1639817006071%2F9bobxx7tZ.png" alt="007.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;Buy Now **, another window will open then **Select Product&lt;/strong&gt; and &lt;strong&gt;Delivery Mode&lt;/strong&gt; as License.&lt;br&gt;
The order process will take some time to complete. Just relax and worry out meanwhile, get a cup of coffee :)&lt;/p&gt;
&lt;h2&gt;
  
  
  The Circuit (Hardware part)
&lt;/h2&gt;

&lt;p&gt;In this section, we're going to build our circuit. Connect the Raspberry Pi on the power source and the keyboard. Mount Ultrasonic sensor on the Raspberry Pi. We use Ultrasonic sensor to measure the level of water calculating the distance from the sensor to the water surface in the tank.&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1639824560292%2FONIJyXUFj.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1639824560292%2FONIJyXUFj.png" alt="image.png"&gt;&lt;/a&gt;&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1640838988178%2F19Rj9Hpom.jpeg" 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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1640838988178%2F19Rj9Hpom.jpeg" alt="circuit.jpg"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Project in Tuya IoT platform (Software part)
&lt;/h2&gt;

&lt;p&gt;In this section, we're going to setup our project in the Tuya IoT platform. We already have the credentials which we got in the above steps (by credentials i mean, PID, UUID and AUTHKEY). We will use these credentials in the &lt;code&gt;tuyalinksdk&lt;/code&gt; to setup a link connection between the circuit and platform. &lt;/p&gt;
&lt;h3&gt;
  
  
  Link Tuya SDK python library
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;tuyalinksdk&lt;/code&gt; is a Python library which makes the connection between the circuit and the Tuya IoT platform.&lt;br&gt;
We'll install this package in our Raspberry Pi in order to link and upload data from the sensor (in the circuit) to the platform. In the directory of your project in Raspberry Pi, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# install the package
$ pip install tuyalinksdk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or install from the github repository:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git clone https://github.com/tuya/tuyaos-link-sdk-python.git
$ python3 -m pip install ./tuyaos-link-sdk-python
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next thing is to write the codes which establish connection by using this package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from tuyalinksdk.client import TuyaClient

client = TuyaClient(productid='PID', uuid='UUID', authkey='AUTHKEY')

def on_connected():
    print('Connected.')

def on_dps(dps):
    print('DataPoints:', dps)
    client.push_dps(dps)

client.on_connected = on_connected
client.on_dps = on_dps
client.connect()
client.loop_start()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;on_connected&lt;/code&gt; is the method which checks if the connection is well setup. If everything is okay the print statement will run.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;on_dps&lt;/code&gt; is a method which receives the datapoints (values of the sensor) and upload them to the platform so that we can monitor the process from our devices (phones and PC), ie IoT itself. Data are uploaded through &lt;code&gt;client.push_dps()&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;Write the codes for the Raspberry Pi codes for the ultrasonic sensor alongside the above codes. This is the complete codes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import coloredlogs
from tuyalinksdk.client import TuyaClient
from tuyalinksdk.console_qrcode import qrcode_generate
from time import sleep

GPIO.setmode(GPIO.BCM)
coloredlogs.install(level='DEBUG')

client = TuyaClient(
    productid='44apXXXXXXXXXXX',
     uuid='tuya19dXXXXXXXXXXX',
      authkey='uFjw3VqrrfXXXXXXXXXXXXXX')

TRIG = 2
ECHO = 3
i=0

GPIO.setup(TRIG ,GPIO.OUT)
GPIO.setup(ECHO,GPIO.IN)
GPIO.setup(4 ,GPIO.OUT)

GPIO.output(TRIG, False)
print("Starting.....")
sleep(2)

while True:
   GPIO.output(TRIG, True)
   sleep(0.00001)
   GPIO.output(TRIG, False)

   while GPIO.input(ECHO)==0:
      pulse_start = time.time()

   while GPIO.input(ECHO)==1:
      pulse_stop = time.time()

   pulse_time = pulse_stop - pulse_start
   water_level = pulse_time * 17150
   print(round(water_level, 2))

   time.sleep(1)

   if water_level &amp;lt; 4:
       print("Water will overflow")
       GPIO.output(4, True)
       time.sleep(0.5)
       GPIO.output(4, False)
       time.sleep(0.5)
       GPIO.output(4, True)
       time.sleep(0.5)
       GPIO.output(4, False)
       time.sleep(0.5)
   else:
       GPIO.output(4, False)

def on_connected():
    print('Connected.')

def on_qrcode(url):
    qrcode_generate(url)

def on_reset(data):
    print('Reset:', data)

def on_dps(dps):
    print('DataPoints:', dps)
    dps = {'101':True}
    dps['101'] = data
    client.push_dps(dps)

client.on_connected = on_connected
client.on_qrcode = on_qrcode
client.on_reset = on_reset
client.on_dps = on_dps
client.connect()
client.loop_start()

while True:
    data = water_level
    time.sleep(1)

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

&lt;/div&gt;



&lt;p&gt;You can get the starter codes from Tuya's page in Github and edit the codes by adding Raspberry Pi configuration codes. Run these commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; $ git clone https://github.com/tuya/tuyaos-link-sdk-python.git
 $ cd examples
# view the starter codes here
 $ cat outlet.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reference is &lt;a href="https://pypi.org/project/tuyalinksdk/#tuyaos-link-sdk-for-python" rel="noopener noreferrer"&gt;here&lt;/a&gt; and the codes can be found  &lt;a href="https://dev.togit"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Running the codes at first time will create a connection between your project in Tuya platform and the Tuya mobile application which will enable you to send commands from the application to your Raspberry Pi remotely through the platform. To allow the connection, you'll need to scan the qrcode by using your mobile phone generated once you run the &lt;code&gt;outlets.py&lt;/code&gt;. &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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1640779236637%2FHkqwA_U4E.jpeg" 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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1640779236637%2FHkqwA_U4E.jpeg" alt="WhatsApp Image 2021-12-29 at 14.51.41.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now lets design a monitoring dashboard in the platform which will receive data from our sensor and display visuals and monitoring. Then after, we will connect a smartphone to view this dashboard just like how we view in the platform (in the platform, a web based)&lt;/p&gt;

&lt;h3&gt;
  
  
  Monitoring dashboard
&lt;/h3&gt;

&lt;p&gt;In the platform, navigate to &lt;strong&gt;Product&lt;/strong&gt; &amp;gt; &lt;strong&gt;Development&lt;/strong&gt;, it will open the product we've just created in the above steps. Open up that Product (aka, the project) and you'll see something like this:&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1639800632724%2FKsTdmxDBq.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1639800632724%2FKsTdmxDBq.png" alt="001.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open the &lt;strong&gt;Device Panel&lt;/strong&gt; and select a blank screen where it will open up a new page for designing the mobile view screen for your dashboard. Make the UI design of your choice, this is what i came up with:&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1639802552711%2FxZBzsPTba.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1639802552711%2FxZBzsPTba.png" alt="002.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you're done with the design, &lt;strong&gt;Preview&lt;/strong&gt; to check if its okay then &lt;strong&gt;Save As&lt;/strong&gt; and finally &lt;strong&gt;Release&lt;/strong&gt; your design. Up to this point, the dashboard is ready. We can visualize this design from the smartphone by using &lt;a href="https://play.google.com/store/apps/details?id=com.tuya.smart&amp;amp;hl=en&amp;amp;gl=US" rel="noopener noreferrer"&gt;Tuya Smart App&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Up to this point, the project is ready for testing and using. You can monitor the water level of your tank remotely from your device (phone for example).&lt;/p&gt;

&lt;h2&gt;
  
  
  Output
&lt;/h2&gt;

&lt;p&gt;If you follow along up to this point, you should be able to send values directly from your phone remotely to the platform.&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1640837937509%2FJLmTAV3ee.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1640837937509%2FJLmTAV3ee.png" alt="device.png"&gt;&lt;/a&gt;&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1640837950212%2FG5-dTuA7a.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1640837950212%2FG5-dTuA7a.png" alt="dps.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=oxfzzZoUqGk" rel="noopener noreferrer"&gt;Video demo&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/tuya/tuyaos-link-sdk-python" rel="noopener noreferrer"&gt;Project examples from Tuya&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/maen08/tuya-linksdk-with-raspberry-pi" rel="noopener noreferrer"&gt;Source codes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.tuya.com/blog" rel="noopener noreferrer"&gt;Tuya blog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tuya/" rel="noopener noreferrer"&gt;Tuya github page&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>raspberrypi</category>
      <category>iot</category>
      <category>monitoring</category>
    </item>
    <item>
      <title>Contribute like a Pro. Git-branching model (Part 2)</title>
      <dc:creator>Ruheza, NS</dc:creator>
      <pubDate>Sun, 28 Nov 2021 18:36:30 +0000</pubDate>
      <link>https://dev.to/maen/contribute-like-a-progit-branching-model-part-2-4k75</link>
      <guid>https://dev.to/maen/contribute-like-a-progit-branching-model-part-2-4k75</guid>
      <description>&lt;p&gt;&lt;strong&gt;Refresh&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;From &lt;a href="https://maenblog.tech/contribute-like-a-pro"&gt;Part 1&lt;/a&gt; of this article, we discussed about &lt;code&gt;--no-ff&lt;/code&gt; flag when merging. It helps to keep track of log messages of events happened in your sub-branch (feature branch) and you can easily roll back. Now lets look something else...&lt;/p&gt;

&lt;h2&gt;
  
  
  Releasing process
&lt;/h2&gt;

&lt;p&gt;Like the feature branch, it is a separate branch but created as sub-branch of &lt;code&gt;develop&lt;/code&gt; branch. It is a branch which contains all necessary environment, support and features for production of your application. It's the branch you need only during production process. Two main things can be found in this branch:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Meta-data(version number - tags, build dates)&lt;/li&gt;
&lt;li&gt;Minor bug fixes&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Create a release branch
&lt;/h2&gt;

&lt;p&gt;When do you create a &lt;code&gt;release&lt;/code&gt; branch? You should only create a release branch when all targeted features are fully developed and merged back to &lt;code&gt;develop&lt;/code&gt; branch ready for release. &lt;strong&gt;Divide and Conquer mindset&lt;/strong&gt; is very important when dealing with your software. I advise you to build your software in &lt;strong&gt;feature-wise&lt;/strong&gt;  that is, you release one feature after another until the entire software is complete. If you're building alone, you &lt;strong&gt;should not&lt;/strong&gt; start building another feature before releasing a current feature. Divide and Conquer mindset will save your time and energy too.&lt;/p&gt;

&lt;p&gt;For example, say version 0.2 is a current production release (in develop branch) and we have a new release coming up called version 0.3. We will branch off from the current state in develop branch and create a new sub-branch of the develop branch called &lt;code&gt;release-0.3&lt;/code&gt;. It's name will point to the coming release, shifting from version 0.2 to 0.3, a new release! This is how you'll do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Create a release branch
$ git checkout -b release-0.3 develop

#Bump the version from 0.2 to 0.3
$ ./bump-version.sh 0.3

#Make a commit
$ git commit -m "Bump v0.2 to v0.3"

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

&lt;/div&gt;



&lt;p&gt;Note that  &lt;code&gt;bump-version.sh&lt;/code&gt; is just a custom bash script you'll write to change version of your software (you can also use &lt;a href="https://docs.github.com/en/actions/learn-github-actions"&gt;git actions&lt;/a&gt; or CI tools) &lt;/p&gt;

&lt;p&gt;You can fix some minor bugs in this branch rather than doing it on the &lt;code&gt;develop&lt;/code&gt; branch. But it is not advised to add large new features here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Release a release branch
&lt;/h2&gt;

&lt;p&gt;Now the software is ready for production. Our sweet feature in a &lt;code&gt;release&lt;/code&gt; branch should be merged into the &lt;code&gt;master&lt;/code&gt;. Remember in &lt;a href="https://maenblog.tech/contribute-like-a-pro"&gt;Part 1&lt;/a&gt;, &lt;code&gt;master&lt;/code&gt; branch will always contain "clean codes" with no bugs at this point in time. After merging our branch, we should &lt;code&gt;tag&lt;/code&gt; it, just to mark the branch with a summary of what we've done for the future reference. And finally, updating the develop branch. In summary:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Merge the release branch into master branch.&lt;/li&gt;
&lt;li&gt;Tagging the branch for future reference.&lt;/li&gt;
&lt;li&gt;Update &lt;code&gt;develop&lt;/code&gt; branch with clean codes so that the future development also contain the bug fixes.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Into master branch
$ git checkout master

#Merge the release into master 
$ git merge --no-ff release-0.3

#Tag it
$ git tag -a 0.3

#Into develop branch
$ git checkout develop

$ git merge --no-ff release-0.3

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  What about hotfix branch?
&lt;/h2&gt;

&lt;p&gt;As the name suggests, this is the branch which you'll create for the purpose of fixing bugs that maybe found (or arise) in a &lt;code&gt;master&lt;/code&gt; branch. But we said, master branch must contain "clean codes" right? So why bugs in a master branch?  Well, the answer is - software becomes real when reach to a user. That's when you realize the bugs - Uncaught fish :) Here's the snippet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Create a hotfix branch 
$ git checkout -b hotfix-0.3 master

#Fix the bugs and commit
$ ./hotfix-version.sh 0.3
$ git commit -m "Fixed bugs in production"

#Update the master branch
$ git checkout master
$ git merge --no-ff hotfix-0.3

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

&lt;/div&gt;



&lt;p&gt;You can also update the &lt;code&gt;develop&lt;/code&gt; branch with this fix just to contain the same clean codebase. After the fix, it's your choice to delete the branch or leave it for your reference. Up to this point, your codebase should be stunning with &lt;strong&gt;zero conflict !&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Congratulations, you're Git ninja now!&lt;/p&gt;

&lt;p&gt;Written from &lt;a href="https://maenblog.tech"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>agile</category>
      <category>opensource</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Contribute like a Pro. A guide for git-branching model (Part 1)</title>
      <dc:creator>Ruheza, NS</dc:creator>
      <pubDate>Sun, 21 Nov 2021 11:52:50 +0000</pubDate>
      <link>https://dev.to/maen/contribute-like-a-proa-guide-for-git-branching-model-part-1-4kff</link>
      <guid>https://dev.to/maen/contribute-like-a-proa-guide-for-git-branching-model-part-1-4kff</guid>
      <description>&lt;p&gt;Building a software in a team requires a clear understanding and proper management of the codebase. If the team members &lt;strong&gt;only&lt;/strong&gt; know the "pull-push",  you'll soon find yourself in the trap of resolving merge conflicts! &lt;/p&gt;

&lt;p&gt;Developing while shipping the software may become tricky if the team is not familiar with version control. Git-flow plays a great role in agile development. I insist you to read every single word in this article, don't skim. Let's start exploring git-branching model.&lt;/p&gt;

&lt;h3&gt;
  
  
  Git-branching model
&lt;/h3&gt;

&lt;p&gt;Implementing the git-flow, your repo should contain two main branches:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;master (or main)&lt;/li&gt;
&lt;li&gt;develop&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Master branch is the main branch which is automatically created once you initialize a repo in a git. It is the origin of the repo and pre-exist. You'll find it written &lt;code&gt;origin/master&lt;/code&gt;.  This is the branch which must contain "clean codes", the codebase which is ready for deployment. You &lt;strong&gt;should not&lt;/strong&gt; contribute or push codes direct to this repo! I'll tell you where to push your codes.&lt;/p&gt;

&lt;p&gt;Develop branch is the branch which you should create. I advice you, to do this even if you're building alone. This is a branch which contains &lt;strong&gt;active codebase&lt;/strong&gt;, the project at development state. Whether the feature is working or buggy, this is the right place for it. This is how you start:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Create a develop branch and switch it on
$ git checkout -b develop
# Pull the codebase from master branch into your current branch(develop)
$ git pull origin master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Other branches
&lt;/h3&gt;

&lt;p&gt;Apart from the main two branches, there are three other branches. All these branches should be created within &lt;code&gt;develop&lt;/code&gt; branch. These branches are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Features branch&lt;/li&gt;
&lt;li&gt;Hotfix branch &lt;/li&gt;
&lt;li&gt;Release branch&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is how you create them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Created as a sub-branch of develop branch (replace feature-backup with a branch name)
$ git checkout -b feature-backup develop
# Or a hotfix branch
$ git checkout -b hotfix-443 develop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Naming convention and merging
&lt;/h3&gt;

&lt;p&gt;Naming these branches follows the standard way. Such as &lt;code&gt;feature-*&lt;/code&gt;,&lt;code&gt;hotfix-*&lt;/code&gt; and &lt;code&gt;release-*&lt;/code&gt;. So for example; &lt;code&gt;feature-login&lt;/code&gt;, or &lt;code&gt;release-1.0.1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After all your implementation in the feature branch (or any other branch apart from main branches) you should merge it back to &lt;code&gt;develop&lt;/code&gt; branch then later to &lt;code&gt;master&lt;/code&gt; branch (during production). This is how you do it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Switch to develop branch
$ git checkout develop
# Merge the feature branch
$ git merge --no-ff feature-backup
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Merging with flag &lt;code&gt;--no-ff&lt;/code&gt; creates a new commit record. This helps to store historical information of the feature branch &lt;strong&gt;even after the merge&lt;/strong&gt;. Thus, makes it easy to roll back in a particular feature just from the develop branch (even after merging).&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1637488117745%2FC6CIU48eL.jpeg" 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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1637488117745%2FC6CIU48eL.jpeg" alt="git-merge(2).jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Don't miss the next part of this article.&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

&lt;p&gt;Originally, posted &lt;a href="https://maenblog.tech" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>opensource</category>
      <category>agile</category>
      <category>github</category>
    </item>
    <item>
      <title>How to start as an Open Source Developer (Beginner level)</title>
      <dc:creator>Ruheza, NS</dc:creator>
      <pubDate>Thu, 11 Nov 2021 13:41:45 +0000</pubDate>
      <link>https://dev.to/maen/how-to-start-as-an-open-source-developer-beginner-level-pmh</link>
      <guid>https://dev.to/maen/how-to-start-as-an-open-source-developer-beginner-level-pmh</guid>
      <description>&lt;h2&gt;
  
  
  What's an open source project ?
&lt;/h2&gt;

&lt;p&gt;The tech world is moving according to the economic shift. There’s no company or startup which is ready to risk a lot of funds for the software project while there’s an alternative for that. What a company needs is to get a service up and running regardless if the software was built from scratch or as an open source project.&lt;/p&gt;

&lt;p&gt;At an individual level, open source saves time and money too. By the way, what reward do you get after building your project from scratch ? Why build something which already exists and you can get it for free ? Would love to hear your thoughts :)&lt;/p&gt;

&lt;p&gt;But what is an open source project ? It is a software project which is publicly free for anyone. That is, you can edit the source codes, change it to how you want. You can build your “big idea project” just on top of open source software. You can also release your sweet project to the community as an open source by allowing other developers to manipulate your codes. Sounds caring, right ?&lt;/p&gt;

&lt;h2&gt;
  
  
  Jump into open source project as a beginner
&lt;/h2&gt;

&lt;p&gt;Step into open source projects as a newbie might be a challenge at first, however getting the right foot to start with can solve overheads. There are things you should know before starting contributing or building your application on top of an open source project.&lt;/p&gt;

&lt;h4&gt;
  
  
  Here’s the list of things you should consider first:
&lt;/h4&gt;

&lt;h5&gt;
  
  
  Able to use Git and Github comfortably.
&lt;/h5&gt;

&lt;p&gt;You’ll always find these projects in version control (VC) like Github. To access them and alter the change, all need a knowledge of the git. You need to know how to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clone a project from Github (or any other VC)&lt;/li&gt;
&lt;li&gt;Branching models (master, develop, feature)&lt;/li&gt;
&lt;li&gt;Push the project&lt;/li&gt;
&lt;li&gt;Raise and resolve issue&lt;/li&gt;
&lt;li&gt;Write good commit&lt;/li&gt;
&lt;li&gt;Tag and versioning the project.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can learn the basics from Github documentation but I also wrote deeply about Git and branching models in my article titled &lt;a href="https://dev.to/maen/contribute-like-a-proa-guide-for-git-branching-model-part-1-4kff"&gt;Contribute as a pro&lt;/a&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  Learn how to write a good “README”.
&lt;/h5&gt;

&lt;p&gt;A README in a Github serves as a brief documentation of a particular project. Writing a precise document about the project helps another developer to jump straight into the project and manipulate on whatever he wishes.&lt;/p&gt;

&lt;p&gt;On another hand, learning how to document your own project will help you to easily read and follow along with the docs. of other projects. While writing, there are a number of online tools to heavy-lift the job. I normally use dillinger to write the README before shipping it into Github. It has some placeholders which you can just change to fit your headings and contents. It supports markdown language as that used in Github.&lt;/p&gt;

&lt;h5&gt;
  
  
  Learn how to write clean codes.
&lt;/h5&gt;

&lt;p&gt;By "clean codes" I mean the codes which are precise and easy to read. Don't just focus on the working codes, but the codes that another developer can read them and scale the project. Write the code while thinking about another person who'll come to read them. &lt;/p&gt;

&lt;h4&gt;
  
  
  Here are the tips for writing clean codes:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Master the domain language of a given project. That is, if the software is about Health, then the naming convention and your variables will all align to the health context.&lt;/li&gt;
&lt;li&gt;Clear naming convention. Be very clean in naming the variables, methods and classes. Don't let your code become unequivocal just for laziness reasons.&lt;/li&gt;
&lt;li&gt;Use comments only where required.&lt;/li&gt;
&lt;li&gt;Obey DRY principle. Only define once and just reuse it where needed. Don't Repeat Yourself !&lt;/li&gt;
&lt;li&gt;Well structured file tree. Your files should be in an organized manner. Don't just write the codes anywhere! Also, specify your main file (entry-point file). This will help another contributor to easily know where your software starts.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  What's next ?
&lt;/h4&gt;

&lt;p&gt;If you're comfortable with the tips above then it's a right time for you to try out doing something handy.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pick one open source project of your choice. I'll write on sample open source projects for beginner.&lt;/li&gt;
&lt;li&gt;Read the project codes and documentation&lt;/li&gt;
&lt;li&gt;Contribute. I will upload soon the article on how to &lt;a href="https://dev.to/maen/contribute-like-a-proa-guide-for-git-branching-model-part-1-4kff"&gt;contribute as a pro&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Or build your software on top of it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks for reading this!&lt;/p&gt;

&lt;p&gt;(It's my first article) &lt;/p&gt;

&lt;p&gt;Written from &lt;a href="https://maenblog.tech"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
