Skip to content

Instantly share code, notes, and snippets.

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

Thanatat Tamtan acoshift

🔥
ლ(*꒪ヮ꒪*)ლ
View GitHub Profile
@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'
package sqldb
import (
"context"
"database/sql"
"net/http"
"github.com/acoshift/middleware"
"github.com/acoshift/pgsql"
)
@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) {
#!/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.go
Last active May 5, 2018 04:18
db, tx in ctx
package main
import (
"context"
"database/sql"
"io"
"log"
"net/http"
)
@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
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
Last active October 15, 2017 13:05
remove duplicate: loop 2
func removeDuplicateLoop2(arr []int) []int {
r := make([]int, 0)
for i := range arr {
for j := range r {
if arr[i] == r[j] {
goto duplicated
}
}
r = append(r, arr[i])
@acoshift
acoshift / main.go
Created October 15, 2017 06:33
remove duplicate: hash map
func removeDuplicateMap(arr []int) []int {
p := make(map[int]struct{})
for _, v := range arr {
p[v] = struct{}{}
}
r := make([]int, 0, len(p))
for v := range p {
r = append(r, v)
}
return r
@acoshift
acoshift / main.go
Created October 15, 2017 06:24
remove duplicate: loop
func removeDuplicateLoop(arr []int) []int {
p := append([]int{}, arr...)
for i := range p {
for j := i + 1; j < len(p); j++ {
if p[i] == p[j] {
p = append(p[:j], p[j+1:]...)
j--
}
}
}