ALL


  First Touch on OpenAI API

It’s been a while since ChatGPT launched, and I’ve been meaning to try out the OpenAI API. Recently, I finally took the plunge, so here’s a walkthrough of my initial experience using it.Objective: I’ve previously used ChatGPT’s interface for language translation tasks between Chinese and English. For this API experiment, I aimed to set up a simple translation function using the OpenAI API.Step 1: Getting the API KeyFirst, to access the API, I created an OpenAI account and generated an API key. This key is required for making API calls. The setup is straightforward...

326 0       TUTORIAL API TRANSLATION OPENAI FREE ACCOUNT


  9 Ways to Create Thread Pools with Java Executors

In Java, the Executors class provides a variety of static factory methods to create different types of thread pools. When learning about thread pools, the Executors class is indispensable. Mastering its usage, principles, and scenarios will enable you to apply it smoothly in actual project development. Here are some commonly used methods, which I will explain one by one:newCachedThreadPool(): Creates a cached thread pool. If a thread has not been used for 60 seconds, it will be terminated and removed from the cache.newFixedThreadPool(int nThreads): Creates a fixed-size thread pool where nThrea...

1,529 0       TUTORIAL JAVA THREAD


  Reflection in Java

What is Reflection?Reflection is a feature in Java that allows a program to obtain information about itself at runtime and dynamically manipulate the properties, methods, and constructors of classes or objects. With reflection, we can instantiate objects, call methods, and set properties without knowing the exact class name beforehand.The core of the reflection mechanism is the Class object, which represents a class. The Java Virtual Machine (JVM) automatically creates this Class object when it loads a class.How the JVM Creates a Class?When we write a class and compile it, the compiler convert...

1,433 0       METHOD TUTORIAL JAVA REFLECTION FIELD


  Connect to SQLite using Go on Windows

In software development, it's often necessary to test and validate logic using a lightweight and easily manageable database system. SQLite, with its minimal setup and zero configuration requirements, is an excellent choice for such scenarios. Leveraging the simplicity and efficiency of SQLite for testing purposes can significantly streamline the development process. In this guide, we'll explore how to seamlessly connect to SQLite using Go on Windows, empowering developers to efficiently test their code with a reliable and straightforward database solution.Install SQLIte3 PackagesGo has built-i...

1,433 0       WINDOWS TUTORIAL GOLANG SQLITE3


  Singleton Pattern in Golang

Singleton pattern is the simplest design pattern in software design. It ensures that only one instance of an object exists globally, regardless of how many times the object is instantiated. Based on the characteristics of the singleton pattern, it can be applied to scenarios such as global unique configuration, database connection objects, file access objects, etc. In Go language, there are multiple ways to implement the singleton pattern. Today, let's learn together about some of these approaches.Eager InitializationImplementing the singleton pattern using eager initialization is very simple....

2,607 0       GOLANG SINGLETON PATTERN TUTORIAL


  What can select do in GoLang

In Go language, select is a keyword used to listen to and perform IO operations related to channels.With the select statement, we can simultaneously listen to multiple channels and perform corresponding operations when any of the channels are ready.This article will summarize the common uses of the select statement and provide some considerations when using it.Basic syntaxThe basic syntax of the select statement is as follows:select {case <-channel1: // when channel1 has data to processcase data := <-channel2: // when channel2 has data to processdefault: // if no channel has dat...

1,452 0       TUTORIAL SELECT USAGE SYNTAX GOLANG


  A simple tutorial on GoLang connecting to Clickhouse

Go, also known as Golang, is a statically-typed, concurrent programming language created by Google. ClickHouse is a high-performance, column-oriented database management system that can be used for real-time data analysis.This tutorial will provide a deep dive into how to connect to ClickHouse from a Go program, including how to perform common database operations such as SELECT and INSERT statements.Before proceeding, it is assumed that you already have Go and ClickHouse installed on your machine. If not, you can download the latest version of Go from the official website and install it by fol...

5,857 0       TUTORIAL GOLANG CLICKHOUSE


  Service discovery with etcd

In previous post, we have talked about etcd and its usage. This post we will cover how to implement server discovery with etcd.Service discovery is to solve one of the most commonly seen scenarios in distributed system where how to find the corresponding target service to talk to. In short, it is to find some server which one can talk to based on some service name.A complete service discovery system include below three key functions:Service registration: A service must register itself to some common place so that others can discover itHealth check: An instance must report its health status to ...

5,252 0       SERVICE DISCOVERY ETCD DEMO TUTORIAL