<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Hardik Sondagar</title>
    <description>The latest articles on Forem by Hardik Sondagar (@hardiksondagar).</description>
    <link>https://forem.com/hardiksondagar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F82425%2F408ed646-64df-47f7-bb55-3e7993e8b419.jpg</url>
      <title>Forem: Hardik Sondagar</title>
      <link>https://forem.com/hardiksondagar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/hardiksondagar"/>
    <language>en</language>
    <item>
      <title>aigit - Git workflow automation with AI</title>
      <dc:creator>Hardik Sondagar</dc:creator>
      <pubDate>Wed, 26 Nov 2025 17:29:12 +0000</pubDate>
      <link>https://forem.com/hardiksondagar/aigit-git-workflow-automation-with-ai-3b17</link>
      <guid>https://forem.com/hardiksondagar/aigit-git-workflow-automation-with-ai-3b17</guid>
      <description>&lt;p&gt;We've all been there.&lt;/p&gt;

&lt;p&gt;It's 11pm. You've been debugging for hours. You finally fix the bug. Time to commit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git commit -m "fix stuff"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or my personal favorite:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Your git history looks like a crime scene. Code reviews are painful because nobody knows what each commit actually did. And six months later, you're trying to figure out why you made a change and the commit message just says "update".&lt;/p&gt;

&lt;p&gt;I got tired of this. So I built aigit.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;What is aigit?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It's a CLI tool that uses AI to write your commit messages, branch names, and PR descriptions. You make changes, run a command, and it figures out what you did.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Commit messages:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add .
aigit commit

→ "feat: add JWT authentication with refresh token support"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Branch names:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aigit branch "add user login"

→ feature/add-user-login-authentication
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pull requests:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aigit pr

→ Creates PR with title and detailed description based on your changes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It also does code review and can explain what changed in any commit.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;How it works&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;aigit reads your git diff, sends it to OpenAI, and gets back a properly formatted message. It uses conventional commits format by default (feat, fix, docs, etc.) so your git history stays consistent.&lt;/p&gt;

&lt;p&gt;The key is in the prompts. I spent time crafting prompts that generate concise, meaningful messages - not the verbose essays that AI tends to write.&lt;/p&gt;

&lt;p&gt;For example, the commit prompt tells the AI:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First line: 50 chars max, imperative mood&lt;/li&gt;
&lt;li&gt;Focus on WHAT changed and WHY, not HOW&lt;/li&gt;
&lt;li&gt;Be specific, avoid vague words like "update" or "fix"&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Installation&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install pipx
pipx install git+https://github.com/hardiksondagar/aigit.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then set your OpenAI API key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aigit config set openai_api_key sk-your-key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. Now &lt;code&gt;aigit commit&lt;/code&gt; works from any repo.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;The commands&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;aigit commit&lt;/code&gt; - Generate commit message from staged changes&lt;/p&gt;

&lt;p&gt;&lt;code&gt;aigit commit -a&lt;/code&gt; - Stage all and commit&lt;/p&gt;

&lt;p&gt;&lt;code&gt;aigit commit -m "auth stuff"&lt;/code&gt; - Give AI a hint for better messages&lt;/p&gt;

&lt;p&gt;&lt;code&gt;aigit branch "description"&lt;/code&gt; - Generate branch name&lt;/p&gt;

&lt;p&gt;&lt;code&gt;aigit pr&lt;/code&gt; - Create GitHub PR with AI-generated title and description&lt;/p&gt;

&lt;p&gt;&lt;code&gt;aigit review&lt;/code&gt; - Code review for bugs, security issues, style&lt;/p&gt;

&lt;p&gt;&lt;code&gt;aigit explain&lt;/code&gt; - Explain what changed in a commit or branch&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;What's next&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I'm working on a "branch context" feature - a markdown file that tracks what you're building on each branch. It auto-updates with every commit and serves as context for AI code editors like Cursor.&lt;/p&gt;

&lt;p&gt;The idea: your AI editor knows exactly what you're working on because there's a living document explaining it.&lt;/p&gt;

