Skip to content

Instantly share code, notes, and snippets.

View wittawasw's full-sized avatar

Wittawas W wittawasw

View GitHub Profile
#!/bin/bash
# Go into every directory 1 level inside current directory
for dir in */; do
# Move files with extension .parquet from sub-directory to current directory
find "$dir" -maxdepth 1 -type f -name "*.parquet" -exec mv -t . {} +
done
# Rename those files by removing sub-string -parquet- from their names
for file in *.parquet; do mv "$file" "${file/-parquet-/}"; done
@wittawasw
wittawasw / gitignore.sh
Last active February 14, 2024 07:31
Setup global .gitignore
# todo will be ignored in all git repos
echo "todo" >> ~/.gitignore
git config --global core.excludesfile ~/.gitignore
plugins {
kotlin("jvm") version "1.9.21"
id("application")
}
repositories {
mavenCentral()
}
val kotlinSdkVersion = "1.0.41"
@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 / golang_web_dev_course_outline.md
Last active January 10, 2024 15:59
Web Development with Golang - Course Outline

Web Development with Golang

1: Running Go

  • Introduction to Go Environment
  • Compilation and Execution
    • go build
    • go run

2: Go Project Structure

  • Understanding Go Packages

Ruby on Rails Course Outline

Day 1: Introduction to Ruby and Rails

Session 1: Ruby Basics

  • Introduction to the Ruby language
  • Basic Tools, IDE, Runtime
  • Basic syntax, data types, and control structures
  • Modules and classes
  • Practical examples of module and class usage
@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"
@wittawasw
wittawasw / set_max_split_size_mb.py
Last active December 12, 2022 06:43
pytorch setting: max_split_size_mb
import torch
# Use when setting up CUDA in the beginning.
# Set max split size = 256 MB
torch.cuda.memory._set_allocator_settings("max_split_size_mb:256")