Skip to content

Instantly share code, notes, and snippets.

View huantt's full-sized avatar
🎯
Focusing

Jack huantt

🎯
Focusing
View GitHub Profile
@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 / 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 / .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
[user]
name = JackTT
email = [email protected]
[user]
name = JackTT
email = [email protected]
@huantt
huantt / Debug goland on mac M1.MD
Last active May 30, 2022 03:15
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->Edit Custom VM Options. Add a line there with -Ddlv.path=/Users/your_name/go/bin/dlv
@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());
/*
package main
import "fmt"
func main() {
var results []*int
for i := 0; i < 10; i++ {
results = append(results, &i)
}
func chunkSlice(slice []int, chunkSize int) [][]int {
var chunks [][]int
for i := 0; i < len(slice); i += chunkSize {
end := i + chunkSize
// necessary check to avoid slicing beyond
// slice capacity
if end > len(slice) {
end = len(slice)
}