Skip to content

Instantly share code, notes, and snippets.

View buildingwatsize's full-sized avatar
🧘‍♂️
Meditating

Chinnawat Chimdee buildingwatsize

🧘‍♂️
Meditating
View GitHub Profile
@buildingwatsize
buildingwatsize / stay_awake.bat
Created May 17, 2021 12:52
BAT Script for Waking your HDD every 10 seconds :D Hope you enjoy it.
@echo off
:awake
cls
wmic logicaldisk get FreeSpace, Name, VolumeName
timeout /t 10
goto awake
@buildingwatsize
buildingwatsize / newGoAPI.sh
Created March 19, 2021 04:06
[v0.1.0] Golang + Fiber Boilerplate with a single command `./newGoAPI.sh` | Note: maybe you have to run `chmod a+x newGoAPI.sh` first
#!/bin/sh
echo "=================================="
echo "Welcome to Golang + Fiber Project Creator v0.1.0"
echo "=================================="
echo "For this script, The user have to input the project name (this will use to be the go module name and the project name."
echo ""
read -n 1 -s -r -p "Press any key to continue"
echo "\n"
@buildingwatsize
buildingwatsize / install_bat.sh
Created February 16, 2021 04:44
Install Bat in CentOS
#!/bin/bash
V=$(curl --silent "https://api.github.com/repos/sharkdp/bat/releases/latest" | grep -Eo '"tag_name": "v(.*)"' | sed -E 's/.*"([^"]+)".*/\1/') && curl -sOL "https://github.com/sharkdp/bat/releases/download/$V/bat-$V-x86_64-unknown-linux-musl.tar.gz" && tar xzvf "bat-$V-x86_64-unknown-linux-musl.tar.gz" -C . && sudo sh -c "cp ./bat-$V-x86_64-unknown-linux-musl/bat /usr/local/bin/bat" && rm bat-$V-x86_64-unknown-linux-musl.tar.gz && unset V
@buildingwatsize
buildingwatsize / Dockerfile
Created August 31, 2020 09:12
[Medium Benchmark ขำๆ] - Dockerfile ฝั่ง Nginx
FROM nginx:1.17.9
COPY nginx/default.conf /etc/nginx/conf.d/
RUN rm -rf /usr/share/nginx/html/*
RUN apt-get -y update
WORKDIR /usr/share/nginx/html
COPY ./build .
CMD ["nginx", "-g", "daemon off;"]
@buildingwatsize
buildingwatsize / repository.go
Created July 20, 2020 09:21
repository.go - Goldnoti [Phase 2]
var (
// Bot : For LINE Bot Client Configuration
Bot *linebot.Client
channelSecret string
channelToken string
)
// SetupLINEConfig : Setup Channel Secret and Channel Token for using in LINE Bot
func SetupLINEConfig() {
channelSecret = os.Getenv("CHANNEL_SECRET")
@buildingwatsize
buildingwatsize / service.go
Last active July 20, 2020 09:18
service.go - Goldnoti [Phase 2]
// HandleLINEEventMessage : Handle LINE Event Message for LINE Bot Client
func HandleLINEEventMessage(event *linebot.Event) {
switch message := event.Message.(type) {
case *linebot.TextMessage:
textIncoming := message.Text
log.Println("[INFO]: Text Incoming |", textIncoming)
uid := event.Source.UserID
log.Println("[INFO]: User ID |", uid)
profile := repository.Bot.GetProfile(uid)
@buildingwatsize
buildingwatsize / api.go
Created July 20, 2020 09:13
api.go - Goldnoti [Phase 2]
// GetTodayPriceForLINEBot : Get today gold price with webhook
func GetTodayPriceForLINEBot(w http.ResponseWriter, r *http.Request) {
log.Println("------- API: GetTodayPriceForLINEBot -------")
defer r.Body.Close()
w.Header().Set(contentTypeKey, contentTypeValue)
if !isPOST(r) {
ResponseMethodNotAllowed(w)
return
}
@buildingwatsize
buildingwatsize / heroku.yml
Created July 16, 2020 09:00
Goldnoti - heroku.yml
# Note: we don't have `run` section because Heroku uses the `CMD` specified in the `Dockerfile` instead
build:
docker:
web: Dockerfile
config:
ENV: dev
@buildingwatsize
buildingwatsize / docker-compose.yml
Created July 16, 2020 08:57
Goldnoti - docker-compose.yml
version: "3"
services:
goldnoti:
container_name: goldnoti
image: goldnoti:latest
ports:
- 10999:10999
@buildingwatsize
buildingwatsize / Dockerfile
Created July 16, 2020 07:31
Goldnoti - Dockerfile
FROM golang:1.14-alpine AS build
COPY ./ /app/
WORKDIR /app/
RUN CGO_ENABLED=0 GOOS=linux go build -o /bin/goldnoti
FROM alpine:3.12
RUN apk add --no-cache tzdata
COPY --from=build /bin/goldnoti /
COPY ./config /config
ENV ENV=dev