Skip to content

Instantly share code, notes, and snippets.

View wittawasw's full-sized avatar

Wittawas W wittawasw

View GitHub Profile
@wittawasw
wittawasw / folder_structure.md
Created January 20, 2024 08:02 — forked from ayoubzulfiqar/folder_structure.md
The Folder Structure for Every Golang Project

Go - The Ultimate Folder Structure

Organizing your Go (Golang) project's folder structure can help improve code readability, maintainability, and scalability. While there is no one-size-fits-all structure, here's a common folder structure for a Go project:

project-root/
    ├── cmd/
    │   ├── your-app-name/
    │   │   ├── main.go         # Application entry point
    │   │   └── ...             # Other application-specific files
@wittawasw
wittawasw / updatefw.sh
Created September 15, 2023 12:21 — forked from selfagency/updatefw.sh
[update digital ocean firewall] update digital ocean firewall rules to add current ip and remove old external ips
# Requires doctl and the "public-ip-cli" npm module to be globally installed.
#!/bin/sh
FWID="YOUR_FIREWALL_ID"
IPV4=$("${HOME}/.nodebrew/current/bin/public-ip" --4)
#IPV6=$("${HOME}/.nodebrew/current/bin/public-ip" --6)
printf "🔥 Updating DO firewall rules\n\n"
OLD_RULES="$(doctl compute firewall get "${FWID}" --format InboundRules | tr ' ' '\n' | grep -E 'ports:22|ports:2022' | tr '\n' ' ' | sed '$ s/.$//')"
@wittawasw
wittawasw / gist:b355310de8b98101d55a614cfebba910
Created May 22, 2023 00:00 — forked from ggilder/gist:1055684
Use Sinatra to serve static files from the current directory
ruby -e "require 'rubygems';require 'sinatra';set :port, 9999;set :public, Dir.pwd"
require "onnxruntime"
require "mini_magick"
img = MiniMagick::Image.open("bears.jpg")
pixels = img.get_pixels
model = OnnxRuntime::Model.new("model.onnx")
result = model.predict({"inputs" => [pixels]})
p result["num_detections"]
@wittawasw
wittawasw / app.rb
Last active March 17, 2022 17:31 — forked from runemadsen/app.rb
Sinatra File Upload
require 'sinatra'
get "/" do
erb :form
end
post '/save_image' do
@filename = params[:file][:filename]
file = params[:file][:tempfile]
@wittawasw
wittawasw / readme.adoc
Created November 16, 2021 14:43 — forked from arun-gupta/readme.adoc
Federated Kubernetes Cluster using Kops on AWS

Let’s set up a federation between earth and mars Kubernetes cluster on AWS.

Earth cluster

  1. Create hosted zone:

    ID=$(uuidgen) && \
       aws route53 create-hosted-zone \
       --name earth.kubernetes-aws.io \
@wittawasw
wittawasw / character_set_and_collation.rb
Created April 18, 2017 03:50 — forked from tjh/character_set_and_collation.rb
Convert all Rails table column collation and character set
#!/usr/bin/env ruby
# Put this file in the root of your Rails project,
# then run it to output the SQL needed to change all
# your tables and columns to the same character set
# and collation.
#
# > ruby character_set_and_collation.rb
DATABASE = ''
@wittawasw
wittawasw / redis.md
Created August 22, 2016 22:08 — forked from diegopacheco/redis.md
How to Install Redis 3 Amazon Linux OS / CentOS

Install Redis cluster on Amazon Linux OS

sudo yum -y upgrade
sudo yum install -y gcc*
sudo yum install -y tcl
sudo wget http://download.redis.io/releases/redis-stable.tar.gz
sudo tar xzf redis-stable.tar.gz
cd redis-stable
cd deps ; sudo make hiredis jemalloc linenoise lua ; cd ..
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# pidfile: /var/run/nginx.pid