Skip to content

Instantly share code, notes, and snippets.

@ledongthuc
ledongthuc / main.go
Created November 7, 2020 20:18
Fyne table custom column width
package main
import (
"fmt"
"fyne.io/fyne"
"fyne.io/fyne/app"
"fyne.io/fyne/dialog"
"fyne.io/fyne/widget"
)
@ledongthuc
ledongthuc / _setup_k8s.md
Created October 13, 2019 18:49
Setup k8s

OS: Ubuntu 16.04 or CentOS 7

  1. Install docker
  2. Install cri_o or containerd
  3. Install kubelet, kubeadm, kubectl
@ledongthuc
ledongthuc / Readme.md
Last active March 23, 2020 08:19
[Github Actions][Go] Check pull requests before merging

Create template actions that's used to verify Go language pull requests before merging. It's easy to custom the flow, tools with your case.

Put pr_checker.yml or pr_checker_simple.yml to .github/workflows/ and see how it works with your pull requests. Make sure you are allows to use actions of Github.

  • pr_checker.yml is using by mine with full checking tools. It will make sure every Go langauge pull requests will be buildable, testable, passed security checking and error-able code checking.
  • pr_checker_simple.yml is more simpler with buildable, testable.

References:

@ledongthuc
ledongthuc / docker_postgres.sh
Last active June 29, 2020 17:02
Docker postgres actions
# Docker postgres backup data
docker exec -t -e PGPASSWORD={password} {container_name} pg_dump -U {username} --column-inserts --data-only --schema={schema} {database_name} > /path/to/exported/file.sql
# Docker postgres run script from outside
docker cp /host_path.sql captrondb:/container_inside.sql
docker exec -u {login_user} {container_name} psql {database_name} {db_username} -f /container_inside.sql # with continer username
docker exec {container_name} psql {database_name} {db_username} -f /container_inside.sql # without continer username
sudo bash -c "cat <<EOT > /etc/logrotate.d/api
/opt/app/*.log {
missingok
notifempty
compress
size 10k
daily
copytruncate
compress
sharedscripts
sudo yum -y install yum-utils
sudo yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
sudo yum install python2-certbot-nginx
sudo certbot --nginx
# NGINX
sudo yum install nginx;
sudo setsebool -P httpd_can_network_connect 1;
sudo bash -c "cat <<EOT > /etc/nginx/sites-enabled/default.conf
server {
server_name thuc.com.vn;
listen 80;
location / {
proxy_pass http://localhost:8080;
# PLEASE REPLACE <username>, <public_key>, <admin_user>
# Add new user with sudo admin
useradd -m -d /home/<username> -s /bin/bash <username>
mkdir -p '/home/<username>/.ssh/'
touch /home/<username>/.ssh/authorized_keys
echo -n "<public_key>" >> /home/<username>/.ssh/authorized_keys
chown -R <username>:<username> /home/<username>/.ssh
# warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
sudo bash -c "cat <<EOT > /etc/environment
LANG=en_US.utf-8
LC_ALL=en_US.utf-8
EOT"
@ledongthuc
ledongthuc / install_kafka.sh
Last active June 25, 2018 06:00
Kafka (Centos)
sudo yum install java-1.8.0-openjdk
mkdir /tmp/install_kafka
cd /tmp/install_kafka
curl http://www-eu.apache.org/dist/kafka/1.1.0/kafka_2.11-1.1.0.tgz --output kafka_2.11-1.1.0.tgz
mkdir -p /opt/
cp /tmp/install_kafka/kafka_2.11-1.1.0.tgz /opt/kafka_2.11-1.1.0.tgz
cd /opt/
tar -xzf kafka_2.11-1.1.0.tgz
ln -s /opt/kafka_2.11-1.1.0 /opt/kafka
cd /opt/kafka/