Skip to main content

Posts

Shikaku Talks To Shikamaru

It was after Asuma lost the battle with Akatsuki.

Phases of Node.js Event Loop

We know that a Node.js application is run in a single-threaded fashion. But, it can handle multiple asynchronous operations in the background and exhibits features as if it is a multi-threaded application. At the base level, Node.js is built on C++ which actually allows the existence of multiple threads. While that's not the actual basis, Node.js utilizes the  libuv library that allows it to interact with the operating system and utilize available resources efficiently. The library enables asynchronous I/O operations such as file reading, database querying, data transferring over the network, and so on, then it will trigger the registered callback for each completed I/O operation to run. Node.js manage all the callbacks in a mechanism called " event loop ". An event loop is a loop of sequential processes which are grouped into several phases. It handles callbacks of asynchronous I/O operations and asynchronous calls initiated by objects or functions in the main appl

Configure Gitlab SMTP Setting

Gitlab CE or EE is shipped with the capability to send messages through SMTP service as the basic feature to send notifications or updates to the users. The configuration parameters are available in /etc/gitlab/gitlab.rb . Each SMTP service provider has a different configuration, therefore the Gitlab configuration parameters should be adjusted according to the requirements. Some examples have been provided by Gitlab here . This is an example if you use the Zoho service. gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.zoho.com" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_authentication'] = "plain" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_user_name'] = "gitlab@mydomain.com" gitlab_rails['smtp_password'] = "mypassword" gitlab_rails['smtp_domain'] = "smtp.zoho.com" This is another example of using Amazon SES w

Measuring Correlation

If we want to know a correlation between a boxer winning a match and using red pants, we can mathematically determine it based on past records of those conditions. There are four possible combinations of the conditions. The boxer loses and he doesn’t use red pants (00) The boxer loses and he uses red pants (01) The boxer wins and he doesn’t use red pants (10) The boxer wins and he uses red pants (11) For example, we have the following past records. Condition “00” is 23 times Condition “01” is 10 times Condition “10” is 45 times Condition “11” is 9 times Then, we can use the phi coefficient formula. The result of this formula is between -1 and 1. If the result is close to 0, it means the conditions have no correlation. If it is close to 1, it means the conditions are strongly correlated. Meanwhile, if it is negative, the correlation is strong but in the opposite way. The formula is as follows. phi = (n11 x n00) – (n01 x n10) / sqrt(n1X x n0X x nX1 x nX0) n1X represents the condition wh

Elements of UI Design

There are some essential elements in designing a user interface. I found that the following items are necessary to bring up a certain feeling, thought, or perspective for the user of our product. Color Color can shape a mood for the user. Combining multiple colors should be carefully picked to create a comfortable look. One of the tools available online to pick colors is here . Positive and Negative Space Positive space is the element containing the main content or information. Meanwhile, negative space is the distance between main elements or empty space around them. Each main element should have distance or space from each other to nicely navigate the focus of the users from one information to another. Typography Typography includes selecting appropriate fonts with good looks and aligning text content on the page. Microcontent We need to provide some short texts or content on a page to make it easy for the user to skim the information on th

First Appearance of Titan Eren

 When Mikasa was trying to grasp herself, a titan appeared killing the other titans.

Downloading A Large File From Google Drive

I just found a helpful answer from Quora about downloading a large file from Google Drive. It utilizes Google Drive API for downloading the file. The steps are as follows. Get the file ID from the shareable link URL. For example, the URL has a format similar to this: https://drive.google.com/file/d/THE_FILE_ID/view?usp=sharing , then the file ID is THE_FILE_ID . Go to Google OAuth 2.0 Playground . On this page, we can get an access token for utilizing Google API to download our file. Select the Drive API v3 and authorize it. Then, keep the access token that is available on the "Exchange authorization code for tokens" tab. Last, we can utilize curl to download the file using a terminal. curl -H "Authorization: Bearer THE_ACCESS_TOKEN" https://www.googleapis.com/drive/v3/files/THE_FILE_ID?alt=media -o THE_OUTPUT_FILE.ext

Utilizing Docker Secret

It likely happens that we need to provide some secrets like passwords, keys, or private things into our Docker containers. If we use the docker-compose tool to generate our containers, we basically can put the secrets as environment variables in the docker-compose.yaml file. But, what if we want to share our configuration with the others, they will find those secrets too. So, for overcoming that issue, we can utilize a feature provided by Docker itself which is the Docker secret, or we can just call it secret . For instance, we want to build a container for the PostgreSQL database. The PostgreSQL image allows us to set a custom database password by providing a value for the POSTGRES_PASSWORD or POSTGRES_PASSWORD_FILE variable. services: postgres: image: postgres environment: - POSTGRES_PASSWORD=$3cureP4ssword Or, we can utilize the Docker bind-mounting to store a file and instruct the Docker to read the secret information from the mounted file. services:

Principles of UX Design

If we want to elaborate a user experience (UX) design for our product, we need to understand some principles of a good UX design. Our design should be based on specific reasons and have certain intentions for our users and ourselves as product owners or as a business. These are several principles that should become our consideration in generating the design. Usefulness We build a product with a desire for providing solutions for any specific needs of the users. So, it is important to make sure that any design elements are provided to make the users completely gain the benefit of using our product and solve their problems. Usability Visions and our good intentions are not enough to build a great product if we don't provide clear ways for the users to take the most benefit of the product. Usability is a focus to provide easiness for the users in utilizing our product. Desirability Why are some products or services instantly abandoned by their users

When Mikasa Got So Emotional But Had To Fight

 She just tried to suppress her feeling.

Generate API Documentation Using Swagger Module in NestJS

Swagger provides us a standard to generate API documentation based on the Open API specification. If we use NestJS for building our API providers, we can utilize a tool provided by NestJS in the  @nestjs/swagger  module to generate the documentation automatically in the built time. This module also requires the swagger-ui-express module if we use Express as the NestJS base HTTP handler. Set Swagger configuration First, we need to define Swagger options and instantiate the documentation provider on the main.ts file. import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; // sample application instance const app = await NestFactory.create(AppModule); // setup Swagger options const options = new DocumentBuilder() .setTitle('Coffee') .setVersion('1.0') .setDescription('Learn NestJS with coffee') .build(); // build the document const document = SwaggerModule.createDocument(app, options); // provide an endpoint

Building Reducer Using Redux Toolkit

Redux Toolkit is one of the libraries that can help us manage our application state which depends on Redux. It allows us to create reducers within our application and separate each reducer from one another based on any criteria that we desired in a specific kind of module. There are some approaches that we can utilize to build reducers in Redux Toolkit. Basic Shape const slice = createSlice({ // ... reducers: { increment: (state) => { state += 1; } } }); On the code above, it seems that we mutate the state, but actually, Redux Toolkit utilizes Immer in the backstage so it will be translated into immutable operation. Then, unlike legacy libraries that require us to manually define the action that will be dispatched to be handled by a specific reducer, Redux Toolkit can generate action creators for us. const { increment } = slice.actions; // "increment" is the action creator Then, we can dispatch the action inside our compone