Skip to main content

Posts

I also write on dev.to → — shorter articles for hackathons and coding challenges.

2021

C/C++ - const with Pointer or Reference

·556 words·3 mins
const with Normal Variables # Two ways to add const for normal variables: const TYPE NAME = VALUE; // more common TYPE const NAME = VAULE; Both mean this variable cannot be assigned to another value. For example,

Add LikeWidget to Jekyll theme

·337 words·2 mins
Update # I’ve moved my blog from Jekyll to Hugo. The method for adding a like button remains similar, but the code and its placement need to be adjusted. LikeCoin # I came across LikeCoin and it piqued my interest. LikeCoin is a cryptocurrency, which was created to encourage content creators. Content creators can embed a Like Button within their content or web pages. Anyone with a LikeCoin account who appreciates the content can click the button, and the content creator will receive the corresponding LikeCoin. The amount of LikeCoin a content creator receives depends on the account type of the likers. The LikeCoin Foundation proportionally rewards free account likers, while payment accounts are proportionally charged based on the number of likes they click each month. More details can be found on LikeCoin’s Medium.

Remove .DS_Store tracking in all Git repositories

·234 words·2 mins
Every time a new folder is created and files are added in macOS, a .DS_Store file is generated within that folder. This results in numerous .DS_Store files scattered across macOS, and it’s quite annoying to add **/.DS_Store to every .gitignore file each time a new Git repository is created. Therefore, I found a method to prevent .DS_Store files from being tracked in all Git repositories.

Managing Pre-existing Global NPM Packages After Installing NVM

·244 words·2 mins
Today I encountered a problem: After installing nvm, the path for installing global packages changed, making it impossible to directly remove previously installed global packages using npm uninstall -g. How did I discover this? A long time ago, I installed a global package that could be executed directly from the terminal using a command. But because it was so long ago, when I tried to upgrade that package, I found it wasn’t listed in npm list -g.

Pyenv Notes

·348 words·2 mins
Functions and Reasons for Using pyenv # pyenv is a tool used to install various versions of Python on a system, and to conveniently switch between Python versions. When you need to develop or maintain projects that require different Python versions simultaneously, you will need to use pyenv to help switch Python versions. New Python versions usually include syntax updates or new features.

Python Coroutine Asyncio

·845 words·4 mins
Before the advent of asyncio, when a Python program had many tasks that needed to be executed concurrently, and wanted to improve program performance, the only options were multiprocessing or threading. After Python 3.4, asyncio became another option. asyncio can be used to write coroutines, and execute coroutines concurrently using an event loop, reducing unnecessary waiting time in the program to improve performance.

Pipenv Notes

·400 words·2 mins
Why Pipenv # When maintaining many Python projects, different projects might use different versions of the same Python libraries. Not using a virtual environment and installing all Python modules directly on your machine will lead to version conflicts. In the past, the mechanism of virtualenv + requirements.txt allowed different projects to use different versions of the same package, and also enabled new developers or production environments to quickly install the packages required by the project.

Stateless HTTP, Stateful Session and Cookies

·578 words·3 mins
Stateless HTTP # HTTP is a stateless protocol, meaning that each request/response is independent, and is unrelated to previous or subsequent requests/responses. The same request will always receive the same response, and will not differ based on the content of previous requests/responses. This allows the server to save a large amount of database and server storage space because it doesn’t need to store user information. It also speeds up response times and saves considerable network bandwidth because the client doesn’t always have to connect to the same socket.

WSL 2 on Windows Part 2 - Terminal Interface Settings

·347 words·2 mins
Bringing the terminal settings from Linux and Mac to Windows for easier operation. Windows Terminal Features # With Windows Terminal, you can: Enable multiple tabs (quickly switch between multiple Linux CLIs, Windows CLIs, PowerShell, etc.) Customize key bindings (shortcuts for opening/closing tabs, copy/paste, etc.) Use search functionality Customize themes These features offer much more than native WSL support, and allow for a setup similar to my Linux or Mac development environments, which is why I decided to use Windows Terminal.