Skip to content

Instantly share code, notes, and snippets.

@pawutj
pawutj / n8n.json
Last active March 10, 2026 10:42
ืn8n
[
{ "name": "สมชาย", "used_days": 3, "request_date": "2026-01-05" },
{ "name": "สมหญิง", "used_days": 9, "request_date": "2026-01-06" },
{ "name": "สมศักดิ์", "used_days": 5, "request_date": "2026-01-11" }
]
@pawutj
pawutj / medium.js
Created May 2, 2023 21:32
medium.js
function findStringInList(s, list) {
let controlFlag = false
for (let i = 0; i < list.length; i++) {
if (controlFlag == false)
if (list[i] === s)
controlFlag = true
console.log("Found")
}
if (controlFlag === false)
console.log("Not Found")
@pawutj
pawutj / db_test.go
Created December 17, 2022 14:07
db_test.go
package go_docker_sandbox
import (
"testing"
)
func TestConnectDB(t *testing.T) {
db := ConnectDB()
if db == nil {
@pawutj
pawutj / 01-init.sql
Created December 17, 2022 12:05
01-init.sql
CREATE TABLE IF NOT EXISTS product (id SERIAL PRIMARY KEY , name TEXT , price INTEGER);
Insert into product (name, price) values ('SomeProduct' , 3)
@pawutj
pawutj / docker-compose.yml
Created December 17, 2022 12:03
docker-compose.yml
version: "3.3"
services:
test_sandbox:
build:
context: .
dockerfile: ./Dockerfile
volumes:
- .:/app
depends_on:
@pawutj
pawutj / db.go
Created December 17, 2022 12:02
db.go
package go_docker_sandbox
import (
"database/sql"
"log"
_ "github.com/lib/pq"
)
func ConnectDB() *sql.DB {
url := "postgres://root:root@db/go-example-db?sslmode=disable"
@pawutj
pawutj / Dockerfile
Created December 17, 2022 12:01
Dockerfile
FROM golang:1.19-alpine
WORKDIR /app
CMD CGO_ENABLED=0 go test -v ./...
@pawutj
pawutj / Dockerfile
Created December 16, 2022 23:03
Dockerfile
FROM golang:1.19-alpine
WORKDIR /app
COPY . .
CMD CGO_ENABLED=0 go test -v ./...
@pawutj
pawutj / sum_test.go
Created December 16, 2022 22:32
sum_test.go
package go_docker_sandbox
import "testing"
func TestSum(t *testing.T) {
result := Sum(1, 2)
want := 3
if result != want {
t.Errorf("Want '%d' result '%d'", want, result)
}
@pawutj
pawutj / sum.go
Created December 16, 2022 22:32
sum.go
package go_docker_sandbox
func Sum(a, b int) int {
return a + b
}