Skip to content

Instantly share code, notes, and snippets.

View acoshift's full-sized avatar
🔥
ლ(*꒪ヮ꒪*)ლ

Thanatat Tamtan acoshift

🔥
ლ(*꒪ヮ꒪*)ლ
View GitHub Profile
@acoshift
acoshift / .eslintrc.cjs
Last active May 8, 2023 05:25
eslint config for svelte kit
module.exports = {
root: true,
extends: ['eslint:recommended'],
plugins: ['svelte3'],
overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020
},
env: {
@acoshift
acoshift / cloudbuild.yaml
Created May 11, 2022 09:57
Google Cloud Build config for Cloudflare Pages
steps:
- name: node:16
entrypoint: npm
args: [ci]
- name: node:16
entrypoint: npm
args: [run, build]
- name: node:16
entrypoint: npx
args: [wrangler, pages, publish, --project-name=$_PROJECT, ./build]
@acoshift
acoshift / index.html
Last active January 30, 2022 10:11
<!doctype html>
<html lang=en>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ethers.umd.min.js" defer></script>
<script src="https://cdn.jsdelivr.net/npm/@metamask/[email protected]/dist/detect-provider.min.js" defer></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js" defer></script>
<script>
window.abi = {
'IERC20': [
{
@acoshift
acoshift / main.go
Created July 15, 2021 14:51
Hello World Handler with sleep
package main
import (
"net/http"
"time"
)
func main() {
http.ListenAndServe(":3000", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
time.Sleep(200 * time.Millisecond)
@acoshift
acoshift / main.go
Created May 20, 2020 05:14
[Golang] Mask struct by role using struct tag
package main
import (
"encoding/json"
"fmt"
"os"
"reflect"
"strings"
)
@acoshift
acoshift / main.go
Last active March 3, 2020 06:20
http1 vs h2c
package main
import (
"context"
"crypto/tls"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
@acoshift
acoshift / main.go
Created February 19, 2019 16:23
Example how to use sync.Once in Golang
package main
import (
"fmt"
"net/http"
"strconv"
"strings"
"sync"
"time"
)
@acoshift
acoshift / main.go
Created February 16, 2019 11:30
Example how to use semaphore in Golang
package main
import (
"context"
"fmt"
"os"
"path/filepath"
"strconv"
"sync"
package main
import "fmt"
func p(s, n, i, j int) int {
if i == 0 || j == 0 || i == n-1 || j == n-1 {
if i-j <= 0 {
return s + j + i + 1
}
return s + 4*(n-1) - j - i + 1
@acoshift
acoshift / gist:bb1db12539ffd0ac8ed0cbf520ec19ac
Last active August 18, 2019 01:21
Delete GCR old images (> 10)
gcloud container images list-tags --format=json gcr.io/$PROJECT_ID/$IMAGE | \
jq -r '.[].digest' | \
awk 'NR > 10 {print "gcr.io/$PROJECT_ID/$IMAGE@" $1}' | \
xargs -P 10 -n 10 gcloud container images delete -q --force-delete-tags