Skip to content

Instantly share code, notes, and snippets.

View huantt's full-sized avatar
🎯
Focusing

Jack huantt

🎯
Focusing
View GitHub Profile
package main
import "fmt"
func main() {
var results []*int
for i := 0; i < 10; i++ {
results = append(results, &i)
}
@huantt
huantt / AddressValidator.java
Created June 8, 2022 02:54
Validate wallet address
public static boolean checksumAddress(String ethereumAddress) {
// to fetch the part after 0x
String subAddr = ethereumAddress.substring(2);
// Make it to original lower case address
String subAddrLower = subAddr.toLowerCase();
// Create a SHA3256 hash (Keccak-256)
SHA3.DigestSHA3 digestSHA3 = new SHA3.Digest256();
digestSHA3.update(subAddrLower.getBytes());
String digestMessage = Hex.toHexString(digestSHA3.digest());
/*
@huantt
huantt / AddressValidator.java
Created June 8, 2022 02:54
Validate wallet address
public static boolean checksumAddress(String ethereumAddress) {
// to fetch the part after 0x
String subAddr = ethereumAddress.substring(2);
// Make it to original lower case address
String subAddrLower = subAddr.toLowerCase();
// Create a SHA3256 hash (Keccak-256)
SHA3.DigestSHA3 digestSHA3 = new SHA3.Digest256();
digestSHA3.update(subAddrLower.getBytes());
String digestMessage = Hex.toHexString(digestSHA3.digest());
/*
@huantt
huantt / Debug goland on mac M1.MD
Last active April 29, 2026 08:02
Resole error: `Cannot find the Delve executable for darwin/arm64. Specify the Delve location by adding 'dlv.path=/path/to/delve' in Help | Edit Custom Properties.`
  1. Install golang for arm64. The easiest way is brew install golang if you have the arm64 version of brew, which is working very well now. Or you can also download the latest arm64 version here: https://go.dev/dl/
  2. Install the Apple Silicon version of Goland
  3. Check out delve. The PR has already been merged, git clone https://github.com/go-delve/delve, then build it with cd delve && make install, which will put delve in /Users/your_name/go/bin/dlv
  4. Open Goland and go to Help-&gt;Edit Custom VM Options. Add a line there with -Ddlv.path=/Users/your_name/go/bin/dlv
[user]
name = JackTT
email = jacktt@facebook.com
[user]
name = JackTT
email = jacktt@google.com
@huantt
huantt / .gitconfig
Last active May 19, 2022 06:30
.gitconfig file supporting multiple configs
[includeIf "gitdir:/Volumes/Data/xantus/"]
path = ~/.gitconfig-xantus
[includeIf "gitdir:/Volumes/Data/personal/"]
path = ~/.gitconfig-personal
[includeIf "gitdir:/Volumes/Data/segu/"]
path = ~/.gitconfig-segu
@huantt
huantt / php-laravel-nginx-dockerfile
Created May 12, 2022 16:07
php7.4 - nginx - lightweight image (~350Mb)
FROM composer@sha256:d374b2e1f715621e9d9929575d6b35b11cf4a6dc237d4a08f2e6d1611f534675 as build_stage
WORKDIR /src
RUN apk add nodejs npm
COPY composer.json composer.lock ./
RUN composer install --prefer-dist --no-progress --no-scripts --no-autoloader --no-dev
COPY package.json package-lock.json ./
RUN npm install
COPY ./resources ./resources
COPY webpack.mix.js .
@huantt
huantt / puppeteer-dockerfile
Last active May 7, 2022 09:18
puppeteer dockerfile - capture html to image
FROM node:14-slim
WORKDIR /usr/src/app
RUN apt-get update \
&& apt-get install -y wget gnupg \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
--no-install-recommends \
@huantt
huantt / clean_code.md
Created May 3, 2022 02:47 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules