<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Madhav Paudel</title>
    <description>I am student of Computer Science and Information Technology at Tribhuvan University.</description>
    <link>https://blog.poudelmadhav.com.np/</link>
    <atom:link href="https://blog.poudelmadhav.com.np/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Tue, 13 May 2025 01:27:46 -0545</pubDate>
    <lastBuildDate>Tue, 13 May 2025 01:27:46 -0545</lastBuildDate>
    <generator>Jekyll v3.10.0</generator>
    
      <item>
        <title>How to add ssh and gpg keys in GitHub or GitLab?</title>
        <description>&lt;h1 id=&quot;configure-git&quot;&gt;Configure git&lt;/h1&gt;
&lt;p&gt;Initial configuration of git if you have not set yet.&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git config --global color.ui true
git config --global user.name &quot;YOUR NAME&quot;
git config --global user.email &quot;YOUR@EMAIL.com&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h1 id=&quot;adding-ssh-key&quot;&gt;Adding SSH key&lt;/h1&gt;
&lt;p&gt;Run this command in your terminal to generate new ssh key&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ssh-keygen &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; ed25519 &lt;span class=&quot;nt&quot;&gt;-C&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;YOUR@EMAIL.com&quot;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Use this if your system doesn&apos;t support the Ed25519&lt;/span&gt;
ssh-keygen &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; rsa &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt; 4096 &lt;span class=&quot;nt&quot;&gt;-C&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;YOUR@EMAIL.com&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The next step is to take the newly generated SSH key and add it to your Github or GitLab account. You can add SSH key in your setting of GitLab or GitHub. You want to copy and paste the output of the following command and paste it in your ssh key setting.&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# For ed25519&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; ~/.ssh/id_ed25519.pub

&lt;span class=&quot;c&quot;&gt;# For RSA&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; ~/.ssh/id_rsa.pub
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Once you’ve done this, you can check and see if it worked:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# For GitHub&lt;/span&gt;
ssh &lt;span class=&quot;nt&quot;&gt;-T&lt;/span&gt; git@github.com

&lt;span class=&quot;c&quot;&gt;# OR for GitLab&lt;/span&gt;
ssh &lt;span class=&quot;nt&quot;&gt;-T&lt;/span&gt; git@gitlab.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;You will get a message like this&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# For GitHub
Hi &amp;lt;your_usename&amp;gt;! You&apos;ve successfully authenticated, but GitHub does not provide shell access.

# OR for GitLab
Welcome to GitLab, @&amp;lt;your_username&amp;gt;!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;signing-commits-with-gpg&quot;&gt;Signing commits with GPG&lt;/h1&gt;
&lt;p&gt;GitHub or GitLab can show whether a commit is verified or not when signed with a GPG key. All you need to do is upload the public GPG key in your profile settings.&lt;/p&gt;

&lt;h1 id=&quot;generating-a-gpg-key&quot;&gt;Generating a GPG key&lt;/h1&gt;
&lt;p&gt;If you don’t already have a GPG key, the following steps will help you get started:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.gnupg.org/download/index.html&quot;&gt;Install GPG&lt;/a&gt; for your operating system. If your Operating System has &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gpg2&lt;/code&gt; installed, replace &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gpg&lt;/code&gt; with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gpg2&lt;/code&gt; in the following commands.&lt;/li&gt;
  &lt;li&gt;Generate the private/public key pair with the following command, which will spawn a series of questions:
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gpg &lt;span class=&quot;nt&quot;&gt;--full-gen-key&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;The first question is which algorithm can be used. Select the kind you want or press &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Enter&lt;/code&gt; to choose the default ECC (sign and encrypt):
Please select what kind of key you want:
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Please &lt;span class=&quot;k&quot;&gt;select &lt;/span&gt;what kind of key you want:
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;1&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; RSA and RSA
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;2&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; DSA and Elgamal
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;3&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; DSA &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;sign only&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;4&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; RSA &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;sign only&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;9&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; ECC &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;sign and encrypt&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;default&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;10&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; ECC &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;sign only&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;14&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; Existing key from card
Your selection? 9
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;The next question is which elliptic curve you want. We recommend to go with the default one. Select the kind you want or press &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Enter&lt;/code&gt;
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Please &lt;span class=&quot;k&quot;&gt;select &lt;/span&gt;which elliptic curve you want:
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;1&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; Curve 25519 &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;default&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;4&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; NIST P-384
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;6&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; Brainpool P-256
Your selection? 1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;Next, you need to specify the validity period of your key. This is something subjective, and you can use the default value which is to never expire:
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Please specify how long the key should be valid.
      0 &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; key does not expire
   &amp;lt;n&amp;gt;  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; key expires &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;n days
   &amp;lt;n&amp;gt;w &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; key expires &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;n weeks
   &amp;lt;n&amp;gt;m &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; key expires &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;n months
   &amp;lt;n&amp;gt;y &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; key expires &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;n years
Key is valid &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt;? &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;0&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; 0
Key does not expire at all
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;Confirm that the answers you gave were correct by typing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;y&lt;/code&gt;:
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Is this correct? &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;y/N&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; y
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;Enter you real name, the email address to be associated with this key (should match a verified email address you use in GitLab) and an optional comment (press Enter to skip):
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;GnuPG needs to construct a user ID to identify your key.
Real name: Mr. Robot
Email address: &amp;lt;your_email&amp;gt;
Comment:
You selected this USER-ID:
&lt;span class=&quot;s2&quot;&gt;&quot;Mr. Robot &amp;lt;your_email&amp;gt;&quot;&lt;/span&gt;
Change &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;N&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;ame, &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;C&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;omment, &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;E&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;mail or &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;O&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;kay/&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;Q&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;uit? O
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;Pick a strong password when asked and type it twice to confirm.&lt;/li&gt;
  &lt;li&gt;Use the following command to list the private GPG key you just created:
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gpg &lt;span class=&quot;nt&quot;&gt;--list-secret-keys&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--keyid-format&lt;/span&gt; LONG &amp;lt;your_email&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;p&gt;&lt;i&gt;Replace &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;your_email&amp;gt;&lt;/code&gt; with the email address you entered above.&lt;/i&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;Copy the GPG key ID that starts with sec. In the following example, that’s 5C426E801C00183B:
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sec   ed25519/5C426E801C00183B 2025-05-13 &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;SC]
  1CFD5B42CF473B60466B69325C426E801C00183B
uid                 &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;ultimate] Mr. Robot &amp;lt;your_email&amp;gt;
ssb   cv25519/B3ED6E8715E10A6E 2025-05-13 &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;E]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;Export the public key of that ID (replace your key ID from the previous step):
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gpg &lt;span class=&quot;nt&quot;&gt;--armor&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--export&lt;/span&gt; 5C426E801C00183B
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;Finally, copy the public key and add it in your profile settings&lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;associating-your-gpg-key-with-git&quot;&gt;Associating your GPG key with Git&lt;/h1&gt;
&lt;p&gt;After you have created your GPG key and added it to your account, it’s time to tell Git which key to use.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Use the following command to list the private GPG key you just created:
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gpg &lt;span class=&quot;nt&quot;&gt;--list-secret-keys&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--keyid-format&lt;/span&gt; LONG &amp;lt;your_email&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;p&gt;Replace &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;your_email&amp;gt;&lt;/code&gt; with the email address you entered above.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;Copy the GPG key ID that starts with sec. In the following example, that’s 5C426E801C00183B:
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sec   ed25519/5C426E801C00183B 2025-05-13 &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;SC]
   1CFD5B42CF473B60466B69325C426E801C00183B
uid                 &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;ultimate] Mr. Robot &amp;lt;your_email&amp;gt;
ssb   cv25519/B3ED6E8715E10A6E 2025-05-13 &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;E]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;Tell Git to use that key to sign the commits:
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git config &lt;span class=&quot;nt&quot;&gt;--global&lt;/span&gt; user.signingkey 5C426E801C00183B
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;p&gt;Replace 5C426E801C00183B with your GPG key ID.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;signing-commits&quot;&gt;Signing commits&lt;/h1&gt;
&lt;p&gt;After you have created your GPG key and added it to your account, you can start signing your commits:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Commit like you used to, the only difference is the addition of the -S flag:
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git commit &lt;span class=&quot;nt&quot;&gt;-S&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;My commit msg&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;Enter the passphrase of your GPG key when asked.&lt;/li&gt;
  &lt;li&gt;Push to GitLab and check that your commits are verified.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you don’t want to type the -S flag every time you commit, you can tell Git to sign your commits automatically:&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git config &lt;span class=&quot;nt&quot;&gt;--global&lt;/span&gt; commit.gpgsign &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;verifying-commits&quot;&gt;Verifying commits&lt;/h1&gt;
&lt;p&gt;Within a project or merge request, navigate to the Commits tab. Signed commits will show a badge containing either “Verified” or “Unverified”, depending on the verification status of the GPG signature.
&lt;img src=&quot;https://gitlab.com/gitlab-org/gitlab-foss/-/raw/13becf042617083d6d95507dd621934077370c5e/doc/user/project/repository/gpg_signed_commits/img/project_signed_and_unsigned_commits.png&quot; alt=&quot;Signed and unsigned commits&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;troubleshooting&quot;&gt;Troubleshooting&lt;/h1&gt;
&lt;ul&gt;
  &lt;li&gt;run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gpg --version&lt;/code&gt;, and make sure you have GnuPG version 2+ (not version 1) installed&lt;/li&gt;
  &lt;li&gt;run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo &quot;test&quot; | gpg --clearsign&lt;/code&gt;, to make sure &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gpg&lt;/code&gt; itself is working&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you get an error message saying &lt;em&gt;“Inappropriate ioctl for device”&lt;/em&gt;, do this:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;export GPG_TTY=$(tty)&lt;/code&gt; and/or add that to your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.bashrc&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;˜/.bash_profile&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;referece-links&quot;&gt;Referece Links&lt;/h1&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.gitlab.com/user/project/repository/signed_commits/gpg/&quot;&gt;GitLab Docs&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://gorails.com/setup/ubuntu/24.04#git&quot;&gt;GoRails&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/a/41054093/7735007&quot;&gt;Stack Overflow&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Tue, 13 May 2025 01:27:00 -0545</pubDate>
        <link>https://blog.poudelmadhav.com.np/how-to-add-ssh-and-gpg-kyes-in-github-or-gitlab/</link>
        <guid isPermaLink="true">https://blog.poudelmadhav.com.np/how-to-add-ssh-and-gpg-kyes-in-github-or-gitlab/</guid>
        
        
        <category>ssh</category>
        
        <category>gpg</category>
        
      </item>
    
      <item>
        <title>Starting docker in rails 7.1 with a separate MySQL container</title>
        <description>&lt;h2 id=&quot;setting-up-mysql&quot;&gt;Setting Up MySQL&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Pull the MySQL image:&lt;/strong&gt;&lt;/p&gt;

    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;docker pull mysql/mysql-server
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Run the MySQL container:&lt;/strong&gt;&lt;/p&gt;

    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;docker run &lt;span class=&quot;nt&quot;&gt;-it&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;mysql_container &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; 3307:3306 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;MYSQL_ROOT_PASSWORD&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;password &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;MYSQL_ROOT_HOST&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;% &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  mysql/mysql-server &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--default-authentication-plugin&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;mysql_native_password
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;ul&gt;
      &lt;li&gt;Explanation:
        &lt;ul&gt;
          &lt;li&gt;-it: Run in interactive.&lt;/li&gt;
          &lt;li&gt;-d: Run the container in the background.&lt;/li&gt;
          &lt;li&gt;–name=mysql_container: Name the container for easier management.&lt;/li&gt;
          &lt;li&gt;-p 3307:3306: Map the container port 3306 (MySQL) to host port 3307.&lt;/li&gt;
          &lt;li&gt;-e MYSQL_ROOT_PASSWORD=password: Set the root password for the MySQL user.&lt;/li&gt;
          &lt;li&gt;-e MYSQL_ROOT_HOST=%: Allow connections from any host.&lt;/li&gt;
          &lt;li&gt;–default-authentication-plugin=mysql_native_password: Use the traditional password authentication plugin.&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Get the container’s IP Address:&lt;/strong&gt;&lt;/p&gt;

    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;docker inspect mysql_container | &lt;span class=&quot;nb&quot;&gt;grep &lt;/span&gt;IPAddress
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;This will display the container’s IP address, which will be used later.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Set environment variables:&lt;/strong&gt;&lt;/p&gt;

    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;DATABASE_URL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;mysql2://root:password@&amp;lt;container_ip&amp;gt;/&amp;lt;db_name&amp;gt;:3306?encoding=utf8mb4&apos;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;RAILS_MASTER_KEY&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&amp;lt;rails_master_key&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;ul&gt;
      &lt;li&gt;Replace &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;container_ip&amp;gt;&lt;/code&gt; with the IP address obtained in the previous step.&lt;/li&gt;
      &lt;li&gt;Replace &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;db_name&amp;gt;&lt;/code&gt; with the name of the database you want to use.&lt;/li&gt;
      &lt;li&gt;Replace &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;rails_master_key&amp;gt;&lt;/code&gt; with the master key from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;config/master.key&lt;/code&gt;.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;running-project&quot;&gt;Running project&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Build the project image:&lt;/strong&gt;&lt;/p&gt;

    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;docker-compose build &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; &amp;lt;rails_app&amp;gt; &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;ul&gt;
      &lt;li&gt;Replace &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;rails_app&amp;gt;&lt;/code&gt; with the name you want to give to the image.&lt;/li&gt;
      &lt;li&gt;This will build the image using the Dockerfile.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Run the project container:&lt;/strong&gt;&lt;/p&gt;

    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;docker run &lt;span class=&quot;nt&quot;&gt;--rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-it&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; 3000:3000 &lt;span class=&quot;nt&quot;&gt;--name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&amp;lt;rails_app_container&amp;gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;DATABASE_URL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$DATABASE_URL&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;RAILS_MASTER_KEY&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$RAILS_MASTER_KEY&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &amp;lt;rails_app&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;ul&gt;
      &lt;li&gt;Replace &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;rails_app_container&amp;gt;&lt;/code&gt; with the name you want to give to the container.&lt;/li&gt;
      &lt;li&gt;Replace &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;rails_app&amp;gt;&lt;/code&gt; with the name of the image you built in the previous step.&lt;/li&gt;
      &lt;li&gt;Explanation:
        &lt;ul&gt;
          &lt;li&gt;–rm: Remove the container when it stops.&lt;/li&gt;
          &lt;li&gt;-it: Run in interactive.&lt;/li&gt;
          &lt;li&gt;-p 3000:3000: Map the container port 3000 (Rails) to host port 3000.&lt;/li&gt;
          &lt;li&gt;-e DATABASE_URL=$DATABASE_URL: Set the database URL environment variable.&lt;/li&gt;
          &lt;li&gt;-e RAILS_MASTER_KEY=$RAILS_MASTER_KEY: Set the Rails master key environment variable.&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;debugging&quot;&gt;Debugging&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;View MySQL container logs:&lt;/strong&gt;&lt;/p&gt;

    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;docker logs mysql_container
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Enter the MySQL container:&lt;/strong&gt;&lt;/p&gt;

    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;docker &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-it&lt;/span&gt; mysql_container bash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;ul&gt;
      &lt;li&gt;This will open a bash shell inside the container.&lt;/li&gt;
      &lt;li&gt;You can then run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mysql -u root -p&lt;/code&gt; to enter the MySQL command line.&lt;/li&gt;
      &lt;li&gt;Use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exit&lt;/code&gt; to leave the container.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;controlling-the-mysql-container&quot;&gt;Controlling the MySQL container&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Stop the container:&lt;/strong&gt;&lt;/p&gt;

    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  docker stop mysql_container
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Start the container:&lt;/strong&gt;&lt;/p&gt;

    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  docker start mysql_container
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Remove the container:&lt;/strong&gt;&lt;/p&gt;

    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  docker &lt;span class=&quot;nb&quot;&gt;rm &lt;/span&gt;mysql_container
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Thu, 29 Feb 2024 02:00:28 -0545</pubDate>
        <link>https://blog.poudelmadhav.com.np/starting-docker-in-rails-7-with-separate-mysql-container/</link>
        <guid isPermaLink="true">https://blog.poudelmadhav.com.np/starting-docker-in-rails-7-with-separate-mysql-container/</guid>
        
        
        <category>rails</category>
        
        <category>docker</category>
        
      </item>
    
      <item>
        <title>Install ruby with rbenv and ruby-build</title>
        <description>&lt;p&gt;To install Ruby using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ruby-build&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rbenv&lt;/code&gt;, you can follow these steps:&lt;/p&gt;