&lt;p&gt;Other planned features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Changelog generation from commits&lt;/li&gt;
&lt;li&gt;Support for Claude, Ollama (local/offline), Gemini&lt;/li&gt;
&lt;li&gt;Custom prompt templates for teams&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Try it&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/hardiksondagar/aigit" rel="noopener noreferrer"&gt;https://github.com/hardiksondagar/aigit&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's open source, free to use, and costs about $0.01 per commit with gpt-4o-mini.&lt;/p&gt;

&lt;p&gt;If you've ever written a commit message you're ashamed of, give it a shot. Your future self (and your teammates) will thank you.&lt;/p&gt;




&lt;p&gt;What's the worst commit message you've ever written? I'll go first: "idk"&lt;/p&gt;

</description>
      <category>git</category>
      <category>ai</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Sanitize Facebook Feed - OnlyFriends</title>
      <dc:creator>Hardik Sondagar</dc:creator>
      <pubDate>Thu, 08 Jul 2021 06:51:57 +0000</pubDate>
      <link>https://forem.com/hardiksondagar/sanitize-facebook-feed-onlyfriends-j4a</link>
      <guid>https://forem.com/hardiksondagar/sanitize-facebook-feed-onlyfriends-j4a</guid>
      <description>&lt;p&gt;This small script will unfollow and unlike all pages from your facebook account. It'll bring sanity to your endless feed by including more posts from your real friends.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/**
* Unlike/unfollow pages in facebook.
* Open https://www.facebook.com/pages/?category=liked and scroll down till all liked/followed pages loads.
* Once all pages loads, copy paste this code in console and wait till all pages unliked/unfollowed (Use Google Chrome).
*/

var pages_followed = document.querySelectorAll('[aria-label="Following"]');
var pages_liked = document.querySelectorAll('[aria-label="Liked"]');

function sleep(ms) {
    return new Promise(resolve =&amp;gt; setTimeout(resolve, ms));
}

async function remove(pages) {
    for (let i=0; i &amp;lt; pages.length; i++) {
        try {
            let page = pages[i];
            page.click();
            console.log(`Page ${i+1} removed`);
        } catch {
            console.error(`Page ${i+1} remove failed`);
        } finally {
            await sleep(1000);
        }
    }
}

await remove(pages_liked);
await remove(pages_followed);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>How to create cross repository milestones in Github</title>
      <dc:creator>Hardik Sondagar</dc:creator>
      <pubDate>Sat, 26 Jun 2021 11:40:47 +0000</pubDate>
      <link>https://forem.com/hardiksondagar/how-to-create-cross-repository-milestones-in-github-423o</link>
      <guid>https://forem.com/hardiksondagar/how-to-create-cross-repository-milestones-in-github-423o</guid>
      <description>&lt;p&gt;In this article, I'll show how to use Github's API to create milestones/sprints across multiple repositories.&lt;/p&gt;

&lt;p&gt;If a person or organization is using multiple repositories under single project and doing sprint planning through Github Project, it requires creating same milestones (to name sprint) across multiple repositories.&lt;/p&gt;

&lt;p&gt;Currently, creating milestones across repos is not supported. But one can search using the milestone across multiple repos to display assigned issues in Github Project. Of course, there are plenty of paid tools that do this and many more things.&lt;/p&gt;

&lt;p&gt;At my current organization, we were using Asana to manage sprints and tasks. The recent acquisition of Github by Microsoft gave tones of useful features including the Github Project. &lt;/p&gt;

&lt;p&gt;It was more convenient for us to connect sprints &amp;amp; tasks with the code through linked issues, but we are using multiple repositories for different micro-services and creating sprint through milestones in each repo was painful.&lt;/p&gt;

&lt;p&gt;I believe many of you who are using multiple repos for a single project facing a similar issue. &lt;/p&gt;

&lt;p&gt;Enough talk, let me show code to copy-paste 😂.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// script.js
import { Octokit } from "https://cdn.skypack.dev/@octokit/core";

const token = "YOUR_GITHUB_PERSONAL_ACCESS_TOKEN"
const octokit = new Octokit({ auth: token});
const repos = await octokit.request('GET /user/repos');
const milestones = [{
    "title": "Sprint 1",
    "description": "June 1 to June 7"
    "due_on": "2021-06-01T00:00:00Z"
}, {
    "title": "Sprint 2",
    "description": "June 7 to June 14"
    "due_on": "2021-06-07T00:00:00Z"
}];

