<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://abmussani.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://abmussani.com/" rel="alternate" type="text/html" /><updated>2024-09-26T04:58:08+00:00</updated><id>https://abmussani.com/feed.xml</id><title type="html">Abdul Basit</title><subtitle>I hate semicolons</subtitle><author><name>Abdul Basit</name></author><entry><title type="html">How to be a good leader</title><link href="https://abmussani.com/leadership/how-to-be-a-good-leader.html" rel="alternate" type="text/html" title="How to be a good leader" /><published>2022-11-20T19:00:00+00:00</published><updated>2022-11-20T19:00:00+00:00</updated><id>https://abmussani.com/leadership/how-to-be-a-good-leader</id><content type="html" xml:base="https://abmussani.com/leadership/how-to-be-a-good-leader.html"><![CDATA[<p>Since 2017, I have been acting as a Line Manager. Most of my managees and other fellow colleagues, ask me this question, “How to be a good leader”. This time I planned to gather all points here for future refrences. There could be many more but these are the one I am practising in projects since 2014.</p>

<ul>
  <li>
    <p>A great leader isn’t one who holds a candle up for others, but helps them light their candles instead.</p>
  </li>
  <li>
    <p>Be decisive: realize that sometimes it’s not that the best decision is made but that a decision is made timely.</p>
  </li>
  <li>
    <p>Positive reinforcement, notice and recognize achievements and improvements, no matter how small, people work harder for people that notice their successes and work just enough for people who only notice their failures.</p>
  </li>
  <li>
    <p>Be the worker you want others to be, lead by example. Volunteer yourself to do projects.</p>
  </li>
  <li>
    <p><strong>IMPORTANT</strong>: Don’t fear being wrong, say you were and move on. Don’t let people think that you shift blame to others or are incapable of recognizing your own failures.</p>
  </li>
  <li>
    <p>Be honest to those below you (in terms of feedback) and open about the reasons behind your decisions, you have to admit your mistakes as well..</p>
  </li>
  <li>
    <p>Be a buffer for them, from your boss.</p>
  </li>
  <li>
    <p>It’s about getting your team to work together, not about goals and targets. (Though you should have them.) Make time to listen to them.</p>
  </li>
  <li>
    <p>Ask for help &amp; advice, hopefully you’re not the only one. If you are having trouble reach out, people will respect you for it, do not think less of you, you may inspire them to do the same.</p>
  </li>
  <li>
    <p>Be accountable to those below you.</p>
  </li>
  <li>
    <p>Be human. Your team will feel more comfortable asking for help and letting you know when things go wrong.</p>
  </li>
  <li>
    <p>Empathy is a good leadership quality</p>
  </li>
</ul>]]></content><author><name>Abdul Basit</name></author><category term="leadership" /><summary type="html"><![CDATA[Few points about good Leader, from different sources and experience]]></summary></entry><entry><title type="html">Setup Mosquitto Broker via Docker compose</title><link href="https://abmussani.com/tech/dockerization-of-moquitto.html" rel="alternate" type="text/html" title="Setup Mosquitto Broker via Docker compose" /><published>2022-09-01T19:00:00+00:00</published><updated>2022-09-01T19:00:00+00:00</updated><id>https://abmussani.com/tech/dockerization-of-moquitto</id><content type="html" xml:base="https://abmussani.com/tech/dockerization-of-moquitto.html"><![CDATA[<p>One of my office collegue got an assignment to setup <strong>Mosquitto</strong> in test environment. He was not aware of Mosquitto and how to setup, asked me to help him. After doing some research, I figured out, Mosquitto can be setup using <strong> DOCKER </strong> containers</p>

<p>Before diving in deep, You should know what is Mosquitto:</p>

<blockquote>Eclipse Mosquitto is an open source message broker that implements the MQTT protocol. The MQTT protocol provides a lightweight method of carrying out messaging using a publish/subscribe model. This makes it suitable for Internet of Things messaging such as with low power sensors or mobile devices such as phones, embedded computers or microcontrollers -- <a href="https://en.wikipedia.org/wiki/Modulo_operation">Wikipedia</a></blockquote>

<p>Following is the <strong>docker-compose.yml</strong> I used to setup Mosquitto:</p>

