Skip to content

Instantly share code, notes, and snippets.

View hungdoansy's full-sized avatar
📺

Hung Doan hungdoansy

📺
View GitHub Profile

Tash - Slack PR Thread Bot - Cost Analysis

Overview

This document provides detailed cost analysis and resource estimates for the Tash Slack PR Thread Bot based on the following usage patterns:

  • 10 Slack users in 1 workspace
  • 6 GitHub repositories being tracked
  • 20 pull requests per day across all repos
  • 2-3 approvals per PR (40-60 approval events/day)
@hungdoansy
hungdoansy / scan-pnpm-vuln-packages.js
Last active September 9, 2025 15:14
A Node.js CLI utility for scanning pnpm projects (and workspaces) against a known list of vulnerable package versions.
#!/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

Summary

eth_estimateGas failed, eth_call (to simulate) failed but tx succeeded 🤷

eth_estimateGas (to estimate gas)

[
    {
        "jsonrpc": "2.0",
        "id": 9,
@hungdoansy
hungdoansy / shuffle.ts
Created July 24, 2023 01:47
Shuffle a list
// 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);
@hungdoansy
hungdoansy / Lib.md
Created April 20, 2023 02:23
Một số thư viện có ích cho tối ưu re-renders

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.

  1. https://github.com/dai-shi/use-context-selector Khi mình có 1 context, ví dụ như:
const contextValue = {
  count: 0,
  text: "hehe"

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": {
@hungdoansy
hungdoansy / Dockerfile
Last active March 25, 2025 10:24
Setting up a custom domain for your local apps, with port-forwarding
FROM nginx
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
@hungdoansy
hungdoansy / renew-gpgkey.md
Created August 16, 2022 08:11 — forked from krisleech/renew-gpgkey.md
Renew Expired GPG key

Renew GPG key

Given that your key has expired.

$ gpg --list-keys
$ gpg --edit-key KEYID

Use the expire command to set a new expire date:

@hungdoansy
hungdoansy / main.ts
Created July 5, 2022 06:02
Call a contract method at a specific block using ethers.js
// 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":"
@hungdoansy
hungdoansy / normalize_string.go
Created June 29, 2022 08:43 — forked from nvtuan305/normalize_string.go
golang: normalize string (include Vietnamese)
package main
import (
"fmt"
"golang.org/x/text/runes"
"golang.org/x/text/transform"
"golang.org/x/text/unicode/norm"
"strings"
"unicode"
)