&lt;h3 id=&quot;step-1&quot;&gt;Step 1&lt;/h3&gt;
&lt;p&gt;First, make sure you have &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ruby-build&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rbenv&lt;/code&gt; installed on your system. You can check if you have them installed by running the following commands in your terminal:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;which ruby-build
which rbenv
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If either of these commands returns a path, it means that the corresponding tool is already installed on your system. If not, you can follow the installation instructions for your operating system.&lt;/p&gt;

&lt;h3 id=&quot;step-2&quot;&gt;Step 2&lt;/h3&gt;
&lt;p&gt;Next, check if the version of Ruby you want to install is available in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ruby-build&lt;/code&gt;. You can do this by running the following command:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ruby-build &lt;span class=&quot;nt&quot;&gt;--definitions&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;grep&lt;/span&gt; &amp;lt;version&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Replace &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;version&amp;gt;&lt;/code&gt; with the version of Ruby you want to install. If the version is available in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ruby-build&lt;/code&gt;, you can proceed to step 3. Otherwise, you will need to wait for the update to become available in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ruby-build&lt;/code&gt;, or you can try installing Ruby manually.&lt;/p&gt;

&lt;h3 id=&quot;step-3&quot;&gt;Step 3&lt;/h3&gt;
&lt;p&gt;Install the Ruby version using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rbenv&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ruby-build&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;rbenv &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &amp;lt;version&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Replace &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;version&amp;gt;&lt;/code&gt; with the version of Ruby you want to install. This will download the Ruby source code and compile it, which may take some time.&lt;/p&gt;

&lt;h3 id=&quot;step-4&quot;&gt;Step 4&lt;/h3&gt;
&lt;p&gt;Once the installation is complete, you can set the global version of Ruby to use:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;rbenv global &amp;lt;version&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will set the global version of Ruby to the version you just installed.&lt;/p&gt;

&lt;h3 id=&quot;step-5&quot;&gt;Step 5&lt;/h3&gt;
&lt;p&gt;Finally, verify that Ruby was installed correctly by running the following command:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ruby &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This should display the version of Ruby you just installed.&lt;/p&gt;

&lt;p&gt;If the version of Ruby you want to install is not available in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ruby-build&lt;/code&gt; yet, but it is available in the official release, you can download the source code from the Ruby website and compile it manually. Once you have the source code, you can use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ruby-build&lt;/code&gt; to compile and install it:&lt;/p&gt;