<pre class="EnlighterJSRAW" data-enlighter-language="docker">
version: "3"
services:
    mosquitto:
        container_name: mqtt
        image: eclipse-mosquitto
        ports:
            - 1883:1883
        volumes:
            - "./mosquitto/config/broker.conf:/mosquitto/config/mosquitto.conf"
            - "./mosquitto/config/password.passwd:/mosquitto/config/mosquitto.passwd"
            - "./mosquitto/data:/mosquitto/data"
        networks:
            - app-network
networks:
    app-network:
        driver: bridge
}</pre>

<p><strong>Here is some explanation:</strong></p>

<p>I gave my container a user-friendly name : “mqtt” so that I can access it and run some commands</p>
<pre class="EnlighterJSRAW" data-enlighter-language="docker">
container_name: mqtt
</pre>

<p>“eclipse-mosquitto” is the official image mentioned on their website. I used the latest image, thats why did not mentioned any version.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="docker">
image: eclipse-mosquitto
</pre>

<p>“1883” is default port used by Mosquitto to enqueue/dequeue messages in broker. Since we are running in container, We need to also expose the port to host machine.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="docker">
ports:
    - 1883:1883
</pre>

<p>Three directories, I used as volume to preconfigure the setup.</p>

<pre class="EnlighterJSRAW" data-enlighter-language="docker">
volumes:
    - "./mosquitto/config/broker.conf:/mosquitto/config/mosquitto.conf"
    - "./mosquitto/config/password.passwd:/mosquitto/config/mosquitto.passwd"
    - "./mosquitto/data:/mosquitto/data"
</pre>

<ul>
    <li>To pass the configuration file</li>
    <li>To pass the list of users with their credentials.</li>
    <li>Since containers are volatile, Everything will be lost if container restarted. To make data persist, I mounted directory to keep the data on host machine.</li>
</ul>

<p><strong>Configuration file:</strong></p>

<pre class="EnlighterJSRAW" data-enlighter-language="conf">
listener 1883
password_file /mosquitto/config/mosquitto.passwd
allow_anonymous false

persistence true
persistence_location /mosquitto/data
autosave_interval 10s
max_queued_messages 100</pre>

<p><strong>Dockerization</strong></p>

<p>To up the container, you can run following command in command line or terminal:</p>
<pre>docker-compose up -d</pre>

<p>To start interactive session, run following command:</p>
<pre>docker exec -it mqtt /bin/sh</pre>

<p><u>Note:</u> Image does not support “bash” alias</p>

<p><strong>Security measurement:</strong></p>

<p>I disabled anonymous usage in configuration file by changing <strong>allow_anonymous</strong> to false and provided the location of password file by <strong>password_file</strong>.</p>

<p>After starting the container, You need to add a user with password so that pub/sub can connect with your broker. Since, directory was mounted added user will presist even after restarting the container. Use</p>
<pre>mosquitto_passwd -c password username</pre>
<p>to store passwords in file. For example, command</p>
<pre>mosquitto_passwd -c golang golang</pre>
<p>will write following content in password file.</p>

<pre class="EnlighterJSRAW" data-enlighter-language="conf">
golang:$7$101$ccJ/dnmr0jLqzO6B$V4Y36vs2XlMFRsCe7zyLJdDeL1s++YSCm7ZbR1cVCA592o0td3hZrQ91J5w0cFSiM/3oBHnnT9gUO5xYSSheMQ==
</pre>

<p><strong>End to End connectivity:</strong></p>

<p>Installation of Mosquitto comes with some utilities to check end to end connectivity. These utilities will be accessable after starting up the docker container successfully.</p>

<p><u>Mosquitto Producer:</u>
This utility helps to enqueue messages in plain text. After opening the interactive bash session in mqtt container, You can run following command to enqueue the message:</p>

<pre>mosquitto_pub -h localhost -p 1883 -u golang -P golang -t my-mqtt-topic -m "Test Message"</pre>

<p><u>Mosquitto Subscriber:</u>
This utility helps to dequeue messages in plain text. After opening the interactive bash session in mqtt container, You can run following command to dequeue the message:</p>

<pre>mosquitto_sub -h localhost -p 1883 -u golang -P golang -t my-mqtt-topic</pre>

<p>Note: Make sure that credentials you set through password utility are correct.</p>