for (let r=0; r &amp;lt; repos.length; r++) {
    let repo = repos[r];
    for (let m=0; m &amp;lt; milestones.length; m++) {
        let milestone = milestones[m];
        let payload = {
            owner: repo.owner.login,
            repo: repo.name,
            title: milestone.title,
            description: milestone.description,
            due_on: milestone.due_on
        };
        await octokit.request(`POST /repos/{owner}/{repo}/milestones`, payload);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Follow steps mentioned in the &lt;a href="https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-token"&gt;documentation&lt;/a&gt; to get access token.&lt;/p&gt;

&lt;p&gt;I've built a small web application to achieve this through the user interface. Feel free to use it and modify it as per need.&lt;/p&gt;

&lt;p&gt;Link - &lt;a href="https://hardiksondagar.github.io/cross-repository-milestones/"&gt;hardiksondagar.github.io/cross-repository-milestones&lt;/a&gt;&lt;/p&gt;

</description>
      <category>github</category>
      <category>sprint</category>
      <category>milestone</category>
      <category>project</category>
    </item>
    <item>
      <title>Reuse sessions using cookies in python selenium</title>
      <dc:creator>Hardik Sondagar</dc:creator>
      <pubDate>Tue, 28 Jul 2020 12:59:22 +0000</pubDate>
      <link>https://forem.com/hardiksondagar/reuse-sessions-using-cookies-in-python-selenium-12ca</link>
      <guid>https://forem.com/hardiksondagar/reuse-sessions-using-cookies-in-python-selenium-12ca</guid>
      <description>&lt;p&gt;I have a scenario where I would like to reuse once authenticated/logged-in sessions. I'm using multiple browser simultaneously.&lt;/p&gt;

&lt;p&gt;I've tried plenty of solutions from blogs and StackOverflow answers. &lt;/p&gt;

&lt;h5&gt;
  
  
  1. Using user-data-dir and profile-directory
&lt;/h5&gt;

&lt;p&gt;These chrome options which solves purpose if you opening one browser at a time, but if you open multiple windows it'll throw an error saying &lt;code&gt;user data directory is already in use&lt;/code&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  2. Using cookies
&lt;/h5&gt;

&lt;p&gt;Cookies can be shared across multiple browsers. Code available in SO answers are have most of the important blocks on how to use cookies in selenium. Here I'm extending those solutions to complete the flow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# selenium-driver.py
import pickle
from selenium import webdriver


class SeleniumDriver(object):
    def __init__(
        self,
        # chromedriver path
        driver_path='/Users/hardiksondagar/work/chrome/chromedriver',
        # pickle file path to store cookies
        cookies_file_path='/Users/hardiksondagar/work/chrome/cookies.pkl',
        # list of websites to reuse cookies with
        cookies_websites=["https://facebook.com"]

    ):
        self.driver_path = driver_path
        self.cookies_file_path = cookies_file_path
        self.cookies_websites = cookies_websites
        chrome_options = webdriver.ChromeOptions()
        self.driver = webdriver.Chrome(
            executable_path=self.driver_path,
            options=chrome_options
        )
        try:
            # load cookies for given websites
            cookies = pickle.load(open(self.cookies_file_path, "rb"))
            for website in self.cookies_websites:
                self.driver.get(website)
                for cookie in cookies:
                    self.driver.add_cookie(cookie)
                self.driver.refresh()
        except Exception as e:
            # it'll fail for the first time, when cookie file is not present
            print(str(e))
            print("Error loading cookies")

    def save_cookies(self):
        # save cookies
        cookies = self.driver.get_cookies()
        pickle.dump(cookies, open(self.cookies_file_path, "wb"))

    def close_all(self):
        # close all open tabs
        if len(self.driver.window_handles) &amp;lt; 1:
            return
        for window_handle in self.driver.window_handles[:]:
            self.driver.switch_to.window(window_handle)
            self.driver.close()

    def quit(self):
        self.save_cookies()
        self.close_all()
        self.driver.quit()



def is_fb_logged_in():
    driver.get("https://facebook.com")
    if 'Facebook – log in or sign up' in driver.title:
        return False
    else:
        return True


def fb_login(username, password):
    username_box = driver.find_element_by_id('email')
    username_box.send_keys(username)

    password_box = driver.find_element_by_id('pass')
    password_box.send_keys(password)

    login_box = driver.find_element_by_id('loginbutton')
    login_box.click()


if __name__ == '__main__':
    """
    Run  - 1
    First time authentication and save cookies

    Run  - 2
    Reuse cookies and use logged-in session
    """
    selenium_object = SeleniumDriver()
    driver = selenium_object.driver
    username = "fb-username"
    password = "fb-password"

    if is_fb_logged_in(driver):
        print("Already logged in")
    else:
        print("Not logged in. Login")
        fb_login(username, password)

    selenium_object.quit()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Run 1: Login &amp;amp; Save Cookies
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python selenium-driver.py
[Errno 2] No such file or directory: '/Users/hardiksondagar/work/chrome/cookies.pkl'
Error loading cookies
Not logged in. Login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will open facebook login window and enter username-password to login. Once logged-in it'll close the browser and save cookies.&lt;/p&gt;

&lt;h3&gt;
  
  
  Run 2: Reuse cookies to continue loggedin session
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python selenium-driver.py
Already logged in
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will open logged in session of facebook using stored cookies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Requirements&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Python 3.7&lt;/li&gt;
&lt;li&gt;Selenium Webdriver&lt;/li&gt;
&lt;li&gt;Pickle&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>selenium</category>
      <category>python</category>
      <category>webdriver</category>
    </item>
    <item>
      <title>How to publish a message with priority in RabbitMQ</title>
      <dc:creator>Hardik Sondagar</dc:creator>
      <pubDate>Wed, 25 Mar 2020 17:24:44 +0000</pubDate>
      <link>https://forem.com/hardiksondagar/how-to-publish-message-with-priority-in-rabbitmq-1jd6</link>
      <guid>https://forem.com/hardiksondagar/how-to-publish-message-with-priority-in-rabbitmq-1jd6</guid>
      <description>&lt;h3&gt;
  
  
  Dependencies
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;RabbitMQ (&amp;gt;=3.5.0)&lt;/li&gt;
&lt;li&gt;Python 3.6&lt;/li&gt;
&lt;li&gt;Pika&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this article, we will learn how to publish and consume messages with priority in RabbitMQ. We will be using python language and pika library for AMQP.&lt;/p&gt;

&lt;p&gt;Here we are declaring queue with &lt;code&gt;x-max-priority&lt;/code&gt; argument. This argument is integer number from 0 to 255. It describes that the queue can accept messages with max priority equal to this number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pika

queue_name = 'priority-queue'
max_priority = 10

# connect and get channel
parameters = pika.ConnectionParameters('localhost')
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
# declare queue with max priority
channel.queue_declare(
    queue=queue_name, arguments={"x-max-priority": max_priority}
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Publish messages with different priorities.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def publish(message, priority)
    message = message + str(priority)
    channel.basic_publish(
        properties=pika.BasicProperties(priority=priority),
        exchange='',
        routing_key=queue_name,
        body=message
    )
# message with priority 0
message = 'message-with-priority-'
publish(message, 0)
# message with priority 5
publish(message, 5)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now consume messages from the queue and find that message with higher priority will be consumed first even if it was published later.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;method_frame, header_frame, body = channel.basic_get(queue_name)
print(body)
# message-with-priority-5
method_frame, header_frame, body = channel.basic_get(queue_name)
print(body)
# message-with-priority-0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Source Code : &lt;a href="https://github.com/hardiksondagar/rabbitmq-priority-queue-example"&gt;rabbitmq-priority-queue-example&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>rabbitmq</category>
    </item>
    <item>
      <title>How to use multiple versions of Python</title>
      <dc:creator>Hardik Sondagar</dc:creator>
      <pubDate>Mon, 20 Aug 2018 06:49:45 +0000</pubDate>
      <link>https://forem.com/hardiksondagar/how-to-use-multiple-versions-of-python-2l2c</link>
      <guid>https://forem.com/hardiksondagar/how-to-use-multiple-versions-of-python-2l2c</guid>
      <description>&lt;p&gt;My system has &lt;code&gt;2.7.6&lt;/code&gt; as a default python version and most of my applications runs on it, but one project that I'm working with AWS IoT requires version &lt;code&gt;2.7.9&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;I will show how to run multiple versions of python using &lt;strong&gt;pyenv&lt;/strong&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisite
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo apt-get update
$ sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Install pyenv
&lt;/h3&gt;

&lt;p&gt;Install pyenv with one-liner provided by the automatic installer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add following lines at the end of .bashrc file and restart the terminal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export PATH="/root/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; : For &lt;code&gt;zsh&lt;/code&gt; use .zshrc file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Usage
&lt;/h3&gt;

&lt;p&gt;Install python version &lt;code&gt;2.7.9&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pyenv install 2.7.9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;List all installed python versions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pyenv versions
* system (set by /home/ubuntu/.pyenv/version)
  2.7.9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use &lt;code&gt;2.7.9&lt;/code&gt; version for your project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ mkdir aws-iot-mqtt
$ cd aws-iot-mqtt
$ pyenv local 2.7.9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, verify which python version is enabled for current directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Inside `aws-iot-mqtt` directory
$ python -V
Python 2.7.9
// Check version in parent directory
$ cd ..
$ python -V
Python 2.7.6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: &lt;em&gt;Tested on &lt;code&gt;Ubuntu 16.04&lt;/code&gt; server edition&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>pyenv</category>
      <category>ubuntu</category>
    </item>
    <item>
      <title>How to use AWS EBS volume as a swap memory</title>
      <dc:creator>Hardik Sondagar</dc:creator>
      <pubDate>Sat, 21 Jul 2018 19:35:47 +0000</pubDate>
      <link>https://forem.com/hardiksondagar/how-to-use-aws-ebs-volume-as-a-swap-memory-5d15</link>
      <guid>https://forem.com/hardiksondagar/how-to-use-aws-ebs-volume-as-a-swap-memory-5d15</guid>
      <description>&lt;h3&gt;
  
  
  What is swap space?
&lt;/h3&gt;

&lt;p&gt;Swap space in Linux can be used when a system requires more memory than it has been physically allocated (RAM). When swap space is enabled, Linux systems can swap infrequently used memory pages from physical memory to swap space (either a dedicated partition or a swap file in an existing file system) and free up that space for memory pages that require high-speed access. [&lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-store-swap-volumes.html"&gt;1&lt;/a&gt;]&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1 - Create EBS Volume
&lt;/h3&gt;

&lt;p&gt;Follow steps to create EBS Volume in AWS Console, that we'll use as a swap memory.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to EC2 Dashboard&lt;/li&gt;
&lt;li&gt;Select EBS Volumes&lt;/li&gt;
&lt;li&gt;Create Volume&lt;/li&gt;
&lt;li&gt;Recommended size of swap volume is 2 times of RAM [&lt;a href="https://askubuntu.com/questions/49109/i-have-16gb-ram-do-i-need-32gb-swap"&gt;2&lt;/a&gt;]&lt;/li&gt;
&lt;li&gt;Select availability zone same as your EC2 instance&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 2 - Attach EBS Volume to EC2
&lt;/h3&gt;

&lt;p&gt;Select EBS Volume that we just created for swap and your EC2 instance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3 - Set EBS Volume as swap space
&lt;/h3&gt;

&lt;p&gt;Run &lt;code&gt;lsblk&lt;/code&gt; to check new volume, it will appear as &lt;code&gt;/dev/xvdf&lt;/code&gt; on instance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
xvda    202:0    0  256G  0 disk
└─xvda1 202:1    0  256G  0 part /
xvdf    202:80   0   32G  0 disk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set up the swap area&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo mkswap /dev/xvdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enable swap&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo swapon /dev/xvdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make this swap setting persist by adding following line in &lt;code&gt;/etc/fstab&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo nano /etc/fstab
/dev/xvdf none swap sw 0 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4 - Check swap space
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo swapon --show
NAME      TYPE      SIZE   USED PRIO
/dev/xvdf partition  32G 279.9M   -1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>aws</category>
      <category>swap</category>
      <category>ec2</category>
      <category>ebs</category>
    </item>
  </channel>
</rss>