&lt;h3 id=&quot;step-1-1&quot;&gt;Step 1&lt;/h3&gt;
&lt;p&gt;Download the Ruby source code from the official Ruby website: &lt;a href=&quot;https://www.ruby-lang.org/en/downloads&quot; target=&quot;_blank&quot;&gt;https://www.ruby-lang.org/en/downloads&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;step-2-1&quot;&gt;Step 2&lt;/h3&gt;
&lt;p&gt;Extract the source code to a directory of your choice.&lt;/p&gt;

&lt;h3 id=&quot;step-3-1&quot;&gt;Step 3&lt;/h3&gt;
&lt;p&gt;Use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ruby-build&lt;/code&gt; to compile and install the Ruby version:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ruby-build &amp;lt;path/to/source/code&amp;gt; &amp;lt;&lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt;/path&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Replace &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;path/to/source/code&amp;gt;&lt;/code&gt; with the path to the directory containing the extracted source code, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;install/path&amp;gt;&lt;/code&gt; with the path where you want to install Ruby.&lt;/p&gt;

&lt;h3 id=&quot;step-4-1&quot;&gt;Step 4&lt;/h3&gt;
&lt;p&gt;Once the installation is complete, you can set the global version of Ruby to use:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;rbenv global &amp;lt;version&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;step-5-1&quot;&gt;Step 5&lt;/h3&gt;
&lt;p&gt;Replace &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;version&amp;gt;&lt;/code&gt; with the version of Ruby you just installed.&lt;/p&gt;

&lt;p&gt;Finally, verify that Ruby was installed correctly by running the following command:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ruby &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This should display the version of Ruby you just installed.&lt;/p&gt;
</description>
        <pubDate>Thu, 30 Mar 2023 22:44:28 -0545</pubDate>
        <link>https://blog.poudelmadhav.com.np/install-ruby-with-rbenv-and-ruby-build/</link>
        <guid isPermaLink="true">https://blog.poudelmadhav.com.np/install-ruby-with-rbenv-and-ruby-build/</guid>
        
        
        <category>ruby</category>
        
      </item>
    
      <item>
        <title>B.Sc. CSIT Sixth Semester All Questions 2075</title>
        <description>&lt;p&gt;Here is a collection of all subjects of B.Sc.CSIT sixth semester questions 2075. Click the respective subject to view or download the question.&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;Compulsory Subjects&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;&lt;a href=&quot;../assets/files/2075/CSc_351_SE_2075.pdf&quot; title=&quot;Software Engineering&quot;&gt;Software Engineering (CSc.351)&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;../assets/files/2075/CSc_352_CDC_2075.pdf&quot; title=&quot;Compiler Design and Construction&quot;&gt;Compiler Design and Construction (CSc.352)&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;../assets/files/2075/CSc_353_WT_2075.pdf&quot; title=&quot;Web Technologies&quot;&gt;Web Technologies (CSc.353)&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;../assets/files/2075/CSc_354_RTS_2075.pdf&quot; title=&quot;Real Time Systems&quot;&gt;Real Time Systems (CSc.354)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;&lt;b&gt;Alternative Subjects&lt;/b&gt;&lt;/h4&gt;
&lt;p&gt;&lt;a href=&quot;../assets/files/2075/CSc_356_EC_2075.pdf&quot; title=&quot;Fundamental of E-commerce&quot;&gt;Fundamental of E-commerce (CSc.356)&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;../assets/files/2075/CSc_360_NCC_2075.pdf&quot; title=&quot;Net Centric Computing&quot;&gt;Net Centric Computing (CSc.360)&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;../assets/files/2075/CSc_362_ESP_2075.pdf&quot; title=&quot;Embedded System Programming&quot;&gt;Embedded System Programming (CSc.362)&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;../assets/files/2075/CSc_363_IP_2075.pdf&quot; title=&quot;Image Processing&quot;&gt;Image Processing (CSc.363)&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;
</description>
        <pubDate>Tue, 29 Jan 2019 08:38:47 -0545</pubDate>
        <link>https://blog.poudelmadhav.com.np/csit-sixth-semester-all-questions-2075/</link>
        <guid isPermaLink="true">https://blog.poudelmadhav.com.np/csit-sixth-semester-all-questions-2075/</guid>
        
        
        <category>old questions collection</category>
        
      </item>
    
      <item>
        <title>C++ program of transfering balance from one account to another</title>
        <description>&lt;script src=&quot;https://gist.github.com/poudelmadhav/6b7264c97c377f094b3cb765d05589a3.js&quot;&gt;&lt;/script&gt;