<p><strong>Conclusion:</strong>
I hope this post gave you a useful overview of getting an MQTT Mosquitto Broker up and running using Docker.</p>]]></content><author><name>Abdul Basit</name></author><category term="tech" /><summary type="html"><![CDATA[Setup and run eclipse mosquitto broker in a docker container]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://abmussani.com/mosquitto-syste-diagram.jpg" /><media:content medium="image" url="https://abmussani.com/mosquitto-syste-diagram.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">It’s all yours</title><link href="https://abmussani.com/jekyll/update/Its-all-yours.html" rel="alternate" type="text/html" title="It’s all yours" /><published>2018-07-19T15:25:15+00:00</published><updated>2018-07-19T15:25:15+00:00</updated><id>https://abmussani.com/jekyll/update/Its-all-yours</id><content type="html" xml:base="https://abmussani.com/jekyll/update/Its-all-yours.html"><![CDATA[<p>One day Buddha was visiting a tiny village.</p>
<p>He had become a religious man, also called a Brahman, and was traveling from town to town to share his message. He was becoming so popular that when people heard the Buddha was coming they went to hear him speak. As a result many other Brahmans lost their audience.</p>
<p>One Brahman was so upset with the Buddha that he found him and went to see him late at night. He was furious! “You have no right teaching others,” he shouted. “You are as stupid as everyone else. You are nothing but a fake!” Buddha smiled at the Brahman and listened until he was done with his rant. When the Brahman was done, Buddha still sat, smiling at him. This made the Brahman even angrier. “Why are you just sitting there smiling? What do you have to say?”</p>
<p>Then Buddha spoke. “Tell me something, Brahman: Do friends and colleagues, relatives and kinsmen, ever come to your house as guests?” “Yes,” the Brahman answered. “And tell me something, Brahman,” Buddha continued. “Do you serve them foods and delicacies when they arrive?” “Yes,” the Brahman answered, “I do.”</p>
<p>“And tell me something, Brahman,” Buddha continued. “If they don’t accept them, to whom do those foods belong?” “Well, I suppose if they don’t accept them, those foods are all mine.” “Yes,” said Buddha. “In the same way, Brahman, I do not accept your anger and your criticism. It is all yours.” The Brahman was stunned and could think of nothing to say. His anger continued to bubble up inside him, but he had nowhere to put it. Nobody was accepting it or taking it from him. Buddha continued: “That with which you have insulted me, who is not insulting, that with which you have taunted me, who is not taunting, that with which you have berated me, who is not berating, that I don’t accept from you. It’s all yours, Brahman. It’s all yours.</p>
<p>“If you become angry with me and I do not get insulted, then the anger falls back on you. You are then the only one who becomes unhappy. All you have done is hurt yourself. If you want to stop hurting yourself, you must get rid of your anger and become loving instead. “Whoever returns insult to one who is insulting, returns taunts to one who is taunting, returns a berating to one who is berating, is eating together, sharing company, with that person. But I am neither eating together nor sharing your company, Brahman. It’s all yours. It’s all yours.”</p>
<h4>Reference:</h4>
<p><em>Pasricha, Neil. The Happiness Equation: Want Nothing + Do Anything = Have Everything (p. 61). Penguin Publishing Group.</em></p>]]></content><author><name>Abdul Basit</name></author><category term="jekyll" /><category term="update" /><summary type="html"><![CDATA[This is my awesome writeup of this fantastic thing]]></summary></entry><entry><title type="html">How to avoid Modulo Operators</title><link href="https://abmussani.com/jekyll/update/Modulo-Operators.html" rel="alternate" type="text/html" title="How to avoid Modulo Operators" /><published>2018-04-15T15:25:15+00:00</published><updated>2018-04-15T15:25:15+00:00</updated><id>https://abmussani.com/jekyll/update/Modulo-Operators</id><content type="html" xml:base="https://abmussani.com/jekyll/update/Modulo-Operators.html"><![CDATA[<p>Mostly programmers are aware of modulo (%) and integer div (/) operators regardless of language they used. They are least used arithmetic operator in most programming languages. Modern off-the-shelf processors have built in instructions to perform such operations.</p>

