<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Repodev.com RSS Feed]]></title><description><![CDATA[A blog where you can find a bunch of useful tips for developers.]]></description><link>https://repodev.com/blog</link><generator>GatsbyJS</generator><lastBuildDate>Thu, 10 Oct 2024 08:32:51 GMT</lastBuildDate><item><title><![CDATA[Shell: Using "grep" to Extract URLs from Junk Data]]></title><description><![CDATA[credit: @imranparray101]]></description><link>https://repodev.com/blog</link><guid isPermaLink="false">https://repodev.com/blog</guid><pubDate>Wed, 22 Mar 2023 17:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;code&gt;credit: @imranparray101&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;cat file | grep -Eo &quot;(http|https)://[a-zA-Z0-9./?=_-]*&quot;*

curl http://host.xx/file.js | grep -Eo &quot;(http|https)://[a-zA-Z0-9./?=_-]*&quot;*
&lt;/code&gt;&lt;/pre&gt;</content:encoded></item><item><title><![CDATA[Setup Typescript for ExpressJS Project]]></title><description><![CDATA[Some of you might already use Typescript on all of your projects, maybe for frontend application or backend application. There're also a few…]]></description><link>https://repodev.com/blog/setup-typescript-for-expressjs-project</link><guid isPermaLink="false">https://repodev.com/blog/setup-typescript-for-expressjs-project</guid><pubDate>Thu, 30 Sep 2021 17:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Some of you might already use Typescript on all of your projects, maybe for frontend application or backend application. There&apos;re also a few Nodejs frameworks that already support Typescript with no config required. I myself still using ExpresJS with plain Javascript, because some of my coworkers are not using Typescript or familiar with it, so that&apos;s the best choice for me. Typescript is really useful for us to prevent bugs in the development phase, yup, Type definitions do their job very well. But, not every Nodejs frameworks support it by default, in this case ExpressJS, we need to configure it to make it work in ExpressJS environment.&lt;/p&gt;
&lt;p&gt;There are so many examples we can find in the internet about how to configure or using ExpressJS using Typescript, but in this article I&apos;d like to share mine.&lt;/p&gt;
&lt;h2&gt;Prerequisite&lt;/h2&gt;
&lt;p&gt;We will start from scratch. First create a directory and install ExpressJS and Typescript packages for our project.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;mkdir express-with-typescript; cd express-with-typescript; npm init -y; npm i express typescript ts-node tslib
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The project structure for this project would be like the following example. Ignore it for now, please jump to the next step.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;express-with-typescript/
  |__src/
    |controllers/
      |__index.controllers.ts
    |__interfaces/
      |__routes.interfaces.ts
    |__routes/
      |__index.route.ts
    app.ts
    server.ts
  nodemon.json
  package.json
  tsconfig.json
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Create a Basic App&lt;/h2&gt;
&lt;p&gt;We will create a very basic example at the moment. Create 2 files, &lt;code&gt;app.js&lt;/code&gt; and &lt;code&gt;server.js&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;// app.js =====
const express = require(&apos;express&apos;);
const app = express();

app.get(&apos;/&apos;, (req, res) =&gt; {
  res.send(&apos;hello index&apos;);
});

module.exports = app;

// server.js =====
const app = require(&apos;./app&apos;);
const port = 3000;

app.listen(port, () =&gt; {
  console.log(`Example app listening at http://localhost:${port}`);
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We are done here, now let&apos;s start to configure Typescript for our simple app.&lt;/p&gt;
&lt;h2&gt;Configure Typescript&lt;/h2&gt;
&lt;p&gt;In our root directory, create a file called &lt;code&gt;tsconfig.json&lt;/code&gt;. More info about this file, please check &lt;a href=&quot;https://www.typescriptlang.org/docs/handbook/tsconfig-json.html&quot;&gt;Typescript documentation&lt;/a&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;compileOnSave&quot;: false,
  &quot;compilerOptions&quot;: {
    &quot;allowSyntheticDefaultImports&quot;: true,
    &quot;allowJs&quot;: true,
    &quot;baseUrl&quot;: &quot;src&quot;,
    &quot;declaration&quot;: true,
    &quot;esModuleInterop&quot;: true,
    &quot;experimentalDecorators&quot;: true,
    &quot;emitDecoratorMetadata&quot;: true,
    &quot;forceConsistentCasingInFileNames&quot;: true,
    &quot;importHelpers&quot;: true,
    &quot;lib&quot;: [&quot;es2017&quot;, &quot;esnext.asynciterable&quot;],
    &quot;moduleResolution&quot;: &quot;node&quot;,
    &quot;module&quot;: &quot;commonjs&quot;,
    &quot;noEmit&quot;: false,
    &quot;outDir&quot;: &quot;./dist&quot;,
    &quot;pretty&quot;: true,
    &quot;paths&quot;: {
      &quot;@/*&quot;: [&quot;*&quot;],
      &quot;@routes/*&quot;: [&quot;routes/*&quot;],
      &quot;@interfaces/*&quot;: [&quot;interfaces/*&quot;],
      &quot;@controllers/*&quot;: [&quot;controllers/*&quot;],
      &quot;@utils/*&quot;: [&quot;utils/*&quot;]
      [...] more directory here
    },
    &quot;resolveJsonModule&quot;: true,
    &quot;sourceMap&quot;: true,
    &quot;target&quot;: &quot;es2017&quot;,
    &quot;typeRoots&quot;: [&quot;node_modules/@types&quot;]
  },
  &quot;exclude&quot;: [&quot;node_modules&quot;]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;compilerOptions&lt;/code&gt; is our main configuration. Inside that block, you can configure how the transpile works on our project. See the &lt;code&gt;paths&lt;/code&gt; block in this example, you can mapping your modules inside that block, you can read &lt;a href=&quot;https://www.typescriptlang.org/tsconfig&quot;&gt;TSConfig page&lt;/a&gt; for more detail.&lt;/p&gt;
&lt;p&gt;Our project is not ready yet. Next, we need to install &lt;code&gt;@types/node&lt;/code&gt; package. This package is used to load in all type definitions when using typescript in node, and we need to install additional packages for our project.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;npm i -D @types/node @types/express tsconfig-paths
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, we need to modify our previous code to become a Typescript files. Change &lt;code&gt;.js&lt;/code&gt; to &lt;code&gt;.ts&lt;/code&gt;, then update the content with the following code.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;// app.ts ===================
import express from &apos;express&apos;;
import Routes from &apos;@interfaces/routes.interface&apos;;

class App {
  public app: express.Application;
  public port: string | number;

  constructor(routes: Routes[]) {
    this.app = express();
    this.port = 3000;
    this.initializeMiddlewares();
    this.initializeRoutes(routes);
  }

  public listen() {
    this.app.listen(this.port, () =&gt; {
      console.log(`App listening on the port ${this.port}`);
    })
  }

  private initializeMiddlewares() {
    // more middewares here...
    this.app.use(express.json());
  }

  private initializeRoutes(routes: Routes[]) {
    routes.forEach(route =&gt; {
      this.app.use(&apos;/&apos;, route.router);
    });
  }
}

export default App;

// server.ts =====================
import App from &apos;@/app&apos;;
import IndexRoute from &apos;@routes/index.route&apos;;

const app = new App([new IndexRoute()])

app.listen()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, I am using mapping for modules, &lt;code&gt;interfaces&lt;/code&gt; &amp;#x26; &lt;code&gt;routes&lt;/code&gt;, because I setup its &lt;code&gt;paths&lt;/code&gt; (based on the project structure) inside &lt;code&gt;compilerOptions&lt;/code&gt;. You can add more modules if you want, but do not forget to update your &lt;code&gt;compilerOptions&lt;/code&gt; configuration. Now create that directories and its file.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;mkdir -p express-with-typescript/{controllers/,interfaces/,routes/}
touch express-with-typescript/{controllers/index.controllers.ts,interfaces/routes.interface.ts,routes/index.route.ts}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then, put these code on each files.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;// index.controllers.ts
import { NextFunction, Request, Response } from &apos;express&apos;;

class IndexController {
  public index = (req: Request, res: Response, next: NextFunction): void =&gt; {
    try {
      res.send(&apos;hello index&apos;);
    } catch (error) {
      next(error);
    }
  };
}

export default IndexController;

// routes.interface.ts ==========
import { Router } from &apos;express&apos;;

interface Route {
  path?: string;
  router: Router;
}

export default Route;

// index.route.ts ==============
import { Router } from &apos;express&apos;;
import Route from &apos;@interfaces/routes.interface&apos;;

class IndexRoute implements Route {
  public path = &apos;/&apos;;
  public router = Router();

  constructor() {
    this.initializeRoutes();
  }

  private initializeRoutes() {
    this.router.get(`${this.path}`, () =&gt; {
      console.log(&apos;hello index&apos;)
    });
  }
}

export default IndexRoute;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We are almost done, before run our application, create &lt;code&gt;nodemon.json&lt;/code&gt; file with the following configuration.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;watch&quot;: [&quot;src&quot;],
  &quot;ext&quot;: &quot;ts,js&quot;,
  &quot;exec&quot;: &quot;ts-node -r tsconfig-paths/register --transpile-only src/server.ts&quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And put a &lt;code&gt;start&lt;/code&gt; script inside &lt;code&gt;package.json&lt;/code&gt; file.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;&quot;scripts&quot;: {
  &quot;start&quot;: &quot;nodemon&quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can now run the application by &lt;code&gt;npm run&lt;/code&gt; command, and try to access it through port 3000, you will see &lt;code&gt;hello index&lt;/code&gt; text as the result. So, that&apos;s how I use Typescript in my node projects, I hope it&apos;s useful for you. By the way, you might want to consider a framework that&apos;s already support Typescript like NestJS, i strongly recommend it.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[JavaScript: Check Vowel in a Sentence]]></title><link>https://repodev.com/blog</link><guid isPermaLink="false">https://repodev.com/blog</guid><pubDate>Mon, 20 Sep 2021 17:00:00 GMT</pubDate><content:encoded>&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;function vowels(str) {
  const matchesVowel = str.match(/[aiueo]/gi);
  return matchesVowel?.length || 0;
}
&lt;/code&gt;&lt;/pre&gt;</content:encoded></item><item><title><![CDATA[JavaScript: Reverse Integer]]></title><link>https://repodev.com/blog</link><guid isPermaLink="false">https://repodev.com/blog</guid><pubDate>Sat, 18 Sep 2021 17:00:00 GMT</pubDate><content:encoded>&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;function reverseInt(num) {
  if (num &amp;#x3C; 0) return -reverseIntOpt(-num);
  const reversed = num.toString().split(&apos;&apos;).reverse().join(&apos;&apos;);

  return Number(reversed);
}
&lt;/code&gt;&lt;/pre&gt;</content:encoded></item><item><title><![CDATA[PostgreSQL Indexes]]></title><description><![CDATA[We know that Index is really important when we develop an app with database. It can improve our query performance to provide a specific…]]></description><link>https://repodev.com/blog/postgresql-indexes</link><guid isPermaLink="false">https://repodev.com/blog/postgresql-indexes</guid><pubDate>Sun, 15 Aug 2021 17:00:00 GMT</pubDate><content:encoded>&lt;p&gt;We know that Index is really important when we develop an app with database. It can improve our query performance to provide a specific result that we want. A little note here, Indexes are entry points for tables and Indexes are stored in storage (stored separately from the table&apos;s main storage a.k.a Heap). PostgreSQL has several types of Index System that we can use, also, we need to know and select the best Index system for our query.&lt;/p&gt;
&lt;p&gt;In this article, I&apos;m going to describe some of the PostgreSQL Indexes and its examples, so let&apos;s start with the basic.&lt;/p&gt;
&lt;h2&gt;1. Create Index&lt;/h2&gt;
&lt;p&gt;First, we create a table and an index.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;CREATE TABLE foo(id INTEGER, fullname TEXT, birthdate DATE, address TEXT, phone NUMERIC);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I assume you&apos;ve provided some data in this table, just create a function or coding to generate a data seed maybe 10K records or even bigger. After that run the &lt;code&gt;EXPLAIN ANALYZE&lt;/code&gt; clause before and after an Index is set. For example:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;EXPLAIN ANALYZE SELECT fullname FROM foo WHERE id = 589;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We&apos;ll get the result of the execution time, but what will happen after we set an index on that table and run the same query.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;CREATE INDEX foo_idx ON foo(id);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Try to run the same explain ANALYZE query above and you will see the different. That&apos;s how an index works. For more info about create an index in PostgreSQL, please refer to the &lt;a href=&quot;https://www.postgresql.org/docs/11/sql-createindex.html&quot;&gt;official website&lt;/a&gt; and do not forget to select the version based on your PostgreSQL version.&lt;/p&gt;
&lt;h2&gt;2. More About Index&lt;/h2&gt;
&lt;p&gt;PostgreSQL index has its own file on disk, as I mentioned above, indexes are stored in storage. We can check that by run the following query and command:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;SELECT relfilenode FROM pg_class WHERE relname LIKE &apos;foo_idx&apos;;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;ls -lrt $PGDATA/
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can see inside that directory for the result that we get from &lt;code&gt;refilenode&lt;/code&gt; value. The same value is the index on the table that we created.&lt;/p&gt;
&lt;p&gt;When we create an index, PostgreSQL will lock the table by using &lt;code&gt;CREATE INDEX ....&lt;/code&gt; query, but in case we do not want lock the table, we can add an additional option to the query like &lt;code&gt;CREATE INDEX CONCURRENTLY .....&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;PostgreSQL by default will use &lt;code&gt;BTREE&lt;/code&gt; to create an index. There is a HASH, BRIN, and GIN index. To use one of these index, we need to write it in the query.&lt;/p&gt;
&lt;h3&gt;Hash index&lt;/h3&gt;
&lt;p&gt;Hash indexes &lt;em&gt;only&lt;/em&gt; handles equality operators &lt;code&gt;=&lt;/code&gt;. For example:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;CREATE INDEX hash_idx ON foo USING HASH (fullname);
EXPLAIN ANALYZE SELECT * FROM foo WHERE fullname = &apos;Test&amp;#x26;&apos;;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;BRIN index (Block Range Index)&lt;/h3&gt;
&lt;p&gt;This index contains only 3 items: &lt;em&gt;Max value&lt;/em&gt;, &lt;em&gt;Min value&lt;/em&gt; of column and &lt;em&gt;Page number&lt;/em&gt;. It is useful for query that have some connection or large sequentially data, for example querying date.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;CREATE INDEX hash_idx ON foo USING BRIN (birthdate);
EXPLAIN ANALYZE SELECT * FROM foo WHERE birthdate &gt; &apos;1990-01-22&apos; AND birthdate &amp;#x3C; &apos;2000-10-12&apos;;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;GIN index (Generalized Inverted Index)&lt;/h3&gt;
&lt;p&gt;I cannot remember when the last time I used this type of index. As far as I know, when we need to index composite values like &lt;code&gt;jsonb&lt;/code&gt; type data (documents and arrays), we use GIN index. For example if you have data:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;SELECT name, detail FROM user;
(&quot;name&quot;: &quot;John Doe&quot;, &quot;detail&quot;: {&quot;Main Street No. 123&quot;, &quot;0888-210-444&quot;}),
....
(50 rows)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And to create an index and anayze it:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;CREATE INDEX gin_idx ON user USING GIN (name);
EXPLAIN ANALYZE SELECT * FROM user WHERE name @&gt; &apos;{&quot;name&quot;: &quot;John Doe&quot;}&apos;;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Please check the &lt;a href=&quot;https://www.postgresql.org/docs/11/sql-createindex.html&quot;&gt;official website&lt;/a&gt; for more detail.&lt;/p&gt;
&lt;h3&gt;GiST index (Generalized Search Tree)&lt;/h3&gt;
&lt;p&gt;This index is preferred text search index type, is it is used for full text search, even if GIN index also can be used to speed up full text searches. I myself never use this index, because I used another full-text search platform instead. But I really want to use this index, I will think of it later :D.&lt;/p&gt;
&lt;p&gt;Again, please check the &lt;a href=&quot;https://www.postgresql.org/docs/11/sql-createindex.html&quot;&gt;official website&lt;/a&gt; for the detail.&lt;/p&gt;
&lt;h3&gt;Expression index&lt;/h3&gt;
&lt;p&gt;Querying is not only for &lt;code&gt;id&lt;/code&gt; column, sometimes we also querying with some expressions. For example we want to retrieve the &lt;code&gt;fullname&lt;/code&gt; column only in Uppercase or Lowercase. This kind of expression are accepted by PostgreSQL to be an index.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;EXPLAIN ANALYZE SELECT * FROM foo WHERE UPPER(fullname) LIKE &apos;Test&apos;;
CREATE INDEX exp_idx ON foo (UPPER(fullname));
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can also create an index for more complex expression though.&lt;/p&gt;
&lt;h3&gt;Partial index&lt;/h3&gt;
&lt;p&gt;Partial index is really useful for querying a specific number of record that we want to retrieve. For example we want to querying data with &lt;code&gt;id&lt;/code&gt; between 500 and 1000.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;CREATE INDEX partial_idx ON foo(id) WHERE id &gt;= 500 AND &amp;#x3C;= 1000;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The index will not selected for id less than 500 and greater than 1000.&lt;/p&gt;
&lt;h3&gt;Duplicate indexes&lt;/h3&gt;
&lt;p&gt;Sometimes it happens, we create multiple indexes. I found a query to check how many duplicate indexes in tables.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;SELECT indrelid::regclass relname, indexrelid::regclass indexname, indkey
FROM pg_index
GROUP BY relname, indexname, indkey;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;SELECT indrelid::regclass relname, indkey, amname,
FROM pg_index i, pg_opclass o, pg_am a
WHERE o.oid = ALL (indclass)
AND a.oid = o.opcmethod
GROUP BY relname, indclass, amname, indkey
HAVING count(*) &gt; 1;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Unused indexes&lt;/h3&gt;
&lt;p&gt;You&apos;ve might created an index but end up not using it and forgot to delete it. To see unused indexes, you can simply run the following query:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;SELECT relname, indexrelname, idx_scan FROM pg_catalog.pg_stat_user_indexes;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Data types for index&lt;/h3&gt;
&lt;p&gt;For specific index has their own supported data types. To see that data types that supported by a specific index, run the following query:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;SELECT amname, opfname FROM pg_opfamily, pg_am WHERE opfmethod = pg_am.oid AND amname = &apos;hash&apos;;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can change the name of index on that query to see the list of supported data types for a particular indexes.&lt;/p&gt;
&lt;h3&gt;Retrieve index status&lt;/h3&gt;
&lt;p&gt;There&apos;s a view that contains information about indexes that we have in our database, check `pg_stat_user_indexes.&lt;/p&gt;
&lt;p&gt;That&apos;s all of the things about PostgreSQL Indexes that i want to share in this article.
I hope it&apos;s useful for you to know and can help you to improve your query by using index. And it&apos;s important to remember that indexes are very costly operation and takes space on your system.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[JavaScript: Get Random Item From an Array]]></title><link>https://repodev.com/blog</link><guid isPermaLink="false">https://repodev.com/blog</guid><pubDate>Fri, 23 Jul 2021 17:00:00 GMT</pubDate><content:encoded>&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;const items = [1, 2, 3, 4, 5, 6, 7, 8, 9];

function getRandomItem(arr) {
  return arr[Math.floor(Math.random() * arr.length)];
}

getRandomItem(items);
&lt;/code&gt;&lt;/pre&gt;</content:encoded></item><item><title><![CDATA[JavaScript: Get Random Number]]></title><link>https://repodev.com/blog</link><guid isPermaLink="false">https://repodev.com/blog</guid><pubDate>Fri, 23 Jul 2021 17:00:00 GMT</pubDate><content:encoded>&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;function getRandomNumber(minVal, maxVal) {
  return Math.floor(Math.random() * (maxVal - minVal + 1)) + minVal;
}
getRandomNumber(5, 99);
&lt;/code&gt;&lt;/pre&gt;</content:encoded></item><item><title><![CDATA[JavaScript: Intersection of Arrays]]></title><link>https://repodev.com/blog</link><guid isPermaLink="false">https://repodev.com/blog</guid><pubDate>Fri, 23 Jul 2021 17:00:00 GMT</pubDate><content:encoded>&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;const arr1 = [&apos;a&apos;, &apos;b&apos;, &apos;c&apos;, &apos;d&apos;, &apos;e&apos;];
const arr2 = [&apos;b&apos;, &apos;e&apos;];

function intersectionArray(a, b) {
  return a.filter(Set.prototype.has, new Set(b));
}

intersectionArray(arr1, arr2); // [&quot;b&quot;, &quot;e&quot;]
&lt;/code&gt;&lt;/pre&gt;</content:encoded></item><item><title><![CDATA[JavaScript: Union of Arrays]]></title><link>https://repodev.com/blog</link><guid isPermaLink="false">https://repodev.com/blog</guid><pubDate>Fri, 23 Jul 2021 17:00:00 GMT</pubDate><content:encoded>&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;const arr1 = [&apos;a&apos;, &apos;b&apos;, &apos;c&apos;];
const arr2 = [&apos;a&apos;, &apos;c&apos;, &apos;b&apos;, &apos;d&apos;, &apos;e&apos;];

const unionArr = (a, b) =&gt; Array.from(new Set([...a, ...b]));

unionArr(arr1, arr2); // [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;]
&lt;/code&gt;&lt;/pre&gt;</content:encoded></item><item><title><![CDATA[JavaScript: Remove Specific Object Key from Array of Objects]]></title><link>https://repodev.com/blog</link><guid isPermaLink="false">https://repodev.com/blog</guid><pubDate>Wed, 21 Jul 2021 17:00:00 GMT</pubDate><content:encoded>&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;const allUser = [
  {
    id: 1,
    name: &apos;John&apos;,
    password: &apos;1234&apos;,
  },
  {
    id: 2,
    name: &apos;Doe&apos;,
    password: &apos;abcd&apos;,
  },
];

// exclude `password` field
const users = allUser.map(({ password, ...rest }) =&gt; rest);
return users;
&lt;/code&gt;&lt;/pre&gt;</content:encoded></item><item><title><![CDATA[Shell: Docker Stop All Running Containers]]></title><link>https://repodev.com/blog</link><guid isPermaLink="false">https://repodev.com/blog</guid><pubDate>Wed, 21 Jul 2021 17:00:00 GMT</pubDate><content:encoded>&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;docker stop $(docker ps -q)
&lt;/code&gt;&lt;/pre&gt;</content:encoded></item><item><title><![CDATA[Shell: rsync Local Files to Server]]></title><link>https://repodev.com/blog</link><guid isPermaLink="false">https://repodev.com/blog</guid><pubDate>Wed, 21 Jul 2021 17:00:00 GMT</pubDate><content:encoded>&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;rsync -arvz -e &apos;ssh -p 22&apos; \
source_dir/{dir1,dir2} \
username@ip_address:/destination_dir
&lt;/code&gt;&lt;/pre&gt;</content:encoded></item><item><title><![CDATA[Shell: SSH Tunnel Server Services to Local]]></title><description><![CDATA[Host docker IP address: 172.17.0.1 Server local IP address: 127.0.0.1 Server private IP address: 192.168.10.111]]></description><link>https://repodev.com/blog</link><guid isPermaLink="false">https://repodev.com/blog</guid><pubDate>Wed, 21 Jul 2021 17:00:00 GMT</pubDate><content:encoded>&lt;ul&gt;
&lt;li&gt;Host docker IP address: &lt;code&gt;172.17.0.1&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Server local IP address: &lt;code&gt;127.0.0.1&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Server private IP address: &lt;code&gt;192.168.10.111&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;# direct
ssh username@public_ip -L 3306:server_local_ip:3306 -L 27017:server_local_ip:27017

# to docker
ssh username@public_ip -L docker_host_ip:3306:server_local_ip:3306 -L docker_host_ip:27017:server_local_ip:27017

# with key
ssh -i ~/key.pem username@public_ip -L docker_host_ip:3306:server_private_ip:3306
&lt;/code&gt;&lt;/pre&gt;</content:encoded></item><item><title><![CDATA[JavaScript: Chunk an Array]]></title><link>https://repodev.com/blog</link><guid isPermaLink="false">https://repodev.com/blog</guid><pubDate>Mon, 12 Jul 2021 17:00:00 GMT</pubDate><content:encoded>&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;function chunkItems(arr, chunkSize = 4) {
  const chunks = Array.from(
    { length: Math.ceil(arr.length / chunkSize) },
    (_, i) =&gt; {
      const start = chunkSize * i;
      return arr.slice(start, start + chunkSize);
    }
  );
}
&lt;/code&gt;&lt;/pre&gt;</content:encoded></item><item><title><![CDATA[JavaScript: Get Date]]></title><link>https://repodev.com/blog</link><guid isPermaLink="false">https://repodev.com/blog</guid><pubDate>Mon, 12 Jul 2021 17:00:00 GMT</pubDate><content:encoded>&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;const date = new Date();

// change `default` to a specific TimeZone
const day = date.toLocaleString(&apos;default&apos;, { weekday: &apos;long&apos; });
const month = date.toLocaleString(&apos;default&apos;, { month: &apos;short&apos; });
const year = date.toLocaleString(&apos;default&apos;, { year: &apos;numeric&apos; });
&lt;/code&gt;&lt;/pre&gt;</content:encoded></item><item><title><![CDATA[JavaScript: Object Properties]]></title><link>https://repodev.com/blog</link><guid isPermaLink="false">https://repodev.com/blog</guid><pubDate>Mon, 12 Jul 2021 17:00:00 GMT</pubDate><content:encoded>&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;const user = { id: 1, name: &apos;John Doe&apos; };
const contact = { phone: 4722880, address: &apos;Akihabara&apos; };

Object.keys(user); // getting the keys =&gt; [&quot;id&quot;, &quot;name&quot;]
Object.values(user); // getting the values =&gt; [1, &quot;John Doe&quot;]
Object.assign(user, contact); // extend objects =&gt; {address: &quot;Akihabara&quot;, id: 1, name: &quot;John Doe&quot;, phone: 4722880}
&lt;/code&gt;&lt;/pre&gt;</content:encoded></item><item><title><![CDATA[Install Android SDK Without Android Studio]]></title><description><![CDATA[Android Studio is one of the best development tool to create Android application. But we know that this tool is too heavy for some machines…]]></description><link>https://repodev.com/blog/install-android-sdk-without-android-studio</link><guid isPermaLink="false">https://repodev.com/blog/install-android-sdk-without-android-studio</guid><pubDate>Tue, 09 Mar 2021 17:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Android Studio is one of the best development tool to create Android application. But we know that this tool is too heavy for some machines, like mine. In order to develop an Android application, we need to use their SDK which is available to be download separately. So let&apos;s get started.&lt;/p&gt;
&lt;h2&gt;1. Prerequisite Tools&lt;/h2&gt;
&lt;p&gt;First, we need to download the latest SDK from &lt;a href=&quot;https://developer.android.com/studio#downloads&quot;&gt;Android official website&lt;/a&gt; and navigate to the &lt;code&gt;Command line tools only&lt;/code&gt; then download the file based on your OS, in this case I&apos;m using Linux. Another tool we need to use is Gradle (optional), please &lt;a href=&quot;https://gradle.org/releases/&quot;&gt;download the latest Gradle file&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;2. Manual Setup&lt;/h2&gt;
&lt;p&gt;Since we&apos;re not using Android studio bundle system, we need to setup the tools manually. I&apos;m going to use &lt;code&gt;/home/username/bin/&lt;/code&gt; for the installation directory. The installation directory would be like &lt;code&gt;/home/username/bin/android/sdk/cmdline-tools/latest&lt;/code&gt; and &lt;code&gt;/home/username/bin/android/gradle&lt;/code&gt;. Extract the SDK or &lt;code&gt;cmdlinetool&lt;/code&gt; and Gradle file inside our installation directory. The structure is supposed to be the following:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;  /home/username/bin/android/sdk/cmdline-tools/latest/
    |_bin/
    |_lib/
    |_NOTICE.txt
    |_source.properties

  /home/username/bin/android/gradle/gradle-x.x.x/
    |_bin/
    |_docs/
    |_init.d/
    |_lib/
    |_src/
    |_LICENSE
    |_NOTICE
    |_README
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Before set our environment variable, try to run the &lt;code&gt;cmdline-tools/bin/sdkmanager&lt;/code&gt; script from terminal command by running &lt;code&gt;./sdkmanager --list&lt;/code&gt; you&apos;ll get a list of available packages.&lt;/p&gt;
&lt;h2&gt;3. Install Packages&lt;/h2&gt;
&lt;p&gt;We need to install such packages like &lt;code&gt;system-images;android-x;google_api;x86_64&lt;/code&gt;, &lt;code&gt;platform;android-x&lt;/code&gt;, &lt;code&gt;platform-tools&lt;/code&gt;, &lt;code&gt;build-tools;x.x.x&lt;/code&gt;, where &lt;code&gt;x&lt;/code&gt; means the version.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;  ./sdkmanager &quot;platforms;android-30&quot; &quot;system-images;android-30;google_apis;x86_64&quot; &quot;platform-tools&quot;
  ./sdkmanager --licenses
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In order to connect our real device to the application, we need to install an additional packages, please install the following packages: &lt;code&gt;sudo pacman -S libmtp android-tools android-udev&lt;/code&gt; (the package name for other Linux Distro might be different).&lt;/p&gt;
&lt;p&gt;Now we create new entry in Path environment variable.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;  vi ~/.bashrc
    # Android SDK files
    export ANDROID_HOME=&quot;$HOME/bin/android/sdk&quot;
    export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools
    # Gradle
    export PATH=$PATH:$HOME/bin/android/gradle/gradle-x.x/bin
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;4. Testing and Run&lt;/h2&gt;
&lt;p&gt;We are ready to create new virtual device.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;  avdmanager create avd -n image_v29 -k &quot;system-images;android-29;google_apis;x86_64&quot;
  avdmanager list avd
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Go to &lt;code&gt;emulator&lt;/code&gt; directory and try to launch the virtual device by running the following command:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;  emulator -avd image_v29
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But if you want to develop your application from your device, you need to enable &lt;code&gt;developer option&lt;/code&gt; and enable &lt;code&gt;USB debugging&lt;/code&gt;, since we&apos;re already install the packages, we can easily plugged-in the phone to our machine and then allow the permission and we&apos;re done. Please refer to the internet, there are so many tutorial about it.&lt;/p&gt;
&lt;p&gt;It is a little tricky but now we are done. We don&apos;t need to use Android studio to create and develop our application, with those tools, we can still run the application through AVD or even our Android phone.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[SSH Keys with Multiple GitHub Accounts On a Single Machine]]></title><description><![CDATA[SSH key is very useful for us if we want to get rid of the need for typing in the username and password every time we make a Git push. But…]]></description><link>https://repodev.com/blog/ssh-keys-with-multiple-github-account-on-a-single-machine</link><guid isPermaLink="false">https://repodev.com/blog/ssh-keys-with-multiple-github-account-on-a-single-machine</guid><pubDate>Tue, 02 Feb 2021 17:00:00 GMT</pubDate><content:encoded>&lt;p&gt;SSH key is very useful for us if we want to get rid of the need for typing in the username and password every time we make a Git push. But if we have multiple GitHub accounts on the same machine, we need to manage the SSH keys for each account.&lt;/p&gt;
&lt;h2&gt;1. Generating the SSH Keys&lt;/h2&gt;
&lt;p&gt;Before generating an SSH key, we need to check our existing SSH Keys by command: &lt;code&gt;ls -la ~/.ssh&lt;/code&gt; Our existing public and private key pairs will list out (if exists).&lt;/p&gt;
&lt;p&gt;Let&apos;s assume &lt;code&gt;~/.ssh/id_rsa&lt;/code&gt; is not available (if it&apos;s available we can reuse it). We can create a new SSH key by running: &lt;code&gt;ssh-key -t rsa&lt;/code&gt;. Accept the default location by pressing enter when asked for the location to save the keys. We will get a private and public key at the default ssh location &lt;code&gt;~/.ssh/&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Above step is supposed to be used for our primary GitHub account, but for our another account, maybe our secondary account, we will create different SSH keys with a specific name.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;$ ssh-keygen -t rsa -b 4096 -C &quot;secondary@email.com&quot; -f &quot;id_rsa_secondary&quot;
OR
$ ssh-keygen -t ed25519 -C &quot;secondary@email.com&quot; -f &quot;id_rsa_secondary&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We have two different SSH keys created:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;~/.ssh/id_rsa
~/.ssh/id_rsa_secondary
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;2. Add SSH Keys to GitHub&lt;/h2&gt;
&lt;p&gt;We already have the SSH keys ready. We will ask our GitHub accounts to recognize the keys we have created. You can follow &lt;a href=&quot;https://docs.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account&quot;&gt;GitHub Doc&lt;/a&gt; in case this process changes on GitHub website.&lt;/p&gt;
&lt;p&gt;To copy the public key to the clipboard, run the following command, substituting for the correct filename. We will copy the primary key first.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;$ xclip -selection clipboard &amp;#x3C; ~/.ssh/id_rsa.pub
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then log in to your primary GitHub account:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Go to &lt;code&gt;Settings&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Select &lt;code&gt;SSH and GPG Keys&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Click on &lt;code&gt;New SSH key&lt;/code&gt; button, provide a title, and paste the key in the box.&lt;/li&gt;
&lt;li&gt;Click &lt;code&gt;Add SSH key&lt;/code&gt; and you are done&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Repeat the above steps in your secondary GitHub account.&lt;/p&gt;
&lt;h2&gt;3. Registering the new SSH Keys&lt;/h2&gt;
&lt;p&gt;New keys need registered before they are useful. We have to register them with the &lt;code&gt;ssh-agent&lt;/code&gt; on our machine. make sure it is running by running &lt;code&gt;eval &quot;$(ssh-agent -s)&quot;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Once running, then add our new keys to the ssh-agent like so:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;ssh-add ~/.ssh/id_rsa
ssh-add ~/.ssh/id_rsa_secondary
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;4. Create a Git Config File&lt;/h2&gt;
&lt;p&gt;This config file is used to tell git to identify which SSH key is to to be used. It lives at &lt;code&gt;~/.ssh/config&lt;/code&gt;, if the config does not yet exist, we can easily create it:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;touch ~/.ssh/config
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here is an example from my &lt;code&gt;~/.ssh/config&lt;/code&gt; file.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;Host github.com
HostName github.com
User git
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa

Host secondary.github.com
HostName github.com
User git
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_secondary
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;git URL that uses &lt;strong&gt;github.com&lt;/strong&gt; should use &lt;strong&gt;id_rsa&lt;/strong&gt; (my primary GitHub account)&lt;/li&gt;
&lt;li&gt;git URL that uses &lt;strong&gt;secondary.github.com&lt;/strong&gt; should use &lt;strong&gt;id_rsa _secondary&lt;/strong&gt; (my secondary GitHub account)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;5. Cloning Repository&lt;/h2&gt;
&lt;p&gt;Now that the config are in place and ready to use, we can try it by cloning the corresponding repositories. Make a note that when we clone a repo, we use the host names that we used in the SSH config file.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;// uses our primary SSH key
$ git clone git@github.com:primary/repoName.git

// uses our secondary SSH key
$ git clone git@secondary.github.com:secondary/repoName.git
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It is a little tricky but now we are done it. Just remember to clone the url with the correct &lt;strong&gt;Host&lt;/strong&gt; format depending on which account you want to use.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How to Install Arch Linux]]></title><description><![CDATA[I have an old Laptop, it has 4GB of RAM and low spec CPU. So I decided to put Arch Linux in it. I was a bit struggle with the installation…]]></description><link>https://repodev.com/blog/how-to-install-arch-linux</link><guid isPermaLink="false">https://repodev.com/blog/how-to-install-arch-linux</guid><pubDate>Tue, 26 Jan 2021 17:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I have an old Laptop, it has 4GB of RAM and low spec CPU. So I decided to put Arch Linux in it. I was a bit struggle with the installation steps (I&apos;m using Manjaro though :D) but I successfully installed it.&lt;/p&gt;
&lt;p&gt;The installation steps is actually explained very well on &lt;a href=&quot;https://wiki.archlinux.org/index.php/Installation_guide&quot;&gt;arch linux official website&lt;/a&gt;. But in this post, I just want to share what I&apos;ve done and maybe it&apos;ll be usefull for you in case you also want to try to install Arch Linux.&lt;/p&gt;
&lt;h2&gt;Let&apos;s get started&lt;/h2&gt;
&lt;p&gt;First, you need to download the ISO file from the &lt;a href=&quot;https://archlinux.org/download/&quot;&gt;Download page&lt;/a&gt;. I was using USB flash drive, please refer to &lt;a href=&quot;https://wiki.archlinux.org/index.php/Installation_guide#Prepare_an_installation_medium&quot;&gt;Pre-installation section&lt;/a&gt; for more details. Be sure to &lt;a href=&quot;https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface/Secure_Boot#Disabling_Secure_Boot&quot;&gt;disable Secure Boot&lt;/a&gt; on your machine, because Arch Linux installation images do not support &lt;code&gt;Secure Boot&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Installation&lt;/h2&gt;
&lt;p&gt;I assume you&apos;ve already logged in on the live environment. You need to connect to the internet to be able to install the packages, check &lt;a href=&quot;https://wiki.archlinux.org/index.php/Installation_guide#Connect_to_the_internet&quot;&gt;set up a network connection in the live environment&lt;/a&gt; for the details.&lt;/p&gt;
&lt;p&gt;For example you might want to use &lt;code&gt;iwctl&lt;/code&gt; to connect to your WiFi network.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;# ip addr                                        &amp;#x3C;== check your WiFi interface name
# iwctl
    [iwd]# station wlan0 scan                    &amp;#x3C;== `wlan0` is an example of WiFi interface name
    [iwd]# station wlan0 connect SSID_NAME
    [iwd]# exit
# ping archlinux.org
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Through the virtual console, set up the system time and date by typing &lt;code&gt;timedatectl set-ntp true&lt;/code&gt;. Then we need to set up our Partitions. I&apos;m using LVM in this example, so feel free to choose your own Partition type.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Partition the disks&lt;/p&gt;
&lt;p&gt;Select the block device, in this case &lt;em&gt;X&lt;/em&gt; is an example like &lt;code&gt;/dev/sdb&lt;/code&gt;, &lt;code&gt;/dev/sdc&lt;/code&gt;, it might be different on your system.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;# lsblk              &amp;#x3C;== to identify a block device

# fdisk /dev/sdX     &amp;#x3C;== don&apos;t forget to change the X
n (to add a new partition)
p (for primary partition)
1 (default partition number)
(accept default start)
(accept default end)
t (to change partition type)
8e (for LVM partition when using MBR)
i (to verify)
w (save and quit)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Alternatively, you can use &lt;code&gt;cfdisk&lt;/code&gt;, for example &lt;code&gt;cfdisk /dev/sdX&lt;/code&gt;, then select &lt;code&gt;gpt&lt;/code&gt; label. Please remember, if you have an &lt;code&gt;EFI System&lt;/code&gt; partition, you&apos;ll need to install &lt;code&gt;efibootmgr&lt;/code&gt; for your machine, we&apos;ll do it later. To verify if your machine support &lt;code&gt;EFI System&lt;/code&gt; or not, please run: &lt;code&gt;ls /sys/firmware/efi/efivars&lt;/code&gt;, if there&apos;s an output from that command, you&apos;re absolutely need an &lt;code&gt;EFI System&lt;/code&gt; partition, if not, then you need a &lt;code&gt;BIOS Boot&lt;/code&gt; partition, create &lt;code&gt;512M&lt;/code&gt; size partition with one of those type.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create LVM partition&lt;/p&gt;
&lt;p&gt;After you finished set up the partition, we need to create our &lt;a href=&quot;https://wiki.archlinux.org/index.php/LVM#Creating&quot;&gt;LVM disk layout&lt;/a&gt;. I have &lt;code&gt;500GB&lt;/code&gt; of storage available, I&apos;ll use all of it as a single boot (Linux only). Run the following command step by step. (Again, don&apos;t forget to change the &lt;em&gt;X&lt;/em&gt;)&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;# pvcreate /dev/sdX1               &amp;#x3C;== create physical volumes

# vgcreate vg1 /dev/sdX1           &amp;#x3C;== create volume groups (vg1 is my group name, you can change it)

== Create logical volumes ==
# lvcreate -L 100G -n root vg1     &amp;#x3C;== 100GB of /root system
# lvcreate -L 4G -n swap vg1       &amp;#x3C;== 4GB of swap
# lvcreate -l 100%FREE -n home vg1 &amp;#x3C;== the rest of available storage after allocation as /home partition

== Format the partitions ==
# mkfs.ext4 /dev/vg1/root
# mkfs.ext4 /dev/vg1/home
# mkswap /dev/vg1/swap
# swapon /dev/vg1/swap

== Mount the file systems ==
# mount /dev/vg1/root /mnt
# mkdir /mnt/home
# mount /dev/vg1/home /mnt/home
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you have &lt;code&gt;EFI System&lt;/code&gt; partition, please format the partition with the following command:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;# mkfs.fat -F32 /dev/sdX1              &amp;#x3C;==  change `1` depends on your `EFI System` partition number
# mkdir /mnt/efi
# mount /dev/sdX1 /mnt/efi
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Install packages&lt;/p&gt;
&lt;p&gt;We&apos;re ready to install our essential packages. Since we&apos;re still in the virtual console of the live boot environment, &lt;code&gt;pacstrap&lt;/code&gt; is the only tool we have to install packages. Run the following command and wait until it finished.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;# pacstrap /mnt base base-devel vi lvm2 dhclient dhcp dhcpcd linux linux-firmware mkinitcpio git iwd iw wpa_supplicant dialog netctl ifplugd nano networkmanager sudo
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Configure the system&lt;/p&gt;
&lt;p&gt;We&apos;re almost finished, next step is go through the following steps and you&apos;ll safe.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shellsession&quot;&gt;# genfstab -U /mnt &gt;&gt; /mnt/etc/fstab

# arch-chroot /mnt /bin/bash

# locale-gen

# vi /etc/locale.gen
LANG=en_US.UTF-8      &amp;#x3C;== uncomment this

# tzselect
# ln -s /usr/share/zoneinfo/Zone/SubZone /etc/localtime   &amp;#x3C;== change your zone

# hwclock --systohc --utc

# vi /etc/mkinitcpio.conf
HOOKS=&quot;...lvm2 filesystems...&quot;    &amp;#x3C;== put lvm2 inside HOOKS

# mkinitcpio -p linux

# vi etc/hostname

# vi /etc/hosts
127.0.0.1       localhost
::1             localhost
127.0.1.1       your_hostname.localdomain       your_hostname

# useradd -G wheel,audio,video -m your_username
# passwd your_username

# passwd     &amp;#x3C;== to create `root` password

# EDITOR=vi visudo
%wheel ALL=(ALL) ALL     &amp;#x3C;== uncomment this

# pacman -S grub                &amp;#x3C;== Only for BIOS Boot
# pacman -S grub efibootmgr     &amp;#x3C;== Only for EFI System

# grub-install --target=i386-pc /dev/sdX   &amp;#x3C;== change the X, Only for BIOS Boot
# grub-install --target=x86_64-efi --efi-directory=/efi/ --bootloader-id=arch_grub     &amp;#x3C;== Only if you use efi boot mode

# grub-mkconfig -o /boot/grub/grub.cfg

# systemctl enable dhcpcd
# systemctl enable NetworkManager

# exit (from `chroot`)

# reboot
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Finally, we&apos;re successully installed Arch Linux. The next step is choose your &lt;a href=&quot;https://wiki.archlinux.org/index.php/General_recommendations#Graphical_user_interface&quot;&gt;Graphical user interface&lt;/a&gt; maybe like GNOME, KDE, etc. If you have problems with the installation steps, feel free to hit me up or refer to &lt;a href=&quot;https://wiki.archlinux.org/index.php/Installation_guide#Post-installation&quot;&gt;Arch Linux installation guide&lt;/a&gt;.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How to Switch From Vundle to Vim-Plug the Easy Way]]></title><description><![CDATA[Recently i just switched to vim-plug. I've searched on the internet for better alternatives, and end up with vim-plug. There is no important…]]></description><link>https://repodev.com/blog/how-to-switch-from-vundle-to-vim-plug-the-easy-way</link><guid isPermaLink="false">https://repodev.com/blog/how-to-switch-from-vundle-to-vim-plug-the-easy-way</guid><pubDate>Fri, 10 Apr 2020 17:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Recently i just switched to &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot;&gt;vim-plug&lt;/a&gt;. I&apos;ve searched on the internet for better alternatives, and end up with vim-plug. There is no important reason why i switched over from Vundle to vim-plug.&lt;/p&gt;
&lt;p&gt;Installing vim-plug is quite easy (see documentation), since i&apos;ve already installed some plugins with Vundle, there is a useful tips to retrieve the installed plugins on Vundle directory and copying them to vim-plug directory, so i don&apos;t need to install all plugins over internet again.&lt;/p&gt;
&lt;h2&gt;Update .vimrc file&lt;/h2&gt;
&lt;p&gt;Before doing it, i recommend you to backup it first. Open your .vimrc file and find Vundle setup, like the following example:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-vim&quot;&gt;    [...]
    &quot; set the runtime path to include VUndle and initialize
    set rtp+=~/.vim/bundle/Vundle.vim
    call vundle#begin()

    &quot; let Vundle manage Vundle, required
    Plugin &apos;VundleVim/Vundle.vim&apos;

    call vundle#end()
    [...]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then you need to replace it with:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-vim&quot;&gt;    [...]
    &quot; Install vim-plug if we don&apos;t already have it
    if empty(glob(&apos;~/.vim/autoload/plug.vim&apos;))
    silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
        \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
    autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
    endif

    call plug#begin(&apos;~/.vim/plugged&apos;)

    call plug#end()
    [...]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We&apos;re not done yet, there is one more thing we need to do, we need to change our plugin list with &lt;code&gt;Plug&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-vim&quot;&gt;    Plugin &apos;preservim/nerdtree&apos;    &quot; &amp;#x3C;= this is for Vundle
    Plug &apos;preservim/nerdtree&apos;      &quot; &amp;#x3C;= this is for vim-plug
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Save it, and restart your vim. After that, you can simply run &lt;code&gt;:PlugInstall&lt;/code&gt; and it will automatically copying all the installed plugins from Vundle directory to vim-plug directory.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How To Setup PostgreSQL and PGAdmin4 on Docker]]></title><description><![CDATA[I use docker almost every day (for my development environment) but i don't know why i installed PostgreSQL on my own laptop and not in…]]></description><link>https://repodev.com/blog/how-to-setup-postgresql-and-pgadmin4-on-docker</link><guid isPermaLink="false">https://repodev.com/blog/how-to-setup-postgresql-and-pgadmin4-on-docker</guid><pubDate>Mon, 13 Jan 2020 17:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I use docker almost every day (for my development environment) but i don&apos;t know why i installed PostgreSQL on my own laptop and not in docker like on my office computer :D. Just for your information, i use Archlinux on my laptop, and i usually got some problems with the regular system update for my PostgreSQL, it tooks me a few hours to fix it that&apos;s why i decide to use PostgreSQL database inside docker.&lt;/p&gt;
&lt;p&gt;But, i found that by using it on docker is bit different, especially for accessing the PostgreSQL commands since it&apos;s being use inside a docker container, so we can&apos;t directly use the command through terminal.&lt;/p&gt;
&lt;p&gt;I assume you guys already know how to work with docker, and in this article i&apos;ll share the basic setup for PostgreSQL database and its tools like PgAdmin through our favorite tool docker compose and terminal. I won&apos;t cover any security tips or best configurations since it&apos;s only for development, but if you still want to know how to hardening your docker environment for PostgreSQL, please read the documentation.&lt;/p&gt;
&lt;p&gt;First step, make sure you have docker and docker compose installed on your machine, then you can pull the PostgreSQL image from docker hub (feel free to choose your own PostgreSQL version), i&apos;m gonna use PostgreSQL 11 and the latest pgadmin4, run &lt;code&gt;docker pull postgres:11-alpine&lt;/code&gt; then &lt;code&gt;docker pull dpage/pgadmin4&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Quick setup&lt;/h2&gt;
&lt;p&gt;You can run the following commands in you terminal:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;  $ mkdir postgres-docker &amp;#x26;&amp;#x26; cd postgres-docker

  # Create docker volume for docker
  $ docker volume create --driver local --name=postgrevolume
  $ docker volume create --driver local --name=pgadminvolume

  # Create docker network for docker
  $ docker network create --driver bridge postgrenetwork

  # Create postgre environment files
  $ nano postgre-env.list
  POSTGRES_USER=your_pg_username
  POSTGRES_PASSWORD=your_pg_password

  $ nano pgadmin-env.list
  PGADMIN_DEFAULT_EMAIL=your_pgadmin_email@yourdomain.com
  PGADMIN_DEFAULT_PASSWORD=your_pgadmin_password

  docker run --publish 5432:5432 \
    --volume=postgrevolume:/pgdata \
    --env-file=postgre-env.list \
    --name=&quot;postgres&quot; \
    --hostname=&quot;postgres&quot; \
    --network=&quot;postgrenetwork&quot; \
    --detach \
  postgres:11-alpine

  docker run --publish 8088:80 \
    --volume=pgadminvolume:/var/lib/pgadmin \
    --env-file=pgadmin-env.list \
    --name=&quot;pgadmin4&quot; \
    --hostname=&quot;pgadmin4&quot; \
    --network=&quot;postgrenetwork&quot; \
    --detach \
  dpage/pgadmin4:latest
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Open your browser to &lt;code&gt;localhost:8088&lt;/code&gt; and input your pgadmin email and password. Add &lt;code&gt;new server&lt;/code&gt; then set the &lt;code&gt;postgres&lt;/code&gt; container IP address as &lt;code&gt;host&lt;/code&gt;, you can check the IP address through this command &lt;code&gt;docker container inspect postgres&lt;/code&gt; or you can just set &lt;code&gt;postgres&lt;/code&gt; as host since we&apos;ve run our docker with &lt;code&gt;--hostname=&quot;postgres&quot;&lt;/code&gt; option.&lt;/p&gt;
&lt;h2&gt;Docker Compose&lt;/h2&gt;
&lt;p&gt;We can also use docker compose to wrapped up our services in one file. Create &lt;code&gt;docker-compose.yml&lt;/code&gt; file inside &lt;code&gt;postgres-docker&lt;/code&gt; directory with the following configurations:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yml&quot;&gt;version: &apos;3.7&apos;
services:
  database:
    image: postgres:11-alpine
    container_name: postgres
    hostname: postgres
    env_file:
      - ./postgre-env.list
    volumes:
      - postgresvolume:/pgdata
    ports:
      - &apos;5432:5432&apos;
    networks:
      - postgrenetwork

  pgadmin4:
    image: dpage/pgadmin4:latest
    container_name: pgadmin4
    hostname: pgadmin4
    env_file:
      - ./pgadmin-env.list
    volumes:
      - pgadminvolume:/var/lib/pgadmin
    ports:
      - &apos;8088:80&apos;
    networks:
      - postgrenetwork

networks:
  postgrenetwork:

volumes:
  postgresvolume:
  pgadminvolume:
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Save it and run &lt;code&gt;docker-compose up -d&lt;/code&gt;, it&apos;ll work as well as you run directly through &lt;code&gt;docker run&lt;/code&gt; command on terminal.&lt;/p&gt;
&lt;p&gt;With this, there will be no problems anymore if i update/upgrade my linux system, i can completely remove PostgreSQL package from my laptop and just using it through docker container.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Set Up VIM as An IDE - Part 2]]></title><description><![CDATA[Now, in this article i'll continue to setup Vim based on the article part 1. The first thing to do is to add a plugin managers, there are a…]]></description><link>https://repodev.com/blog/set-up-vim-as-an-ide-part-2</link><guid isPermaLink="false">https://repodev.com/blog/set-up-vim-as-an-ide-part-2</guid><pubDate>Sat, 02 Nov 2019 17:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Now, in this article i&apos;ll continue to setup Vim based on the &lt;a href=&quot;https://repodev.com/blog/set-up-vim-as-an-ide-part-1&quot;&gt;article part 1&lt;/a&gt;. The first thing to do is to add a plugin managers, there are a few plugin manager that you can choose, you can search on google and pick which one do you want to use, but for me, i&apos;m gonna use &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot;&gt;Vundle&lt;/a&gt;. Please see the installation instructions for the plugin manager that you choose.&lt;/p&gt;
&lt;h2&gt;Theming&lt;/h2&gt;
&lt;p&gt;Okay, let&apos;s assume that you&apos;ve already installed the plugin manager, then we&apos;ll add the following setup inside &lt;code&gt;.vimrc&lt;/code&gt; file.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-vim&quot;&gt;  &quot; PLUGINS
  &quot; ************************************************************************
  &quot; set the runtime path to include VUndle and initialize
  set rtp+=~/.vim/bundle/Vundle.vim
  call vundle#begin()

  &quot; let Vundle manage Vundle, required
  Plugin &apos;VundleVim/Vundle.vim&apos;

  &quot; Brief help
  &quot; :PluginList       - lists configured plugins
  &quot; :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
  &quot; :PluginSearch foo - searches for foo; append `!` to refresh local cache
  &quot; :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal

  Plugin &apos;flazz/vim-colorschemes&apos;
  Plugin &apos;elzr/vim-json&apos;
  Plugin &apos;plasticboy/vim-markdown&apos;
  Plugin &apos;severin-lemaignan/vim-minimap&apos;
  Plugin &apos;airblade/vim-gitgutter&apos;

  &quot; Icon files
  Plugin &apos;tiagofumo/vim-nerdtree-syntax-highlight&apos;
  Plugin &apos;ryanoasis/vim-devicons&apos;
  &quot; Airline
  Plugin &apos;vim-airline/vim-airline&apos;
  Plugin &apos;vim-airline/vim-airline-themes&apos;

  &quot; theme plugins
  Plugin &apos;nightsense/office&apos;
  Plugin &apos;fatih/molokai&apos;
  Plugin &apos;nightsense/cosmic_latte&apos;
  Plugin &apos;ErichDonGubler/vim-sublime-monokai&apos;
  Plugin &apos;Nequo/vim-allomancer&apos;

  &quot; All of your Plugins must be added before the following line
  call vundle#end()

  try
    &quot; Choose colorscheme
    &quot; *********************************************
    if strftime(&apos;%H&apos;) &gt;= 7 &amp;#x26;&amp;#x26; strftime(&apos;%H&apos;) &amp;#x3C; 20
        colorscheme sublimemonokai
    else
        &quot; colorscheme office-dark
        colorscheme allomancer
        let g:airline_theme=&apos;cosmic_latte_dark&apos;
    endif
  catch
  endtry
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After you add those setup in you &lt;code&gt;.vimrc&lt;/code&gt; file, try to open your Vim and then install all the plugins we&apos;ve set by using vundle command &lt;code&gt;:PluginInstall&lt;/code&gt;. It&apos;ll take a few seconds then re-open your Vim and you&apos;ll see a theme (color scheme) has been applied on our Vim. Okay, it&apos;s cool, but there&apos;s one more thing you need to do before going further, since i use &lt;code&gt;vim-devicons&lt;/code&gt;, this plugin will adds file type icons for our files inside Vim, so you need to follow the instructions &lt;a href=&quot;https://github.com/ryanoasis/vim-devicons&quot;&gt;here&lt;/a&gt; to make it work.&lt;/p&gt;
&lt;p&gt;Let&apos;s add some more plugins for our Vim. &lt;em&gt;NOTES: the following plugins are just for my own used, you might not need it, so you can uninstall it later.&lt;/em&gt; Please put the following plugin list right above &lt;code&gt;call vundle#end()&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-vim&quot;&gt;  Plugin &apos;scrooloose/nerdtree&apos;                                                &quot; Better file browser
  Plugin &apos;scrooloose/nerdcommenter&apos;                                           &quot; Code commenter
  Plugin &apos;majutsushi/tagbar&apos;                                                  &quot; Class/module browser
  Plugin &apos;ctrlpvim/ctrlp.vim&apos;                                                 &quot; Code and files fuzzy finder
  Plugin &apos;mattn/emmet-vim&apos;                                                    &quot; emmet, you know what it is
  Plugin &apos;kien/tabman.vim&apos;                                                    &quot; Tab list panel
  Plugin &apos;Townk/vim-autoclose&apos;                                                &quot; Autoclose chars
  Plugin &apos;fisadev/dragvisuals.vim&apos;                                            &quot; Drag visual blocks arround (it is like Ctrl+d arrow up/down on sublime)
  Plugin &apos;t9md/vim-choosewin&apos;                                                 &quot; Land on window like tmux&apos;s &apos;display-pane&apos;
  Plugin &apos;tpope/vim-fugitive&apos;                                                 &quot; Git integration
  Plugin &apos;google/vim-searchindex&apos;                                             &quot; display number of search matches &amp;#x26; index of a current match
  Plugin &apos;ap/vim-css-color&apos;                                                   &quot; Paint css colors with the real color
  Plugin &apos;tpope/vim-surround&apos;                                                 &quot; Surround
  Plugin &apos;vim-scripts/matchit.zip&apos;                                            &quot; XML/HTML tags navigation
  Plugin &apos;vim-scripts/YankRing.vim&apos;                                           &quot; Yank history navigation
  Plugin &apos;pangloss/vim-javascript&apos;                                            &quot; Javascript indentation and syntax support
  Plugin &apos;w0rp/ale&apos;                                                           &quot; Check syntax in Vim asynchronously and fix files
  Plugin &apos;MaxMEllon/vim-jsx-pretty&apos;                                           &quot; JSX syntax pretty highlighting
  Plugin &apos;styled-components/vim-styled-components&apos;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Save it, and install again by using vundle command &lt;code&gt;:PluginInstall&lt;/code&gt;. Cool, we&apos;re are done with the plugins setup. But we&apos;re not done yet, we need to configure our installed plugins. All the plugins are configurable, which mean you can configure it base on your needs, that&apos;s why Vim is powerful. So here is my plugins setup, just put it in the very bottom of &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;
&lt;h2&gt;Plugin Tweak&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-vim&quot;&gt;  &quot; PLUGINS SETUP
  &quot; ********************************************************************************

  &quot; NERDTree -----------------------------
  map &amp;#x3C;C-b&gt; :NERDTreeToggle&amp;#x3C;CR&gt;
  let g:NERDTreeDirArrowExpandable = &apos;▸&apos;&quot; Prettier
  &quot; open nerdtree with the current file selected
  nmap &amp;#x3C;leader&gt;t :NERDTreeFind&amp;#x3C;CR&gt;
  let g:NERDTreeDirArrowCollapsible = &apos;▾&apos;
  let g:NERDTreeMouseMode = 3
  let NERDTreeShowLineNumbers = 1
  let NERDTreeShowHidden = 1
  let NERDTreeMinimalUI = 1
  let NERDTreeIgnore=[&apos;\.pyc$&apos;, &apos;\~$&apos;]         &quot;ignore files in NERDTree

  &quot; Tagbar -----------------------------
  &quot; toggle tagbar display
  map &amp;#x3C;F4&gt; :TagbarToggle&amp;#x3C;CR&gt;
  &quot; autofocus on tagbar open
  let g:tagbar_autofocus = 1

  &quot; Airline -----------------------------
  let g:airline_powerline_fonts = 1
  let g:airline_theme = &apos;distinguished&apos;
  let g:airline#extensions#ale#enabled = 1
  let g:airline#extensions#tabline#enabled = 1
  let g:airline#extensions#whitespace#enabled = 0
  let g:Powerline_symbols = &quot;fancy&quot;
  let g:Powerline_dividers_override = [&quot;\Ue0b0&quot;,&quot;\Ue0b1&quot;,&quot;\Ue0b2&quot;,&quot;\Ue0b3&quot;]
  let g:Powerline_symbols_override = {&apos;BRANCH&apos;: &quot;\Ue0a0&quot;, &apos;LINE&apos;: &quot;\Ue0a1&quot;, &apos;RO&apos;: &quot;\Ue0a2&quot;}

  &quot; to use fancy symbols for airline
  if !exists(&apos;g:airline_symbols&apos;)
      let g:airline_symbols = {}
  endif

  &quot; Airline unicode symbols
  let g:airline_left_sep = &apos;»&apos;
  let g:airline_right_sep = &apos;«&apos;
  let g:airline_left_alt_sep = &apos;&apos;
  let g:airline_right_alt_sep = &apos;&apos;

  let g:airline_symbols.branch = &apos;&apos;
  let g:airline_symbols.readonly = &apos;&apos;
  let g:airline_symbols.linenr = &apos;&apos;
  let g:airline_symbols.paste = &apos;ρ&apos;
  let g:airline_symbols.whitespace = &apos;Ξ&apos;

  &quot; vim-minimap -----------------------------
  let g:minimap_highlight=&apos;Visual&apos;
  let g:minimap_show=&apos;&amp;#x3C;leader&gt;ms&apos;
  let g:minimap_update=&apos;&amp;#x3C;leader&gt;mu&apos;
  let g:minimap_close=&apos;&amp;#x3C;leader&gt;gc&apos;
  let g:minimap_toggle=&apos;&amp;#x3C;leader&gt;gt&apos;

  &quot; CtrlP -----------------------------
  &quot; file finder mapping
  let g:ctrlp_map = &apos;&amp;#x3C;leader&gt;ee&apos;
  &quot; tags (symbols) in current file finder mapping
  nmap &amp;#x3C;leader&gt;g :CtrlPBufTag&amp;#x3C;CR&gt;
  &quot; tags (symbols) in all files finder mapping
  nmap &amp;#x3C;leader&gt;G :CtrlPBufTagAll&amp;#x3C;CR&gt;
  &quot; general code finder in all files mapping
  nmap &amp;#x3C;leader&gt;f :CtrlPLine&amp;#x3C;CR&gt;
  &quot; recent files finder mapping
  nmap &amp;#x3C;leader&gt;m :CtrlPMRUFiles&amp;#x3C;CR&gt;
  &quot; commands finder mapping
  nmap &amp;#x3C;leader&gt;c :CtrlPCmdPalette&amp;#x3C;CR&gt;
  &quot; to be able to call CtrlP with default search text
  function! CtrlPWithSearchText(search_text, ctrlp_command_end)
      execute &apos;:CtrlP&apos; . a:ctrlp_command_end
      call feedkeys(a:search_text)
  endfunction
  &quot; same as previous mappings, but calling with current word as default text
  nmap &amp;#x3C;leader&gt;wg :call CtrlPWithSearchText(expand(&apos;&amp;#x3C;cword&gt;&apos;), &apos;BufTag&apos;)&amp;#x3C;CR&gt;
  nmap &amp;#x3C;leader&gt;wG :call CtrlPWithSearchText(expand(&apos;&amp;#x3C;cword&gt;&apos;), &apos;BufTagAll&apos;)&amp;#x3C;CR&gt;
  nmap &amp;#x3C;leader&gt;wf :call CtrlPWithSearchText(expand(&apos;&amp;#x3C;cword&gt;&apos;), &apos;Line&apos;)&amp;#x3C;CR&gt;
  nmap &amp;#x3C;leader&gt;we :call CtrlPWithSearchText(expand(&apos;&amp;#x3C;cword&gt;&apos;), &apos;&apos;)&amp;#x3C;CR&gt;
  nmap &amp;#x3C;leader&gt;pe :call CtrlPWithSearchText(expand(&apos;&amp;#x3C;cfile&gt;&apos;), &apos;&apos;)&amp;#x3C;CR&gt;
  nmap &amp;#x3C;leader&gt;wm :call CtrlPWithSearchText(expand(&apos;&amp;#x3C;cword&gt;&apos;), &apos;MRUFiles&apos;)&amp;#x3C;CR&gt;
  nmap &amp;#x3C;leader&gt;wc :call CtrlPWithSearchText(expand(&apos;&amp;#x3C;cword&gt;&apos;), &apos;CmdPalette&apos;)&amp;#x3C;CR&gt;
  &quot; don&apos;t change working directory
  let g:ctrlp_working_path_mode = 0
  &quot; ignore these files and folders on file finder
  let g:ctrlp_custom_ignore = {
              \ &apos;dir&apos;:  &apos;\v[\/](\.git|\.hg|\.svn|node_modules|vendor)$&apos;,
              \ &apos;file&apos;: &apos;\.pyc$\|\.pyo$\|\.sh$\|\.so$&apos;,
              \ }

  &quot; vim emmet trigger key, prest ctrl + e + comma -----------------------------
  let g:user_emmet_leader_key=&apos;&amp;#x3C;C-E&gt;&apos;

  &quot; TabMan ------------------------------
  &quot; mappings to toggle display, and to focus on it
  let g:tabman_toggle = &apos;tl&apos;
  let g:tabman_focus  = &apos;tf&apos;

  &quot; Autoclose ------------------------------
  &quot; Fix to let ESC work as espected with Autoclose plugin
  let g:AutoClosePumvisible = {&quot;ENTER&quot;: &quot;\&amp;#x3C;C-Y&gt;&quot;, &quot;ESC&quot;: &quot;\&amp;#x3C;ESC&gt;&quot;}

  &quot; DragVisuals ------------------------------
  &quot; mappings to move blocks in 4 directions
  vmap &amp;#x3C;expr&gt; &amp;#x3C;S-M-LEFT&gt; DVB_Drag(&apos;left&apos;)
  vmap &amp;#x3C;expr&gt; &amp;#x3C;S-M-RIGHT&gt; DVB_Drag(&apos;right&apos;)
  vmap &amp;#x3C;expr&gt; &amp;#x3C;S-M-DOWN&gt; DVB_Drag(&apos;down&apos;)
  vmap &amp;#x3C;expr&gt; &amp;#x3C;S-M-UP&gt; DVB_Drag(&apos;up&apos;)
  &quot; mapping to duplicate block
  vmap &amp;#x3C;expr&gt; D DVB_Duplicate()

  &quot; choosewin  ------------------------------
  &quot; mapping
  nmap  -  &amp;#x3C;Plug&gt;(choosewin)
  &quot; show big letters
  let g:choosewin_overlay_enable = 1

  &quot; vim-javascript --------------------------
  &quot; set conceallevel=1
  map &amp;#x3C;leader&gt;co :exec &amp;#x26;conceallevel ? &quot;set conceallevel=0&quot; : &quot;set conceallevel=1&quot;&amp;#x3C;CR&gt;
  let g:javascript_conceal_function             = &quot;ƒ&quot;
  let g:javascript_conceal_null                 = &quot;ø&quot;
  let g:javascript_conceal_this                 = &quot;@&quot;
  let g:javascript_conceal_return               = &quot;⇚&quot;
  let g:javascript_conceal_undefined            = &quot;¿&quot;
  let g:javascript_conceal_NaN                  = &quot;ℕ&quot;
  let g:javascript_conceal_prototype            = &quot;¶&quot;
  let g:javascript_conceal_static               = &quot;•&quot;
  let g:javascript_conceal_super                = &quot;Ω&quot;
  let g:javascript_conceal_arrow_function       = &quot;⇒&quot;
  let g:javascript_conceal_noarg_arrow_function = &quot;🞅&quot;
  let g:javascript_conceal_underscore_arrow_function = &quot;🞅&quot;

  &quot; ALE (eslint)  -------------------------
  map &amp;#x3C;C-t&gt; :ALEDetail&amp;#x3C;CR&gt;
  let g:ale_fix_on_save = 1
  let g:ale_sign_error = &apos;✗&apos;
  let g:ale_sign_warning = &apos;⚠&apos;
  let g:ale_open_list = 1
  let g:ale_set_loclist = 0
  let g:ale_lint_on_enter = 0
  let g:ale_set_quickfix = 1
  let g:ale_keep_list_window_open = 0
  let g:ale_lint_delay = 960000                 &quot; 16 minutes
  let g:ale_lint_on_text_changed= &quot;never&quot;
  let g:ale_list_window_size = 5                &quot; Show 5 lines of errors (default: 10)
  nmap &amp;#x3C;silent&gt; &amp;#x3C;Leader&gt;k &amp;#x3C;Plug&gt;(ale_previous_wrap)
  nmap &amp;#x3C;silent&gt; &amp;#x3C;Leader&gt;j &amp;#x3C;Plug&gt;(ale_next_wrap)
  let g:ale_linters = {
    \  &apos;sh&apos;: [&apos;shell&apos;],
    \  &apos;javascript&apos;: [&apos;eslint&apos;],
    \}
  let g:ale_fixers = {
    \  &apos;sh&apos;: [&apos;shfmt&apos;],
    \  &apos;javascript&apos;: [&apos;prettier&apos;, &apos;eslint&apos;],
    \  &apos;json&apos;: [&apos;prettier&apos;],
    \  &apos;markdown&apos;: [&apos;prettier&apos;],
    \  &apos;yaml&apos;: [&apos;prettier&apos;],
    \  &apos;css&apos;: [&apos;prettier&apos;],
    \}

  &quot; vim jsx pretty -----------------------
  let g:vim_jsx_pretty_colorful_config = 1

  let g:coc_node_path = &apos;/home/your_username/.nvm/versions/node/v12.13.0/bin/node&apos;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After you added it, you need to install some javascript packages globally like &lt;code&gt;eslint&lt;/code&gt; and &lt;code&gt;prettier&lt;/code&gt; because i want my Vim to automatically detect syntax error and format my code. To install it, run this command through your terminal &lt;code&gt;npm install -g eslint prettier&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Cool, we&apos;re almost done. The last thing you need to do is to install &lt;em&gt;Intellisense engine&lt;/em&gt; for Vim. I&apos;m gonna use &lt;code&gt;coc.nvim&lt;/code&gt; so please follow the instructions &lt;a href=&quot;https://github.com/neoclide/coc.nvim&quot;&gt;here&lt;/a&gt; to install it. After you install it, re-open again your Vim and install the following &lt;em&gt;coc&lt;/em&gt; extensions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;coc-tsserver&lt;/li&gt;
&lt;li&gt;coc-yank&lt;/li&gt;
&lt;li&gt;coc-styled-components&lt;/li&gt;
&lt;li&gt;coc-sql&lt;/li&gt;
&lt;li&gt;coc-snippets&lt;/li&gt;
&lt;li&gt;coc-python&lt;/li&gt;
&lt;li&gt;coc-pairs&lt;/li&gt;
&lt;li&gt;coc-markdownlint&lt;/li&gt;
&lt;li&gt;coc-json&lt;/li&gt;
&lt;li&gt;coc-import-cost&lt;/li&gt;
&lt;li&gt;coc-html&lt;/li&gt;
&lt;li&gt;coc-highlight&lt;/li&gt;
&lt;li&gt;coc-docker&lt;/li&gt;
&lt;li&gt;coc-css&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To install it, use this command through you Vim: &lt;code&gt;:CocInstall coc-tsserver coc-yank etc&lt;/code&gt;. Oh i forgot to mention that you need to change &lt;code&gt;your_username&lt;/code&gt; inside the config to your user, please change it now and save it again :D.&lt;/p&gt;
&lt;p&gt;Okay, we&apos;re done with the setup, let&apos;s try to edit a javascript file, if it works, it should behave like an IDE, automatically detect built-in functions.&lt;/p&gt;
&lt;p&gt;This setup is mean to be use for &lt;code&gt;Javascript&lt;/code&gt; environment, i know it&apos;s not the good or even best setup for javascript environment but it&apos;s quite useful for me. By the way, &lt;em&gt;coc&lt;/em&gt; it&apos;s not just for javascript, you can even use it for another programming languages, just read on &lt;code&gt;coc.nvim&lt;/code&gt; documentations for more details.&lt;/p&gt;
&lt;p&gt;Okay our setup is completed. You might be ask, why do i need Vim and set it up to be like an IDE? Why don&apos;t just use a modern text editor like VSCode, Sublime or even a powerfull IDE like Netbeans or WebStorm. Well, these tools are not quite suitable for low-end laptop/PC, that&apos;s why Vim is the best choice.&lt;/p&gt;
&lt;p&gt;I actually not use Vim regularily, but it is fun to use it and get a new exprience for trying a cool stuff with it. Just try it by yourself, i&apos;m sure you will love it.&lt;/p&gt;
&lt;p&gt;For the complete setup, you can grab it &lt;a href=&quot;https://pastebin.com/G9aFdra3&quot;&gt;here&lt;/a&gt; or from my &lt;a href=&quot;https://github.com/nubilfi/dotfiles&quot;&gt;github&lt;/a&gt; for the updated config.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Set Up VIM as An IDE - Part 1]]></title><description><![CDATA[Have you ever heard about Vim before? Many people say that it's a powerfull text editor. I started to use this tool couple months ago and i…]]></description><link>https://repodev.com/blog/set-up-vim-as-an-ide-part-1</link><guid isPermaLink="false">https://repodev.com/blog/set-up-vim-as-an-ide-part-1</guid><pubDate>Fri, 01 Nov 2019 17:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Have you ever heard about &lt;a href=&quot;https://www.vim.org&quot;&gt;Vim&lt;/a&gt; before? Many people say that it&apos;s a powerfull text editor. I started to use this tool couple months ago and i enjoy it. I&apos;m not a hardcore Vim user that knows all commands or good setup, but i just want to share how do i setup my Vim.&lt;/p&gt;
&lt;h2&gt;The Basic Tweak&lt;/h2&gt;
&lt;p&gt;I assume you guys already know (at least) about how to use Vim, like navigation, searching, etc, you can googling &quot;Vim cheat sheet&quot; to get an overview of all the commands. Here is the very basic setup:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-vim&quot;&gt;  set autoread                                                                &quot; Set to auto read when a file is changed from the outside
  set backspace=indent,eol,start                                              &quot; more powerful backspacing
  set clipboard=unnamed                                                       &quot; access your system clipboard
  set cmdheight=2                                                             &quot; Height of the command bar
  syntax enable                                                               &quot; enable syntax highlighting and plugin (for netrw)
  set encoding=utf8                                                           &quot; Set utf8 as standard encoding and en_US as the standard language
  set expandtab                                                               &quot; convert tabs into spaces
  set ffs=unix,dos,mac                                                        &quot; Use Unix as the standard file type
  set foldmethod=indent                                                       &quot; Code folding
  set foldlevel=99
  set history=500                                                             &quot; Sets how many lines of history VIM has to remember
  set incsearch                                                               &quot; incremental search
  set laststatus=2                                                            &quot; Always show the status line
  set list                                                                    &quot; Show trailing white space
  set listchars=tab:&gt;·,trail:~,extends:&gt;,precedes:&amp;#x3C;,space:.                   &quot; eol:¬,tab:&gt;·,trail:~,extends:&gt;,precedes:&amp;#x3C;,space:.
  set mouse=nicr
  set magic                                                                   &quot; For regular expressions turn magic on
  set nocompatible                                                            &quot; enter the current millenium
  set number                                                                  &quot; always show line numbers
  set hidden
  set ruler                                                                   &quot; Always show current position
  set scrolloff=3                                                             &quot; when scrolling, keep cursor 3 lines away from screen border
  set shiftwidth=2                                                            &quot; amount of block indenting
  set smarttab                                                                &quot; uses the shiftwidth instead of tabstop to delete indented line
  set synmaxcol=200                                                           &quot; performance ???
  set tabstop=2                                                               &quot; press tab, 2 spaces forward, 1 tab == 2 spaces
  set wrap                                                                    &quot; Wrap lines
  filetype plugin indent on
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, there are a bunch of &lt;code&gt;set&lt;/code&gt; command for each configuration settings, you can read the notes for each settings i set or you can check on Vim website for more details about the settings.&lt;/p&gt;
&lt;p&gt;Try to copy and paste in your empty &lt;code&gt;.vimrc&lt;/code&gt; file if you&apos;re on &lt;code&gt;*nix&lt;/code&gt; system or &lt;code&gt;_vimrc&lt;/code&gt; on Windows, then try re-open your vim and edit a file, you&apos;ll see (at least) there&apos;s color on the text and dots for each spaces. It actually does a lot than you think since i just mention about color and dots, that&apos;s why i write a note for each settings so you can read it :D.&lt;/p&gt;
&lt;p&gt;Let&apos;s move to the next phase, we&apos;ll set some shortcuts to interact inside Vim.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-vim&quot;&gt;  let mapleader = &quot;,&quot;
  let maplocalleader = &quot;,&quot;
  set termguicolors
  nnoremap &amp;#x3C;leader&gt;N :setlocal number!&amp;#x3C;cr&gt;            &quot; Toggle line numbers

  &quot; comma+s to save, comma+q to quit (does not save!), quit all without saving
  nnoremap &amp;#x3C;leader&gt;ss :w&amp;#x3C;cr&gt;
  nnoremap &amp;#x3C;leader&gt;q :q!&amp;#x3C;cr&gt;
  nnoremap &amp;#x3C;leader&gt;qa :qa!&amp;#x3C;cr&gt;

  let $MYVIMRC=&quot;/home/you_username/.vimrc&quot;
  nnoremap &amp;#x3C;leader&gt;rv :source&amp;#x3C;Space&gt;$MYVIMRC&amp;#x3C;cr&gt;       &quot; Reload vimrc
  nnoremap &amp;#x3C;leader&gt;ev :tabnew $MYVIMRC&amp;#x3C;cr&gt;             &quot; Edit vimrc

  &quot; Copy &amp;#x26; paste to clipboard
  noremap &amp;#x3C;Leader&gt;Y &quot;+y
  noremap &amp;#x3C;Leader&gt;P &quot;+p

  &quot; change Escape key behaviour
  imap &amp;#x3C;leader&gt;q &amp;#x3C;Esc&gt;
  inoremap jj &amp;#x3C;Esc&gt;

  nnoremap &amp;#x3C;leader&gt; z                                  &quot; Enable folding with the z

  &quot; Buffer key mappings
  nnoremap &amp;#x3C;leader&gt;l :bn&amp;#x3C;cr&gt;
  nnoremap &amp;#x3C;leader&gt;h :bp&amp;#x3C;cr&gt;
  nnoremap &amp;#x3C;leader&gt;0 :bf&amp;#x3C;cr&gt;
  nnoremap &amp;#x3C;leader&gt;9 :bl&amp;#x3C;cr&gt;
  nnoremap &amp;#x3C;leader&gt;dd :bd&amp;#x3C;cr&gt;

  &quot; Managing tabs
  nnoremap tn :tabnew&amp;#x3C;Space&gt;
  nnoremap tk :tabnext&amp;#x3C;CR&gt;
  nnoremap tj :tabprev&amp;#x3C;CR&gt;
  nnoremap th :tabfirst&amp;#x3C;CR&gt;
  nnoremap tl :tablast&amp;#x3C;CR&gt;
  nnoremap tc :tabclose&amp;#x3C;CR&gt;

  &quot; :W sudo saves the file
  &quot; (useful for handling the permission-denied error)
  command W w !sudo tee % &gt; /dev/null

  &quot; navigate split screens easily
  nmap &amp;#x3C;silent&gt; &amp;#x3C;c-k&gt; :wincmd k&amp;#x3C;CR&gt;
  nmap &amp;#x3C;silent&gt; &amp;#x3C;c-j&gt; :wincmd j&amp;#x3C;CR&gt;
  nmap &amp;#x3C;silent&gt; &amp;#x3C;c-h&gt; :wincmd h&amp;#x3C;CR&gt;
  nmap &amp;#x3C;silent&gt; &amp;#x3C;c-l&gt; :wincmd l&amp;#x3C;CR&gt;

  &quot; Pressing Shift &amp;#x3C; or Shift &gt; will let you indent/unident selected lines
  vnoremap &amp;#x3C; &amp;#x3C;gv
  vnoremap &gt; &gt;gv

  &quot; comma-1 insert &quot;!&quot; commenting
  nnoremap &amp;#x3C;leader&gt;1 :norm i!&amp;#x3C;cr&gt;
  vnoremap &amp;#x3C;leader&gt;1 :norm i!&amp;#x3C;cr&gt;

  &quot; comma-&apos; insert &quot;&quot;&quot; commenting
  nnoremap &amp;#x3C;leader&gt;&apos; :norm i&quot;&amp;#x3C;cr&gt;
  vnoremap &amp;#x3C;leader&gt;&apos; :norm i&quot;&amp;#x3C;cr&gt;

  &quot; comma-3 insert &quot;#&quot; commenting
  nnoremap &amp;#x3C;leader&gt;3 :norm i#&amp;#x3C;cr&gt;
  vnoremap &amp;#x3C;leader&gt;3 :norm i#&amp;#x3C;cr&gt;

  &quot; comma-- insert &quot;--&quot; commenting
  nnoremap &amp;#x3C;leader&gt;- :norm i--&amp;#x3C;cr&gt;
  vnoremap &amp;#x3C;leader&gt;- :norm i--&amp;#x3C;cr&gt;

  &quot; comma-6 uncomment
  nnoremap &amp;#x3C;leader&gt;6 :norm ^x&amp;#x3C;cr&gt;
  vnoremap &amp;#x3C;leader&gt;6 :norm ^x&amp;#x3C;cr&gt;

  &quot; Make Y yank everything from the cursor to the end of the line. This makes Y
  &quot; act more like C or D because by default, Y yanks the current line (i.e. the
  &quot; same as yy).
  noremap Y y$
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I set &lt;code&gt;mapleader&lt;/code&gt; with &lt;code&gt;commad ( , )&lt;/code&gt;, you can change it if you want. So, those shortcuts help me a lot to interact inside Vim, for example, i can press &lt;code&gt;, + ev&lt;/code&gt; to directly edit my &lt;code&gt;.vimrc&lt;/code&gt; file on new buffer and press &lt;code&gt;, + ss&lt;/code&gt; to save a file. It&apos;s easy right? But you might want to use &lt;code&gt;:verbose imap &amp;#x3C;your_key&gt;&lt;/code&gt; to check is there a conflict for each key-mappings that has been set.&lt;/p&gt;
&lt;p&gt;And the last phase for the basic setup is just a miscellaneous setup, you can read the notes for a little information.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-vim&quot;&gt;  &quot; Ignore compiled files
  set wildignore=*.o,*~,*.pyc
  if has(&quot;win16&quot;) || has(&quot;win32&quot;)
      set wildignore+=.git\*,.hg\*,.svn\*
  else
      set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
  endif

  &quot; autocompletion of files and commands behaves like shell
  &quot; (complete only the common part, list the options that match)
  set wildmode=list:longest

  &quot; FINDING FILES: **********************************************************
  &quot; search down into subfolders
  &quot; provides tab-completion for all file-related tasks
  set path+=**

  &quot; display all matching files when we tab complete
   set wildmenu
   set wildmode=list:longest,full
   set lazyredraw

  &quot; NOW WE CAN:
  &quot; - hit tab to :find by partial match
  &quot; - use * to make it fuzzy
  &quot; THINGS TO CONSIDER:
  &quot; - :b lets you autocomplete any open buffer
  &quot; END FINDING FILES: **********************************************************

  &quot; FILE BROWSING: *********************************************************
  &quot; tweaks for browsing
   let g:netrw_banner=0                                    &quot; disable annoying banner
   let g:netrw_browse_split=4                              &quot; open in prior window
   let g:netrw_altv=1                                      &quot; open splits to the right
   let g:netrw_liststyle=3                                 &quot; tree view
   let g:netrw_list_hide=netrw_gitignore#Hide()
   let g:netrw_list_hide.=&apos;,\(^\|\s\s\)\zs\.\S\+&apos;

  &quot; NOW WE CAN:
  &quot; - :edit a folder to open a file browser
  &quot; - &amp;#x3C;CR&gt;/v/t to open in an h-split/v-split/tab
  &quot; - check |netrw-browse-maps| for more mappings
  &quot; END FILE BROWSING: *********************************************************

  &quot; Enable 256 colors palette in Gnome Terminal
  if $COLORTERM == &apos;gnome-terminal&apos;
      set t_Co=256
  endif

  set background=dark

  &quot; Set extra options when running in GUI mode
  if has(&quot;gui_running&quot;)
      set guioptions-=T
      set guioptions-=e
      set t_Co=256
      set guitablabel=%M\ %t
      set cursorcolumn!

      &quot; Set up the gui cursor to look nice
      set guicursor=n-v-c:block-Cursor-blinkon0
      set guicursor+=ve:ver35-Cursor
      set guicursor+=o:hor50-Cursor
      set guicursor+=i-ci:ver25-Cursor
      set guicursor+=r-cr:hor20-Cursor
      set guicursor+=sm:block-Cursor-blinkwait175-blinkoff150-blinkon175
  endif

  &quot; better backup, swap and undos storage
  set directory=~/.vim/dirs/tmp     &quot; directory to place swap files in
  set backup                        &quot; make backup files
  set backupdir=~/.vim/dirs/backups &quot; where to put backup files
  set undofile                      &quot; persistent undos - undo after you re-open the file
  set undodir=~/.vim/dirs/undos
  set viminfo+=n~/.vim/dirs/viminfo

  &quot; create needed directories if they don&apos;t exist
  if !isdirectory(&amp;#x26;backupdir)
      call mkdir(&amp;#x26;backupdir, &quot;p&quot;)
  endif
  if !isdirectory(&amp;#x26;directory)
      call mkdir(&amp;#x26;directory, &quot;p&quot;)
  endif
  if !isdirectory(&amp;#x26;undodir)
      call mkdir(&amp;#x26;undodir, &quot;p&quot;)
  endif
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This setup is actually not from my own experiment, but i do a lot of searching and pick one by one setup that i found and combine it. For now, let&apos;s stop here just for the basic setup, i&apos;ll continue on part 2 article for the complete setup.&lt;/p&gt;
&lt;p&gt;I hope it is useful for you, and you can grab all phase configs from &lt;a href=&quot;https://pastebin.com/mg0h5KeH&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How to Easily Setup Webpack Configuration]]></title><description><![CDATA[When a developer start to learn a framework or library like ReactJS or VueJS we usually found an example project bundled with webpack. Since…]]></description><link>https://repodev.com/blog/how-to-easily-setup-webpack-configuration</link><guid isPermaLink="false">https://repodev.com/blog/how-to-easily-setup-webpack-configuration</guid><pubDate>Tue, 22 Oct 2019 17:00:00 GMT</pubDate><content:encoded>&lt;p&gt;When a developer start to learn a framework or library like &lt;a href=&quot;&amp;#x27;https://reactjs.org/&amp;#x27;&quot;&gt;ReactJS&lt;/a&gt; or &lt;a href=&quot;&amp;#x27;https://vuejs.org/&amp;#x27;&quot;&gt;VueJS&lt;/a&gt; we usually found an example project bundled with &lt;code&gt;webpack&lt;/code&gt;. Since we&apos;re a newcomer in this kind of tool, we don&apos;t know how it work. Each articles on the internet has a different configuration on this &lt;code&gt;webpack&lt;/code&gt; thing.&lt;/p&gt;
&lt;p&gt;Some people might be say &lt;em&gt;just use create-react-app&lt;/em&gt;. I know this tool is awesome (i use it a lot though), with just one command, our project is ready to use. But it might be important to know how this thing work, so we should try to setup our own config from scratch. We need to jump to &lt;a href=&quot;&amp;#x27;https://webpack.js.org&amp;#x27;&quot;&gt;webpack official website&lt;/a&gt; to find out how it work, i myself already read all of its content, it is easy to follow, you should try by yourself.&lt;/p&gt;
&lt;p&gt;But, here is the important thing in this article. I have found a website (some of you might be already know about this website), like an interactive website to generate a &lt;code&gt;webpack&lt;/code&gt; config file. It is support transpiler, styling, image, utilities, linting and optimization. It&apos;s called &lt;a href=&quot;&amp;#x27;https://createapp.dev/&amp;#x27;&quot;&gt;createapp.dev&lt;/a&gt;. Of course you should read the webpack concepts first to understand those things work, but if you already know about those things and you&apos;re a bit lazy to create your own config, may be you can try to use this website to generate your webpack config.&lt;/p&gt;
&lt;p&gt;I know this is not the best config and/or may be not suit with your need, there are so many webpack config that you can find on google. Through this article, i hope it will help you to easily setting up your webpack config.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Running PostgreSQL in Power Saving Mode]]></title><description><![CDATA[Have you heard about it? Running in power saving mode, is it a feature? Actually, it is only for for laptop though. Why for laptop? Let say…]]></description><link>https://repodev.com/blog/running-postgresql-in-power-saving-mode</link><guid isPermaLink="false">https://repodev.com/blog/running-postgresql-in-power-saving-mode</guid><pubDate>Tue, 15 Oct 2019 17:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Have you heard about it? Running in power saving mode, is it a feature? Actually, it is only for for laptop though. Why for laptop? Let say if your PostgreSQL is only used very sporadically or has periods of total inactivity, like when you&apos;re developing an application on your laptop or computer.&lt;/p&gt;
&lt;p&gt;Just for your information, i found this tips from a book but i forgot the title.&lt;/p&gt;
&lt;h2&gt;How to do it?&lt;/h2&gt;
&lt;p&gt;We all know that a database server mostly does nothing at all if there are no active clients. So, to minimize server activity, set the following paramaters in the &lt;code&gt;postgresql.conf&lt;/code&gt; file:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;autovacuum = off&lt;/li&gt;
&lt;li&gt;wal_writer_delay = 10000 # milliseconds&lt;/li&gt;
&lt;li&gt;bgwriter_delay = 10000 # milliseconds&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;NOTE&lt;/code&gt;: please backup your default or current configuration before doing it.&lt;/p&gt;
&lt;p&gt;As you can see, we turned off the &lt;code&gt;autovacuum&lt;/code&gt;, but why? PostgreSQL has so many awesome features and &lt;code&gt;autovacuum&lt;/code&gt; is one of them. I do recommend to use it in &lt;code&gt;production&lt;/code&gt; only, and for development, we usually not doing heavy activity or even having a large data on our database, so it should be okay to turn it off.&lt;/p&gt;
&lt;p&gt;The WAL writer process wakes up by default every 200 milliseconds. The maximum setting is also 10 seconds. This setting cannot be disable though, if there&apos;s no write activity then no work will be performed.&lt;/p&gt;
&lt;p&gt;It is actually just a tunning, not a feature. It won&apos;t impact the performance while you&apos;re doing a development. I&apos;m still using this setting on my laptop though.&lt;/p&gt;
&lt;p&gt;Well, i hope this article is useful for you, and i highly recommend you guys to read the &lt;a href=&quot;https://www.postgresql.org/docs/current/config-setting.html&quot;&gt;PostgreSQL Official Documentation: Config Settings&lt;/a&gt; for more details.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[The Official Introduction to My Blog]]></title><description><![CDATA[My blog just spawned!!! Hello my readers, here I am from Indonesia. I want to introduce myself to you, my name is Muh Ibnu Habil Hanafi (my…]]></description><link>https://repodev.com/blog/introduction</link><guid isPermaLink="false">https://repodev.com/blog/introduction</guid><pubDate>Mon, 14 Oct 2019 17:00:00 GMT</pubDate><content:encoded>&lt;h2&gt;My blog just spawned!!!&lt;/h2&gt;
&lt;p&gt;Hello my readers, here I am from Indonesia. I want to introduce myself to you, my name is &lt;em&gt;Muh Ibnu Habil Hanafi&lt;/em&gt; (my friends call me &lt;em&gt;Bill&lt;/em&gt;). Currently i work as a Developer at &lt;a href=&quot;http://arkadiacorp.com&quot;&gt;Arkadia Digital Media&lt;/a&gt; (one of Indonesia&apos;s Digital Media Group). Some of our core technologies that we use are Opensource. I am feel most comfortable in the backend development, but i do like playing around with Javascript for the frontend. Just for your information, English is not my first language, so you might found incorrect sentences or grammar in this blog (sorry for any mistakes), I am still working on my English.&lt;/p&gt;
&lt;h2&gt;What can i expect in this blog?&lt;/h2&gt;
&lt;p&gt;I&apos;ll put everything in this blog about tips and technical topics, i&apos;ll share my personal knowledge, this also includes useful tips that I found around the internet and hopefully it&apos;ll be useful for developers out there.&lt;/p&gt;
&lt;p&gt;I know this blog still lack of features, but don&apos;t worry, it&apos;s just about time and i&apos;ll add more features so it can be a complete blog. Finally, don&apos;t forget to comeback or you can bookmark now for future content.&lt;/p&gt;</content:encoded></item></channel></rss>