</description>
        <pubDate>Fri, 20 Jul 2018 01:49:47 -0545</pubDate>
        <link>https://blog.poudelmadhav.com.np/cplus-program-to-transfer-balance/</link>
        <guid isPermaLink="true">https://blog.poudelmadhav.com.np/cplus-program-to-transfer-balance/</guid>
        
        
        <category>c++ program</category>
        
      </item>
    
      <item>
        <title>Simple Network Design With DNS Servers in Packet Tracer</title>
        <description>&lt;p&gt;&lt;img src=&quot;../assets/images/cisco-network/1_overall_design.png&quot; alt=&quot;overall-design-of-network&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;i&gt;fig. Simple network with DNS and FTP server&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;We should use copper cross-over cable(dotted lines) to connect from router to router and copper straight-through cable(smooth line) to connect from router to switch and switch to end devices.&lt;/p&gt;

&lt;p&gt;Here we are assuming the ip addresses as given in the figure above.&lt;/p&gt;

&lt;h1 id=&quot;ip-configuration&quot;&gt;IP configuration:&lt;/h1&gt;
&lt;p&gt;We are configuring all the static ip. An example for PC0 is given in the figure below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PC0&lt;/strong&gt;&lt;br /&gt;
IP address: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.1.2&lt;/code&gt; &lt;br /&gt;
Subnet Mask: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;255.255.255.0&lt;/code&gt; &lt;br /&gt;
Default Gateway: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.1.1&lt;/code&gt; &lt;br /&gt;
DNS Server: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.5.4&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;../assets/images/cisco-network/2_com0_ip_configuration.png&quot; alt=&quot;ip-configuration-pc0&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;i&gt;fig. IP configuration for PC0&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;In the same way, you can configure IP of all end devices as:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PC1&lt;/strong&gt;&lt;br /&gt;
IP address: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.1.3&lt;/code&gt; &lt;br /&gt;
Subnet Mask: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;255.255.255.0&lt;/code&gt; &lt;br /&gt;
Default Gateway: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.1.1&lt;/code&gt; &lt;br /&gt;
DNS Server: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.5.4&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PC2&lt;/strong&gt;&lt;br /&gt;
IP address: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.5.2&lt;/code&gt; &lt;br /&gt;
Subnet Mask: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;255.255.255.0&lt;/code&gt; &lt;br /&gt;
Default Gateway: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.5.1&lt;/code&gt; &lt;br /&gt;
DNS Server: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.5.4&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Web and FTP server&lt;/strong&gt;&lt;br /&gt;
IP address: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.5.3&lt;/code&gt; &lt;br /&gt;
Subnet Mask: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;255.255.255.0&lt;/code&gt; &lt;br /&gt;
Default Gateway: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.5.1&lt;/code&gt; &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DNS Server&lt;/strong&gt;&lt;br /&gt;
IP address: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.5.4&lt;/code&gt; &lt;br /&gt;
Subnet Mask: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;255.255.255.0&lt;/code&gt; &lt;br /&gt;
Default Gateway: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.5.1&lt;/code&gt; &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Make sure that we have not write DNS server to the Web, FTP and DNS server.&lt;/p&gt;

&lt;h1 id=&quot;for-router&quot;&gt;For Router&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Router0 To Switch0&lt;/strong&gt;&lt;br /&gt;
Ip address: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.1.1&lt;/code&gt; &lt;br /&gt;
Subnet Mask: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;255.255.255.0&lt;/code&gt;&lt;br /&gt;
&lt;img src=&quot;../assets/images/cisco-network/3_router0_to_computer_ip.png&quot; alt=&quot;ip-configuration-router0-switch0&quot; /&gt;
&lt;em&gt;fig. An example figure for IP configuration of Router0 To Switch0&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Router0 To Router1&lt;/strong&gt;&lt;br /&gt;
Ip address: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.50.1&lt;/code&gt; &lt;br /&gt;
Subnet Mask: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;255.255.255.0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Router1 To Switch1&lt;/strong&gt;&lt;br /&gt;
Ip address: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.5.1&lt;/code&gt; &lt;br /&gt;
Subnet Mask: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;255.255.255.0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Router1 To Router0&lt;/strong&gt;&lt;br /&gt;
Ip address: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.50.2&lt;/code&gt; &lt;br /&gt;
Subnet Mask: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;255.255.255.0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;For the network to communicate for different network, we have to set static routes at router. We can do that by clicking on the router and from the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;config&lt;/code&gt; option select &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static&lt;/code&gt;, and then configure as follows:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Static Route for Router0&lt;/strong&gt;&lt;br /&gt;
Network: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.5.0&lt;/code&gt;&lt;br /&gt;
Mask: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;255.255.255.0&lt;/code&gt;&lt;br /&gt;
Next Hop: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.50.2&lt;/code&gt;&lt;br /&gt;
And then click &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Add&lt;/code&gt;
&lt;img src=&quot;../assets/images/cisco-network/5_static_routes_router0.png&quot; alt=&quot;static-route-router0&quot; /&gt;
&lt;em&gt;fig. Static Routes for Router0&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Static Route for Router1&lt;/strong&gt; &lt;br /&gt;
Network: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.1.0&lt;/code&gt;&lt;br /&gt;
Mask: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;255.255.255.0&lt;/code&gt;&lt;br /&gt;
Next Hop: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.50.1&lt;/code&gt;&lt;br /&gt;
And then click &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Add&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now our network is complete. It’s time to test and enjoy.&lt;/p&gt;

&lt;h1 id=&quot;dns&quot;&gt;DNS&lt;/h1&gt;

&lt;p&gt;Let us check if web server is pinging to PC1 or not. Go to terminal of PC1 and type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ping 192.168.5.3&lt;/code&gt;
&lt;img src=&quot;../assets/images/cisco-network/17_pinging_web_address_frm_com0.png&quot; alt=&quot;ping&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;i&gt;fig. Pinging web server from PC0&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;Let us check the files at web server. When we click &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;web server&lt;/code&gt; and click &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;services&lt;/code&gt;, we see that:
&lt;img src=&quot;../assets/images/cisco-network/10_web_server_files.png&quot; alt=&quot;web-server&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;i&gt;fig. Web Server files&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;Now, browse it from PC0. Click on PC0 and browse &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;https://192.168.5.3&lt;/code&gt;, you will get the page like following:
&lt;img src=&quot;../assets/images/cisco-network/15_browing_http_ip.png&quot; alt=&quot;http-browsing&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;i&gt;fig. Web browing from PC0 using IP address&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;If we want to browse files using custom domain. We have to configure custom domain to point to web server at DNS server. Here, I am using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;www.madhav.com&lt;/code&gt; &lt;em&gt;(You can use your desired domain)&lt;/em&gt;
To do that follow the steps below:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Click on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DNS server&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Click &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DNS&lt;/code&gt; from the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;services&lt;/code&gt; option&lt;/li&gt;
  &lt;li&gt;Turn on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DNS Service&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;On &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Resource Records&lt;/code&gt;:- Name: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;www.madhav.com&lt;/code&gt;, Type: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;A Record&lt;/code&gt;, Address: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.5.3&lt;/code&gt;
&lt;img src=&quot;../assets/images/cisco-network/13_dns_configuration.png&quot; alt=&quot;dns-config&quot; /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p align=&quot;center&quot;&gt;&lt;i&gt;fig. DNS Configuration&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;Now, browse &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://www.madhav.com&lt;/code&gt;, your site is now working.
&lt;img src=&quot;../assets/images/cisco-network/16_browing_http_dns_frm_pc0.png&quot; alt=&quot;http-browsing&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;i&gt;fig. Web browing from PC0 using custom domain&lt;/i&gt;&lt;/p&gt;

&lt;h1 id=&quot;ftp&quot;&gt;FTP&lt;/h1&gt;
&lt;p&gt;We have same server for FTP and DNS. To make ftp server, first make sure it is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;turned on&lt;/code&gt;. And then we need password to login ftp server. Default username is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cisco&lt;/code&gt; and password is also &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cisco&lt;/code&gt;
&lt;img src=&quot;../assets/images/cisco-network/11_ftp_server.png&quot; alt=&quot;ftp-server&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;i&gt;fig. FTP server&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FTP GET&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, extract the files from ftp server to PC0. Go to terminal of PC0 and login to ftp server:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ftp 192.168.5.3
username: cisco
password: cisco
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;img src=&quot;../assets/images/cisco-network/18_ftp_login.png&quot; alt=&quot;ftp-login&quot; /&gt;
&lt;em&gt;fig. FTP login&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You can get the files of ftp using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;get &amp;lt;filename&amp;gt;&lt;/code&gt;
&lt;img src=&quot;../assets/images/cisco-network/19_get_ftp.png&quot; alt=&quot;ftp-get&quot; /&gt;
&lt;em&gt;fig. FTP GET&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FPT PUT&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This means saving our files from computer to ftp server. We do this by using the command &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;put &amp;lt;filename&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;First, create a file going to PC0, I named it as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;madhav.txt&lt;/code&gt;
&lt;img src=&quot;../assets/images/cisco-network/20_create_ftp_file.png&quot; alt=&quot;ftp-create-file&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;i&gt;fig. Creating file in PC&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;Finally, put the file to server &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;put madhav.txt&lt;/code&gt;
&lt;img src=&quot;../assets/images/cisco-network/21_put_ftp_file.png&quot; alt=&quot;ftp-put&quot; /&gt;
&lt;em&gt;fig. FTP PUT&lt;/em&gt;&lt;/p&gt;
</description>
        <pubDate>Sun, 18 Mar 2018 01:00:31 -0545</pubDate>
        <link>https://blog.poudelmadhav.com.np/network-with-dns-server/</link>
        <guid isPermaLink="true">https://blog.poudelmadhav.com.np/network-with-dns-server/</guid>
        
        
        <category>cisco</category>
        
        <category>networking</category>
        
      </item>
    
      <item>
        <title>C program to find the HCF of the two numbers</title>
        <description>