<p><strong>What is Modulo Operator:</strong></p>
<blockquote>In computing, the <b>modulo</b> operation finds the remainder after division of one number (<em>dividend</em>) by another (<em>divisor) -- <a href="https://en.wikipedia.org/wiki/Modulo_operation">Wikipedia</a></em></blockquote>
<p>One common use case for this operator is to check if a number is even or odd. If remainder of a number is Zero when 2 divide it then it is an Even number else it is Odd.</p>

<pre class="lang:c++ decode:true ">0 % 2 = 0
1 % 2 = 1
2 % 2 = 0
3 % 2 = 1
4 % 2 = 0
5 % 2 = 1</pre>

<p>The result of modulo operator can never be greater than divisor, it will always be one lesser then second number. The reason this happens is because division is all about fair sharing.</p>

<p><strong>How to avoid Modulo operator:</strong></p>

<p>I modern architecture, Division operator may take several clock cycles to perform its operation. Modulo operators can be easily translated into <em>Bitwise operators</em>. If a divisor is <em>power of 2</em> then it can be replaced by bitwise <em>AND</em> operator. It will take only one CPU cycle. for example:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="cpp">int remainder = value % 1024;</pre>
<p>it can be translated into:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="cpp">int remainder = value &amp; 0x3FF;
int remainder = value &amp; (1024-1);</pre>
<p>in general, If divisor n is power of 2, the modulo operators can be translated into bitwise AND with <em>divisor - 1</em>.</p>

<p><strong>What is the real impact of modulo operator:</strong></p>

<p>Marco Ziccardi wrote a program to answer this question:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="cpp">int main(int argc, char** argv) { 
    int remainder;
    int value = 1301081;
    int divisor = 1024;
    int i = 0;
    while (i &lt; 10000000) {
        remainder = value % divisor;
        i++;
    }
}</pre>
<p>And compared its execution times with the same program implemented using binary AND (&amp;) operator. Results are shown below (1000 runs of the program for both % and &amp; versions):</p>

<p><img class="size-medium aligncenter" src="http://mziccard.me/public/images/MODvsANDresults.png" width="842" height="418" /></p>

<p>As you can see, in the average case the program with the modulo operation is 62% slower than the one using &amp;  operator.</p>

<p><strong>Conclusion:</strong></p>

<p>It is not always possible to avoid modulo operator in the favor of bitwise.</p>]]></content><author><name>Abdul Basit</name></author><category term="jekyll" /><category term="update" /><summary type="html"><![CDATA[Mostly programmers are aware of modulo (%) and integer div (/) operators regardless of language they used. They are least used arithmetic operator in most programming languages. Modern off-the-shelf processors have built in instructions to perform such operations.]]></summary></entry><entry><title type="html">Bulleya Ki jaana main Kaun</title><link href="https://abmussani.com/poetry/Bulleya.html" rel="alternate" type="text/html" title="Bulleya Ki jaana main Kaun" /><published>2018-01-01T15:25:15+00:00</published><updated>2018-01-01T15:25:15+00:00</updated><id>https://abmussani.com/poetry/Bulleya</id><content type="html" xml:base="https://abmussani.com/poetry/Bulleya.html"><![CDATA[<p><strong>Na main momin vich maseetaan</strong>
<strong>Na main vich kufar diyan reetaan</strong>
<strong>Na main paakaan vich paleetaan</strong>
<strong>Na main moosa na firown</strong></p>

<p>Not a believer inside the mosque, am I
Nor a pagan disciple of false rites
Not the pure amongst the impure
Neither Moses, nor the Pharoh</p>

<p><strong>Bulleya Ki jaana main Kaun</strong>
Bulleya! to me, I am not known</p>

<p><strong>Na main andar ved kitaabaan</strong>
<strong>Na vich bhangaan na sharaabaan</strong>
<strong>Na vich rindaan masat kharaabaan</strong>
<strong>Na vich jaagan na vich saun</strong></p>

<p>Not in the holy Vedas, am I
Nor in opium, neither in wine
Not in the drunkard’s intoxicated craze
Neither awake, nor in a sleeping daze</p>

<p><strong>Bulleya Ki jaana main Kaun</strong>
Bulleya! to me, I am not known</p>]]></content><author><name>Abdul Basit</name></author><category term="poetry" /><summary type="html"><![CDATA[Bulleya Ki jaana main Kaun]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://abmussani.com/DSC_0018.jpg" /><media:content medium="image" url="https://abmussani.com/DSC_0018.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry></feed>