<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tín Huỳnh on Medium]]></title>
        <description><![CDATA[Stories by Tín Huỳnh on Medium]]></description>
        <link>https://medium.com/@tinhuynh1?source=rss-ffebf0df636b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*n45-Ej_EqHBzjHiIwg-MaA.jpeg</url>
            <title>Stories by Tín Huỳnh on Medium</title>
            <link>https://medium.com/@tinhuynh1?source=rss-ffebf0df636b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 12:06:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tinhuynh1/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[REST API design, Best Practices]]></title>
            <link>https://medium.com/@tinhuynh1/rest-api-design-best-practices-8cfdd6c50299?source=rss-ffebf0df636b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8cfdd6c50299</guid>
            <dc:creator><![CDATA[Tín Huỳnh]]></dc:creator>
            <pubDate>Mon, 07 Mar 2022 11:17:45 GMT</pubDate>
            <atom:updated>2022-03-07T11:17:45.127Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/0*SzpHOBm_pU4aFiAc.jpg" /></figure><h3>What is a Resource?</h3><p>In <a href="https://restfulapi.net/">REST</a>, the primary data representation is called resource. Having a consistent and robust REST resource naming strategy — will prove one of the best design decisions in the long term.</p><h3><strong>Best Practices</strong></h3><ol><li>Don’t use verbs in URIs</li></ol><p>Because HTTP method was present the action, which you want to do. We should use nouns to represent resources.</p><p>Bad Practices:</p><pre>GET: /posts/list-post</pre><p>Good Practices:</p><pre>POST: /posts/</pre><p>2. Use plural nouns for resource</p><p>Using plural or singular nouns for defining resources has no any impact on how your API will work; however, there are common conventions that are used in all good RESTful APIs. One of such conventions is the use of plural nouns for defining resources.</p><p>Bad Practices:</p><pre>GET: /post/:id/</pre><p>Good Practices:</p><pre>GET: /posts/:id/</pre><p>3. Represent complex parameters with query string</p><p>In RESTful APIs, a query string (“?”) is commonly used for setting complex parameters to define resources. It keeps the URL short, logical, and simple. Remember that all optional parameters have to be recognized through a query string.</p><p>Good Practices</p><pre>GET: /users?location=US&amp;age=2</pre><p>4. Use a limit parameter</p><p>When you request some data and you know the results will fill numerous pages, you should set the limit of results per one page:</p><pre>GET: /page?limit=10</pre><p>The limit, which is set after the query string, regulates the number of results that have to be displayed on one page. Use a Start Parameter If you need to display specific results on a page, you should use a “start” parameter. Set a limit parameter and the first result which should be displayed after the query string:</p><pre>GET: /page?limit=10&amp;start=21</pre><p>This is article about Restful API Design and best practices.</p><p>References:</p><p><a href="https://restfulapi.net/resource-naming/">https://restfulapi.net/resource-naming/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8cfdd6c50299" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[gRPC Introduction]]></title>
            <link>https://medium.com/@tinhuynh1/grpc-introduction-9c0f7f896193?source=rss-ffebf0df636b------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c0f7f896193</guid>
            <dc:creator><![CDATA[Tín Huỳnh]]></dc:creator>
            <pubDate>Wed, 02 Mar 2022 03:39:11 GMT</pubDate>
            <atom:updated>2022-03-02T03:42:01.732Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>What is Remote Procedure Call (RPC)?</strong></h3><p>Remote Procedure Call is a software communication protocol that one program can use to request a service from a program located in another computer on a network without having to understand the network’s details. RPC is used to call other processes on the remote systems like a local system. A procedure call is also sometimes known as a <em>function call</em> or a <em>subroutine call</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lhsax9z4NWs_DTtX.jpeg" /></figure><p>RPC uses the <a href="https://www.techtarget.com/searchnetworking/definition/client-server">client-server</a> model. The requesting program is a client, and the service-providing program is the server. Like a local procedure call, an RPC is a <a href="https://whatis.techtarget.com/definition/synchronous">synchronous</a> operation requiring the requesting program to be suspended until the results of the remote procedure are returned. However, the use of lightweight processes or <a href="https://whatis.techtarget.com/definition/thread">threads</a> that share the same address space enables multiple RPCs to be performed concurrently.</p><h3>What is gRPC?</h3><p>gRPC is a modern open source high performance Remote Procedure Call (RPC) framework that can run in any environment. It can efficiently connect services in and across data centers with pluggable support for load balancing, tracing, health checking and authentication. It is also applicable in last mile of distributed computing to connect devices, mobile applications and browsers to backend services.</p><p>In gRPC, a client application can directly call a method on a server application on a different machine as if it were a local object, making it easier for you to create distributed applications and services. As in many RPC systems, gRPC is based around the idea of defining a service, specifying the methods that can be called remotely with their parameters and return types. On the server side, the server implements this interface and runs a gRPC server to handle client calls. On the client side, the client has a stub (referred to as just a client in some languages) that provides the same methods as the server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/0*VhB0Yd9IxLGM7alt.png" /><figcaption><strong>gRPC Architecture</strong></figcaption></figure><p>gRPC clients and servers can run and talk to each other in a variety of environments — from servers inside Google to your own desktop — and can be written in any of gRPC’s supported languages. So, for example, you can easily create a gRPC server in Java with clients in Go, Python, or Ruby. In addition, the latest Google APIs will have gRPC versions of their interfaces, letting you easily build Google functionality into your applications.</p><p><strong>References:</strong></p><p><a href="https://grpc.io/docs/what-is-grpc/introduction/">Introduction to gRPC</a></p><p><a href="https://www.techtarget.com/searchapparchitecture/definition/Remote-Procedure-Call-RPC">https://www.techtarget.com/searchapparchitecture/definition/Remote-Procedure-Call-RPC</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c0f7f896193" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CRUD using GIN, GORM, POSTGRES]]></title>
            <link>https://medium.com/@tinhuynh1/crud-using-gin-gorm-postgres-90f3194a48db?source=rss-ffebf0df636b------2</link>
            <guid isPermaLink="false">https://medium.com/p/90f3194a48db</guid>
            <dc:creator><![CDATA[Tín Huỳnh]]></dc:creator>
            <pubDate>Tue, 01 Mar 2022 04:35:15 GMT</pubDate>
            <atom:updated>2022-03-01T04:35:15.912Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is ORM?</h3><p>ORM stands for <strong>O</strong>bject-<strong>R</strong>elational <strong>M</strong>apping (ORM) is a programming technique for converting data between relational databases and object oriented programming languages such as Java, C#, etc.</p><h3>What is GORM?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*koHQwCU2xB04zpRK" /></figure><p>The GORM is fantastic ORM library for Golang, aims to be developer friendly. It is an ORM library for dealing with relational databases. This gorm library is developed on the top of <strong>database/sql</strong> package.</p><p>The overview and feature of ORM are:</p><ul><li>Full-Featured ORM (almost)</li><li>Associations (Has One, Has Many, Belongs To, Many To Many, Polymorphism)</li><li>Callbacks (Before/After Create/Save/Update/Delete/Find)</li><li>Preloading (eager loading)Transactions</li><li>Composite Primary Key</li><li>SQL Builder</li><li>Logger</li><li>Developer Friendly</li></ul><p>GORM officially supports databases MySQL, PostgreSQL, SQLite, SQL Server.</p><h3><strong>Connect Database</strong></h3><p>In this post, we will use Postgres to store our data. Before continue, your computer have to install Postgres. If you want to know further more about Postgres and how to install. This is my post about Postgres: <a href="https://medium.com/@tinhuynh1/what-is-postgres-5da4bb29340d">Postgres Introduction</a>.</p><p>Let&#39;s install <strong>GORM</strong> and Postgres driver, run:</p><pre>go get -u gorm.io/gorm<br>go get -u gorm.io/driver/postgres</pre><p>Now, you can use <strong>GORM</strong> and <strong>Postgres</strong> in your project.</p><pre>package main</pre><pre>import (<br>      &quot;fmt&quot;<br>      &quot;gorm.io/driver/postgres&quot;  <br>      &quot;gorm.io/gorm&quot;<br>)<br>func main(){ </pre><pre>      dsn := &quot;host=localhost user=gorm password=gorm dbname=gorm       port=9920 sslmode=disable TimeZone=Asia/Shanghai&quot;<br>    <br>      _, err := gorm.Open(postgres.Open(dsn), &amp;gorm.Config{})</pre><pre>      if err != nil { <br>          fmt.Println(&quot;Fail to connect db. Error : &quot; + err.Error())<br>      }<br> <br>      fmt.Println(&quot;Connect database successfully!&quot;)</pre><pre>}</pre><pre>)</pre><p><strong>API CRUD</strong></p><p>Define simple <strong>Post</strong> struct:</p><pre>type Post struct {<br>  Id          int    `json:&quot;id&quot; gorm:&quot;column:id;&quot;`<br>  Title       string `json:&quot;title&quot; gorm:&quot;column:title;&quot;`<br>  Description string `json:&quot;description&quot; gorm:&quot;column:description;&quot;`<br>}</pre><p>Create API get list <strong>Post</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5E-DVWdBuqy4O4KqYwIEcg.png" /></figure><p>Create API get Post by id</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Aqc6Ea8EQiriK4U6AyGyig.png" /></figure><p>Create API create new <strong>Post</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*20vRFelUEuNydar0u5t0RQ.png" /></figure><p>Create API update <strong>Post</strong> by id</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xXxnUF7NbGsvh-U3mbn1Dg.png" /></figure><p>Create API delete <strong>Post</strong> by id</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G2xyy3EUnvfXImSx8sfbtw.png" /></figure><h3>Summary</h3><p>Writing CRUD restful APIs using Go can be easy and fast, and with the help of Gorm adapter, our api data which is food order in this post can be saved to our database and retrieved it back easily. Thank You.</p><p>Full source code: <a href="https://github.com/tinhuynh1/go-crud">https://github.com/tinhuynh1/go-crud</a></p><p>References:</p><p><a href="https://gorm.io/">https://gorm.io/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90f3194a48db" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is VCS? What is Git? Basic Git command]]></title>
            <link>https://medium.com/@tinhuynh1/what-is-vcs-what-is-git-basic-git-command-d17d6012bd27?source=rss-ffebf0df636b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d17d6012bd27</guid>
            <dc:creator><![CDATA[Tín Huỳnh]]></dc:creator>
            <pubDate>Tue, 01 Mar 2022 03:40:59 GMT</pubDate>
            <atom:updated>2022-03-01T03:40:59.976Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is a Version Control System (VCS)?</h3><p>A version control system is a software that tracks changes to a file or set of files over time so that you can recall specific versions later. It also allows you to work together with other programmers.</p><p>The version control system is a collection of software tools that help a team to manage changes in a source code. It uses a special kind of database to keep track of every modification to the code.</p><p>Developers can compare earlier versions of the code with an older version to fix the mistakes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/0*82JZ9aqgPaoo0smt.png" /></figure><h3>Benefits of the Version Control System</h3><p>The Version Control System is very helpful and beneficial in software development; developing software without using version control is unsafe. It provides backups for uncertainty. Version control systems offer a speedy interface to developers. It also allows software teams to preserve efficiency and agility according to the team scales to include more developers.</p><p>Some key benefits of having a version control system are as follows.</p><ul><li>Complete change history of the file</li><li>Simultaneously working</li><li>Branching and merging</li><li>Traceability</li></ul><h3>What is Git?</h3><p>Git is the most commonly used version control system. Git tracks the changes you make to files, so you have a record of what has been done, and you can revert to specific versions should you ever need to. Git also makes collaboration easier, allowing changes by multiple people to all be merged into one source.</p><p>So regardless of whether you write code that only you will see, or work as part of a team, Git will be useful for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/0*KAh85KKggUf4MYoq.png" /></figure><p>Git is software that runs locally. Your files and their history are stored on your computer. You can also use online hosts (such as <a href="https://github.com/">GitHub</a> or <a href="https://bitbucket.org/">Bitbucket</a>) to store a copy of the files and their revision history. Having a centrally located place where you can upload your changes and download changes from others, enable you to collaborate more easily with other developers. Git can automatically merge the changes, so two people can even work on different parts of the same file and later merge those changes without losing each other’s work!</p><h3>Ways to Use Git</h3><p>Git is software that you can access via a command line (terminal), or a desktop app that has a GUI (graphical user interface) such as <a href="https://www.sourcetreeapp.com/">Sourcetree</a> shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JN_-HeFvT7FBVP2D.png" /><figcaption>Source: <a href="https://blog.sourcetreeapp.com/">https://blog.sourcetreeapp.com/</a></figcaption></figure><h3><strong>Git Repositories</strong></h3><p>A Git <strong>repository</strong> (or <strong>repo</strong> for short) contains all of the project files and the entire revision history. You’ll take an ordinary folder of files (such as a website’s root folder), and tell Git to make it a repository. This creates a <strong>.git </strong>subfolder, which contains all of the Git metadata for tracking changes.</p><p>On Unix-based operating systems such as macOS, files and folders that start with a period (.) are hidden, so you will not see the <strong>.git</strong> folder in the macOS Finder unless you show hidden files, but it’s there! You might be able to see it in some code editors.</p><h3>Stage &amp; Commit Files</h3><p>Think of Git as keeping a list of changes to files. So how do we tell Git to record our changes? Each recorded change to a file or set of files is called a commit.</p><p>Before we make a commit, we must tell Git what files we want to commit. This is called staging and uses the <strong>add</strong> command. Why must we do this? Why can’t we just commit the file directly? Let’s say you’re working on a two files, but only one of them is ready to commit. You don’t want to be forced to commit both files, just the one that’s ready. That’s where Git’s <strong>add</strong> command comes in. We add files to a staging area, and then we commit the files that have been staged.</p><h3>Remote Repositories (on GitHub &amp; Bitbucket)</h3><p>Storing a copy of your Git repo with an online host (such as <a href="https://github.com/">GitHub</a> or <a href="https://bitbucket.org/">Bitbucket</a>) gives you a centrally located place where you can upload your changes and download changes from others, letting you collaborate more easily with other developers. After you have a remote repository set up, you upload (push) your files and revision history to it. After someone else makes changes to a remote repo, you can download (pull) their changes into your local repo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/0*ZGPhNOh-BDr6_8xm.png" /></figure><h3>Branches &amp; Merging</h3><p>Git lets you branch out from the original code base. This lets you more easily work with other developers, and gives you a lot of flexibility in your workflow.</p><p>Here’s an example of how Git branches are useful. Let’s say you need to work on a new feature for a website. You create a new branch and start working. You haven’t finished your new feature, but you get a request to make a rush change that needs to go live on the site today. You switch back to the master branch, make the change, and push it live. Then you can switch back to your new feature branch and finish your work. When you’re done, you merge the new feature branch into the master branch and both the new feature and rush change are kept!</p><p>When you merge two branches (or merge a local and remote branch) you can sometimes get a conflict. For example, you and another developer unknowingly both work on the same part of a file. The other developer pushes their changes to the remote repo. When you then pull them to your local repo you’ll get a merge conflict. Luckily Git has a way to handle conflicts, so you can see both sets of changes and decide which you want to keep.</p><h3>Pull Requests</h3><p>Pull requests are a way to discuss changes before merging them into your codebase. Let’s say you’re managing a project. A developer makes changes on a new branch and would like to merge that branch into the master. They can create a pull request to notify you to review their code. You can discuss the changes, and decide if you want to merge it or not.</p><h3>Basic Git commands</h3><p>Here is a list of some basic Git commands to get you going with Git.</p><pre>git config --global user.name &quot;Sam Smith&quot;<br>git config --global user.email sam@example.com</pre><p>Tell Git who you are? Configure the author name and email address to be used with your commits.</p><pre>git init</pre><p>Create a new local repository.</p><pre>git clone /path/to/repository</pre><p>Checkout a repository. Create a working copy of a local repository.</p><p>For a remote server, use:</p><pre>git clone username@host:/path/to/repository</pre><pre>git add &lt;filename&gt;<br>git add *</pre><p>Add one or more files to staging (index).</p><pre>git commit -m &quot;Commit message&quot;</pre><p>Commit changes to head (but not yet to the remote repository):</p><pre>git commit -a</pre><p>Commit any files you’ve added with git add, and also commit any files you&#39;ve changed since then.</p><pre>git push origin master</pre><p>Send changes to the master branch of your remote repository.</p><pre>git status</pre><p>List the files you’ve changed and those you still need to add or commit.</p><pre>git checkout -b &lt;branchname&gt;</pre><p>Create a new branch and switch to it.</p><pre>git checkout &lt;branchname&gt;</pre><p>Switch from one branch to another.</p><pre>git branch</pre><p>List all the branches in your repo, and also tell you what branch you’re currently in.</p><pre>git branch -d &lt;branchname&gt;</pre><p>Delete the feature branch.</p><pre>git push origin &lt;branchname&gt;</pre><p>Push the branch to your remote repository, so others can use it.</p><pre>git pull</pre><p>Fetch and merge changes on the remote server to your working directory.</p><pre>git merge &lt;branchname&gt;</pre><p>To merge a different branch into your active branch.</p><p>For more detail, check out the <a href="http://atlassian.com/git?utm_source=basic-git-commands&amp;utm_medium=link&amp;utm_campaign=git-microsite"><strong>Atlassian Git Tutorials</strong></a><strong> </strong>for a visual introduction to Git commands and workflows, including examples.</p><p><strong>References:</strong></p><p><a href="https://confluence.atlassian.com/bitbucketserver/basic-git-commands-776639767.html">Basic Git commands</a></p><p><a href="https://www.nobledesktop.com/learn/git/what-is-git">https://www.nobledesktop.com/learn/git/what-is-git</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d17d6012bd27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Postgres Introduction]]></title>
            <link>https://medium.com/@tinhuynh1/what-is-postgres-5da4bb29340d?source=rss-ffebf0df636b------2</link>
            <guid isPermaLink="false">https://medium.com/p/5da4bb29340d</guid>
            <dc:creator><![CDATA[Tín Huỳnh]]></dc:creator>
            <pubDate>Fri, 18 Feb 2022 03:28:55 GMT</pubDate>
            <atom:updated>2022-02-18T03:29:59.729Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is Postgres?</h3><p><strong>PostgreSQL</strong> is an enterprise-class open source database management system. It supports both SQL and JSON for relational and non-relational queries for extensibility and SQL compliance. PostgreSQL supports advanced data types and performance optimization features, which are only available in expensive commercial databases, like Oracle and SQL Server. It is also known as Postgres.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/0*aW9oBhxQJoBgS3D8.png" /><figcaption>Introduction to postgres</figcaption></figure><p>It is backed by an experienced community of developers who have made tremendous contributions to make it a highly reliable DBMS system.</p><h3>Why use PostgreSQL?</h3><p>PostgreSQL comes with <a href="https://www.postgresql.org/about/featurematrix/">many features</a> aimed to help developers build applications, administrators to protect data integrity and build fault-tolerant environments, and help you manage your data no matter how big or small the dataset. In addition to being <a href="https://www.postgresql.org/about/license/">free and open source</a>, PostgreSQL is highly extensible. For example, you can define your own data types, build out custom functions, even write code from <a href="https://www.postgresql.org/docs/current/xplang.html">different programming languages</a> without recompiling your database!</p><p>PostgreSQL tries to conform with the <a href="https://www.postgresql.org/docs/current/features.html">SQL standard</a> where such conformance does not contradict traditional features or could lead to poor architectural decisions. Many of the features required by the SQL standard are supported, though sometimes with slightly differing syntax or function. Further moves towards conformance can be expected over time. As of the version 14 release in September 2021, PostgreSQL conforms to at least 170 of the 179 mandatory features for SQL:2016 Core conformance. As of this writing, no relational database meets full conformance with this standard.</p><p>Below is an inexhaustive list of various features found in PostgreSQL, with more being added in every <a href="https://www.postgresql.org/developer/roadmap/">major release</a>:</p><p><strong>Data Types</strong></p><ul><li>Primitives: Integer, Numeric, String, Boolean</li><li>Structured: Date/Time, Array, Range / Multirange, UUID</li><li>Document: JSON/JSONB, XML, Key-value (Hstore)</li><li>Geometry: Point, Line, Circle, Polygon</li><li>Customizations: Composite, Custom Types</li></ul><p><strong>Data Integrity</strong></p><ul><li>UNIQUE, NOT NULL</li><li>Primary Keys</li><li>Foreign Keys</li><li>Exclusion Constraints</li><li>Explicit Locks, Advisory Locks</li></ul><p><strong>Concurrency, Performance</strong></p><ul><li>Indexing: B-tree, Multicolumn, Expressions, Partial</li><li>Advanced Indexing: GiST, SP-Gist, KNN Gist, GIN, BRIN, Covering indexes, Bloom filters</li><li>Sophisticated query planner / optimizer, index-only scans, multicolumn statistics</li><li>Transactions, Nested Transactions (via savepoints)</li><li>Multi-Version concurrency Control (MVCC)</li><li>Parallelization of read queries and building B-tree indexes</li><li>Table partitioning</li><li>All transaction isolation levels defined in the SQL standard, including Serializable</li><li>Just-in-time (JIT) compilation of expressions</li></ul><p><strong>Reliability, Disaster Recovery</strong></p><ul><li>Write-ahead Logging (WAL)</li><li>Replication: Asynchronous, Synchronous, Logical</li><li>Point-in-time-recovery (PITR), active standbys</li><li>Tablespaces</li></ul><p><strong>Security</strong></p><ul><li>Authentication: GSSAPI, SSPI, LDAP, SCRAM-SHA-256, Certificate, and more</li><li>Robust access-control system</li><li>Column and row-level security</li><li>Multi-factor authentication with certificates and an additional method</li></ul><p><strong>Extensibility</strong></p><ul><li>Stored functions and procedures</li><li>Procedural Languages: PL/PGSQL, Perl, Python (and many more)</li><li>SQL/JSON path expressions</li><li>Foreign data wrappers: connect to other databases or streams with a standard SQL interface</li><li>Customizable storage interface for tables</li><li>Many extensions that provide additional functionality, including PostGIS</li></ul><p><strong>Internationalisation, Text Search</strong></p><ul><li>Support for international character sets, e.g. through ICU collations</li><li>Case-insensitive and accent-insensitive collations</li><li>Full-text search</li></ul><h3>Advantage of PostgreSQL</h3><p>Below are the main advantages of PostgreSQL:</p><ul><li>PostgreSQL can run dynamic websites and web apps as a LAMP stack option.</li><li>PostgreSQL’s write-ahead logging makes it a highly fault-tolerant database.</li><li>PostgreSQL source code is freely available under an open source license. This allows you the freedom to use, modify, and implement it as per your business needs.</li><li>PostgreSQL supports geographic objects so you can use it for location-based services and geographic information systems</li><li>PostgreSQL supports geographic objects so it can be used as a geospatial data store for location-based services and geographic information systems</li><li>To learn Postgres, you don’t need much training as its easy to use</li><li>Low maintenance and administration for both embedded and enterprise use of PostgreSQL</li></ul><h3>Disadvantage of PostGRESQL</h3><p>Below are the disadvantages of PostgreSQL:</p><ul><li>Postgres is not owned by one organization. So, it has had trouble getting its name out there despite being fully featured and comparable to other DBMS systems</li><li>Changes made for speed improvement requires more work than MySQL as PostgreSQL focuses on compatibility</li><li>Many open source apps support MySQL, but may not support PostgreSQL</li><li>On performance metrics, it is slower than MySQL.</li></ul><p>Download and Install Postgres, <a href="https://www.postgresql.org/download/">click this.</a></p><h3><strong>Reference :</strong></h3><p><a href="https://www.guru99.com/introduction-postgresql.html">https://www.guru99.com/introduction-postgresql.html</a></p><p><a href="https://www.postgresql.org/">https://www.postgresql.org/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5da4bb29340d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GIN Introduction]]></title>
            <link>https://medium.com/@tinhuynh1/gin-introduction-23fb8c32a1c1?source=rss-ffebf0df636b------2</link>
            <guid isPermaLink="false">https://medium.com/p/23fb8c32a1c1</guid>
            <dc:creator><![CDATA[Tín Huỳnh]]></dc:creator>
            <pubDate>Thu, 17 Feb 2022 04:11:29 GMT</pubDate>
            <atom:updated>2022-02-17T04:11:29.118Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/566/0*vrC2UIHflKMEB-9s" /><figcaption>Credit: Google.com</figcaption></figure><h3><strong>What is Gin?</strong></h3><blockquote>“GIN is a web framework written in Go (Golang). It features a martini-like API with performance that is up to 40 times faster thanks to <a href="https://github.com/julienschmidt/httprouter">httprouter</a>. If you need performance and good productivity, you will love GIN.”</blockquote><p>Gin allows you to build web applications and microservices in Go. It contains a set of commonly used functionalities (e.g., routing, middleware support, rendering, etc.) that reduce boilerplate code and make it simpler to build web applications.</p><p>In fact, GIN is quite popular and widely used to develop projects. So, we should research and practice it right now.</p><h3><strong>Installation:</strong></h3><p>Before install Gin, we should say something about Go Mod.</p><p>To manage modules in Go conveniently and easily, from version Go 1.11, Go’s team published Go Modules.</p><p>We can use Go Modules to install packages automatically when we execute program.</p><p><em>Why we need go modules?</em> Before Go mod introduced, we have some problems :</p><ul><li>All Go project in $GOPATH/src directory. This was a big limitation in terms of that it restricted where you can keep your project.</li><li>No native dependency management support.When we do a go get it will download the required package in the $GOPATH/src directory.</li><li>All the dependency will be downloaded in the $GOPATH/src directory without versioning.</li></ul><p>Let&#39;s initialize the go module:</p><pre>go mod init github.com/tinhuynh1/example</pre><p><strong>Note: </strong>You can replace &quot;<em>github.com/tinhuynh1/example</em>” by any string which you want. Above is my style when init go mod with syntax: <strong>github.com/{username}/{project_name}</strong></p><p>After initializing the go module, project will auto generate 2 files:</p><p><strong>go.mod</strong> : specifies a module name, dependencies, and the minimal versions.</p><p><strong>go.sum : </strong>is an auto-generated dependencies lock file.</p><p>Both files are located at the root level of the project.</p><p>Now, you can install gin, this package will managed by Go Module.</p><p>Let’s install gin package:</p><pre>go get -u github.com/gin-gonic/gin</pre><p>During development, you may sometimes need to update the version of the module you are using to a specific branch or tag version. This can be done through command with the following examples:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2napYgqtfFNZHd6SISlbPw.png" /><figcaption>Credit: <a href="https://blogs.halodoc.io/">https://blogs.halodoc.io/</a></figcaption></figure><p>Example API use Gin.</p><pre>package main<br><br>import &quot;github.com/gin-gonic/gin&quot;<br><br>func main() {<br>	r := gin.Default()<br>	r.GET(&quot;/ping&quot;, func(c *gin.Context) {<br>		c.JSON(200, gin.H{<br>			&quot;message&quot;: &quot;pong&quot;,<br>		})<br>	})</pre><pre>	r.Run()<br>}</pre><p>r := gin.Default() Create a gin router with default middleware.</p><p>r.GET(“/ping”, func(c *gin.Context) {...}) In this, you can define and handle your api.</p><p>gin.H is a shortcut for Map[string]interface{}</p><p>r.run() listen and serve on port 8080, this is Gin&#39;s default port number . You can use another by injecting a port number into “run()” method. Example: r.run(“:3000”) .</p><p>This is a very simple API. You will receive a JSON string with content “message” : “pong” when you send request http://localhost:8080/ping .</p><p><strong>API using GIN</strong></p><pre>router.GET(&quot;/post/:id&quot;, func(c *gin.Context) {<br>		id := c.Param(&quot;id&quot;)<br>		c.JSON(http.StatusOK, gin.H{<br>                     &quot;message&quot; : &quot;This post has id is: &quot; + id,<br>                })<br>})</pre><p><strong>GET : </strong>/post/:id</p><p>This code block, I create an API use GET method. Gin Context support get value of param through Param() method. In this case, we need get value of param, which has name is “id&quot;. Example, if we browsing <a href="http://localhost:8080/api/post/1">http://localhost:8080/post/1</a> . We will have value of id is 1.</p><pre>router.POST(&quot;/post&quot;, func(c *gin.Context) {<br>		//Handle create new post<br>		c.JSON(http.StatusOK, gin.H{<br>                     &quot;message&quot; : &quot;Create new post successfully!&quot;,<br>                })<br>})</pre><p><strong>POST : </strong>/post</p><pre>router.PUT(&quot;/post/update/:id&quot;, func(c *gin.Context) {<br>                id := c.Param(&quot;id&quot;) <br>                //Handle update Post<br>                c.JSON(http.StatusOK, gin.H{<br>                     &quot;message&quot; : &quot;Update data successfully&quot;,<br>                })	<br>})</pre><p><strong>PUT : </strong>/post/:id</p><pre>router.PUT(&quot;/post/update/:id&quot;, func(c *gin.Context) {<br>                id := c.Param(&quot;id&quot;) <br>                //Handle update Post<br>                c.JSON(http.StatusOK, gin.H{<br>                     &quot;message&quot; : &quot;Delete data successfully&quot;,<br>                })	<br>})</pre><p><strong>DELETE :</strong>/post/:id</p><h3>Grouping routes</h3><p>There are simple example API using http method (GET, POST,PUT,DELETE). You can see these routes have the same “/post&quot; in endpoint. And the different is http method. Now, router:= Router.Group(“/post”) creates a route group. Which means, all our requests starting with /post will be routed/handled from this part.</p><p>If we group rotes, we will have code like below:</p><pre>func main() {<br>	router := gin.Default()<br>	api := router.Group(&quot;/post&quot;)<br>	{<br>		api.GET(&quot;/get/:id&quot;, func(c *gin.Context) {<br>		    id := c.Param(&quot;id&quot;)<br>		    //Handle get post, which you want<br>                    c.JSON(http.StatusOK, gin.H{<br>                       &quot;message&quot; : &quot;This post has id is: &quot; + id,<br>                    })<br>                })</pre><pre>                api.POST(&quot;/create&quot;, func(c *gin.Context) {<br>		    //Handle create new post<br>		    c.JSON(http.StatusOK, gin.H{<br>                       &quot;message&quot; : &quot;Create new post successfully!&quot;,<br>                    })<br>                })</pre><pre>                api.PUT(&quot;/update/:id&quot;, func(c *gin.Context) {<br>		    id := c.Param(&quot;id&quot;)<br>                    //Handle update post, 		    <br>                    c.JSON(http.StatusOK, gin.H{<br>                       &quot;message&quot; : &quot;Update post id: &quot; + id + &quot; successfully!&quot;,<br>                    })<br>                })         <br>                    <br>                api.DELETE(&quot;/delete/:id&quot;, func(c *gin.Context) {<br>		    id := c.Param(&quot;id&quot;)<br>                    //Handle delete post		    <br>                    c.JSON(http.StatusOK, gin.H{<br>                       &quot;message&quot; : &quot;Delete post id: &quot; + id + &quot; successfully!&quot;,<br>                    })<br>                })	<br>       }<br>       router.Run(&quot;:8080&quot;)<br>}</pre><p>Following above code and use post man to test API. We have the result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0bZyksKBXAF8wdHyhJpNmg.png" /><figcaption>Terminal</figcaption></figure><p>This is article about gin basic and simple API with Gin. We don’t have database in this project. So, in the next post, I will write about “How to connect database?And CRUD API with Gin.”.</p><p>I hope this article will be useful to you if you are looking for a web framework written in Golang. Thank for reading.</p><p><strong>Reference:</strong> https://github.com/gin-gonic/gin#quick-start</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23fb8c32a1c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tìm hiểu về Golang]]></title>
            <link>https://medium.com/@tinhuynh1/t%C3%ACm-hi%E1%BB%83u-v%E1%BB%81-golang-v%C3%A0-c%C3%A1ch-c%C3%A0i-%C4%91%E1%BA%B7t-a31f6ab7f4de?source=rss-ffebf0df636b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a31f6ab7f4de</guid>
            <dc:creator><![CDATA[Tín Huỳnh]]></dc:creator>
            <pubDate>Tue, 15 Feb 2022 04:47:24 GMT</pubDate>
            <atom:updated>2022-03-03T09:42:24.365Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Giới thiệu</strong></p><p>Go (hay còn gọi là Golang) là ngôn ngữ lập trình mã nguồn mở giúp xây dựng phần mềm dễ dàng, tin cậy và hiệu quả. Golang giống như C++ hay Java, nó cũng là một ngôn ngữ dùng để lập trình. Tuy nhiên điểm khiến ngôn ngữ Go trở nên khác biệt nằm ở sự đơn giản của nó. Nó sở hữu những cú pháp khá tinh gọn. Điều này có thể khiến những người mới học thấy khó khăn. Dù vậy cú pháp của Go có độ tương đồng rất lớn với C++.</p><p>Go được phát triển bởi Robert Griesemer, Rob Pike và Ken Thompson tại Google vào năm 2007.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pwXxmif9nt5dMscS.jpg" /><figcaption>Bộ 3 tác giả của Go</figcaption></figure><p><strong>Một số fact về Go:</strong></p><ul><li>Các lập trình viên sử dụng Go thường được gọi là <strong>gopher</strong>.</li><li>Linh vật của Go là gopher.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*AXK7i6vAYR0ujk36.jpg" /><figcaption>Gopher</figcaption></figure><p><strong>Ưu điểm và nhược điểm:</strong></p><p>Ưu điểm:</p><ul><li>Thời gian build nhanh. Thời gian build của Go chỉ vỏn vẹn vài giây đến vài phút.</li><li>Hỗ trợ lập trình đồng thời. Xử lý nhiều tác vụ một lúc trở nên đơn giản hơn với từ khoá “Go&quot; được đặt trước nơi gọi hàm.</li></ul><p>Nhược điểm:</p><ul><li>Golang không có OOP (<a href="https://en.wikipedia.org/wiki/Object-oriented_programming">Object-oriented Programming</a>). Điều này có thể gây khó khăn cho nhiều người khi chuyển từ một ngôn ngữ lập trình hướng đối tượng (như Java, C++,…) sang Go.</li><li>Không hỗ trợ Generic. Điều này có thể làm giảm khả năng reusable code và giảm hiệu quả trong quá trình phát triển. Vì là static-type nên khi hỗ trợ Generic có thể làm giảm tốc độ thực thi, làm mất đi tính chất đáng có của Go. Chủ đề này được bàn tán trong nhiều năm qua, cuối cùng Go thông báo sẽ chính thức hỗ trợ Generic trong bản thử nghiệm 1.18 sắp tới.</li></ul><p><strong>Cài đặt Golang:</strong></p><p>Để lập trình Go, chúng ta chỉ cần cài đặt mỗi Go là đủ, không còn gì thêm nữa.</p><p>Hướng dẫn cài đặt Golang tại <a href="https://go.dev/doc/install">đây</a></p><p>Sau khi cài đặt xong, để kiểm tra đã cài đặt thành công hay chưa? Sử dụng terminal và sử dụng lệnh sau:</p><pre>go version</pre><p>Kết quả:</p><pre>go version go1.17.5 darwin/arm64</pre><p>Nếu kết quả dạng tương tự như trên thì bạn đã cài đặt Go thành công(ở đây mình đang sử dụng version 1.17.5).</p><h3><strong>Hello World</strong></h3><p>Như một thói quen. Viết chương trình “Hello World&quot; đầu tiên khi học một ngôn ngữ lập trình mới.</p><p>Tạo file có tên là “main.go&quot;</p><pre>package main //cho biết file này thuộc về &quot;main package&quot;</pre><pre>import &quot;fmt&quot; // nơi import các package cần sử dụng trong file code<br> <br>func main(){ //hàm này là điểm bắt đầu (entry point) để thực thi<br>     fmt.Println(&quot;Hello World&quot;) <br>}</pre><p>Để chạy chương trình, dùng lệnh:</p><pre>go run main.go</pre><p>Nhìn vào đoạn code trên có thể thấy không xuất hiện dấu “;”. Đây là một điều tạo nên sự khác biệt đối với các ngôn ngữ lập trình khác.</p><p>Trong Golang không có các key word như private, public,… nên access modifiers sẽ được xác định thông qua cách đặt tên.<br>Tên biến, tên hàm nếu bắt đầu bằng chữ thường (ví dụ: abc(), abc) thì khi đứng từ một package khác sẽ không truy cập được biến, hàm này.</p><p>Để có thể gọi được biến, hàm từ bên ngoài chúng ta nên đặt tên với việc viết hoa chữ cái đầu(ví dụ: Abc(), Abc).</p><p>Nhìn vào chương trình “Hello World&quot; bên trên, có thể thấy hàm “Println()” của package “fmt&quot; được viết hoa chữ cái đầu.</p><p>Dưới đây là 25 key word của Golang, những từ khoá này không được sử dụng để đặt tên biến và hàm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZUveixqqus6g0BvW.png" /><figcaption>25 key word</figcaption></figure><p>Để tìm hiểu nhiều hơn về các key word trên. Golang cung cấp một web site để bạn có thể vừa học và thực hành: <a href="https://go.dev/tour">https://go.dev/tour</a></p><p><strong>Kết luận:</strong></p><p>Bên trên là những gì mình tìm hiểu về Golang thông qua nhiều nguồn. Mình cũng chỉ là người mới bắt đầu tìm hiểu về Go nên bài viết trên có thể có những sai sót.Hi vọng bài viết này sẽ có ích cho các bạn bắt đầu tìm hiểu và muốn lập trình với Go. Nếu bạn muốn tìm hiểu sâu hơn về Go thì bạn có thể tìm hiểu tại <a href="https://go.dev/doc/">Go document</a> và vọc vạch tại <a href="https://go.dev/play/">Go Playground</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a31f6ab7f4de" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DNS là gì? Nó hoạt động như thế nào?]]></title>
            <link>https://medium.com/@tinhuynh1/dns-l%C3%A0-g%C3%AC-n%C3%B3-ho%E1%BA%A1t-%C4%91%E1%BB%99ng-nh%C6%B0-th%E1%BA%BF-n%C3%A0o-96423cb48951?source=rss-ffebf0df636b------2</link>
            <guid isPermaLink="false">https://medium.com/p/96423cb48951</guid>
            <dc:creator><![CDATA[Tín Huỳnh]]></dc:creator>
            <pubDate>Thu, 10 Feb 2022 10:36:31 GMT</pubDate>
            <atom:updated>2022-02-10T10:36:31.585Z</atom:updated>
            <content:encoded><![CDATA[<h3>DNS “Domain Name Server” là gì?</h3><p>Hệ thống phân giải tên miền (DNS) về căn bản là một hệ thống giúp cho việc chuyển đổi các tên miền mà con người dễ ghi nhớ (dạng ký tự, ví dụ <a href="http://www.example.com)/">www.example.com)</a> sang địa chỉ IP vật lý (dạng số, ví dụ 123.11.5.19) tương ứng của tên miền đó. DNS giúp liên kết với các trang thiết bị mạng cho các mục đích định vị và địa chỉ hóa các thiết bị trên Internet.</p><p>Phép so sánh thường được sử dụng để giải thích cho DNS là, nó phục vụ như một “Danh bạ điện thoại”, có khả năng tìm kiếm và dịch tên miền thành địa chỉ IP. Ví dụ, <a href="http://www.example.com/">www.example.com</a> dịch thành 208.77.188.166. Tên miền Internet dễ nhớ hơn các địa chỉ IP, là 208.77.188.166 (<a href="https://vi.wikipedia.org/wiki/IPv4">IPv4</a>) hoặc 2001: db8: 1f70:: 999: de8: 7648:6 e8 (<a href="https://vi.wikipedia.org/wiki/IPv6">IPv6</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*hDLt7ILXbSjOYts5.jpg" /><figcaption>Image credit: Google.com</figcaption></figure><h3>Quy trình tra cứu DNS?</h3><p>Đối với hầu hết các trường hợp, DNS liên quan đến việc một tên miền được dịch sang địa chỉ IP thích hợp. Để tìm hiểu cách thức hoạt động của quá trình này, hãy thực hiện theo đường dẫn của tra cứu DNS khi nó di chuyển từ trình duyệt web, thông qua quy trình tra cứu DNS và quay lại lần nữa. Chúng ta hãy xem xét các bước.</p><p>Lưu ý: Thường thì thông tin tra cứu DNS sẽ được lưu trữ cục bộ bên trong máy tính truy vấn hoặc từ xa trong cơ sở hạ tầng DNS. Thường có 8 bước trong tra cứu DNS. Khi thông tin DNS được lưu vào bộ nhớ đệm, các bước sẽ được bỏ qua khỏi quy trình tra cứu DNS, giúp quá trình này nhanh hơn. Ví dụ dưới đây phác thảo tất cả 8 bước khi không có gì được lưu vào bộ nhớ đệm.</p><ol><li>Người dùng nhập ‘example.com’ vào trình duyệt web và truy vấn sẽ truyền vào Internet và được nhận bởi trình phân giải đệ quy DNS.</li><li>Sau đó, trình phân giải sẽ truy vấn một máy chủ định danh gốc DNS (.).</li><li>Sau đó, máy chủ gốc sẽ phản hồi trình phân giải bằng địa chỉ của máy chủ DNS của Miền cấp cao nhất (TLD) (chẳng hạn như .com hoặc .net), nơi lưu trữ thông tin cho các miền của nó. Khi tìm kiếm example.com, yêu cầu của chúng tôi được hướng tới TLD .com.</li><li>Sau đó, trình phân giải đưa ra yêu cầu tới .com TLD.</li><li>Sau đó, máy chủ TLD sẽ phản hồi bằng địa chỉ IP của máy chủ định danh của miền, example.com.</li><li>Cuối cùng, trình phân giải đệ quy gửi một truy vấn đến máy chủ định danh của miền.</li><li>Địa chỉ IP cho example.com sau đó được trả về trình phân giải từ máy chủ định danh.</li><li>Sau đó, trình phân giải DNS phản hồi trình duyệt web bằng địa chỉ IP của miền được yêu cầu ban đầu.</li></ol><p>Sau khi 8 bước tra cứu DNS đã trả lại địa chỉ IP cho example.com, trình duyệt có thể thực hiện yêu cầu cho trang web:</p><p>9. Trình duyệt thực hiện một yêu cầu <a href="https://www.cloudflare.com/learning/ddos/glossary/hypertext-transfer-protocol-http/">HTTP</a> đến địa chỉ IP.</p><p>10. Máy chủ tại IP đó trả về trang web sẽ được hiển thị trong trình duyệt (bước 10).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vDhp8sJDYYY1c64n.png" /><figcaption>Nguồn ảnh: Cloudflare.com</figcaption></figure><h3>Tổng kết</h3><p>Trên đây là định nghĩa căn bản về DNS và các buớc tra cứu DNS khi truy cập một tên miền. Hi vọng bài viết trên sẽ giúp bạn hiểu rõ hơn về DNS. Chúc bạn thành công!</p><p>Link tham khảo: <a href="https://www.cloudflare.com/learning/dns/what-is-dns/">https://www.cloudflare.com/learning/dns/what-is-dns/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96423cb48951" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>