&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt;&lt;span class=&quot;cpf&quot;&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
#include&lt;/span&gt;&lt;span class=&quot;cpf&quot;&gt;&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;hcfactor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hcfactor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Enter two numbers:&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;scanf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;%d%d&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hcfactor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;HCF of %d and %d is %d.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;getch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

</description>
        <pubDate>Sun, 25 Dec 2016 01:49:47 -0545</pubDate>
        <link>https://blog.poudelmadhav.com.np/c-program-hcf/</link>
        <guid isPermaLink="true">https://blog.poudelmadhav.com.np/c-program-hcf/</guid>
        
        
        <category>c program</category>
        
      </item>
    
      <item>
        <title>C++ program of file handling to write a file in the disk and read from a file</title>
        <description>
&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-c--&quot; data-lang=&quot;c++&quot;&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt;&lt;span class=&quot;cpf&quot;&gt;&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
#include&lt;/span&gt;&lt;span class=&quot;cpf&quot;&gt;&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
#include&lt;/span&gt;&lt;span class=&quot;cpf&quot;&gt;&amp;lt;fstream.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;roll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;	
	&lt;span class=&quot;n&quot;&gt;ofstream&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;outf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;madhav.txt&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;	&lt;span class=&quot;c1&quot;&gt;//creates a file madhav.txt&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;cout&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Enter name:&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;cin&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;cout&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Enter Roll No:&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;cin&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;roll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;outf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Name = &quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;outf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Roll No. = &quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;roll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;outf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;endl&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;cout&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Data successfully written to disk.&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;outf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
	
	&lt;span class=&quot;k&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;LEN&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LEN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;ifstream&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;infile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;madhav.txt&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;	&lt;span class=&quot;c1&quot;&gt;//file is opened for read operation&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;cout&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;The data reading from file is:&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;infile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;infile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getline&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LEN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;cout&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;endl&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;infile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
	
	&lt;span class=&quot;n&quot;&gt;getch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

</description>
        <pubDate>Sun, 25 Dec 2016 01:49:47 -0545</pubDate>
        <link>https://blog.poudelmadhav.com.np/cplus-file-handling/</link>
        <guid isPermaLink="true">https://blog.poudelmadhav.com.np/cplus-file-handling/</guid>
        
        
        <category>c++ program</category>
        
      </item>
    
      <item>
        <title>Stopping by Woods on a Snowy Evening</title>
        <description>&lt;p&gt;&lt;strong&gt;-BY ROBORT FROST&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;
Whose woods these are I think I know.&lt;br /&gt;
His house is in the village though;&lt;br /&gt;
He will not see me stopping here&lt;br /&gt;
To watch his woods fill up with snow.&lt;br /&gt;
&lt;/p&gt;

&lt;p&gt;
My little horse most think it queer&lt;br /&gt;
To stop without a farmhouse near&lt;br /&gt;
Between the woods and frozen lake&lt;br /&gt;
The darkest evening of the year.&lt;br /&gt;
&lt;/p&gt;

&lt;p&gt;
He gives his harness bells a shake&lt;br /&gt;
To aske if there is some mistake.&lt;br /&gt;
The only other sound&apos;s the sweep&lt;br /&gt;
Of easy wind and downly flags&lt;br /&gt;
&lt;/p&gt;

&lt;p&gt;
The woods are lovely, dark and deep,&lt;br /&gt;
But I have promises to keep,&lt;br /&gt;
And miles to go before I sleep,&lt;br /&gt;
And miles to go before I sleep.&lt;br /&gt;
&lt;/p&gt;
</description>
        <pubDate>Thu, 22 Dec 2016 02:50:47 -0545</pubDate>
        <link>https://blog.poudelmadhav.com.np/poem/2016/12/22/stopping-by-woods-on-a-snowy-evening/</link>
        <guid isPermaLink="true">https://blog.poudelmadhav.com.np/poem/2016/12/22/stopping-by-woods-on-a-snowy-evening/</guid>
        
        
        <category>poem</category>
        
      </item>
    
      <item>
        <title>Welcome to Madhav&apos;s Blog!</title>
        <description>&lt;p&gt;You are welcome to my site!&lt;/p&gt;

&lt;p&gt;This is the personal blog for posting my ideas and views.&lt;/p&gt;
</description>
        <pubDate>Wed, 21 Dec 2016 06:18:24 -0545</pubDate>
        <link>https://blog.poudelmadhav.com.np/welcome/2016/12/21/welcome-to-jekyll/</link>
        <guid isPermaLink="true">https://blog.poudelmadhav.com.np/welcome/2016/12/21/welcome-to-jekyll/</guid>
        
        
        <category>welcome</category>
        
      </item>
    
  </channel>
</rss>
