<?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>DEV Community: Rodel Talampas</title>
    <description>The latest articles on DEV Community by Rodel Talampas (@limacon23).</description>
    <link>https://dev.to/limacon23</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%2F1007505%2F62c1a8d7-f80e-4189-bcc1-a4816d17831e.png</url>
      <title>DEV Community: Rodel Talampas</title>
      <link>https://dev.to/limacon23</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/limacon23"/>
    <language>en</language>
    <item>
      <title>Singleton Connection with Transactions in MongoDB</title>
      <dc:creator>Rodel Talampas</dc:creator>
      <pubDate>Sat, 23 Sep 2023 00:05:47 +0000</pubDate>
      <link>https://dev.to/limacon23/singleton-connection-with-transactions-in-mongodb-1b5c</link>
      <guid>https://dev.to/limacon23/singleton-connection-with-transactions-in-mongodb-1b5c</guid>
      <description>&lt;p&gt;I was looking at some patterns on how to use MongoDB Transactions but I want it to be a common wrapper and should be simple enough for nodejs beginners (like me) to understand. I saw some functions accepting another, function with multiple parameters, as a parameter, but you need to take care of &lt;code&gt;overloading&lt;/code&gt; cases.&lt;/p&gt;

&lt;p&gt;Thinking of a simple solution, why not just wrap all arguments into a single variable like a &lt;code&gt;map&lt;/code&gt;.  This may not work for others but certainly works on our case.&lt;/p&gt;

&lt;p&gt;First, I need to make sure that I only have 1 DB Connection always. Hence I created a &lt;code&gt;Singleton&lt;/code&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mongoose = require('mongoose');
...
...

// Define Singleton DB Connection Class
class Connection {
  constructor() {
    if (!Connection.instance) {
      mongoose.connect(config.mongoose.url, config.mongoose.options);
      this.conn = mongoose.connection;
      this.conn.on('error', () =&amp;gt; logger.error.bind(console, 'connection error'));
      this.conn.on('open', () =&amp;gt; logger.info(`Connected to MongoDB ${config.mongoose.url} for Transaction...`));
    }
  }
}

module.exports = new Connection();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I will use this class in every part of my systems and it will ensure that I won't be having multiple cases of DB connection.&lt;/p&gt;

&lt;p&gt;Now to create a transaction wrapper, I do this. This is a self-managed transaction meaning I dont need to call commit and rollback. But if you want to manually handle each commit and rollback, you may do so here as well.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const db = require('./connection');

const withTransaction = async (fn) =&amp;gt; async (map) =&amp;gt; {
  const session = await db.conn.startSession();
  await session.withTransaction(fn(map), { session });
  session.endSession();
};

module.exports = withTransaction;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To call do something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function saveFunction(map) {
  //.. implementation
  const { var1, var2 } = map;
  // use the var1, var2 here ....
  // call mongodb CRUD here 
}

