- Go to https://thegraph.com/hosted-service/, register a new account using your Github account
- Go to https://thegraph.com/hosted-service/dashboard, -> Add Subgraph, then fill the information. Use: Test Uniswap Graph for name
- Grab your subgraph id. If it is https://thegraph.com/hosted-service/subgraph/hungdoansy/uniswap-v2-experiment, grab hungdoansy/uniswap-v2-experiment
- Clone an example repo or create a new one from CLI
git clone [email protected]:hungdoansy/test-the-graph.git test-uniswap-graph cd test-uniswap-graphyarnto install all dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "golang.org/x/text/runes" | |
| "golang.org/x/text/transform" | |
| "golang.org/x/text/unicode/norm" | |
| "strings" | |
| "unicode" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Example of using ethers.js to interact with a smart contract | |
| // Call a contract method at a specific block | |
| // This example is to get rate of a token at a block | |
| import { ethers } from "ethers" | |
| import BigNumber from "bignumber.js" | |
| // prettier-ignore | |
| const oracleABI = '[{"inputs":[{"internalType":"contract MultiWrapper","name":"_multiWrapper","type":"address"},{"internalType":"contract IOracle[]","name":"existingOracles","type":"address[]"},{"internalType":"enum OffchainOracle.OracleType[]","name":"oracleTypes","type":"uint8[]"},{"internalType":"contract IERC20[]","name":"existingConnectors","type":"address[]"},{"internalType":"contract IERC20","name":"wBase","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC20","name":"connector","type":"address"}],"name":"ConnectorAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC20","name":"connector","type":"address"}],"name":" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM nginx | |
| COPY ./nginx.conf /etc/nginx/conf.d/default.conf |
File package.json
{
"main": "index.js",
"script": {
"build": "babel src -d build --copy-files",
"start": "rm -rf build && yarn build && node build/index.js"
},
"dependencies": {Nọ đội Dwarves Foundation mới đăng 1 bài viết về cấu trúc cũng như các thư viện họ dùng trong các dự án React. Có 1 cái khá thú vị là họ bảo éo thèm chơi state management lib, ví dụ như Redux, mà chỉ cần dùng Context là đủ. Bất ngờ vãi nồi. Hệ thống lớn mà ko có thằng như Redux thì phải tự optimize re-renders bằng tay. Xong hoá ra có lý do cả, họ dùng mấy thằng lib ở bên dưới đây. Cái danh sách này có thêm 1-2 cái của cùng tác giả, tiện em viết luôn.
- https://github.com/dai-shi/use-context-selector Khi mình có 1 context, ví dụ như:
const contextValue = {
count: 0,
text: "hehe"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Source: https://stackoverflow.com/a/2450976/6812545 | |
| const shuffle = <T>(array: T[]): T[] => { | |
| let currentIndex = array.length, randomIndex; | |
| // While there remain elements to shuffle. | |
| while (currentIndex != 0) { | |
| // Pick a remaining element. | |
| randomIndex = Math.floor(Math.random() * currentIndex); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| /* | |
| * Scan pnpm workspace/project for known bad package versions. | |
| */ | |
| const fs = require("fs"); | |
| const path = require("path"); | |
| const { execFile } = require("child_process"); | |
| // 👇 paste your affected list here |