Skip to main content

· One min read
Luong

NanoID is a lib for generating random identifiers. It is compared to UUID but said faster, smaller in code size, friendlier in URL, and shorter in length (21 symbols vs 36) although both have the same collision probability. Also NanoId is widely ported to over 20 programming languages.

For instance, with speed of generating 1000 IDs per hours, it needs ~149 billion years or 1,307,660T IDs in order to have a 1% probability of at least one collision.

Install

npm install nanoid

Usage

import { nanoid } from 'nanoid';
const id = nanoid(); // "V1StGXR8_Z5jdHi6B-myT"

In case you want to customize alphabet or ID length:

import { customAlphabet } from 'nanoid';
const nanoid = customAlphabet('1234567890abcdef', 10);
const id = nanoid(); // "4f90d13a42"

References

· One min read
Luong

Looking for a tool to design database of my new project, I found out a great one in the niche, that's DbDiagram. It is really simple to use, designed by DBML and exported to MySQL / PostgreSQL or SQL Server in one second. Certainly you can learn and start your database design with DbDiagram in less than ten minutes.

Database design with DbDiagram

DbDiagram stores your design files on cloud. For free version, they do public our designs. In case you want them in private, just pay ~$9 per month. In addition, you can collaborate with your team by purchasing team plan.

· 2 min read
Luong

Docusaurus is a great tool to set up documentations for a software project, set of features included such as a homepage, documentations, blogs. etc. Docusaurus is simple to use, requires a little Javascript skills to install, develop more functions. Contents in Docusaurus are composed by Markdown or MDX, friendly markup languages. For a plus, it is developed by Meta team, this ensures for long-term maintenance.

To see how great this tool is, visit Docusaurus homepage, that is exactly what this tool can do for you easily. Of course, my simple blog you are reading here is also done by Docusaurus. Docusaurus homepage

Install

To install a project with Docusaurus, you need Node.js version 18.0 or above installed. Then run the following command to scaffold the project bundled with sample data:

npx create-docusaurus@latest my-website classic --typescript

Edit files in /blog, /docs, or /src/pages (homepage) with Markdown language, then preview changes.

Run on Development

To run the website at your local development and watch changes:

cd my-website
npm run start

Run on Production

Create an account at GitHub pages or Vercel, then hook it to your Github repository, and everything is deployed automatically. Basically, these hosting providers proceed building code and start services for you. I prefer Vercel because it is super easy in deployment with SSL support and domain linking.

npm run build

For code of my simple blog, you can check here and feel free to give me any feedback. Thank you.