Exports, Imports, and Modules in Modern TypeScript/JavaScript
Things start getting confusing when your npm package wants to support both ECMAScript Modules (ESM) and CommonJS (CJS), which makes it a dual-package. Assume we have a package whose file structure...
View ArticleExpose a Local Service with Cloudflare Tunnel
Expose a service running on your local machine to a remote server without opening any ports. For instance, let your OpenClaw agent (the remote server) access qBittorrent Web UI on your Mac (the local...
View ArticleClaude Code: Things I Learned After Using It Every Day
I've used Claude Code daily since it came out. Here are the best practices, tools, and configuration patterns I've picked up. Most of this applies to other coding agents (Codex, Gemini CLI) too. TL;DR...
View ArticleCloudflare Quick Tunnel (TryCloudflare)
Expose your local server to the Internet with one cloudflared command (just like ngrok). No account registration needed, no installation required (via docker run), and free. # assume your local server...
View ArticleGKE Autopilot Cluster: Pay for Pods, Not Nodes
If you're already on Google Cloud, it's highly recommended to use GKE Autopilot Cluster: you only pay for resources requested by your pods (system pods and unused resources are free in Autopilot...
View ArticleStop Paying for Kubernetes Load Balancers: Use Cloudflare Tunnel Instead
To expose services in a Kubernetes cluster, you typically need an Ingress backed by a cloud provider's load balancer, and often a NAT Gateway. For small projects, these costs add up fast (though...
View Article1Password CLI: How NOT to Store Plaintext AWS Credentials or .env on Localhost
No More ~/.aws/credetials According to AWS security best practices, human users should access AWS services using short-term credentials provided by IAM Identity Center. Long-term credentials ("Access...
View ArticleSolidity: call() vs delegatecall()
tl;dr: delegatecall runs in the context of the caller contract. The difference between call and delegatecall in Solidity relates to the execution context: target.call(funcData): the function...
View ArticleSolidity: Multicall - Aggregate Multiple Contract Calls
There are different implementations of multicall: https://github.com/Vectorized/multicaller https://github.com/mds1/multicall https://github.com/AmazingAng/WTF-Solidity/tree/main/55_MultiCall In the...
View ArticleSolidity: abi.encode() vs abi.encodePacked() vs abi.encodeWithSignature() vs...
There are some encode/decode functions in Solidity, for instance: abi.encode() will concatenate all values and add padding to fit into 32 bytes for each values. To integrate with other contracts, you...
View ArticleBuild Docker Images using Google Cloud Build from Your GitHub Repository
Triggering a Docker image build on Google Cloud Build when pushing commits to a GitHub repository. Create Google Cloud Build Configuration File Create a cloudbuild.yaml in the root folder: steps: - id:...
View ArticleSolidity: Read Contract Storage by Slots with Foundry
State variables are stored in different "slots" in a contract, and each slot is 32 bytes (256 bits). However, multiple adjacent state variables declared in the contract may be packed into the same slot...
View ArticleHow to Stay Safe Online: Tips for Personal Security
How I learned to "start worrying" and love the illusion of feeling safe. Digital security and privacy have become more important than ever. With cyber threats constantly evolving, it is crucial to...
View ArticleSolidity: CREATE vs CREATE2
In Solidity, there are two opcodes for creating contracts: CREATE and CREATE2. Also, the deployed contract address can be precomputed via: keccak256(deployerAddress, deployerNonce) if you're using...
View ArticleSolidity: calldata, memory, and storage
Variables There are three types of variables in Solidity: Global variables Provide information about the blockchain For example, block.number, block.timestamp, or msg.sender State variables Declared...
View Articlehardhat-deploy: Upgradeable Contracts with Linked Libraries
Library Assume ContractA imports LibraryA, when deploying ContractA, LibraryA is embedded into ContractA if LibraryA contains only internal functions. If LibraryA contains at least one external...
View ArticleDeploy Ethereum RPC Provider Load Balancer with HAProxy in Kubernetes (AWS EKS)
To achieve high availability and better performance, we could build a HAProxy load balancer in front of multiple Ethereum RPC providers, and also automatically adjust traffic weights based on the...
View ArticleDeploy graph-node (The Graph) in Kubernetes (AWS EKS)
graph-node is an open source software that indexes blockchain data, as known as indexer. Though the cost of running a self-hosted graph node could be pretty high. We're going to deploy a self-hosted...
View ArticleAmazon EKS: Setup Cluster Autoscaler
The Kubernetes's Cluster Autoscaler automatically adjusts the number of nodes in your cluster when pods fail or are rescheduled onto other nodes. Here we're going to deploy the AWS implementation that...
View ArticleAmazon EKS: Setup aws-load-balancer-controller for Kubernetes Ingress
AWS Load Balancer Controller replaces the functionality of the AWS ALB Ingress Controller. Install aws-load-balancer-controller Create an IAM OIDC provider for your cluster eksctl utils...
View Article