Skip to content

Instantly share code, notes, and snippets.

Avatar
🔥
ლ(*꒪ヮ꒪*)ლ

Thanatat Tamtan acoshift

🔥
ლ(*꒪ヮ꒪*)ლ
View GitHub Profile
@acoshift
acoshift / main.go
Created May 20, 2020
[Golang] Mask struct by role using struct tag
View main.go
package main
import (
"encoding/json"
"fmt"
"os"
"reflect"
"strings"
)
@acoshift
acoshift / main.go
Last active Mar 3, 2020
http1 vs h2c
View main.go
package main
import (
"context"
"crypto/tls"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
@acoshift
acoshift / main.go
Created Feb 19, 2019
Example how to use sync.Once in Golang
View main.go
package main
import (
"fmt"
"net/http"
"strconv"
"strings"
"sync"
"time"
)
@acoshift
acoshift / main.go
Created Feb 16, 2019
Example how to use semaphore in Golang
View main.go
package main
import (
"context"
"fmt"
"os"
"path/filepath"
"strconv"
"sync"
View main.go
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
View gist:bb1db12539ffd0ac8ed0cbf520ec19ac
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
@acoshift
acoshift / script.sh
Created Nov 6, 2018
Script เทพแปลง 2 spaces เป็น 1 tab
View script.sh
find . -type f | xargs -n1 sed -i '' $'s/ /\t/g'
View sqldb.go
package sqldb
import (
"context"
"database/sql"
"net/http"
"github.com/acoshift/middleware"
"github.com/acoshift/pgsql"
)
@acoshift
acoshift / main.c
Created Oct 24, 2018
Go string in C
View main.c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct {
char *str;
int len;
} string;
string appendString(string s1, string s2) {
View update.bash
#!/bin/bash
brew update && brew upgrade
gcloud components update --quiet
rustup update
nvim +PluginInstall +qall
n lts
npm -g outdated --parseable --depth=0 | cut -d: -f4 | xargs npm -g i