Sitemap Fetching Issues with CC and Certain Domain
Two or three years ago, I registered the emn178.cc domain and tried to move my blog to it. At the time, I ran into an issue with submitting the sitemap to Google Search Console: its status remained stuck at “Couldn’t fetch”. I tried many different solutions, but nothing worked. Even pages that I manually submitted to Google would gradually disappear from the index, and eventually the site became impossible to find through Google Search. Later, I tried using GitHub Pages and submitted the site ...
ancestry vs. awesome_nested_set
There are several gems available for handling tree structures in Rails. This article will compare the following solutions: ancestry awesome_nested_set closure_tree ScenarioSuppose there is a model called Node that can have child nodes in a tree structure. FeaturesancestrySetupUsing the new rules, add the following to config/initializers/ancestry.rb 1Ancestry.default_ancestry_format = :materialized_path2 Tables that need to support a tree structure should include some dedicated colum ...
acts-as-taggable-on vs. PostgreSQL Array (acts-as-taggable-array-on)
acts-as-taggable-on is a commonly used gem in Rails for handling tagging functionality. However, similar features can also be implemented using PostgreSQL’s special Array type. For example, the acts-as-taggable-array-on gem utilizes PostgreSQL Arrays to achieve this. This article will compare the following solutions: acts-as-taggable-on acts-as-taggable-array-on pg_taggable ScenarioSuppose there are two models: Post and User. A Post has a tags attribute and belongs to a User. Common functional ...
jbuilder vs active_model_serializers vs oj_serializers - Rails JSON API Comparison
Rails provides a built-in as_json method for generating JSON. Additionally, jbuilder is the default gem for handling JSON APIs, and there are other alternative gems available. This article compares the following solutions: as_json jbuilder active_model_serializers oj_serializers Based on personal experience, the evaluation considers the following criteria: Ease of maintenance. Reusability of defined structures. Ability to generate JSON objects and use them within the code. Performance. Ease o ...
Using Ethers.js to Sign and Recover EIP-712 Typed Structured Data
Solidity - EIP-712 Typed Structured Data Hashing and Signing explains how smart contracts verify the signature of EIP-712. This article explains how to use Ethers.js for EIP-712 signing. This article uses Ethers.js version 6.7.1. Signsigner.signTypedDataEthers.js uses the following function to sign. Refer to the previous article Using Ethers.js to Sign and Recover to obtain the Signer. 1signer.signTypedData(domain, types, value): Promise<string> domain: The data of eip712Domain in the con ...
Using Web3.js to Sign and Recover EIP-712 Typed Structured Data
Solidity - EIP-712 Typed Structured Data Hashing and Signing explains how smart contracts verify the signature of EIP-712. This article explains how to use Web3.js for EIP-712 signing. This article uses Web3.js version 4.1.1. SignBrowser WalletWeb3.js can use the following functions to sign EIP-712: web3.eth.signTypedData web3.currentProvider.request Browser wallets can use the above functions, but Web3.js does not have a private key signing method, so another library will be introduced later ...
Solidity - EIP-712 Typed Structured Data Hashing and Signing
This article explains the EIP-712 standard and how to use Solidity to implement EIP-712 in smart contract. IntroductionIn the previous article, we introduced some methods of signing and verification. In practice, we may sign many data. For example: 123456789function permit(address owner, address spender, uint value, uint nonce, uint deadline, uint8 v, bytes32 r, bytes32 s) external { require(deadline >= block.timestamp, "signature expired"); require(!usedNonces[nonce], " ...
Using Ethers.js to Sign and Recover
Solidity - ecrecover this article explains how smart contracts verify signatures. This article will explain how to use Ethers.js to sign and recover. This article uses Ethers.js version 6.7.1. SignerThe Signer object will be used in the following content. Here is a brief explanation of how to obtain it. Private Key12345import { JsonRpcProvider, Wallet } from "ethers";const privateKey = '0x...'const provider = new JsonRpcProvider(url);const signer = new Wallet(privat ...
Using Web3.js to Sign and Recover
Solidity - ecrecover this article explains how smart contracts verify signatures. This article will explain how to use Web3.js to sign and recover. This article uses Web3.js version 4.1.1. SignWeb3.js provides several off-chain signing functions. This article introduces the following three: web3.eth.sign web3.eth.accounts.sign web3.personal.sign For EIP-712 related methods, refer to Using Web3.js to Sign and Recover EIP-712 Typed Structured Data. web3.eth.signThis is an old function, and the s ...
Solidity - Signature Malleability
The previous article introduced the usage of ecrecover, but the built-in ecrecover has a signature malleability problem. This article will explain this problem and how to solve it. ProblemExamples from the previous article: 1234567function test() external view returns(address) { bytes32 hash = 0xc1af4b94166cd32fc49b7b926cbb91ee421de2d04450e8ae57857b9b56ac7e53; uint8 v = 0x1b; bytes32 r = 0xe1077fb9321c187d8a43926896abac5455ce6add269e098f855ff059d6b846a3; bytes32 s = 0x56320be5f6d79c4d0e ...


