Skip to content

Instantly share code, notes, and snippets.

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

Thanatat Tamtan acoshift

🔥
ლ(*꒪ヮ꒪*)ლ
View GitHub Profile
@acoshift
acoshift / main.go
Created April 7, 2018 11:50
main.go for k8s app
package main
import (
"context"
"log"
"net/http"
"os"
"os/signal"
"sync"
"syscall"
@acoshift
acoshift / main.go
Created April 7, 2018 12:06
main.go for k8s app w/ hime
package main
import (
"log"
"net/http"
"time"
"github.com/acoshift/hime"
"github.com/acoshift/probehandler"
)
@acoshift
acoshift / main.go
Last active May 5, 2018 04:18
db, tx in ctx
package main
import (
"context"
"database/sql"
"io"
"log"
"net/http"
)
#!/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
@acoshift
acoshift / main.c
Created October 24, 2018 08:17
Go string in C
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct {
char *str;
int len;
} string;
string appendString(string s1, string s2) {
package sqldb
import (
"context"
"database/sql"
"net/http"
"github.com/acoshift/middleware"
"github.com/acoshift/pgsql"
)
@acoshift
acoshift / script.sh
Created November 6, 2018 14:16
Script เทพแปลง 2 spaces เป็น 1 tab
find . -type f | xargs -n1 sed -i '' $'s/ /\t/g'
@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
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 / 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"