I think ...https://blog.kmonsoor.com/2024-01-22T00:00:00+06:00সহজ বাংলায় Scalability এর একটা উদাহরণ2024-01-22T00:00:00+06:002024-01-22T00:00:00+06:00Khaled Monsoortag:blog.kmonsoor.com,2024-01-22:/sohoz-banglay-scalability-example-1-bn/<p>আপনার কোম্পানি যে ইমেইল পাঠাচ্ছে, সেটা কি&nbsp;scalable?</p><p>সিঙ্গাপুরের Grab এ থাকতে আমার একবার বস ছিল অরুণ নামের এক&nbsp;ইন্ডিয়ান।</p> <p>জয়েনের কিছুদিন পরে, বসের কাছে কমপ্লেন গেলো যে খালেদ এই কাজ টা এমনে করে না, অমনে করে। বস আমাকে উইকলি মিটিং এ জিজ্ঞেস করলো, অমনে করো কেনো? আমি বললাম, এই এই কারণে অমনে করি। সে আমাকে এক কথায় উত্তর দিলো যেটা আমার কানে এখনও বাজে। সে বলছিল, &ldquo;তোমার উদ্দেশ্যটা ভালো, কিন্তু এটা scalable না&rdquo;। বেশি ব্যাখ্যা করা লাগে নাই, কারণ হোল আমরা দুজনেই জানতাম যে আমার ২৫+ টা টীমের সাথে কাজ করা লাগে, আমি যেভাবে আগাচ্ছিলাম, সেভাবে পাঁচ সাতটা টীমের সাথে হয়তো কাজ ম্যানেজ করা যেতো, কিন্তু ২৫ টা&nbsp;না।</p> <p>আমাদের দেশের আইটি সেক্টরের বিভিন্ন উদ্যোগেও আমি এই ব্যপারটা খেয়াল করি খুব বেশি রকম, &ldquo;উদ্দেশ্যটা ভালো, কিন্তু scalable না&rdquo; কি দেখে হঠাত এই কথা মনে আসলো সেইটা&nbsp;বলি।</p> <p>ব্র্যাক ব্যাংক একটা মেইল পাঠিয়েছে, সিস্টেম মেইনটেনেন্সে সার্ভিস কিছুক্ষণ বন্ধ থাকবে এইটা হোল বিষয়। ইমেইলে বডিতে কোন টেক্সট নাই, খালি একটা ইমেজ। ভালো কথা। টেক্সট অনেকে পড়তে চায় না, ইমেজ দিলে খেয়াল করে পরবে। অনেকের মোবাইলে বাংলা ঠিকমতো দেখায় না, সেটাও একটা বিষয়। তো &ldquo;উদ্দেশ্যটা ভালো&rdquo;। কিন্তু সাধারণ এই ইমেজ এর সাইজ ৩ মেগাবাইট (ধরেন, ৩০০০ কিলোবাইট), যেই ইমেজটা ৫০ কিলোবাইট হলেও একই লেখা প্রায় একই রকম দেখা যেতো। পার্থক্যটা খালি চোখে ধরা কঠিন। মানে প্রয়োজনের তুলনায় ৬০ গুন বড়। এখন আসেন scalability বিবেচনা করি&nbsp;। </p> <p>ব্র্যাক ব্যাংক এর কাস্টমারের সংখ্যা যদি হয় ৫ লক্ষ, এই একটা মেইল পাঠাতে ব্যাংকের মেইল সার্ভার (edm. bracbank .com) থেকে &ldquo;Data Out&rdquo; ট্রাফিক জেনারেট হয়েছে (৩ মেগাবাইট x ৫,০০,০০০) = ১৫০০ গিগাবাইট। আর ইমেজটার সাইজ যদি হতো ৫০ কিলোবাইট, এই একই কাজটা হয়ে যেতো ২৬ গিগাবাইট মতো ডাটা ট্রাফিকে, মানে ৬০ ভাগের এক ভাগ, আর পুরো ব্যাচ ইমেইল পাঠানো শেষ হতো ৬০ গুন&nbsp;দ্রুত।</p> <p>এখন বলতে পারেন, ব্যাংকের টাকা আছে খরচ করুক। সেটা এক কথা, কিন্তু আরেকটা সাইড&nbsp;ভাবেন।</p> <p>বাংলাদেশের বেশির ভাগ মানুষ ইন্টারনেট চালায় মোবাইলে। অর্থাৎ, এই গুরুত্বপূর্ণ ইমেইল টা দেখতে যে ৩ মেগাবাইট বাড়তি খরচটা হোল, ধরেন ১০০০ গিগাবাইট, এর বড় একটা অংশ গেলো মোবাইল কোম্পানিগুলার পকেটে। আবার, বাংলাদেশের বেশির ভাগ জায়গাতে ইন্টারনেটের যে অবস্থা, এই মেইল লোড হতে সময় নিবে ১০ সেকেন্ড, যেটা কিনা এক সেকেন্ডএর ও কম সময়ে করা&nbsp;যেতো।</p> <p>এবার ধরেন, ইমেজটার সাইজ হোল ১০ মেগাবাইট, ৩ মেগাবাইটের বদলে। কি সমস্যা? &ldquo;scalable না&rdquo;, এই&nbsp;আরকি।</p>Growth requires discomfort2023-04-12T00:00:00+06:002023-04-12T00:00:00+06:00Khaled Monsoortag:blog.kmonsoor.com,2023-04-12:/growth-requires-discomfort/<p>Growth requires discomfort. Do you have what it takes to go through&nbsp;it?</p><p>Growth almost always lies in the discomfort.<br> The more tolerance someone has being uncomfortable, the more they got the potential to&nbsp;grow. </p> <p>That also means, unfortunately, if you&rsquo;re comfortable in your current situation, you&rsquo;re stagnant; not growing. As change is the only constant in life, the above means, in actuality you&rsquo;re in&nbsp;decline. </p> <p>Resting, uninvested money get devalued with inflation. Resting gold gets targeted by miscreants.<br> Body decides to reduce unused muscles (mass, strength) and bones (density) and start accumulating fat instead.<br> Not-growing relationships get stale. Dead bedroom, barely held together by the responsibility of kids.<br> Skills get rusty very quickly. Stop speaking your mother tongue for a year and you&rsquo;ll be hardly able to speak&nbsp;later. </p> <p>Keep investing, diversified <span class="amp">&amp;</span> informed.<br> Keep moving, growing muscle <span class="amp">&amp;</span> strength.<br> Keep loving, bring surprise <span class="amp">&amp;</span> fun.<br> Keep learning, new tricks <span class="amp">&amp;</span>&nbsp;frameworks. </p> <p>Stay uncomfortable. Become&nbsp;invincible. </p>Control vs Agency - The chosen path2023-03-14T00:00:00+06:002023-04-02T00:00:00+06:00Khaled Monsoortag:blog.kmonsoor.com,2023-03-14:/control-vs-agency-the-chosen-path/<p>Control vs Agency - The chosen&nbsp;path</p><p>Most things are completely out of your control, but you have control over your action about them.<br> The second part is called &ldquo;having&nbsp;agency&rdquo;.</p> <p>You can&rsquo;t stop the sun from rising, but you can always get a pair of&nbsp;sunglasses.</p> <p>You can&rsquo;t do anything when it&rsquo;s raining outside, but you can take an umbrella with you.<br> You have &ldquo;zero&rdquo; control over the economy, but have control over your spending <span class="amp">&amp;</span> saving habits.<br> You don&rsquo;t know when your heart gonna stop, but can try to eat healthy and do&nbsp;exercise. </p> <p>You can&rsquo;t tell when your employer is going to fire you, but can always prepare for the next interview.<br> You can&rsquo;t make someone like you, but you can always love yourself and become the best version of&nbsp;yourself. </p> <p>Focusing on the first will make you feel hopeless and frustrated. Every time.<br> Focusing on the second will make you feel fulfilled and grounded. Every&nbsp;time. </p> <p>You have to choose over the other.<br> In the end, this is the decision that will define&nbsp;you. </p> <p>Choose&nbsp;wisely.</p>সহজ বাংলায় vice versa মানে2021-12-15T07:30:00+06:002021-12-15T07:30:00+06:00Khaled Monsoortag:blog.kmonsoor.com,2021-12-15:/সহজ-বাংলায়-vice-versa-মানে/<p>ইংরেজি ভাষায় বেশ কিছু শব্দ, বাক্য কিংবা বাগধারা ব্যবহার করা হয়, যেটার বাংলা ভাষায় এক শব্দে কোনও অনুবাদ নেই। বা থাকলেও সাধারণ মানুষের জন্য খুব খটমটে। এরকম একটি শব্দগুচ্ছ হোল &ldquo;vice versa&rdquo; যেটি ল্যাটিন ভাষা থেকে এসেছে।&nbsp;&hellip;</p><h1 id="vice-versa">সহজ বাংলায় vice versa মানে<a class="headerlink" href="#vice-versa" title="Permanent link">&para;</a></h1> <p>বাংলা আক্ষরিক অর্থ: “তদ্বিপরীত”, বা “উলটা ভাবে” ।<br> “vice versa” শব্দগুচ্ছটি সতেরো-শতকের গোড়ার দিকে ল্যাটিন থেকে ধীরে ধীরে সরাসরি ইংরেজিতে “the other way around” বোঝাতে ব্যবহার করা&nbsp;হচ্ছে। </p> <p>এটি সাধারণত একটি বাক্যের দ্বিতীয় অংশে ব্যবহার করা হয়, এবং বাক্যের প্রথমাংশে যে দুটি জিনিসের সম্পর্ক নিয়ে বলা হয়েছে, “vice versa” ব্যবহার করে তার বিপরীত দিকের সম্পর্কটিকে বোঝানো&nbsp;হয়।</p> <p>যেমন: </p> <blockquote> <p>“John doesn&rsquo;t like Tom, and <ins>Tom also doesn&rsquo;t like John</ins>.” <br> অর্থাৎ, “জন টমকে পছন্দ করে না, আর টমও জনকে পছন্দ করে&nbsp;না।” </p> </blockquote> <p>ইংরেজিতে ঠিক এই কথাটিকেই সুন্দর এবং সংক্ষেপ করে লেখা যায়&nbsp;&hellip; </p> <blockquote> <p>“John doesn&rsquo;t like Tom, and <ins>vice versa</ins>.” </p> </blockquote> <p>এবার বাংলা থেকে ইংরেজি করার একটি উদাহরণ দেই&nbsp;।</p> <blockquote> <p>“পারুর পরিবার দেবদাসকে চাইলেও দেবদাসের পরিবার কিন্তু পারুকে চায় নি।”<br> ইংরেজিতে আক্ষরিক অনুবাদ করলে দাড়ায় &hellip;<br> “Paru&rsquo;s family wanted Devdas, but <ins>Devdas&rsquo; family didn&rsquo;t want Paru</ins>.” </p> </blockquote> <p>কিন্তু “vice versa” ব্যবহার করে একই কথা বেশ সংক্ষেপে আর প্রাঞ্জলভাবে লেখা যায়&nbsp;&hellip; </p> <blockquote> <p>“Paru&rsquo;s family wanted Devdas, but <ins><strong>not</strong> vice versa</ins>.” </p> </blockquote>সহজ বাংলায় silver lining এর মানে2021-12-02T01:30:00+06:002021-12-02T01:30:00+06:00Khaled Monsoortag:blog.kmonsoor.com,2021-12-02:/সহজ-বাংলায়-silver-lining-এর-মানে/<p>ইংরেজি ভাষায় বেশ কিছু শব্দ, বাক্য কিংবা বাগধারা ব্যবহার করা হয়, যেটার বাংলা ভাষায় এক শব্দে কোনও অনুবাদ নেই। বা থাকলেও সাধারণ মানুষের জন্য খুব খটমটে। এরকম একটি concept বা ধারণা হোল &ldquo;silver lining&rdquo;।&nbsp;&hellip;</p><h1 id="silver-lining">“Silver lining”<a class="headerlink" href="#silver-lining" title="Permanent link">&para;</a></h1> <p>“Silver lining” এর সরাসরি(শাব্দিক) অনুবাদ করলে দাড়ায় “রূপালি আস্তরণ”, যা প্রকৃত অর্থের ধারেকাছেও না। “Silver lining” আসলে একটা বহুল-প্রচলিত বাগধারার(“Idiom”) সংক্ষিপ্ত রূপ। ইংরেজিতে বাগধারাটি হলো “Every cloud has a silver lining” যার ভাবার্থ বাংলায় করা হয় &ldquo;দুঃখের পরে সুখ আসে&rdquo;। আরেক ভাবে অর্থ করা হয় যে “প্রত্যেক বিপদ-আপদের কিছু ভালো দিকও থাকে”। এজন্য শুধু &ldquo;silver lining&rdquo; দিয়ে কোনও বিপদাপদ বা ক্ষতিকর জিনিসের সাথে আসা ভালো বা উপকারী দিকটিকেও বুঝানো&nbsp;হয়।</p> <h2 id="_1">উদাহরণ<a class="headerlink" href="#_1" title="Permanent link">&para;</a></h2> <p>(সব চরিত্র&nbsp;কাল্পনিক)</p> <p><strong>১.</strong><br> <em>ডেভিড</em>: Losing my job had a silver lining. (&ldquo;আমার চাকরি যাওয়ায় একদিক দিয়ে ভালোই হয়েছে।&rdquo;)<br> <em>মারিয়া</em>: How so? (&ldquo;কিভাবে?&rdquo;)<br> <em>ডেভিড</em>: Not having the extra money helped me quit smoking, finally. (&ldquo;বাড়তি পয়সা না থাকায় আমার ধূমপানের অভ্যাসটা এবার বাদ দিতে&nbsp;পেরেছি।&rdquo;) </p> <p><strong>২.</strong><br> <em>দুখু মিয়া</em> : My dad got sick. What&rsquo;s the silver lining in that, Asha? (&ldquo;আমার বাবা অসুস্থ। আশা, এতে ভালো কি থাকতে পারে?&rdquo;)<br> <em>আশা</em> : Of course, there is. For example, this situation is going to make you more responsible. (&ldquo;অবশ্যই আছে। যেমন: এই পরিস্থিতিতে তুমি আরও দায়িত্বশীল হয়ে&nbsp;উঠবে।&rdquo;)</p> <hr> <p>যদি লেখাটি শেয়ার করতে চান, ব্রাউজারের লিংকটি শেয়ার করতে পারেন, অথবা নিচের ইমেজটি ডাউনলোড করেও শেয়ার করতে পারেন। ধন্যবাদ&nbsp;!</p> <p><img alt="what silver-lining means in easy Bengali" src="https://i.imgur.com/C86jng8h.png"></p>সহজ বাংলায় ad hominem এর মানে2021-11-25T00:00:00+06:002021-11-25T00:00:00+06:00Khaled Monsoortag:blog.kmonsoor.com,2021-11-25:/সহজ-বাংলায়-ad-hominem-এর-মানে/<p>ইংরেজি ভাষায় বেশ কিছু শব্দ বা ধারনা অন্য কোনও ভাষা থেকে সরাসরি ব্যবহার করা হয়, কিন্তু বাংলা ভাষায় সেই শব্দ বা ধারনাটির এক শব্দে কোনও অনুবাদ নেই। বা থাকলেও সাধারণ মানুষের জন্য খুব খটমটে। এরকম একটি concept বা ধারণা হোল &ldquo;ad hominem&rdquo; যেটি ল্যাটিন ভাষা থেকে এসেছে।&nbsp;&hellip;</p><hr> <h1 id="ad-hominem-attack">ad hominem (attack)<a class="headerlink" href="#ad-hominem-attack" title="Permanent link">&para;</a></h1> <p>ল্যাটিন &lsquo;<em>argumentum ad hominem</em>&lsquo; এর ইংরেজিতে আক্ষরিক অনুবাদ হয় &lsquo;<em>to the person</em>&lsquo;। </p> <p>কিন্তু ইংরেজিতে সাধারণত সরাসরি &ldquo;<em>ad hominem</em>&rdquo; তার সাথে &ldquo;<em>attack</em>&rdquo; যোগ করা হয়।<br> যেমন: some members attacked him ad hominem; instead of discussing his proposal, they were talking about how poor he grew&nbsp;up. </p> <p>যদিও বাংলায় এটাকে &ldquo;ব্যক্তিগত আক্রমন&rdquo; বলে লেখা যায়, কিন্তু তাতে পুরোপুরি অর্থটা প্রকাশ পায় না। বরং কারো কোনও একটি প্রস্তাব, মতামত বা যুক্তিকে পাশ কাটাতে দ্বিতীয় কোনও ব্যক্তি সেই প্রস্তাব (বা মতামত) নিয়ে আলোচনা না করে, বরং সেই প্রথমজনকে ব্যক্তিগত (কিন্তু সেই মতামতের সাথে কোনও সম্পর্ক নেই) একটা বিষয়ে সমালোচনা করে, সেটাই &ldquo;ad hominem&rdquo; আক্রমণ । সেই ব্যক্তিগত আক্রমণের বিষয়টি সত্য বা মিথ্যা হতে&nbsp;পারে।</p> <h2 id="_1">উদাহরণ :<a class="headerlink" href="#_1" title="Permanent link">&para;</a></h2> <p>(সব চরিত্র&nbsp;কাল্পনিক)</p> <p><strong>১.</strong><br> <em>জয়নাল:</em> চীন আমেরিকাকে ঠকায় ১৯৮০ সালের চুক্তিতে ট্রেড সুবিধা পেয়ে।<br> <em>দিলারা:</em> জয়নাল তো ঠিকমতো ইনকাম ট্যাক্স দেয় না। আন্তর্জাতিক সম্পর্ক কি বুঝে? (<em>ad hominem</em> আক্রমণ) <br> <em>রেবেকা:</em> ১৯৮০ সালের চুক্তির পরে তো চীনে আমেরিকার ভুট্টা রপ্তানি বেড়ে দ্বিগুণ হয়েছে, তাহলে? (যুক্তি খণ্ডন, কিন্তু <em>ad hominem</em> আক্রমণ&nbsp;নয়) </p> <p><strong>২.</strong><br> <em>সলিমুদ্দিঃ</em> শুনেছি, রোজা রাখা শরীরের জন্য ভালো ।<br> <em>কলিমুদ্দিঃ</em> ধুর মিয়া, আপনে নামাজই তো পড়েন না ঠিকমতো, রোজার কি জানেন? (<em>ad hominem</em> আক্রমণ)<br> <em>রহিমুদ্দিঃ</em> যাই হোক, রোজা রাখলে শরীর তো খুব কাহিল লাগে। (প্রাসঙ্গিক আলোচনা, কিন্তু <em>ad hominem</em> আক্রমণ&nbsp;নয়) </p> <hr> <p>যদি লেখাটি শেয়ার করতে চান, ব্রাউজারের লিংকটি শেয়ার করতে পারেন, অথবা নিচের ইমেজটি ডাউনলোড করেও শেয়ার করতে পারেন। ধন্যবাদ&nbsp;!</p> <p><img alt="ad-hominem means in easy Bengali" src="https://i.imgur.com/tM1dXmsh.png"></p>Investments with the biggest ROI2021-11-22T00:00:00+06:002021-11-22T00:00:00+06:00Khaled Monsoortag:blog.kmonsoor.com,2021-11-22:/investments-with-the-biggest-roi/<p>Once you have the essentials covered, like food, rent, clothes, etc., the best investment you can make is on&nbsp;&hellip;</p><p>Once you have the essentials covered, like food, rent, clothes, etc., the best investment you can make is on &hellip; <span class="caps">YOURSELF</span>. <br> Duh?! you might be thinking. But hold that thought for a moment. This post isn&rsquo;t so much about the money you can make but about fixing the internal issues holding you from the 100x, which you won&rsquo;t be able to make&nbsp;otherwise.</p> <p>The <span class="caps">ROI</span> should be in the 100x range, if not&nbsp;1000x.</p> <h2 id="invest-in-your-physical-health-and-fitness">Invest in your physical health and fitness<a class="headerlink" href="#invest-in-your-physical-health-and-fitness" title="Permanent link">&para;</a></h2> <p>Eat proper food, and secure some time to exercise regularly. Even better, if you can afford it, consult a real-life fitness trainer, not some <span class="caps">IG</span>&nbsp;bozo.</p> <h2 id="invest-in-your-mental-health">Invest in your mental health<a class="headerlink" href="#invest-in-your-mental-health" title="Permanent link">&para;</a></h2> <p>Talk to a trained mental health professional. Find out if there&rsquo;s any childhood trauma, subconscious burden, or any mental illness you&rsquo;re carrying. Then, actively work on resolving it. There&rsquo;s no shame in having an issue, but it&rsquo;s not right to make the closed ones suffer because of&nbsp;it.</p> <h2 id="invest-in-continuous-education">Invest in continuous education<a class="headerlink" href="#invest-in-continuous-education" title="Permanent link">&para;</a></h2> <p>No, not talking about another degree or a certificate course. What I mean is about continuously educating yourself to be a better person, a true leader, a effective planner, and such. Learning can be done in many forms <span class="amp">&amp;</span> shapes. There are so many resources online or offline; free or paid; be it books, videos, podcasts, blogs, etc. you name it. Choose the one that fits your lifestyle and daily schedule.<br> Regardless of the medium, make an active habit of keep&nbsp;learning.</p> <h2 id="buy-time"><span class="dquo">&ldquo;</span>Buy&rdquo; time<a class="headerlink" href="#buy-time" title="Permanent link">&para;</a></h2> <p>This one sounds a bit edgy, right? I know. But, hold on for a moment. This investment is good to go after you have started taking care of the previous ones. Then, the next best thing is to &ldquo;buy&rdquo; more time for yourself. I mean, save your own time by delegating chore-like repetitive tasks to others who are willing to do it for less. Everyone isn&rsquo;t in the same financial position, and that&rsquo;s how it works. When considering something to buy, don&rsquo;t just consider it&rsquo;s upfront price; consider how much time you have to spend to make it usable. Now, re-invest the saved time in something more productive. When you have a lot of time to spare, you can do&nbsp;more.</p> <p>Be productive, be happy. Then, please share the happiness with&nbsp;others.</p>Create a free go-link server “on edge” using Cloudflare Worker KV2021-06-06T00:00:00+06:002021-06-06T00:00:00+06:00Khaled Monsoortag:blog.kmonsoor.com,2021-06-06:/golink-server-using-cloudflare-worker-kv/<p>Among quite a few ways to implement a go-link server (i.e., url-forwarder, short-url server, etc.), I will show how to use free-tier Cloudflare Worker (&amp; <span class="caps">KV</span>) to create an in-house, on-edge, <strong>no-webserver</strong> go-link&nbsp;server.</p><p>Among quite a few ways to implement a go-link server (i.e., url-forwarder, short-url server, etc.), I&rsquo;m going to show you how to use free-tier Cloudflare Worker (&amp; <span class="caps">KV</span>) to create an in-house, on-edge, <strong>no-webserver</strong> go-link&nbsp;server.</p> <p>For example, the short-link for this article is <a href="https://go.kmonsoor.com/golink-kv">go.kmonsoor.com/golink-kv</a> </p> <p><img alt="overall structure" src="https://i.imgur.com/MjIS5gD.png"></p> <ul> <li><code>/latest</code> (by which I mean <code>go.yourdomain.co/latest</code>) may point to <code>https://www.yourcompany.com/about/news</code> which is a public&nbsp;page</li> <li><code>/hr-help</code> may point to <code>https://www.company-internal.com/long-link/hr/contact.html</code>, which is company&rsquo;s internal human-resources help&nbsp;portal</li> <li><code>/cnypromo</code> may point to <code>https://shop.yourcompany.com/sales/promotions/?marketing-promo=2021-cny</code> which is a temporary sales promotions page targeting the shoppers during the Chinese new year of&nbsp;2021.</li> </ul> <p>Please note that using the setup and the code below, it&rsquo;ll be possible to resolve short-links via a <strong>single</strong> sub-domain, e.g., <code>go.your-domain.co</code>. However, it&rsquo;s possible (with some modification of the code) to resolve/redirect via <em>any number of domains</em> (your own, of course) towards any other public or private <span class="caps">URL</span>, and all sorts of novelties. However, for brevity&rsquo;s sake, I will discuss the first one, a single sub-domain&nbsp;usecase.</p> <p>To set up a go-link server or short-<span class="caps">URL</span> resolver via a proper <span class="caps">KV</span>+Worker combination, we&rsquo;ll go through these&nbsp;steps:</p> <div class="toc"> <ul> <li><a href="#pre-requisites">Pre-requisites</a></li> <li><a href="#create-the-short-link-map-as-a-kv">Create the short-link map as a <span class="caps">KV</span></a></li> <li><a href="#mapping-a-kv-to-a-worker-variable">Mapping a <span class="caps">KV</span> to a Worker&nbsp;variable</a></li> <li><a href="#handling-a-route-with-webworker">Handling a route with&nbsp;webworker</a></li> <li><a href="#create-the-worker">Create the&nbsp;Worker</a></li> <li><a href="#pointing-a-dns-record-to-the-worker">Pointing a <span class="caps">DNS</span> record to the&nbsp;Worker</a></li> <li><a href="#next-step">Next&nbsp;step</a></li> <li><a href="#related">Related</a></li> </ul> </div> <h1 id="pre-requisites">Pre-requisites<a class="headerlink" href="#pre-requisites" title="Permanent link">&para;</a></h1> <ul> <li>The <span class="caps">DNS</span> resolver for the <strong>root</strong> domain (in the example below, <em><code>kmonsoor.com</code></em>) needs to be Cloudflare. Because the core of the solution, the &ldquo;worker&rdquo;, runs on the nearest (from the user) edge of Cloudflare using a standard <span class="caps">KV</span> (&ldquo;key, value&rdquo;)&nbsp;list.</li> <li>Write permission to the <span class="caps">DNS</span> configuration as you&rsquo;d need to add a new <span class="caps">AAAA</span> <span class="caps">DNS</span>&nbsp;record.</li> <li>Some knowledge of Javascript(<code>ES6</code>), as we are going to write the &ldquo;worker&rdquo; in that&nbsp;language.</li> </ul> <h1 id="create-the-short-link-map-as-a-kv">Create the short-link map as a <span class="caps">KV</span><a class="headerlink" href="#create-the-short-link-map-as-a-kv" title="Permanent link">&para;</a></h1> <p>We&rsquo;ll start the setup by creating the short-link map, the list between the short-link segments that you (or someone in your org) define, and the actual URLs they need to point&nbsp;to.</p> <p>Find the <span class="caps">KV</span> stuff in the <code>Workers</code> section. From the screenshot, please ignore the &ldquo;Route&rdquo; section for&nbsp;now. </p> <p><img alt="Find the KV stuff in the Workers section" src="https://i.imgur.com/b2Rk45u.png"></p> <ul> <li>you&rsquo;d need to create a Worker <span class="caps">KV</span> &ldquo;Namespace&rdquo;. Name the namespace as you seem fit. I named it <code>REDIRECTS</code> (in all caps just as a convention, not&nbsp;required). </li> <li>List the short links <span class="amp">&amp;</span> their respective target URLs. From the examples in the intro, the keys <code>latest</code>, <code>hr-help</code>, <code>cnypromo</code> etc. would be in as the &ldquo;key&rdquo;, and the target full links as the respective&nbsp;&ldquo;value&rdquo;.</li> <li>Remember <span class="caps">NOT</span> to start the short part with &lsquo;/&rsquo;. It&rsquo;ll be taken care of in the&nbsp;code.</li> </ul> <p><img alt="Create the short-link map as a KV" src="https://i.imgur.com/jkC8bSr.png"></p> <p>Once you&rsquo;ve listed all your desired (short-link, target-link) combinations, now we have a <span class="caps">KV</span> on Cloudflare. However, it&rsquo;s not referencable from your Worker code, not yet. Hence the next&nbsp;step.</p> <h1 id="mapping-a-kv-to-a-worker-variable">Mapping a <span class="caps">KV</span> to a Worker variable<a class="headerlink" href="#mapping-a-kv-to-a-worker-variable" title="Permanent link">&para;</a></h1> <p>Now, we will map the previously created <span class="caps">KV</span> to a variable that can be referenced from our Worker code. Please note that though I used different names, it can be the same as well. Also, note that multiple Workers can access a single <span class="caps">KV</span>, and vice versa is also true; a single Worker can reference multiple&nbsp;KVs.</p> <p><img alt="Mapping a KV to a Worker variable" src="https://i.imgur.com/lb7G9si.png"></p> <h1 id="handling-a-route-with-webworker">Handling a route with webworker<a class="headerlink" href="#handling-a-route-with-webworker" title="Permanent link">&para;</a></h1> <p><img alt="Handling a route with webworker" src="https://i.imgur.com/KohHRfR.png"></p> <h1 id="create-the-worker">Create the Worker<a class="headerlink" href="#create-the-worker" title="Permanent link">&para;</a></h1> <p>Now, we will write Worker-code that runs on <code>V8</code> runtime on the nearest (from the requesting user) &ldquo;edge&rdquo; location of Cloudflare, to execute the code and deliver the result(s) to the user. In this case, that would be to redirect user-requested address to the mapped one (by you, in the <span class="caps">KV</span> namespace&nbsp;above).</p> <p><img alt="Creating a worker" src="https://i.imgur.com/eNfZNyN.png"></p> <p>The code editor looks like&nbsp;this: </p> <p><img alt="The code editor for Cloudflare worker" src="https://i.imgur.com/pb9AE9v.png"></p> <p>If you rather prefer to copy-paste, please feel free to do it from the below GitHub&nbsp;Gist.</p> <div class="gist"> <script src="https://gist.github.com/kmonsoor/dc9f96660423c96471f8574ba018d867.js"></script> </div> <p>Once done, it should look like &hellip; <img alt="created webworker" src="https://i.imgur.com/XSdKB56.png"></p> <h1 id="pointing-a-dns-record-to-the-worker">Pointing a <span class="caps">DNS</span> record to the Worker<a class="headerlink" href="#pointing-a-dns-record-to-the-worker" title="Permanent link">&para;</a></h1> <p>Finally, we need to point a <span class="caps">DNS</span> record that&rsquo;ll redirect all requests to your re-soutign sub-domain (e.g. <code>go.your-domain.com</code>) to the Cloudflare Worker that we just&nbsp;created.</p> <p>According to the Cloudflare docs, the <span class="caps">DNNS</span> record must be an <span class="caps">AAAA</span> record, pointing to the IPv6 address <code>100::</code>. The &ldquo;Name&rdquo; here is the &ldquo;sub-domain&rdquo; part of your choice, which is better be short, to rightfully serve our goal&nbsp;here. </p> <p><img alt="Pointing a DNS record to it" src="https://i.imgur.com/62bk7pe.png"></p> <p>Voila ! Now, test some of the short-urls that you&rsquo;ve mapped via the <span class="caps">KV</span>. Enjoy ! Watch out for the target usage though. <a href="https://developers.cloudflare.com/workers/platform/limits#worker-limits">Here&rsquo;s the limit</a>. </p> <p>I think you&rsquo;ll be fine, unless you&rsquo;re some celebrity&nbsp;;)</p> <h1 id="next-step">Next step<a class="headerlink" href="#next-step" title="Permanent link">&para;</a></h1> <p>As the next step, I&rsquo;m thinking to create a generic <code>Go/Link</code> resolver browser extension. Then, someone can set their own default domain or company domain of choice as short-domain host. In that case, entering just <code>go/hr-help</code> on the browser will take to <code>https://www.company-internal.com/.../hr/contact.html</code> that we have discussed at the beginning (remember the example case of an internal human resources help&nbsp;portal?).</p> <h1 id="related">Related<a class="headerlink" href="#related" title="Permanent link">&para;</a></h1> <p>If you want to do this url-direction <strong>on your server, but only using webserver</strong>, try this: <a href="https://go.kmonsoor.com/golink-caddy">Personal short-link server using only&nbsp;Caddyserver</a></p> <hr> <p>If you find this post helpful, you can show your support <a href="https://www.patreon.com/kmonsoor">through Patreon</a> or by <a href="https://ko-fi.com/kmonsoor">buying me a coffee</a>. <em>Thanks!</em></p>TL;DR what cloud provider to use in 20212021-05-22T00:00:00+06:002021-05-22T00:00:00+06:00Khaled Monsoortag:blog.kmonsoor.com,2021-05-22:/TLDR-what-cloud-to-use-2021/<p>Among the thousands of combinations a company can take to choose from the cloud providers and their products, this is my <span class="caps">TL</span>;<span class="caps">DR</span>&nbsp;suggestion</p><p>The sheer number of combinations a company can choose from the cloud providers and their product suites is mind-boggling. Hence, I decided to break it down in a concise form for the busy C-suite&nbsp;executives.</p> <p>According to my little experiences and humble opinion, I suggest&nbsp;&hellip;</p> <p>➤ If your company is a small SaaS shop with 10-ish engineers, stick with DigitalOcean, Linode, <span class="caps">OVH</span>, etc., which are best known as cloud &ldquo;instance&rdquo; providers.<br> Think McDonald&rsquo;s; reliable, cheapest, fast, but you won&rsquo;t take your date there. <br> <strong>Budget</strong>:&nbsp;💰</p> <p>➤ If you want a whole cloud experience (e.g., <span class="caps">VPC</span>, firewall, <span class="caps">WAF</span>, etc., on the menu), start with Google Cloud, then try <span class="caps">AWS</span> later.<br> Google Cloud would be the quickest to grasp the cloud concepts and get going. The <span class="caps">UI</span> of the <span class="caps">AWS</span> console is a bit messy compared to <span class="caps">GCP</span>; it just takes more time to get a proper grip.<br> Imagine them as full-course, Michelin-star restaurants. However, the product names are so abstract that they need a full-sized chart for that. ;) <strong>Budget</strong>:&nbsp;💰💰💰</p> <p>➤ Are you planning to set up a million-dollar infra for a billion-dollar company? Go for some <span class="caps">GCP</span>+<span class="caps">AWS</span> multi-cloud setup. You gonna get rebates from both on the scale of hundreds of thousands of dollars. And Microsoft Azure gonna offer you some million-$ free-tier, hoping to get the company hooked on Azure. :D <strong>Budget</strong>:&nbsp;💰💰</p> <p>➤ On the other hand, if you run a govt agency or a company where wearing suits is the mainstream, Microsoft Azure is your best bet.<br> A bunch of consultancy companies to choose from; you need to just approve the budget, you get the things to get up <span class="amp">&amp;</span> running but miss the deadline by months, if not years. But there&rsquo;d be no need for hiring more smarter ppl than that you already have. <strong>Budget</strong>:&nbsp;💰💰💸</p> <p>Need an even more comprehensive guide? Gotcha, fam&nbsp;&hellip;</p> <blockquote class="twitter-tweet"><p lang="en" dir="ltr"><span class="caps">CTO</span>: we&#39;re having hard time choosing a cloud provider<br>&#8230;<br>&#8220;say no more, fam, I gotcha &#8230;&#8221; <a href="https://t.co/hR3rMruWWi">pic.twitter.com/hR3rMruWWi</a></p>&mdash; Khaled Monsoor ✨ (@kmonsoor) <a href="https://twitter.com/kmonsoor/status/1395959443376857088?ref_src=twsrc%5Etfw">May 22, 2021</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> <p><em><span class="caps">PS</span></em> This post is inspired by a LinkedIn post of mine where I shared about my short experience with the Microsoft Azure <strong>DevOps</strong>&nbsp;suite</p>Deploying a short-link aka go-link server using only Caddyserver2021-04-16T00:00:00+06:002021-04-16T00:00:00+06:00Khaled Monsoortag:blog.kmonsoor.com,2021-04-16:/deploying-golink-server-using-Caddy/<p>Yeah, there are tons of open-source, full-fledged link-shorteners. But, none were exactly what I wanted. Hence, the minimal approach only by utilizing an amazing webserver, <code>Caddy</code>. Here we go&nbsp;&hellip;</p><p>Before I go into any details, please note that I&rsquo;ve used the term &ldquo;shortlink-server&rdquo; instead of &ldquo;url-shortener&rdquo; because the difference is significant for this post. A url-shortener takes a long url, and gives a short url, then redirects any requests for the shortened link to its longer counterpart. On the contrary, shortlink-server takes both the long and short url as inputs, then only does the redirect-ion&nbsp;part.</p> <h2 id="backstory">Backstory<a class="headerlink" href="#backstory" title="Permanent link">&para;</a></h2> <p>If I wanted a fantastic, personal url-shortener or &ldquo;go link&rdquo; server, there are many excellent solutions out there, which are not only free or open-source but full-fledged as well for personal or public usage. Instead, I wanted some &ldquo;service&rdquo; that would &ldquo;resolve&rdquo; my personal, short links. I have been using bit.ly for a long time for its customizable &ldquo;short-half&rdquo; part, but the problem with bit.ly is &ndash; for some God-forsaken reason &ndash; blocked by the Bangladeshi govt. So, I needed a replacement to be appropriately &ldquo;glocal&rdquo;. There are many free (unbranded) and commercial (branded) options as well, but I wanted something that would be resolved via my hosted service (and personal domain) and as cheap as possible. So, basically solution for a poor nerd&nbsp;:D</p> <p>Before jumped into this solution, I tried (deployed <span class="amp">&amp;</span> tested) few others myself, mainly <a href="https://github.com/kellegous/go">kellegous/go</a>, <a href="kutt.it">kutt.it</a> and <a href="https://github.com/adamyi/golinks">adamyi/golinks</a>. But, all of them &ldquo;too featureful&rdquo; for my&nbsp;needs.</p> <p><img alt="Simple, on-prem short-link server using Caddy webserver" src="https://i.imgur.com/4nZbnUE.png"></p> <p>What I wanted is to be able&nbsp;to:</p> <ul> <li>resolve only my custom shortlinks (hence, no need for&nbsp;url-shortener)</li> <li>not a public, internet-facing service (hence, any frontend, authentication, email verification etc. would be overkill&nbsp;)</li> <li>minimal setup (if possible, no webapp at&nbsp;all)</li> </ul> <p>Given my previous experience with <code>Caddy</code> webserver, which is an amazing one(<a href="https://caddyserver.com/docs/">why?</a>), I had a gut feeling that Caddy has something for me &ndash; under the sleeve &ndash; to meet my minimal set of requirements. Thankfully, I managed to find&nbsp;it.</p> <p>I believe <span class="caps">NGINX</span>, currently the most popular webserver, has some kind of similar mechanism as well. But, I&rsquo;m not an expert, and once I was genuinely intimidated by its config file syntax. <span class="caps">YMMV</span>.</p> <h2 id="what-you-gonna-need">What you gonna need?<a class="headerlink" href="#what-you-gonna-need" title="Permanent link">&para;</a></h2> <ul> <li>your own domain which will be the root of the shortlinks. While sub-domained <span class="caps">URL</span> like <code>go.company-name.com/*</code> is quite common, if you have some short domain, like you.co/*, only for this purpose, that&rsquo;s fine as&nbsp;well.</li> <li>A web-host server or public-facing instance with its own, <strong>public IPv4 address</strong>.</li> <li>working knowledge of&nbsp;Linux</li> </ul> <h2 id="step-1-point-your-subdomain-to-the-right-place">Step-1: Point your subdomain to the right place<a class="headerlink" href="#step-1-point-your-subdomain-to-the-right-place" title="Permanent link">&para;</a></h2> <ul> <li>Find out what&rsquo;s the <strong>puplic IPv4 address</strong> of your instance that&rsquo;ll act as the webserver. It&rsquo;s usually on the cloud management&nbsp;dashboard.</li> <li>make sure that, regardless of your cloud architecture (e.g. <span class="caps">VPC</span>, subnet, firewall etc.), the <span class="caps">SSL</span> port (<code>:443</code>) of the instance is reachable from the public&nbsp;internet.</li> <li>now go to your domain name registrar (or, <span class="caps">DNS</span> management provider which in my case is Cloudflare). There, you need to point shortlink subdomain (<code>go.</code>)to the webserver&rsquo;s <span class="caps">I.P.</span> address. In <span class="caps">DNS</span> terms, you&rsquo;ll be creating a <span class="caps">CNAME</span> entry on the domain&rsquo;s nameserver&nbsp;table.</li> </ul> <p>You can do this step as the last one. But for some reason, I prefer it to do first. Because sometimes, <a href="https://blog.cloudflare.com/never-deal-with-dns-propagation-again/"><span class="caps">DNS</span> propagation</a> takes some time. But, once my web service is up and running, I like to see the result instantaneously.&nbsp;;)</p> <h2 id="step-2-install-caddy-a-mighty-webserver">Step-2: Install Caddy, a mighty webserver<a class="headerlink" href="#step-2-install-caddy-a-mighty-webserver" title="Permanent link">&para;</a></h2> <p>Depending on your host <span class="caps">OS</span> (Ubuntu 20.04 <span class="caps">LTS</span> in my case), you need to <a href="https://caddyserver.com/docs/install">install the <code>Caddy</code> webserver</a>. While there are some hacky solutions to run, I think running <code>Caddy</code> as a background service is the simplest to manage. In fact, the documentation of Caddy is excellent, so I&rsquo;d better leave that part to&nbsp;you.</p> <p>After running with the default config(<code>Caddyfile</code>), (in Ubuntu&rsquo;s case, located as <code>/etc/caddy/Caddyfile</code>), it should show a status somewhat like the below image. Please note that, in many cases, if running without <code>sudo</code>, Caddy cannot attach itself with the <span class="caps">SSL</span> port (<code>:443</code>), which is necessary for serving <code>https://</code>. So, check for that error message in the &ldquo;status&rdquo;&nbsp;log.</p> <p><img alt="Caddy service on Ubuntu" src="https://i.imgur.com/cfS5nvZ.png?1"></p> <p><em><strong><span class="caps">PS</span>:</strong> By the way, want your console and command prompt to look 🚀 like mine? Here&rsquo;s the guide: <a href="https://blog.kmonsoor.com/pimp-up-my-terminal/">How do I pimp up my terminal on&nbsp;Linux</a></em></p> <h2 id="step-3-tell-caddy-your-short-links-to-redirect">Step-3: Tell Caddy your short-links to redirect<a class="headerlink" href="#step-3-tell-caddy-your-short-links-to-redirect" title="Permanent link">&para;</a></h2> <p>Now, it&rsquo;s time to configure Caddy to actually do the&nbsp;job.</p> <p>Caddy has its native <code>redir</code> <span class="dquo">&ldquo;</span>directive&rdquo; to redirect incoming web-request from one to another. While the <code>map</code> directive is relatively new, it makes the config file, i.e., Caddyfile, look elegant in case you have (or will have in the long run) a long list of&nbsp;short-links.</p> <p>Here&rsquo;s mine, which is working nicely&nbsp;&hellip; </p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos=" 1 "></span># /etc/caddy/Caddyfile <span class="linenos" data-linenos=" 2 "></span> <span class="linenos" data-linenos=" 3 "></span>go.kmonsoor.com { # replace it your web-url root <span class="linenos" data-linenos=" 4 "></span> <span class="linenos" data-linenos=" 5 "></span> map {path} {redirect-uri} { <span class="linenos" data-linenos=" 6 "></span> /blog https://blog.kmonsoor.com <span class="linenos" data-linenos=" 7 "></span> /photos https://photos.kmonsoor.com <span class="linenos" data-linenos=" 8 "></span> <span class="linenos" data-linenos=" 9 "></span> /resume https://drive.google.com/file/d/1nMS3i1ai6nsI70zZ7NFnNQ_XmvAa4GOl <span class="linenos" data-linenos="10 "></span> /resume-doc https://docs.google.com/document/d/1ECx1Yr8Jzz9I3S5VcoKnZQz56oIht2XaM5gSNetcWag <span class="linenos" data-linenos="11 "></span> <span class="linenos" data-linenos="12 "></span> /rickrolled https://www.youtube.com/watch?v=dQw4w9WgXcQ <span class="linenos" data-linenos="13 "></span> <span class="linenos" data-linenos="14 "></span> # will add new ones here like the above <span class="linenos" data-linenos="15 "></span> # ... <span class="linenos" data-linenos="16 "></span> } <span class="linenos" data-linenos="17 "></span> <span class="linenos" data-linenos="18 "></span> # this below code is required to actually make the above `map` work <span class="linenos" data-linenos="19 "></span> <span class="linenos" data-linenos="20 "></span> @hasRedir expression `{redirect-uri} != &quot;&quot;` <span class="linenos" data-linenos="21 "></span> redir @hasRedir {redirect-uri} <span class="linenos" data-linenos="22 "></span> <span class="linenos" data-linenos="23 "></span> # code below is to set the default response if the requested shortlink isn&#39;t here <span class="linenos" data-linenos="24 "></span> respond &quot;Thas&#39;s an unknown short URL ... :(&quot; <span class="linenos" data-linenos="25 "></span>} </code></pre></div> <p>Note: Don&rsquo;t forget to restart the <code>caddy</code> service to let the new config to take&nbsp;effect.</p> <h2 id="step-4-profit">Step-4: Profit<a class="headerlink" href="#step-4-profit" title="Permanent link">&para;</a></h2> <p>Yeah, that&rsquo;s it. Now, add some own personal stuff with some cool short-links, and proudly share with the&nbsp;world.</p> <h2 id="whats-next">What&rsquo;s next ?<a class="headerlink" href="#whats-next" title="Permanent link">&para;</a></h2> <p>I&rsquo;m thinking that given the very low workload my shortlink resolver needs — unless I&rsquo;m becoming an overnight internet sensation — using a server instance only for this purpose is overkill. My next goal is to have the same service using some &ldquo;serverless&rdquo; function or using the &ldquo;<a href="https://developers.cloudflare.com/workers/examples/redirect">worker on the edge</a>&rdquo; thing from Cloudflare. Let&rsquo;s see&nbsp;;)</p> <p><strong>Update</strong> Now, actually done it. Here is the link: <a href="https://blog.kmonsoor.com/golink-server-using-cloudflare-worker-kv/">Free short-link server &ldquo;on edge&rdquo; using Cloudflare Worker <span class="caps">K.V.</span></a></p> <hr> <p>If you find this post helpful, you can show your support <a href="https://www.patreon.com/kmonsoor">through Patreon</a> or <a href="https://paypal.me/KhaledMonsoor/">Paypal</a> or by <a href="https://ko-fi.com/kmonsoor">buying me a coffee</a>. <em>Thanks!</em></p>