<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Soumya Ranjan Mohanty on Medium]]></title>
        <description><![CDATA[Stories by Soumya Ranjan Mohanty on Medium]]></description>
        <link>https://medium.com/@geekysrm?source=rss-55a4a6567407------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MkoMMKUV7aa_M29snng9uw.png</url>
            <title>Stories by Soumya Ranjan Mohanty on Medium</title>
            <link>https://medium.com/@geekysrm?source=rss-55a4a6567407------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 13:22:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@geekysrm/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Create a Discord Slash Bot using HarperDB Custom Functions]]></title>
            <link>https://geekysrm.medium.com/discord-slash-bot-with-harperdb-custom-functions-787e7bb53442?source=rss-55a4a6567407------2</link>
            <guid isPermaLink="false">https://medium.com/p/787e7bb53442</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[harperdb]]></category>
            <dc:creator><![CDATA[Soumya Ranjan Mohanty]]></dc:creator>
            <pubDate>Fri, 22 Oct 2021 06:44:43 GMT</pubDate>
            <atom:updated>2021-10-22T06:44:43.279Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jiElAVa3tqjS4eYwUuvbKw.png" /></figure><p>Hello folks 👋!</p><p>Have you ever created a Node.js server using Express/Fastify? Have you used a service like HarperDB to store your data?</p><p>If yes, then you are in luck! HarperDB has introduced <a href="https://harperdb.io/docs/custom-functions/">Custom Functions</a> which helps us to use HarperDB methods to create our custom API endpoints. Custom Functions are written in Node.js and are powered by Fastify.</p><p>HarperDB Custom Functions can be used to power things like integration with third-party apps and APIs, AI, third-party authentication, defining database functionality, and serving a website.</p><p>All the things that we will cover in this tutorial are within the FREE tier of HarperDB.</p><ul><li><em>If you want to review the code at any point, </em><a href="https://github.com/geekysrm/harperdb-discordbot"><em>here is the GitHub repo</em></a> .</li></ul><h3>What are we going to build?</h3><p>We will build a Discord bot which responds to <a href="https://support.discord.com/hc/en-us/articles/1500000368501-Slash-Commands-FAQ">slash commands</a> .</p><p>Users can say a programming joke on the discord channel using <strong>/sayjoke</strong> command. We will keep count of the number of jokes each user has posted and the jokes in a HarperDB database.</p><p>Any user can use the <strong>/top</strong> command to see who is the user who has posted the most programming jokes.</p><p>And finally, one can view the jokes posted by a particular user by using the <strong>/listjokes</strong> command.</p><p>Our bot will be able to fetch the data from the HarperDB database, perform some logic and respond to the user with the results.</p><p><em>A small demo of what we will be building</em></p><h3>Prerequisites</h3><p>Before starting off with this tutorial, make sure you have the following:</p><ul><li><a href="https://nodejs.org/">Node.js</a> and npm installed</li><li>Basic JavaScript knowledge</li><li>A discord.com account</li><li><a href="https://www.postman.com/">Postman</a> or other REST API Client</li><li>A code editor like <a href="https://code.visualstudio.com/download">VS Code</a></li><li>A <a href="https://studio.harperdb.io/sign-up">HarperDB Account</a></li></ul><h3>Installation</h3><p>We need to set up our local environment first. Make sure to use node v14.17.3 to avoid errors during installation. So we will install the HarperDB package from npm using:</p><pre>npm install -g harperdb</pre><p>For more details and troubleshooting while installing, <a href="https://harperdb.io/docs/install-harperdb/">visit the docs</a> .</p><p>You should be able to run HarperDB now on your local machine by running:</p><pre>harperdb run</pre><p>The local instance runs on port 9925 by default.</p><h3>Registering our local instance</h3><p>Now that our local instance is up and running, we need to register our local instance on HarperDB studio. Go ahead and <a href="https://harperdb.io/">sign up</a> for a free account if you haven&#39;t already.</p><p>After login, click on <strong>Create new HarperDB cloud instance / Register User installed instance</strong>.</p><p>Now click on <strong>Register User-installed instance</strong>:</p><p>Now enter the following details for the local user instance running on localhost:9925:</p><p>&lt;center&gt;</p><p><em>the default id and password is HDB_ADMIN which can be changed later</em> &lt;/center&gt;</p><p>Select the free option for RAM in the next screen and add the instance in the next screen after that:</p><p>&lt;center&gt;</p><p>&lt;/center&gt;</p><p>Wait for some seconds as the instance is getting registered.</p><h3>Configuring the local instance</h3><p>Once the local instance is registered, on the following screen, you will see various tabs. Click on the <strong>browse</strong> tab and add the schema. Let&#39;s name our schema dev:</p><p>For the discord bot, we will need 2 tables: users and jokes.</p><p>The users table will hold user information like id (of the user from discord), username (discord username), score (count of number of jokes posted).</p><p>The jokes table will hold the jokes. It will have columns: id (of the joke), joke (joke text), user_id (id of the user who posted the joke).</p><p>For now, let&#39;s create those 2 tables by clicking the + button:</p><ol><li>users table with hash attr. as id</li><li>jokes table with hash attr. as id</li></ol><h3>Custom Functions</h3><p>Now we come to the most exciting part! Custom Functions! Custom functions are powered by Fastify.</p><p>Click on the <strong>functions</strong> tab and click on <strong>Enable Custom Functions</strong> on the left.</p><p>After you have enabled HarperDB Custom Functions, you will have the option to create a project. Let&#39;s call ours: discordbot.</p><p>You can also see where the custom functions project is stored on your local machine along with the port on which it runs on (default: 9926).</p><p>Fire up the terminal now, and change directory to where the custom functions project is present.</p><pre>cd ~/hdb/custom_functions</pre><p>Now let&#39;s clone a function template into a folder discordbot (our custom functions project name) provided by HarperDB to get up and running quickly!</p><pre>git clone https://github.com/HarperDB/harperdb-custom-functions-template.git discordbot</pre><p>Open the folder discordbot in your favourite code editor to see what code the template hooked us up with!</p><p>Once you open up the folder in your code editor, you&#39;ll see it is a typical npm project.</p><p>The routes are defined in routes folder.</p><p>Helper methods are present in helpers folder.</p><p>Also, we can have a static website running by using the static folder, but we won&#39;t be doing that in this tutorial.</p><p>We can also install npm packages and use them in our code.</p><h3>Discord Bot Setup</h3><p>Before we write some code, let us set up our discord developer account and create our bot and invite it into a Discord server.</p><p>Before all this, I recommend you to create a discord server for testing this bot, which is <a href="https://blog.discord.com/starting-your-first-discord-server-4dcacda8dad5">pretty straight-forward</a> . Or you can use an existing Discord server too.</p><p>Now, let&#39;s create our bot.</p><p>Go to <a href="https://discord.com/developers/applications">Discord Developer Portal</a> and click &quot;New Application&quot; on the top right. Give it any name and click &quot;Create&quot;.</p><p>Next click the &quot;Bot&quot; button on the left sidebar and click &quot;Add Bot&quot;. Click &quot;Yes, do it!&quot; when prompted.</p><p>Now, we have created our bot successfully. Later we are going to need some information which will allow us to access our bot. Please follow the following instructions to find everything we will need:</p><p><strong>Application ID:</strong> Go to the &quot;General Information&quot; tab on the left. Copy the value called &quot;Application ID&quot;.</p><p><strong>Public Key:</strong> On the &quot;General Information&quot; tab, copy the value in the field called &quot;Public Key&quot;.</p><p><strong>Bot Token:</strong> On the &quot;Bot&quot; tab in the left sidebar, copy the &quot;Token&quot; value.</p><p>Keep these values safe for later.</p><h3>Inviting our bot to our server</h3><p>The bot is created but we still need to invite it into our server. Let&#39;s do that now.</p><p>Copy the following URL and replace &lt;YOUR_APPLICATION_ID&gt; with your application ID that you copied from Discord Developer Portal:</p><p>https://discord.com/api/oauth2/authorize?client_id=&lt;YOUR_APPLICATION_ID&gt;&amp;permissions=8&amp;scope=applications.commands%20bot</p><p><em>Here we are giving the bot commands permission and bot admin permissions</em></p><p>Open that constructed URL in a new tab, and you will see the following:</p><p>Select your server and click on <strong>Continue</strong> and then <strong>Authorize</strong> in the next screen. Now you should see your bot in your Discord server.</p><p>Now, let&#39;s finally get to some code, shall we?</p><h3>Get. Set. Code.</h3><p>Switch to your editor where you have opened the discordbot folder in the previous steps.</p><p>First, let&#39;s install the dependencies we will need:</p><ol><li>npm i discord-interactions: discord-interactions contains handy discord methods to make the creation of our bot simple.</li><li>npm i nanoid: nanoid is a small uuid generator which we will use to generate unique ids for our jokes.</li><li>npm i fastify-raw-body: For verifying our bot later using discord-interactions, we need access to the raw request body. As Fastify doesn&#39;t support this by default, we will use fastify-raw-body.</li></ol><p>Open the <strong>examples.js</strong> file and delete all the routes present. We will add our routes one by one. Your file should look like below:</p><pre>&quot;use strict&quot;;<br><br><br>// eslint-disable-next-line no-unused-vars,require-await<br>module.exports = async (server, { hdbCore, logger }) =&gt; {<br><br>};</pre><p>Now, we will add our routes inside the file. All routes created inside this file, will be relative to /discordbot.</p><p>For example, let&#39;s now create a GET route at / which will open at localhost:9926/discordbot</p><pre>server.route({<br>    url: &quot;/&quot;,<br>    method: &quot;GET&quot;,<br>    handler: (request) =&gt; {<br>      return { status: &quot;Server running!&quot; };<br>    },<br>  });<br>};<br>. . .</pre><p>Now save the file and go to HarperDB studio and click on &quot;restart server&quot; on the &quot;functions&quot; tab:</p><p>Anytime you make any change to the code, make sure to restart the custom functions server.</p><p>By the way, did you see that your code was reflected in the studio on the editor? Cool, right?</p><p>Now to see the results of your added route, visit localhost:9926/discordbot on your browser, and you should get a JSON response of:</p><pre>{<br>  &quot;status&quot;: &quot;Server running!&quot;<br>}</pre><p>Yay! Our code works!</p><p>Now for the most exciting part, let&#39;s start coding the discord bot. We will import InteractionResponseType, InteractionType and verifyKey from discord-interactions.</p><pre>const {<br>  InteractionResponseType,<br>  InteractionType,<br>  verifyKey,<br>} = require(&quot;discord-interactions&quot;);</pre><p>We will create a simple POST request at / which will basically respond to a PING interaction with a PONG interaction.</p><pre>. . .<br>server.route({<br>    url: &quot;/&quot;,<br>    method: &quot;POST&quot;,<br>    handler: async (request) =&gt; {<br>      const myBody = request.body;<br>      if (myBody.type === InteractionType.PING) {<br>        return { type: InteractionResponseType.PONG };<br>      }<br>    },<br>  });<br>. . .</pre><p>Now let&#39;s go to the Discord Portal and register our POST endpoint as the <strong>Interactions Endpoint URL</strong>. Go to your application in Discord Developer Portal and click on the &quot;General Information&quot; tab, and paste our endpoint in the <strong>Interactions Endpoint URL</strong> field. But oops! Our app is currently running on localhost which Discord cannot reach. So for a temporary solution, we will use a tunnelling service called <strong>ngrok</strong>. <em>After we finish coding and testing our code, we will deploy the bot to HarperDB cloud instance with a single click for free.</em></p><p>For Mac, to install ngrok:</p><pre>brew install ngrok # assuming you have homebrew installed<br>ngrok http 9926 # create a tunnel to localhost:9926</pre><p>For other operating systems, follow the <a href="https://ngrok.com/download">installation instructions</a> .</p><p>Copy the https URL you get from ngrok.</p><p>Paste the following to the <strong>Interactions Endpoint URL</strong> field: YOUR_NGROK_URL/discordbot.</p><p>Now, click on &quot;Save changes&quot;. But we get an error:</p><p>So, actually discord won&#39;t accept ANY request which is sent to it, we need to perform verification to check for the validity of the request. Let&#39;s perform that verification. For that, we need access to the raw request body and for that we will use fastify-raw-body.</p><p>Add the following code just before the GET / route.</p><pre>. . . <br><br>server.register(require(&quot;fastify-raw-body&quot;), {<br>    field: &quot;rawBody&quot;,<br>    global: false, <br>    encoding: &quot;utf8&quot;, <br>    runFirst: true, <br>  });<br><br>  server.addHook(&quot;preHandler&quot;, async (request, response) =&gt; {<br>    if (request.method === &quot;POST&quot;) {<br>      const signature = request.headers[&quot;x-signature-ed25519&quot;];<br>      const timestamp = request.headers[&quot;x-signature-timestamp&quot;];<br>      const isValidRequest = verifyKey(<br>        request.rawBody,<br>        signature,<br>        timestamp,<br>        &lt;YOUR_PUBLIC_KEY&gt; // as a string, e.g. : &quot;7171664534475faa2bccec6d8b1337650f7&quot;<br>      );<br>      if (!isValidRequest) {<br>        server.log.info(&quot;Invalid Request&quot;);<br>        return response.status(401).send({ error: &quot;Bad request signature &quot; });<br>      }<br>    }<br>  });<br>. . .</pre><p>Also, we will need to add rawBody:true to the config of our POST / route. So, now it will look like this:</p><pre>. . .<br>server.route({<br>    url: &quot;/&quot;,<br>    method: &quot;POST&quot;,<br>    config: {<br>      // add the rawBody to this route<br>      rawBody: true,<br>    },<br>    handler: async (request) =&gt; {<br>      const myBody = request.body;<br><br>      if (myBody.type === InteractionType.PING) {<br>        return { type: InteractionResponseType.PONG };<br>      }<br>    },<br>  });<br>. . .</pre><p>(Don&#39;t forget to restart the functions server after each code change)</p><p>Now try to put YOUR_NGROK_URL/discordbot in the <strong>Interactions Endpoint URL</strong> field. And voila! We will be greeted with a success message.</p><p>So, now our endpoint is registered and verified. Now let&#39;s add the commands for our bot in the code. We will have 3 slash commands.</p><ol><li><strong>/sayjoke &lt;joke&gt;</strong> : post a joke on the discord server.</li><li><strong>/listjokes &lt;username&gt;</strong>: view jokes of a particular user.</li><li><strong>/top</strong>: check the leader with the max. number of jokes posted.</li></ol><p>Let&#39;s first create a commands.js file inside the helpers folder and write the following code for the commands. We will be using this in the routes.</p><pre>const SAY_JOKE = {<br>  name: &quot;sayjoke&quot;,<br>  description: &quot;Say a programming joke and make everyone go ROFL!&quot;,<br>  options: [<br>    {<br>      type: 3, // a string is type 3<br>      name: &quot;joke&quot;,<br>      description: &quot;The programming joke.&quot;,<br>      required: true,<br>    },<br>  ],<br>};<br><br>const TOP = {<br>  name: &quot;top&quot;,<br>  description: &quot;Find out who is the top scorer with his score.&quot;,<br>};<br><br>const LIST_JOKES = {<br>  name: &quot;listjokes&quot;,<br>  description: &quot;Display programming jokes said by a user.&quot;,<br>  options: [<br>    {<br>      name: &quot;user&quot;,<br>      description: &quot;The user whose jokes you want to hear.&quot;,<br>      type: 6, // a user mention is type 6<br>      required: true,<br>    },<br>  ],<br>};<br><br>module.exports = {<br>  SAY_JOKE,<br>  TOP,<br>  LIST_JOKES,<br>};</pre><h3>Registering the slash commands</h3><p>Before using these in the routes file, we will need to register them first. This is a one-time process for each command.</p><p>Open Postman or any other REST API client.</p><p>Make a New Request with type: POST.</p><p>URL should be: <a href="https://discord.com/api/v8/applications/YOUR_APPLICATION_ID/commands">https://discord.com/api/v8/applications/YOUR_APPLICATION_ID/commands</a></p><p>On the Headers tab, add 2 headers:</p><pre>Content-Type:application/json<br>Authorization:Bot &lt;YOUR_BOT_TOKEN&gt;</pre><p>Now for each command, change the Body and Hit Send. For sayjoke:</p><pre>{<br>    &quot;name&quot;: &quot;sayjoke&quot;,<br>    &quot;description&quot;: &quot;Say a programming joke and make everyone go ROFL!&quot;,<br>    &quot;options&quot;: [<br>        {<br>            &quot;type&quot;: 3,<br>            &quot;name&quot;: &quot;joke&quot;,<br>            &quot;description&quot;: &quot;The programming joke.&quot;,<br>            &quot;required&quot;: true<br>        }<br>    ]<br>}</pre><p>You should see a response similar to this:</p><p>Similarly, let&#39;s register the other 2 commands.</p><p>For listjokes:</p><pre>{<br>    &quot;name&quot;: &quot;listjokes&quot;,<br>    &quot;description&quot;: &quot;Display all programming jokes said by a user.&quot;,<br>    &quot;options&quot;: [<br>        {<br>            &quot;name&quot;: &quot;user&quot;,<br>            &quot;description&quot;: &quot;The user whose jokes you want to hear.&quot;,<br>            &quot;type&quot;: 6,<br>            &quot;required&quot;: true<br>        }<br>    ]<br>}</pre><p>For top:</p><pre>{<br>    &quot;name&quot;: &quot;top&quot;,<br>    &quot;description&quot;: &quot;Find out who is the top scorer with his score.&quot;<br>}</pre><p><strong>NOTE</strong>: Now we have to wait 1 hour till all the commands are registered. If you don&#39;t want to wait, you can use your <a href="https://github-wiki-see.page/m/manix84/discord_gmod_addon_v2/wiki/Finding-your-Guild-ID-%28Server-ID%29">Guild/server ID</a> . But in this case, your bot will work in that server/guild.</p><p>Just replace the URL with: https://discord.com/api/v8/applications/892533254752718898/guilds/&lt;YOUR_GUILD_ID&gt;/commands</p><p>Once your commands are registered, you should be able to see those commands popup when you type / on the chat.</p><p>But when you select any of these, you&#39;ll get an error. This is expected as we haven&#39;t written the code for these slash commands.</p><h3>Writing code for the slash commands</h3><p>Hop over to the routes/examples.js file and let&#39;s write some more code.</p><p>We will add a condition to the / POST route to check if it is a slash command:</p><pre>. . .<br>server.route({<br>    url: &quot;/&quot;,<br>    method: &quot;POST&quot;,<br>    config: {<br>      // add the rawBody to this route<br>      rawBody: true,<br>    },<br>    handler: async (request) =&gt; {<br>      const myBody = request.body;<br><br>      if (myBody.type === InteractionType.PING) {<br>        return { type: InteractionResponseType.PONG };<br>      } else if (myBody.type === InteractionType.APPLICATION_COMMAND) {<br>          // to handle slash commands here<br>      }<br>    },<br>  });<br>. . .</pre><p>So inside the else if block, we are checking if the type is InteractionType.APPLICATION_COMMAND i.e. our slash commands. Inside this block, we will add the logic for handling our 3 slash commands.</p><p>Let&#39;s import the commands information from commands.js in examples.js file.</p><p>At the top of the file, add the following lines:</p><pre>const { SAY_JOKE, TOP, LIST_JOKES } = require(&quot;../helpers/commands&quot;);</pre><h3>The /sayjoke command:</h3><p>The /sayjoke command allows a user to post a programming joke to the Discord channel. First, Let&#39;s add the code for /sayjoke command.</p><pre>// replace the existing line with below line<br>else if (myBody.type === InteractionType.APPLICATION_COMMAND) {<br>        const user = myBody.member.user; // discord user object<br>        const username = `${user.username}`; // discord username<br><br>        const id = user.id; //discord userid (e.g. 393890098061771919)<br>        switch (myBody.data.name.toLowerCase()) {<br>          case SAY_JOKE.name.toLowerCase():<br>            request.body = {<br>              operation: &quot;sql&quot;,<br>              sql: `SELECT * FROM dev.users WHERE id = ${id}`,<br>            };<br>            const sayJokeResponse = await hdbCore.requestWithoutAuthentication(request);<br>            if (sayJokeResponse.length === 0) {<br>              // new user, so insert a new row to users table<br>              request.body = {<br>                operation: &quot;sql&quot;,<br>                sql: `INSERT INTO dev.users (id, name, score) VALUES (&#39;${id}&#39;, &#39;${username}&#39;, &#39;1&#39;)`,<br>              };<br>              await hdbCore.requestWithoutAuthentication(request);<br>            } else {<br>              // old user, so update the users table by updating the user&#39;s score<br>              request.body = {<br>                operation: &quot;sql&quot;,<br>                sql: `UPDATE dev.users SET score = ${<br>                  sayJokeResponse[0].score + 1<br>                }  WHERE id = ${id}`,<br>              };<br>              await hdbCore.requestWithoutAuthentication(request);<br>            }<br>            const jokeId = nanoid(); // creating a new id for joke<br>            const joke = myBody.data.options[0].value;<br>              // insert the joke into the jokes table<br>            request.body = {<br>              operation: &quot;sql&quot;,<br>              sql: `INSERT INTO dev.jokes (id, joke, person_id) VALUE (&#39;${jokeId}&#39;, &#39;${joke}&#39;, &#39;${id}&#39;)`,<br>            };<br>            await hdbCore.requestWithoutAuthentication(request);<br>            const newScore = sayJokeResponse.length === 0 ? 1 : sayJokeResponse[0].score + 1;<br><br>            return {<br>              type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,<br>              data: {<br>                content: `&lt;@${id}&gt; says:\n*${joke}* \n&lt;@${id}&gt;&#39;s score is now: **${newScore}**`, // in markdown format<br>                embeds: [<br>            // we have an embedded image in the response<br>                  {<br>                    type: &quot;rich&quot;,<br>                    image: {<br>                      url: &quot;https://res.cloudinary.com/geekysrm/image/upload/v1632951540/rofl.gif&quot;,<br>                    },<br>                  },<br>                ],<br>              },<br>            };</pre><p>Woah! That&#39;s a lot of code. Let&#39;s understand the code we just wrote step by step.</p><p>First of all, we get the user object from Discord containing all the details of the user who called this command. From that object, we extract the username and id of the discord user.</p><p>Now, inside the switch case, we compare the name of the command to our 3 slash command names. Here, we are handling the /sayjoke command.</p><p>We do a SELECT SQL query to HarperDB&#39;s database, to get the details of the user with the id as the userid we just extracted. There are 2 cases:</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=787e7bb53442" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Tailwind CSS and why you should use it]]></title>
            <link>https://levelup.gitconnected.com/what-is-tailwind-css-and-why-you-should-use-it-soumyas-blog-d103f870071a?source=rss-55a4a6567407------2</link>
            <guid isPermaLink="false">https://medium.com/p/d103f870071a</guid>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[tailwind-css]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Soumya Ranjan Mohanty]]></dc:creator>
            <pubDate>Tue, 20 Oct 2020 17:22:57 GMT</pubDate>
            <atom:updated>2020-10-27T20:49:52.603Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZV9BlRikdRrsBqBM" /></figure><blockquote>Originally published at <a href="https://soumya.dev/what-is-tailwind-css"><strong>soumya.dev</strong></a>.</blockquote><p>Tailwind CSS is a utility-first CSS framework which means it has various utility classes which help to create layouts and rapidly create custom designs.</p><p>I have always loved Adam( <a href="https://tailwindcss.com/">Tailwind CSS</a> creator)’s <a href="https://www.youtube.com/playlist?list=PL7CcGwsqRpSMgVc5NxXUpqmGOS9s1YrWF">streams</a> where he creates awesome-looking, well-designed layouts using Tailwind CSS. Now I cannot imagine a future project without using Tailwind CSS.</p><p>My <a href="https://soumya.dev/blog">blog</a> is built using Tailwind CSS. 😉</p><h3>How is it different from Bootstrap or Bulma etc.? 🤔</h3><p>Most UI frameworks like Bootstrap, Material UI, Bulma etc. have pre-designed UI components like cards, buttons, navbars, alerts. You use those components and create designs on top of those components.</p><p>But in Tailwind CSS, you don’t get a pre-designed set of components. You get utility-classes. You can combine those to create your layout and components.</p><h3>How is this advantageous over other frameworks?</h3><ol><li>If you use other frameworks, say Bootstrap, your site feels Bootstrap-y. It means one can easily tell it is built using Bootstrap (which of course is not a problem) but it looks very similar to thousand other sites built using the same framework. This is <strong>not a problem</strong> with Tailwind CSS because it doesn’t give you pre-defined components to use. You can use tailwind utility-classes in any combination to create your own UI components. See below how to do so.</li><li>To overcome the above problem, you have one solution: <strong>override styles.</strong> If you have ever done this before, you know that this gets out of hand pretty fast. This is not a problem with Tailwind CSS.</li><li>You solve one of the <a href="https://martinfowler.com/bliki/TwoHardThings.html">2 hardest things</a> of computer science: naming things, here making up <strong>class names</strong>. As iterated earlier, Tailwind CSS gives you utility classes which you can use to create your styles without worrying about class names invention.</li><li><strong>Responsive by design:</strong> If you use Tailwind CSS, you don’t need to write custom styles for handling responsiveness for different screen sizes. You can use Tailwind’s responsive utilities to handle it easily. We will see that below.</li><li><strong>Pseudo classes:</strong> We can style elements on hover, focus etc. similar to how we do responsive design in Tailwind CSS.</li><li><strong>And a lot more!</strong> — New features are always getting added like Dark mode support, animations etc.</li></ol><h3>Getting Started with Tailwind CSS</h3><p>The easiest way to get started with Tailwind CSS is to grab the CDN and start playing with it. For serious projects, I recommend installing it via npm which I have described just below the CDN method.</p><h3>Using the CDN:</h3><p>Add the CDN to your HTML:</p><pre>&lt;link<br>  href=&quot;&lt;https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css&gt;&quot;<br>  rel=&quot;stylesheet&quot;<br>/&gt;</pre><h3>Installing it via npm:</h3><ol><li>In order to use it, you have to first install Tailwind CSS via npm.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/76ff96fdee16dfee6177382e33460f56/href">https://medium.com/media/76ff96fdee16dfee6177382e33460f56/href</a></iframe><p>2. Create a tailwind config file: This file is used to configure and customize tailwind to your liking: npx tailwind init<br>This creates tailwind.config.js in the root of your project.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c78286dd9bbab39971c55aef9c1b9699/href">https://medium.com/media/c78286dd9bbab39971c55aef9c1b9699/href</a></iframe><p>3. Add Tailwind CSS to your CSS: Create a CSS file with the following contents and import it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5c1a14df1a5f5f4c9c9fea414e7a5be/href">https://medium.com/media/d5c1a14df1a5f5f4c9c9fea414e7a5be/href</a></iframe><p>4. Using Tailwind with PostCSS: Tailwind CSS is a PostCSS plugin meaning you have to create a postcss.config.js file in the root of your project:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fbaff99cda246e7afd28788d0e23ba35/href">https://medium.com/media/fbaff99cda246e7afd28788d0e23ba35/href</a></iframe><p>In production, to decrease the CSS bundle size, it is recommended to use purge the unused CSS. You can find more information <a href="https://tailwindcss.com/docs/controlling-file-size#purge-css-options">here</a>.</p><h3>Using Tailwind CSS</h3><p>As mentioned earlier, Tailwind CSS provided us with utility classes.</p><p>For example, to give an element display: flex property, we just have to add the flex class to the element. Easy, right?</p><p>Similarly, there are many classes for various colors, flexbox, CSS Grid, spacing, typography, border styles, transitions etc.</p><p>I have depicted some of the utility-classes provided to us by Tailwind CSS below:</p><p><strong>Colors:</strong> We can use hand-picked colors like red, blue, yellow and others with different shaded from 100–900 which are specified in the <a href="https://tailwindcss.com/docs/customizing-colors#default-color-palette">default color pallete</a>. We can also add or remove colors from the pallete by modifying the taiwind.config.js file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/17420134363406e1b2fb4e9202e5ca7a/href">https://medium.com/media/17420134363406e1b2fb4e9202e5ca7a/href</a></iframe><p><strong>Margin and padding:</strong> To use margin, we use mx-1 , my-3 , m-4 to apply margin to the left-right, up-down and all around respectively. The numbers 1, 3 and 4 follow the <a href="https://tailwindcss.com/docs/customizing-spacing#default-spacing-scale">default spacing scale</a> that Tailwind follows.</p><p><strong>Responsivenes:</strong> We can easily add responsiveness to our website. Suppose we want a paragraph to have font bold on small screens and font semibold on large screens and above, we can do that very easily by the following HTML:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9bd118c2a5959a6da91f8046da5dbcd/href">https://medium.com/media/c9bd118c2a5959a6da91f8046da5dbcd/href</a></iframe><p>Tip: To debug responsive styles in all screen-sizes very easily, I use <a href="https://link.soumya.dev/sizzy">Sizzy browser</a>.</p><p><strong>Display:</strong> These are used to control the display property of an element. For example, to make an item display:block , we give the element a class block . In the same way, we use classes flex, grid, table etc. to give respective styles to the element.</p><p>There are a lot many different utility classes which I have not covered, but you can find those in the <a href="https://tailwindcss.com/docs/">documentation</a>.</p><p>Let’s learn more about Tailwind CSS by looking at some examples:</p><h3>Examples:</h3><p>a. <strong>HTML:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd4bd9a5357f36dd14661e61855522ad/href">https://medium.com/media/cd4bd9a5357f36dd14661e61855522ad/href</a></iframe><p>becomes:</p><p><a href="https://codepen.io/geekysrm/embed/XWKKNKd?default-tab=result&amp;theme-id=dark">CodePen — Tailwind CSS Example 1</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fgeekysrm%2Fembed%2Fpreview%2FXWKKNKd%3Fheight%3D600%26slug-hash%3DXWKKNKd%26default-tabs%3Dhtml%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2Fgeekysrm%2Fpen%2FXWKKNKd&amp;image=https%3A%2F%2Fassets.codepen.io%2F1524920%2Finternal%2Fscreenshots%2Fpens%2FXWKKNKd.default.png%3Ffit%3Dcover%26amp%3Bformat%3Dauto%26amp%3Bha%3Dfalse%26amp%3Bheight%3D360%26amp%3Bquality%3D75%26amp%3Bv%3D2%26amp%3Bversion%3D1603050593%26amp%3Bwidth%3D640&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/884f02287ba9b3be9ebe34a18d79f29d/href">https://medium.com/media/884f02287ba9b3be9ebe34a18d79f29d/href</a></iframe><p><strong>Explanation:</strong></p><p>px-4 and py-2 give padding on the horizontal and vertical axes respectively.</p><p>font-semibold applies a font-weight of 600 to the button text.</p><p>bg-blue-400 gives it a blue color with shade 400 from the tailwind <a href="https://tailwindcss.com/docs/customizing-colors#default-color-palette">pallete</a>.</p><p>Finally, rounded gives the button border-radius: 0.25rem; .</p><p>b. <strong>HTML</strong> (this example is taken from the docs itself):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3fc03d8aa58ab19625733b3240f000e/href">https://medium.com/media/e3fc03d8aa58ab19625733b3240f000e/href</a></iframe><p>becomes:</p><p><a href="https://codepen.io/geekysrm/embed/ExyyNgg?default-tab=result&amp;theme-id=dark">CodePen — Tailwind CSS Example 2</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fgeekysrm%2Fembed%2Fpreview%2FExyyNgg%3Fheight%3D600%26slug-hash%3DExyyNgg%26default-tabs%3Dhtml%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2Fgeekysrm%2Fpen%2FExyyNgg&amp;image=https%3A%2F%2Fassets.codepen.io%2F1524920%2Finternal%2Fscreenshots%2Fpens%2FExyyNgg.default.png%3Ffit%3Dcover%26amp%3Bformat%3Dauto%26amp%3Bha%3Dfalse%26amp%3Bheight%3D360%26amp%3Bquality%3D75%26amp%3Bv%3D2%26amp%3Bversion%3D1603051012%26amp%3Bwidth%3D640&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f5355a9bb4ff684ec6e2ec2f8b16861/href">https://medium.com/media/9f5355a9bb4ff684ec6e2ec2f8b16861/href</a></iframe><p>c. <strong>HTML</strong> (blog post listing on <a href="https://soumya.dev/blog">my blog</a>):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/22b2f8c02dd64d78636682e2ec753a2f/href">https://medium.com/media/22b2f8c02dd64d78636682e2ec753a2f/href</a></iframe><p>becomes:</p><p><a href="https://codepen.io/geekysrm/embed/YzWWpNe?default-tab=result&amp;theme-id=dark">CodePen — Tailwind CSS Example 3</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fgeekysrm%2Fembed%2Fpreview%2FYzWWpNe%3Fheight%3D600%26slug-hash%3DYzWWpNe%26default-tabs%3Dhtml%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2Fgeekysrm%2Fpen%2FYzWWpNe&amp;image=https%3A%2F%2Fassets.codepen.io%2F1524920%2Finternal%2Fscreenshots%2Fpens%2FYzWWpNe.default.png%3Ffit%3Dcover%26amp%3Bformat%3Dauto%26amp%3Bha%3Dtrue%26amp%3Bheight%3D360%26amp%3Bquality%3D75%26amp%3Bv%3D2%26amp%3Bversion%3D1603051249%26amp%3Bwidth%3D640&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/9af616f1d768a5c57de411f861957ebe/href">https://medium.com/media/9af616f1d768a5c57de411f861957ebe/href</a></iframe><p><strong>Tip:</strong> To quickly refer Tailwind classes at a glance, use <a href="https://nerdcave.com/tailwind-cheat-sheet">TailwindCSS cheatsheet</a> 📝.</p><h3>Using Tailwind CSS with React:</h3><p>It can be quite painful to repeat the same utility classes for reusable components in your site. To solve this issue, you can extract out the common styles into a React component (or a component in your frontend framework of choice), make it dynamic using props and re-use it.</p><p><strong>Example of a simple Card Component:</strong></p><p><em>Usage:</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54a6ddf112f513a9c6c3c5a7fa42874b/href">https://medium.com/media/54a6ddf112f513a9c6c3c5a7fa42874b/href</a></iframe><p><em>Card Component:</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a003068488fd0791ecbc73677e27115/href">https://medium.com/media/2a003068488fd0791ecbc73677e27115/href</a></iframe><p><a href="https://codesandbox.io/s/github/arnorhaux/tailwindcss-react-boilerplate?file=/src/components/app.js">Here is a CodeSandbox</a> with React + Tailwind CSS for you to play around!</p><p>In case you want to use Tailwind CSS with CSS-in-JS libraries like Emotion or styled-components, you can follow my <a href="https://soumya.dev/tailwindcss-gatsby-styled-emotion">guide</a>.</p><p>I hope these examples made you understand the various properties of Tailwind CSS and how it is different from traditional CSS frameworks like Bootstrap and others. I am sure you will love Tailwind CSS once you start using it in your projects, just like I did.</p><h3>Subscribe to Soumya’s dev thoughts</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fslidetosubscribe.com%2Fembed%2Fgeekysrm&amp;dntp=1&amp;display_name=Slide+to+Subscribe&amp;url=https%3A%2F%2Fslidetosubscribe.com%2Fgeekysrm%2F&amp;image=https%3A%2F%2Fslidetosubscribe.com%2Fi%2Fgeekysrm.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=slidetosubscribe" width="450" height="152" frameborder="0" scrolling="no"><a href="https://medium.com/media/a595db42ca9a9fe61ab98aa50b0b9f92/href">https://medium.com/media/a595db42ca9a9fe61ab98aa50b0b9f92/href</a></iframe><h3>Happy Coding! 👨‍💻</h3><p>If this post helped you, and you want to help me create more tutorials/ videos like this, please consider supporting me at <a href="https://coffee.soumya.dev/"><em>https://coffee.soumya.dev/</em></a></p><p>Want more such posts in your inbox? Subscribe to my <a href="https://tinyletter.com/geekysrm">newsletter here</a> and my <a href="https://link.soumya.dev/youtube">YouTube Channel</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d103f870071a" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/what-is-tailwind-css-and-why-you-should-use-it-soumyas-blog-d103f870071a">What is Tailwind CSS and why you should use it</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Use TailwindCSS with Gatsby (with Emotion or styled-components)]]></title>
            <link>https://medium.com/swlh/use-tailwindcss-with-gatsby-with-emotion-or-styled-components-7504135b9941?source=rss-55a4a6567407------2</link>
            <guid isPermaLink="false">https://medium.com/p/7504135b9941</guid>
            <category><![CDATA[gatsbyjs]]></category>
            <category><![CDATA[tailwind]]></category>
            <category><![CDATA[gatsby]]></category>
            <category><![CDATA[tailwind-css]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Soumya Ranjan Mohanty]]></dc:creator>
            <pubDate>Thu, 06 Feb 2020 12:10:08 GMT</pubDate>
            <atom:updated>2020-10-27T20:52:18.491Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Gatsby + Tailwind + Emotion" src="https://cdn-images-1.medium.com/max/1024/1*zkfrBF3dj1_3LQJDA_zy5Q.png" /><figcaption>Gatsby + Tailwind + Emotion</figcaption></figure><blockquote>Originally published at <a href="http://soumya.dev/tailwindcss-gatsby-styled-emotion"><strong>soumya.dev</strong></a>.</blockquote><p>I was amazed by the stuff one can do using <a href="https://tailwindcss.com/">Tailwindcss</a>. I watched in awe the <a href="https://www.youtube.com/playlist?list=PL7CcGwsqRpSMgVc5NxXUpqmGOS9s1YrWF">live streams</a> of <a href="https://twitter.com/adamwathan">Adam Wathan</a> (creator of tailwindcss)where he used to build various layouts using tailwindcss, without using any custom CSS.</p><p>Not being a great designer by myself, I decided to give TailwindCSS a try. Being a React developer, I wanted to try tailwind with React.</p><p>Then, I was starting with a <a href="https://gatsbyjs.org/">Gatsby </a>site, I thought why not use tailwind with this. I also wanted to use it with a CSS-in -JS solution like <a href="https://emotion.sh/">Emotion </a>or <a href="https://styled-components.com/">styled-components</a> being a big fan of CSS-in-JS. I googled a lot, tried different starters and here I am with what I can tell the <strong><em>“best </em></strong>👌<strong><em>”</em> way to use TailwindCSS with Gatsby along with CSS-in-JS solutions like Emotion or styled-components.</strong></p><h3>Steps to get the perfect 👌combo:</h3><ol><li>Run the following command on your terminal to get a default Gatsby site up and running.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/69d6877466f0350fa78ec990fbada7aa/href">https://medium.com/media/69d6877466f0350fa78ec990fbada7aa/href</a></iframe><p>2. Run gatsby develop on your terminal to open your site on <strong>port 8000 </strong>(default).<br>You can view your site with live reload (updates site as you edit and save code).</p><p>3. Install Tailwind and generate <a href="https://tailwindcss.com/docs/configuration/#creating-your-configuration-file">Tailwind config file</a>.<br>( To learn more about how to use Tailwind in your CSS, visit the <a href="https://tailwindcss.com/docs/installation#3-use-tailwind-in-your-css">Tailwind Documentation</a>)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f2c562a20f022e6599305d08f6c5599/href">https://medium.com/media/7f2c562a20f022e6599305d08f6c5599/href</a></iframe><p>Now you can use tailwind classes in your project using className attribute. But to use CSS-in-JS magic and styled components pattern, follow the below steps.</p><p>4. Now install <em>Emotion packages, tailwind-micro, gatsby-plugin-postcss, postcss-preset-env, postcss-import, </em><a href="https://stylelint.io/"><em>stylelint</em></a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bdb6e271d9f3841d36142c2bc4a1e723/href">https://medium.com/media/bdb6e271d9f3841d36142c2bc4a1e723/href</a></iframe><p>5. Create a file postcss.config.js in the root of your project with the following content:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7d889070110746921ae7c0c6a740f4f/href">https://medium.com/media/a7d889070110746921ae7c0c6a740f4f/href</a></iframe><p>6. Add gatsby-plugin-postcss and gatsby-plugin-emotion to your gatsby-config.js file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d7a352d98557b84d4c076814aa23bd61/href">https://medium.com/media/d7a352d98557b84d4c076814aa23bd61/href</a></iframe><p>7. Restart Gatsby dev server using Ctrl+C and again running gatsby develop .<br>Now our gatsby site knows about the plugins we have installed.</p><p>8. To use default Tailwind base styles and utilities styles, create a globals.css file. I like to keep it in src/styles/globals.css :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b29e56ef960191f259e3286151b60fe0/href">https://medium.com/media/b29e56ef960191f259e3286151b60fe0/href</a></iframe><p>9. Now to use the globals.css styles, we import it in the gatsby-browser.js file in our root directory:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9f9d96bffd22fd8e48dd721d7a9d3cf/href">https://medium.com/media/d9f9d96bffd22fd8e48dd721d7a9d3cf/href</a></iframe><p>10. Restart Gatsby dev server using Ctrl+C and again running gatsby develop .</p><h3>Usage 💻</h3><p>Finally, we are done with all installation and configuration. Whew!<br>We can now use the tailwind classes quite easily in our components in 3 ways:</p><p><em>a.</em> <em>Using tailwind classes directly in markup:</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a682b273621c9bc15520c261061bab7/href">https://medium.com/media/8a682b273621c9bc15520c261061bab7/href</a></iframe><p>Here, the tailwind classes font-semibold, text-lg, leading-snug, truncate will be applied to h4 tag.</p><p><em>b. Using styled components pattern:</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11f12e0bad4263163f8c84802b8b8f97/href">https://medium.com/media/11f12e0bad4263163f8c84802b8b8f97/href</a></iframe><p><em>c. In case you want to apply custom CSS along with some TailwindCSS properties:</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/803ed06a49a6ec76ea68d8aa02be077a/href">https://medium.com/media/803ed06a49a6ec76ea68d8aa02be077a/href</a></iframe><p>Tip: To quickly refer Tailwind classes, use <a href="https://nerdcave.com/tailwind-cheat-sheet">TailwindCSS cheatsheet</a> 📝.</p><p>That’s it! Congratulations! 🎉<br>You have successfully setup a Gatsby site that uses TailwindCSS along with Emotion.</p><p>Suggestions and comments are welcome!</p><h3>Subscribe to Soumya’s dev thoughts</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fslidetosubscribe.com%2Fembed%2Fgeekysrm&amp;dntp=1&amp;display_name=Slide+to+Subscribe&amp;url=https%3A%2F%2Fslidetosubscribe.com%2Fgeekysrm%2F&amp;image=https%3A%2F%2Fslidetosubscribe.com%2Fi%2Fgeekysrm.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=slidetosubscribe" width="450" height="152" frameborder="0" scrolling="no"><a href="https://medium.com/media/a595db42ca9a9fe61ab98aa50b0b9f92/href">https://medium.com/media/a595db42ca9a9fe61ab98aa50b0b9f92/href</a></iframe><h3>Happy Coding! 👨‍💻</h3><p><em>If this post helped you, and you want to help me create more tutorials/ videos like this, please consider supporting me at </em><a href="https://coffee.soumya.dev/"><em>https://coffee.soumya.dev/</em></a></p><p>You can find me online at: <strong><em>(@geekySRM everywhere)</em></strong></p><p><strong>My website:</strong><a href="https://soumya.dev/"> soumya</a>.dev</p><p><strong>Buy me a Coffee: </strong><a href="https://coffee.soumya.dev/">coffee.soumya.dev</a></p><p><strong>Youtube: </strong><a href="https://link.soumya.dev/youtube">link.soumya.dev/youtube</a></p><p><strong>Twitter:</strong> <a href="https://twitter.com/geekysrm">twitter.com/geekysrm</a></p><p><strong>Github:</strong> <a href="https://github.com/geekysrm">github.com/geekysrm</a></p><p><strong>Facebook: </strong><a href="https://facebook.com/geekysrm">facebook.com/geekysrm</a></p><p><strong>Medium:</strong> <a href="https://medium.com/@geekysrm">medium.com/@geekysrm</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7504135b9941" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/use-tailwindcss-with-gatsby-with-emotion-or-styled-components-7504135b9941">Use TailwindCSS with Gatsby (with Emotion or styled-components)</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hack The Box: How to get invite code]]></title>
            <link>https://codeburst.io/hack-the-box-how-to-get-invite-code-56e369fc8dae?source=rss-55a4a6567407------2</link>
            <guid isPermaLink="false">https://medium.com/p/56e369fc8dae</guid>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[capture-the-flag]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[htb]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Soumya Ranjan Mohanty]]></dc:creator>
            <pubDate>Sat, 27 Jan 2018 21:48:05 GMT</pubDate>
            <atom:updated>2021-02-04T14:06:34.245Z</atom:updated>
            <content:encoded><![CDATA[<h4>Updated guide for 2021</h4><blockquote>Spoiler Alert : I suggest you to try to hack your way into the site, before actually reading anything below. If you fail after considerable tries or you want to know a method which may be different than yours, you can follow along below.</blockquote><p><em>Contact me to learn Software and/or Web Development from scratch: </em><strong><em>soumyarnm@gmail.com</em></strong></p><h3>(Updated) Video Version of tutorial:</h3><p>If you want to watch a video instead of following the below tutorial, you can do that:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fx4VFkskpkvM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dx4VFkskpkvM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fx4VFkskpkvM%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9e055b457784922961f2ade22ab5a15/href">https://medium.com/media/c9e055b457784922961f2ade22ab5a15/href</a></iframe><p>If you enjoyed the video, please <a href="https://link.soumya.dev/youtube">subscribe </a>to a budding youtuber:</p><h3><strong>First of all, a small-ish intro about myself:</strong></h3><p>I am Soumya Ranjan Mohanty ( <em>@geekysrm</em> on the web), a <a href="https://www.credential.net/9h8314eo?key=219f5a29de9f98ac6d2def0a89a0a38c7f1ffe5e">Google Certified Mobile Web Specialist</a> and Full Stack Developer. I also develop Native desktop apps with Electron and Android apps with React Native. <br>Visit my site to know more about me:<strong><em> </em></strong><a href="https://soumya.dev/"><em>https://soumya.dev</em></a><br>Contact me for freelance/contract work : <a href="/service/mailto:soumyarnm@gmail.com"><strong><em>soumyarnm@gmail.com</em></strong></a></p><p><strong>What is Hack The Box :</strong></p><p>It is basically an online platform to test and advance your skills in penetration testing and cyber security. It contains several challenges that are constantly updated. Some of them simulating real world scenarios and some of them leaning more towards a CTF style of challenge. You should try this site out if you have interest in network security or information security.</p><p><strong>Now, let’s hack our way in! Shall we?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*opqAY7vIyfRcXjiwYgi73A.png" /><figcaption>Hack The Box Website</figcaption></figure><ol><li>First, visit the <a href="https://www.hackthebox.eu/">Hack the Box site</a> and read along its FAQs and other useful stuff written there.</li><li>You will be told to go to <a href="https://www.hackthebox.eu/invite">https://www.hackthebox.eu/invite</a> to join HTB.</li><li>When you go to that page, you will see a text box asking you for an<em> invite code</em>.</li><li>Right click on the page, and open inspect element. Alternatively, press Ctrl+Shift+I to open the Chrome Developers Tools.</li><li>Go through the elements tab and you will find a script with source (src) as: /js/inviteapi.min.js</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l71_Z8DSmHqAURPPu3ZCOQ.png" /><figcaption>See the script src: /js/inviteapi.min.js</figcaption></figure><p>6. So now, go to <a href="https://www.hackthebox.eu/js/inviteapi.min.js">https://www.hackthebox.eu/js/inviteapi.min.js</a> . You will see a JS file like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pmXbnn4EjGZRKtJTKyYGEA.png" /><figcaption>See the makeInviteCode which is highlighted</figcaption></figure><p>7. makeInviteCode looks interesting. So let’s go back to <a href="https://www.hackthebox.eu/invite">https://www.hackthebox.eu/invite</a> and try to find its contents.</p><p>8. Goto console tab in Chrome Developer Tools, and type makeInviteCode() and press ENTER. You will get a 200 Success status and data as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aMf_Gn0CLJNpRHVMz5zW5A.jpeg" /><figcaption>See the hint and data</figcaption></figure><p>9. When you click the small arrow alongside <em>data, </em>you will see that the text is encrypted and the encoding type is <strong>ROT13</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p2sNYqzDlBY0CrtYBbUWuQ.jpeg" /><figcaption>ROT13 Encoding Type</figcaption></figure><p>10.Let’s decode that message! Copy the contents of data. And open decoder:<br><a href="https://soumya.dev/decode">https://soumya.dev/decode</a></p><p>11. Select<strong> type: ROT13</strong>, paste the copied data onto the <strong>Encoded Text box</strong> and click <strong>Decode</strong>. You will get something like below.</p><figure><a href="https://soumya.dev/decode"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OFPyzdIlTsUPR_K6gNa5Xw.jpeg" /></a><figcaption>ROT13 decryption</figcaption></figure><p>12. So, as we can see in Decoded Text, in order to generate an invite code, we need to make a POST request to “<a href="https://www.hackthebox.eu/">https://www.hackthebox.eu</a>/api/invite/generate”.</p><p>13. Fire up your terminal/ command-prompt. And make a POST request by typing:</p><blockquote><strong>curl -XPOST </strong><a href="https://www.hackthebox.eu/api/invite/generate"><strong>https://www.hackthebox.eu/api/invite/generate</strong></a></blockquote><p>14. You will get a success message as:</p><blockquote><em>{“success”:1,”data”:{“code”: “</em><strong><em>somerandomcharacters12345</em></strong><em>”, “format”: “</em><strong><em>encoded</em></strong><em>”}, “0”:200}</em></blockquote><p>15. As you saw, we code a code. But this is not our invite code as it says <em>format:encoded.</em></p><p>16. Lets’s try decoding it, by again using decoder: <a href="https://soumya.dev/decode">https://soumya.dev/decode</a>.</p><p>17. But this time, select <strong>type</strong> as <strong>Base64. </strong>Paste the code you got as the response of the POST request into the Encoded Text box and press Decode. <em>Voila! You get your invite code.</em></p><figure><a href="https://soumya.dev/decode"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TtmI32KSF6IQn17rpChTew.jpeg" /></a><figcaption>You get your invite code (Don’t try using this invite code as it won’t work for you)</figcaption></figure><p>18. Now, finally go to <a href="https://www.hackthebox.eu/invite">https://www.hackthebox.eu/invite</a> and paste the Invite Code you got in the textbox asking for the same.</p><p>19. You’re in! You can sign up on the site now and become a member.</p><h3><strong>Happy Hacking! </strong>💻</h3><p><em>If this post helped you, and you want to help me create more tutorials/ videos like this, please consider supporting me at </em><a href="https://coffee.soumya.dev/"><em>https://coffee.soumya.dev/</em></a></p><figure><a href="https://coffee.soumya.dev/"><img alt="Buy Me A Coffee" src="https://cdn-images-1.medium.com/max/201/1*9m5lVBCkAnFfgC97FT8hiA.jpeg" /></a><figcaption>Buy Me A Coffee</figcaption></figure><h3>Subscribe to “Soumya’s dev thoughts”</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fslidetosubscribe.com%2Fembed%2Fgeekysrm&amp;dntp=1&amp;display_name=Slide+to+Subscribe&amp;url=https%3A%2F%2Fslidetosubscribe.com%2Fgeekysrm%2F&amp;image=https%3A%2F%2Fslidetosubscribe.com%2Fi%2Fgeekysrm.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=slidetosubscribe" width="450" height="152" frameborder="0" scrolling="no"><a href="https://medium.com/media/a595db42ca9a9fe61ab98aa50b0b9f92/href">https://medium.com/media/a595db42ca9a9fe61ab98aa50b0b9f92/href</a></iframe><p>You can find me online at:</p><p><strong>My website:</strong> <a href="https://soumya.dev/">https://soumya.dev</a></p><p><strong>Buy me a Coffee: </strong><a href="https://coffee.soumya.dev/">https://coffee.soumya.dev/</a></p><p><strong>Linkedin:</strong> <a href="https://www.linkedin.com/in/geekysrm">https://linkedin.com/in/geekysrm</a></p><p><strong>Twitter:</strong> <a href="https://twitter.com/geekysrm">https://twitter.com/geekysrm</a></p><p><strong>Github:</strong> <a href="https://github.com/geekysrm">https://github.com/geekysrm</a></p><p><strong>Medium:</strong> <a href="https://medium.com/@geekysrm">https://medium.com/@geekysrm</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56e369fc8dae" width="1" height="1" alt=""><hr><p><a href="https://codeburst.io/hack-the-box-how-to-get-invite-code-56e369fc8dae">Hack The Box: How to get invite code</a> was originally published in <a href="https://codeburst.io/">codeburst</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HPDF Journey: Completing Twitter Clone]]></title>
            <link>https://geekysrm.medium.com/hpdf-journey-f208c2798f92?source=rss-55a4a6567407------2</link>
            <guid isPermaLink="false">https://medium.com/p/f208c2798f92</guid>
            <category><![CDATA[twitter]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[hpdf]]></category>
            <category><![CDATA[hasura]]></category>
            <category><![CDATA[material-ui]]></category>
            <dc:creator><![CDATA[Soumya Ranjan Mohanty]]></dc:creator>
            <pubDate>Wed, 06 Dec 2017 22:23:52 GMT</pubDate>
            <atom:updated>2020-10-27T20:54:34.701Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Originally published at <a href="https://soumya.dev/hpdf-journey-twitter-clone"><strong>soumya.dev</strong></a></blockquote><p>Hello readers! First of all, a small introduction about myself. I am <em>Soumya Ranjan Mohanty </em>, a software developer.</p><p>I took the <a href="https://nptel.ac.in/courses/106/106/106106156/"><strong>Introduction to Modern Application Development course</strong> </a>which was being jointly offered by IIT Madras and <a href="http://hasura.io/">Hasura</a>. I was new to web development and app development. But I grasped all the concepts taught to us in the 8 week course quite easily, thanks to the amazing teaching style of Tanmai Sir along with others, while doing a handful of practical exercises. An NPTEL online exam was held and top 5%(~400) students were selected for the <a href="https://blog.hasura.io/go-from-an-idea-to-an-mvp-with-hasura-28f941c52076"><strong>Hasura Product Development Fellowship</strong></a><strong>. </strong>And to my joy, I was also selected for the fellowship as I was in top 2%.</p><p>We were allotted Front End and Back End Technologies to work on. I got Front End (<a href="https://reactjs.org/"><em>React</em></a>) which I had given as my preference. I was quite interested in learning a frontend library which was completely new to me.</p><p>I got the first task to create the <a href="http://twitter.com/">twitter main timeline page</a> and <a href="https://twitter.com/search?q=aadhaar">twitter search results page</a>, using <a href="http://material-ui.com/">material-ui </a>. At first, it was quite difficult for me to get hold of <a href="https://en.wikipedia.org/wiki/React_(JavaScript_library)#JSX">JSX</a>. But slowly, I understood it by following various tutorials online and researching on my own (StackOverflow and Google are your friends!). Then came the part of using material-ui. I was quite amazed by the material design and became used to the library quite easily thanks to its good documentation.</p><p>I was able to complete the task on time and this is the final result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZBuAPDs6jB2p6oad8-mDkw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E8QgCODef8FQec2qv7W4CA.png" /><figcaption>Final Result</figcaption></figure><p>We were then divided into teams of 3 and given projects to complete.</p><blockquote>I won the Pub2Hub challenge held during the programme. Finally, I successfully completed my project and was awarded the “<a href="https://bit.ly/geekysrm-high-performer">Distinguished High Performer</a>” award.</blockquote><p>You can contact me in case of any doubts on my <a href="https://twitter.com/geekysrm">twitter</a>, <a href="https://linkedin.com/in/geekysrm">linkedin </a>or <a href="https://t.me/geekysrm">telegram</a>. I will try my best to clear your doubts.</p><h3>Subscribe to Soumya’s dev thoughts</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fslidetosubscribe.com%2Fembed%2Fgeekysrm&amp;dntp=1&amp;display_name=Slide+to+Subscribe&amp;url=https%3A%2F%2Fslidetosubscribe.com%2Fgeekysrm%2F&amp;image=https%3A%2F%2Fslidetosubscribe.com%2Fi%2Fgeekysrm.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=slidetosubscribe" width="450" height="152" frameborder="0" scrolling="no"><a href="https://medium.com/media/a595db42ca9a9fe61ab98aa50b0b9f92/href">https://medium.com/media/a595db42ca9a9fe61ab98aa50b0b9f92/href</a></iframe><p><em>You can find me online at:</em></p><p><strong>My website:</strong> <a href="https://soumya.dev/">soumya.dev</a></p><p><strong>My Blog:</strong> <a href="https://soumya.dev/blog">soumya.dev/blog</a></p><p><strong>YouTube: </strong><a href="https://link.soumya.dev/youtube">link.soumya.dev/youtube</a></p><p><strong>LinkedIn:</strong> <a href="https://linkedin.com/in/geekysrm">linkedin.com/in/geekysrm</a></p><p><strong>Twitter:</strong> <a href="https://twitter.com/geekysrm">twitter.com/geekysrm</a></p><p><strong>Github:</strong> <a href="https://github.com/geekysrm">https://github.com/geekysrm</a></p><p><strong>Medium:</strong> <a href="https://medium.com/@geekysrm">https://medium.com/@geekysrm</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f208c2798f92" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>