// service call
const save = async (map) =&amp;gt; {
  withTransaction(saveFunction(map));
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hoping to get some comments so that I can improve this wrapper in the future.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>programming</category>
      <category>node</category>
    </item>
    <item>
      <title>Authorisation using NodeJS, AzureAD and MongoDB (Part 1 - Design)</title>
      <dc:creator>Rodel Talampas</dc:creator>
      <pubDate>Tue, 17 Jan 2023 01:04:19 +0000</pubDate>
      <link>https://dev.to/limacon23/authorisation-using-nodejs-azuread-and-mongodb-part-1-design-5488</link>
      <guid>https://dev.to/limacon23/authorisation-using-nodejs-azuread-and-mongodb-part-1-design-5488</guid>
      <description>&lt;p&gt;Application administrators use roles to group together permissions and assign them to individual users or groups of users. These permissions determine the actions that a user is able to take within a particular software. The roles that are assigned to a user depend on their tasks within the application itself. For instance, in a simple inventory application, users who are analysts might only need permissions to browse and download, but not to modify or change information. However, in an analyst group, a senior analyst may be granted full permissions to allow them to modify existing data or create/upload new inventory data.&lt;/p&gt;

&lt;p&gt;In general, roles are used to make it easier to manage permissions by allowing administrators to assign a set of permissions to a user or group of users all at once, rather than having to assign individual permissions one at a time. This can make it more efficient to set up and manage access controls within an application.&lt;/p&gt;

&lt;p&gt;A role is therefore defined as a collection of permissions that are grouped together and assigned to a user or group of users. A permission, on the other hand, is a specific action or set of actions that a user is allowed to take within a particular application.&lt;/p&gt;

&lt;p&gt;I am designing an integration with AzureAD, and MongoDB collections using NodeJS. Roles/Groups will be created in AzureAD that will be synced in MongoDB for application usage. Each role will have its own permissions and Users can have one or more roles.&lt;/p&gt;

&lt;h2&gt;
  
  
  Data Definition
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Permission Schema
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const permissionSchema = mongoose.Schema(
  {
    permission: {
        type: String,
        unique: true,
        required: true
    }
  }
  {
    timestamps: true,
  }
);

const Permission = mongoose.model('Permission', permissionSchema);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Role Schema
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const roleSchema = mongoose.Schema(
  {
    role: {
        type: String,
        unique: true,
        required: true
    },
    permissions: [
      {
        permissionId: {
          type: mongoose.Schema.Types.ObjectId,
          ref: 'Permission',
        },
      },
    ]
  }
  {
    timestamps: true,
  }
);

const Role = mongoose.model('Role', roleSchema);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  User Schema
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const userSchema = mongoose.Schema(
  {
    firstName: {
      type: String,
      required: true,
    },
    lastName: {
      type: String,
      required: true,
    },
    phone: {
      type: String,
      required: true,
    },
    email: {
      type: String,
      required: true,
      unique: true,
      lowercase: true,
    },
    roles: [
      {
        roleId: {
          type: mongoose.Schema.Types.ObjectId,
          ref: 'Role',
        }
      },
    ],
  },
  {
    timestamps: true,
  }
);

const User = mongoose.model('User', userSchema);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Management Process
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm14e801jbgq36btz3hdt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm14e801jbgq36btz3hdt.png" alt="Image description" width="723" height="213"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Sync Process
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fept7ib95c84r6g3pb38p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fept7ib95c84r6g3pb38p.png" alt="Image description" width="781" height="147"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  On Load
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fddql1r1hgcte06fdm051.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fddql1r1hgcte06fdm051.png" alt="Image description" width="800" height="371"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>welcome</category>
      <category>career</category>
      <category>learning</category>
      <category>webdev</category>
    </item>
    <item>
      <title>GIT Flow</title>
      <dc:creator>Rodel Talampas</dc:creator>
      <pubDate>Sun, 15 Jan 2023 03:58:58 +0000</pubDate>
      <link>https://dev.to/limacon23/git-flow-5c89</link>
      <guid>https://dev.to/limacon23/git-flow-5c89</guid>
      <description>&lt;p&gt;&lt;a href="https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow#:~:text=The%20overall%20flow%20of%20Gitflow,merged%20into%20the%20develop%20branch" rel="noopener noreferrer"&gt;Gitflow Workflow&lt;/a&gt; is a Git workflow that helps with continuous software development and implementing &lt;a href="https://www.atlassian.com/devops/what-is-devops" rel="noopener noreferrer"&gt;DevOps&lt;/a&gt; practices. It was first published and made popular by Vincent Driessen at nvie. The Gitflow Workflow defines a strict branching model designed around the project release. This provides a robust framework for managing larger projects. This is suited for projects that releases are based on a schedule.&lt;/p&gt;

&lt;p&gt;Gitflow workflow is not for everybody. But for those who loves and using it below are some shortcuts that can help you understand what is this workflow.&lt;/p&gt;

&lt;p&gt;Installing git-flow plugin for git client is plain and simple. For mac-os, easiest to install is &lt;code&gt;brew install git-flow&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic Commands and Configuration&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;git flow init&lt;/li&gt;
&lt;li&gt;git flow feature start/finish &lt;/li&gt;
&lt;li&gt;git flow release start/finish &lt;/li&gt;
&lt;li&gt;git flow hotfix start/finish &lt;/li&gt;
&lt;li&gt;git merge &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Basic Configuration Flow&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz08ks0yavlp4po8mvwqy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz08ks0yavlp4po8mvwqy.png" alt="Image description" width="800" height="475"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concurrent Configuration Flow&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu9nneyirdqu4faiivbzw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu9nneyirdqu4faiivbzw.png" alt="Image description" width="800" height="285"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The overall flow of Gitflow is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A &lt;code&gt;develop&lt;/code&gt; branch is created from &lt;code&gt;main&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;release&lt;/code&gt; branch is created from &lt;code&gt;develop&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Feature&lt;/code&gt; branches are created from &lt;code&gt;develop&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;When a &lt;code&gt;feature&lt;/code&gt; is complete it is merged into the &lt;code&gt;develop&lt;/code&gt; branch.&lt;/li&gt;
&lt;li&gt;When the &lt;code&gt;release&lt;/code&gt; branch is done it is merged into &lt;code&gt;develop&lt;/code&gt; and &lt;code&gt;main&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If an issue in &lt;code&gt;main&lt;/code&gt; is detected a &lt;code&gt;hotfix&lt;/code&gt; branch is created from &lt;code&gt;main&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Once the &lt;code&gt;hotfix&lt;/code&gt; is complete it is merged to both &lt;code&gt;develop&lt;/code&gt; and &lt;code&gt;main&lt;/code&gt; and/or &lt;code&gt;feature&lt;/code&gt; branches.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Git vs Git Flow Commands&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These are base guidelines that corresponds to some of the git commands used by the git-flow wrapper client. These commands are not fixed in stone. Depending on situations, there are steps that can be altered or change within the course of the development.&lt;/p&gt;

&lt;p&gt;Create a develop branch on your local if one doesn’t exists in the repo. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Initialisation (specific for git flow only)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git flow init
Which branch should be used for bringing forth production releases?
   - develop
   - master
Which branch should be used for integration of the "next release"?
   - master
   - develop
Branch name for "next release" development: [develop]

How to name your supporting branch prefixes?
Feature branches? [feature/]
Bugfix branches? [bugfix/]
Release branches? [release/]
Hotfix branches? [hotfix/]
Support branches? [support/]
Version tag prefix? []
Hooks and filters directory? [../../.git/hooks]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Creating feature branches
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git flow feature start &amp;lt;branch&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;vs&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout develop                     # this switches the branch to the develop branch, do a `git pull` to make sure it is latest
git checkout -b feature/&amp;lt;branch&amp;gt;         # this creates a branch named 'feature/&amp;lt;branch&amp;gt;'
git push --set-upstream origin feature/&amp;lt;branch&amp;gt;   # push changes to git repo to a new 'feature/&amp;lt;branch&amp;gt;'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Completed a feature
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git flow feature finish &amp;lt;branch&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;vs&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout feature/&amp;lt;branch&amp;gt;            # this switches the branch to the 'feature/&amp;lt;branch&amp;gt;' if you are not in it, do a `git pull` to make sure it is latest
git checkout develop                     # this switches the branch to the develop branch, do a `git pull` to make sure it is latest
git merge feature/&amp;lt;branch&amp;gt;               # merge feature/branch to develop
git push                                 # push changes to git repo in develop branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Creating a release branch
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git flow release start &amp;lt;branch&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;vs&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout develop                     # this switches the branch to the develop branch, do a `git pull` to make sure it is latest
git checkout -b release/&amp;lt;branch&amp;gt;         # this creates a branch named 'release/&amp;lt;branch&amp;gt;'
git push --set-upstream origin release/&amp;lt;branch&amp;gt;   # push changes to git repo to a new 'release/&amp;lt;branch&amp;gt;' and this will trigger the BUILD to QA
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Release Completed
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git flow release finish &amp;lt;branch&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;vs&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout release/&amp;lt;branch&amp;gt;            # this switches the branch to the 'release/&amp;lt;branch&amp;gt;' if you are not in it, do a `git pull` to make sure it is latest
git checkout develop                     # this switches the branch to the develop branch, do a `git pull` to make sure it is latest
git merge release/&amp;lt;branch&amp;gt;               # merge release/branch to develop
git push                                 # push changes to git repo in develop branch
git checkout main                        # this switches the branch to the main branch, do a `git pull` to make sure it is latest
git merge release/&amp;lt;branch&amp;gt;               # merge release/branch to main
git push                                 # push changes to git repo in main branch
git push --tags                          # push tags
git push -d origin release/&amp;lt;branch&amp;gt;      # delete remote branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Creating a hotfix
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git flow hotfix start &amp;lt;branch&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;vs&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout main                        # this switches the branch to the main branch, do a `git pull` to make sure it is latest
git checkout -b hotfix/&amp;lt;branch&amp;gt;          # this creates a branch named 'hotfix/&amp;lt;branch&amp;gt;'
git push --set-upstream origin hotfix/&amp;lt;branch&amp;gt;   # push changes to git repo to a new 'hotfix/&amp;lt;branch&amp;gt;' and this will trigger the BUILD to QA
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Hotfix Completed
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git flow hotfix finish &amp;lt;branch&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;vs&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout hotfix/&amp;lt;branch&amp;gt;             # this switches the branch to the 'hotfix/&amp;lt;branch&amp;gt;' if you are not in it, do a `git pull` to make sure it is latest
git checkout develop                     # this switches the branch to the develop branch, do a `git pull` to make sure it is latest
git merge hotfix/&amp;lt;branch&amp;gt;                # merge hotfix/branch to develop
git push                                 # push changes to git repo in develop branch
git checkout main                        # this switches the branch to the main branch, do a `git pull` to make sure it is latest
git merge hotfix/&amp;lt;branch&amp;gt;                # merge hotfix/branch to main
git push                                 # push changes to git repo in main branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>discuss</category>
      <category>community</category>
      <category>welcome</category>
    </item>
    <item>
      <title>Enabling PlantUML in Visual Studio Code</title>
      <dc:creator>Rodel Talampas</dc:creator>
      <pubDate>Sun, 15 Jan 2023 03:42:45 +0000</pubDate>
      <link>https://dev.to/limacon23/enabling-plantuml-in-visual-studio-code-6ca</link>
      <guid>https://dev.to/limacon23/enabling-plantuml-in-visual-studio-code-6ca</guid>
      <description>&lt;p&gt;&lt;a href="https://plantuml.com/" rel="noopener noreferrer"&gt;PlantUML&lt;/a&gt; is a component that allows you to quickly write the following diagrams in plain and simple intuitive language - a.k.a. Diagram-As-Code.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sequence diagram&lt;/li&gt;
&lt;li&gt;Usecase diagram&lt;/li&gt;
&lt;li&gt;Class diagram&lt;/li&gt;
&lt;li&gt;Object diagram&lt;/li&gt;
&lt;li&gt;Component diagram&lt;/li&gt;
&lt;li&gt;Deployment diagram&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are many similar tools out there. &lt;code&gt;PlantUML&lt;/code&gt; is free to use and was created using Java and GraphViz.  A simple way of using it is to download the &lt;a href="http://sourceforge.net/projects/plantuml/files/plantuml.jar/download" rel="noopener noreferrer"&gt;plantuml.jar&lt;/a&gt; and run it to open PlantUML's &lt;a href="https://plantuml.com/gui" rel="noopener noreferrer"&gt;graphical user interface&lt;/a&gt;. There is no need to unpack or install anything.&lt;/p&gt;

&lt;p&gt;Most developers use Visual Studio Code, why not install its plugin:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Facgkgcaytxno7s15mt4k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Facgkgcaytxno7s15mt4k.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Browse the plugin and click install.  After installing the plugin, there is a need to install GraphViz binary. You can follow the link to install &lt;a href="https://graphviz.org/download/" rel="noopener noreferrer"&gt;it&lt;/a&gt;.  For mac users, easy to run &lt;code&gt;brew install graphviz&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When all done, create a test file &lt;code&gt;test.puml&lt;/code&gt;  and add the following code&lt;/p&gt;

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

@startuml Basic Sample
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml

Person(admin, "Administrator")
System_Boundary(c1, "Sample System") {
    Container(web_app, "Web Application", "C#, ASP.NET Core 2.1 MVC", "Allows users to compare multiple Twitter timelines")
}
System(twitter, "Twitter")

Rel(admin, web_app, "Uses", "HTTPS")
Rel(web_app, twitter, "Gets tweets from", "HTTPS")
@enduml


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Press &lt;code&gt;Option + D&lt;/code&gt; in Mac or &lt;code&gt;Alt-D&lt;/code&gt; for other OS's, should give the following output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvzsv7d3q1ly6303eux7n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvzsv7d3q1ly6303eux7n.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>vscode</category>
      <category>uml</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Blackbox - Secrets amongst your code</title>
      <dc:creator>Rodel Talampas</dc:creator>
      <pubDate>Sun, 15 Jan 2023 03:29:21 +0000</pubDate>
      <link>https://dev.to/limacon23/blackbox-secrets-amongst-your-code-11jm</link>
      <guid>https://dev.to/limacon23/blackbox-secrets-amongst-your-code-11jm</guid>
      <description>&lt;p&gt;One of the major concerns amongst developers is how to store shared secrets. Storing secrets in a config file along with your source code is problematic as it can compromise privacy. Storing it outside without proper process or documentation can tend to be forgotten (not saying this is not good as using &lt;code&gt;SAAS&lt;/code&gt; tools like &lt;code&gt;Vault&lt;/code&gt; is the way to go). But in case you have a limited budget and limited capability, using &lt;code&gt;GPG&lt;/code&gt; is the way to go. Here comes &lt;a href="https://github.com/StackExchange/blackbox" rel="noopener noreferrer"&gt;Blackbox&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For any secrets you want to store alongside the source code, we should limit the risk of intentional or accidental sharing by encrypting secrets.&lt;/p&gt;

&lt;p&gt;You should encrypt these data in your repositories:&lt;/p&gt;

&lt;p&gt;SSH keys&lt;br&gt;
Private keys&lt;br&gt;
Usernames and passwords&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installation&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;Blackbox&lt;/code&gt; is a GPG-based encryption tool for Git. Assuming &lt;code&gt;Homebrew&lt;/code&gt; is installed in a mac or linux machine, the command below is sufficient. Otherwise look for the Blackbox link above for more information&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 blackbox
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;GPG Keys&lt;/strong&gt;&lt;br&gt;
GnuPG, also known as GPG, is a free, full implementation of the OpenPGP standard as outlined in RFC4880 (also known as PGP). It enables you to encrypt, sign and authenticate data and communication.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gpg --full-generate-key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When key has been generated, look through the messages that displayed on the screen and find your Key ID.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gpg: key &amp;lt;key_id&amp;gt; marked as ultimately trusted
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Generate a revocation certificate for the primary public key. If your private key is compromised or lost, this revocation certificate may be published to notify others that the public key should no longer be used.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gpg --output revoke.asc --gen-revoke &amp;lt;key_id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The revoke.asc file is stored in your user directory. Store the certificate key somewhere safe, ideally &lt;code&gt;keypass&lt;/code&gt; or &lt;code&gt;macpass&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Add your public key to the keys server so that others have verify it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gpg --keyserver=pgp.key-server.io --armor --send-keys &amp;lt;key_id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Browse to pgp.key-server.io and search for your name to see if your gpg key is there or not.&lt;/p&gt;

&lt;p&gt;In case pgp.key-server.io is not registering your key, use other public known keyservers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://keys.openpgp.org/" rel="noopener noreferrer"&gt;https://keys.openpgp.org/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://keyserver.ubuntu.com/" rel="noopener noreferrer"&gt;https://keyserver.ubuntu.com/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pgp.mit.edu/" rel="noopener noreferrer"&gt;https://pgp.mit.edu/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Using Blackbox&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make a repository a &lt;code&gt;blackbox&lt;/code&gt; repo
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ blackbox_initialize 
Enable blackbox for this git repo? (yes/no) y
VCS_TYPE: git

NEXT STEP: You need to manually check these in:
      git commit -m'INITIALIZE BLACKBOX' .blackbox /talampas/development/repo/.gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Add a new user in the &lt;code&gt;blackbox&lt;/code&gt; repo&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is a need to look for the user's key to verify and add it in your keychain&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gpg --keyserver keys.openpgp.org --search-key &amp;lt;personA@email.com | fingerprint&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the user as an admin of &lt;code&gt;blackbox&lt;/code&gt; for that repo.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;blackbox_addadmin &amp;lt;personA@email.com&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update all secret files to incorporate the new key registered&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;blackbox_update_all_files
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Do a commit / push for the repo&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# the next two lines are not required if no other files where edited
git add .
git commit -m"Add new user - personA"
# Required to push changes
git push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Updating Blackbox Encrypted files&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If there is a need to update the secrets in the encrypted file, follow the steps below    &lt;/p&gt;

&lt;p&gt;Open the file for editing&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;blackbox_edit_start &amp;lt;filename&amp;gt;.gpg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;End the Editing process&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;blackbox_edit_end &amp;lt;filename&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same as above, commit and push when you're done&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Developer Setup for Mac</title>
      <dc:creator>Rodel Talampas</dc:creator>
      <pubDate>Sun, 15 Jan 2023 02:49:44 +0000</pubDate>
      <link>https://dev.to/limacon23/developer-setup-for-mac-epc</link>
      <guid>https://dev.to/limacon23/developer-setup-for-mac-epc</guid>
      <description>&lt;p&gt;You have a new MacBook! Congrats! &lt;/p&gt;

&lt;p&gt;You need to setup your mac to be Developer Ready and don't know what to do. You are in the right place. I have compiled a list of installation scripts for a typical Developer to kick start a Developer Machine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;macOS Updates&lt;/strong&gt;&lt;br&gt;
Before installing any applications you require, it is a good idea to update the Operating System. As much as possible, I try to have the latest version of the MacOS with patches.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;XCode&lt;/strong&gt;&lt;br&gt;
First step, you need to install &lt;b&gt;XCode&lt;/b&gt; which is Apple's integrated development environment for MacOS. You can download it in the Apple Store free of charge. There is a command line instruction to install xcode. Open a new terminal and type the code below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;xcode-select --install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Homebrew&lt;/strong&gt;&lt;br&gt;
I pretty much use &lt;code&gt;Homebrew&lt;/code&gt; or &lt;code&gt;brew&lt;/code&gt; to install anything on my MacBook and Linux Machines. Run the following commands to download and install &lt;code&gt;brew&lt;/code&gt; and upgrade it, though there should not be anything to upgrade. No harm doing though.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew upgrade
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Python 3 and JQ&lt;/strong&gt;&lt;br&gt;
Next to Java, Python is probably my next go to programming language. I used python a lot to build client tools and serverless applications. &lt;code&gt;JQ&lt;/code&gt; is a tool to parse JSON Strings and I predominantly use this with python and aws. &lt;code&gt;VirtualEnv&lt;/code&gt; is my favorite environment configuration for python. Python virtualization is a must if you are going to develop using python. Python is also a requirement for some client tools like &lt;code&gt;awscli&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;brew install python3
curl https://bootstrap.pypa.io/get-pip.py | python3
pip install virtualenv
brew install jq
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;AWS&lt;/strong&gt;&lt;br&gt;
I work mostly with AWS Cloud hence I require AWS Client that uses Python. If you are not in AWS, you may skip this part. This command will help you install and upgrade your aws client. I have both added &lt;code&gt;awscli&lt;/code&gt; and &lt;code&gt;awscli-local&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;brew install awscli
brew link awscli --overwrite 
pip install awscli-local
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Docker Desktop&lt;/strong&gt;&lt;br&gt;
Since Mac-OS is not a linux distro, it is impossible to install docker base binaries. Don't fear though, docker created a desktop installer for mac &lt;a href="https://docs.docker.com/desktop/install/mac-install/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Localstack&lt;/strong&gt;&lt;br&gt;
Since AWS is a paid service, creating infrastructure usually cost $$$ if you are unable to use the free-tier. To test out my infrastructure-as-code scripts, I spin up a Mock AWS Service called &lt;code&gt;localstack&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;pip install localstack 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Terminal&lt;/strong&gt;&lt;br&gt;
MacOS' terminal is nice, no complains about it. As a developer, sometimes I would like to work on multiple Terminals but within the same window. Hence, I require some Split functionality and &lt;code&gt;iTerm2&lt;/code&gt; has that capability. ZSH is the prefered console of MacOS terminal nowadays.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chsh -s /bin/zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
brew install iterm2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;NodeJS&lt;/strong&gt;&lt;br&gt;
As much as I don't want to tackle NodeJS, this programming language is pretty much use anywhere from backend processing to UI development using frameworks such as &lt;code&gt;react&lt;/code&gt; or &lt;code&gt;angular&lt;/code&gt; or &lt;code&gt;vue&lt;/code&gt;. Somehow, I got the hang of this programming framework as well. I've been using this in my side projects. &lt;code&gt;Yarn&lt;/code&gt; is my favourite package manager. You can install any PM you want.&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 node
brew install nvm
brew install yarn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Serverless Framework&lt;/strong&gt;&lt;br&gt;
Between AWS Severless Application Model (&lt;code&gt;SAM&lt;/code&gt;) and Serverless Framework (&lt;code&gt;SLS&lt;/code&gt;), I prefer the latter. Both framework patterns their syntax from AWS Cloudformation, but I firmly believe Serverless Framework is more mature. Don't get me wrong, I love &lt;code&gt;AWS&lt;/code&gt;. SLS is my own choice.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -o- -L https://slss.io/install | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Infrastructure As Code&lt;/strong&gt;&lt;br&gt;
I've been using Cloudformation ever since I had moved to the cloud. But when I've learned &lt;code&gt;Terraform&lt;/code&gt;, I seldom touch Cloudformation unless I am working with &lt;code&gt;SLS&lt;/code&gt; above.&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 terraform
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Git and Git Flow&lt;/strong&gt;&lt;br&gt;
In one way or another, you might be using a Source Code Versioning System like &lt;code&gt;github&lt;/code&gt; or &lt;code&gt;gitlab&lt;/code&gt;. A &lt;code&gt;git&lt;/code&gt; client is required.I have added a plugin called &lt;code&gt;git flow&lt;/code&gt; for the purpose of following a release framework.&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 git
brew install git-flow
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Database Connectivity Tool&lt;/strong&gt;&lt;br&gt;
We use databases to persist data. I've used a lot of databases in my career, from &lt;code&gt;MS SQL Server&lt;/code&gt; to &lt;code&gt;Oracle&lt;/code&gt; to &lt;code&gt;Postgres&lt;/code&gt; or &lt;code&gt;MySQL&lt;/code&gt;. I don't have a clear favourite but for this tutorial, I will go with the easiest &lt;code&gt;postgres&lt;/code&gt;. Take note, this is only a connection tool, you may ask how do you install your database? As I've mentioned above, I would containerise my databases, read it &lt;a href="https://dev.to/limacon23/postgres-database-in-a-docker-container-367g"&gt;here&lt;/a&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 libpq
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Miscellaneous Tools&lt;/strong&gt;&lt;br&gt;
The rest of the apps in this code block are optional. Some are required due to the fact that I am using it like gpg for encryption and java being my favourite programming language. It is to your discretion if you will install them or not. &lt;code&gt;Atom&lt;/code&gt; here is a good IDE but since Microsoft bought Github, it is not being developed anymore and &lt;a href="https://go.microsoft.com/fwlink/?LinkID=534106"&gt;Visual Studio Code Express&lt;/a&gt; is the preferred IDE.&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 atom
brew install kubectx
brew install gpg
brew install blackbox
brew install java
brew cask install eclipse-java
brew cask install postman
brew install macpass
brew install credstash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;Full Script&lt;/h4&gt;

&lt;p&gt;For all the apps that can be installed using the terminal, I've compiled a full list below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Install Homebrew - preferred apps installation manager
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew upgrade

# Install Python 3
brew install python3
# update pip 
curl https://bootstrap.pypa.io/get-pip.py | python3
# install virtualenv for python, if you dont use python no need to install this
pip install virtualenv
# install jq
brew install jq

# Install AWS Client using Homebrew
brew install awscli
# if there is already an install client, ovewrite its softlink
brew link awscli --overwrite 
# install aws client for localstack
pip install awscli-local


# install docker using docker installer
brew cask install docker

# install localstack
pip install localstack

# preferred mac terminal
brew install iterm2

# CHANGE TO zsh, if you want too.
chsh -s /bin/zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# all about NODEJS
brew install node
brew install nvm
brew install yarn
# if your office has certificate restrictions, you may want to remove ssl restriction
yarn config set strict-ssl false

# for AWS lambda deployment, we prefer Serverless Framework
curl -o- -L https://slss.io/install | bash

# for Infrastructure as Code
brew install terraform

#install git
brew install git

# install git flow
brew install git-flow

# postgres tool
brew install libpq 

# this is my preferred editor, if you dont like it dont install it
brew install atom

# some passwords used for OPs are in keepass and macpass is the keepass version for mac
brew install macpass

# we do use kubernetes, this is required to connect to it
brew install kubectx

# install gpg 
brew install gpg

# install Java
brew install java
brew cask install eclipse-java
brew cask install postman

# password tools
brew install blackbox
brew install credstash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>beginners</category>
      <category>devs</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Postgres Database in a Docker Container</title>
      <dc:creator>Rodel Talampas</dc:creator>
      <pubDate>Sun, 15 Jan 2023 02:33:43 +0000</pubDate>
      <link>https://dev.to/limacon23/postgres-database-in-a-docker-container-367g</link>
      <guid>https://dev.to/limacon23/postgres-database-in-a-docker-container-367g</guid>
      <description>&lt;p&gt;You want to install a Database in your machine for development purposes, correct? I would advise not to but instead install Docker and create a Dockerise Database, &lt;code&gt;Postgres&lt;/code&gt; for example.&lt;/p&gt;

&lt;p&gt;Why? Simple, you can spin off multiple instances of a database and you can easily drop the containers once you are done with it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;PostgreSQL&lt;/code&gt; is an open-source, object-relational database with strong capabilities. It allows for more sophisticated data types and object inheritance, but this increased functionality also increases complexity. It uses a single storage engine that guarantees ACID compliance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run --name mydb -e POSTGRES_PASSWORD='mypassword' -d -p 5432:5432 postgres
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Parameters&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;name&lt;/td&gt;
&lt;td&gt;The name of your container&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;-e POSTGRES_PASSWORD='mypassword' &lt;/td&gt;
&lt;td&gt;This is the password of the admin user 'postgres'.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;-p &amp;lt;local port&amp;gt;:&amp;lt;container port&amp;gt;&lt;/td&gt;
&lt;td&gt;Port mapping between container and local machine&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;-d&lt;/td&gt;
&lt;td&gt;Run the process in the background&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;postgres[:&amp;lt;version&amp;gt;&lt;/td&gt;
&lt;td&gt;The container image to download from dockerhub. Add :&amp;lt;version&amp;gt; to specify the version of the container&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;Create the Database&lt;/h4&gt;

&lt;p&gt;Creating the database is as simple as running a createdb command. This command is part of the postgres client library libpq.&lt;br&gt;
Make sure that an environment variable 'PGPASSWORD' has been set to have the value of the password&lt;br&gt;
defined in the docker container command above.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export PGPASSWORD=mypassword
createdb -h localhost -U postgres mydatabase
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
  &lt;li&gt;-h &amp;lt;hostname&amp;gt;
  &lt;blockquote&gt;This specifies the hostname of the database server. Since this is a docker container, it is default to be the localhost.&lt;/blockquote&gt;
&lt;/li&gt;
  &lt;li&gt;-U postgres
    &lt;blockquote&gt;The default postgres admin user.&lt;/blockquote&gt;
&lt;/li&gt;
  &lt;li&gt;&amp;lt;database name&amp;gt;
    &lt;blockquote&gt;The name of the database to be created, here it's 'mydatabase'&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Create Database Users&lt;/h4&gt;

&lt;p&gt;You don't use the default user to connect to the database regularly, specially in a Production Environment. 
  You need to create users. The psql command is part of the postgres client library 'libpq'.
&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;psql -h localhost -U postgres -d mydatabase -c "create user db_admin superuser;"
psql -h localhost -U postgres -d mydatabase -c "create user write;"
psql -h localhost -U postgres -d mydatabase -c "create user readonly;"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
  &lt;li&gt;-h &amp;lt;hostname&amp;gt;
  &lt;blockquote&gt;This specifies the hostname of the database server. Since this is a docker container, it is default to be the localhost.&lt;/blockquote&gt;
&lt;/li&gt;
  &lt;li&gt;-U postgres
    &lt;blockquote&gt;The default postgres admin user.&lt;/blockquote&gt;
&lt;/li&gt;
  &lt;li&gt;-d &amp;lt;databae name&amp;gt;
    &lt;blockquote&gt;The database you want to connect to.&lt;/blockquote&gt;
&lt;/li&gt;
  &lt;li&gt;-c &amp;lt;sql statements&amp;gt;
    &lt;blockquote&gt;The sql statement you want to run. In this case the create user statement.&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Assign Permission&lt;/h4&gt;

&lt;p&gt;Creating user is not enough. You will not be able to use the user you created without giving them permission to access
  the database.
&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;psql -h localhost -U postgres -d mydatabase -c "GRANT ALL PRIVILEGES ON DATABASE mydatabase TO write;"
psql -h localhost -U postgres -d mydatabase -c "GRANT SELECT ON ALL TABLES IN SCHEMA myschema TO readonly;"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;Full Script&lt;/h3&gt;

&lt;p&gt;I've compiled all of the above commands into one script below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  docker run --name mydb -e POSTGRES_PASSWORD='mypassword' -d -p 5432:5432 postgres    
  # add in `:&amp;lt;version&amp;gt;` to install a specific version of postgres (e.g. :11)
  brew install libpq # install postgres client libraries if havent done so

  # PGPASWORD env variable is used by psql command to authenticate a user with the -U option
  export PGPASSWORD=mypassword

  # Create a database based on your project
  createdb -h localhost -U postgres mydatabase

  # Create users based on your project
  psql -h localhost -U postgres -d mydatabase -c "create user admin superuser;"
  psql -h localhost -U postgres -d mydatabase -c "create user write;"
  psql -h localhost -U postgres -d mydatabase -c "create user readonly;"

  # Grant users
  psql -h localhost -U postgres -d mydatabase -c "GRANT ALL PRIVILEGES ON DATABASE mydatabase TO write;"
  psql -h localhost -U postgres -d mydatabase -c "GRANT SELECT ON ALL TABLES IN SCHEMA myschema TO readonly;"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ai</category>
      <category>top7</category>
      <category>softwaredevelopment</category>
    </item>
  </channel>
</rss>
