Eric Guo's blog.cloud-mes.com

Hoping writing JS, Ruby & Rails and Go article, but fallback to DevOps note

Expose Local Server to the Internet Without Ngrok

Permalink

Option 1

config/environments/development.rb
Rails.application.configure do
config.hosts << ".example.com"
end
config/puma.rb
ssl_bind "0.0.0.0""8443"{
# Run "certbot certificates" to get these
key "server.key".
cert"server.crt"
}
expose SSH port:
ssh -R 8443:localhost:8443 -N user@example.com

Option 2

ssh -C2qTnN -R 3003:localhost:3003 user@ssss.com
# Then, configure an Nginx proxy with a 3003 domain name for external access

Option 3

Open cursor, goto port tab to create one.

If meet error goto ‘/Applications/Cursor.app/Contents/Resources/app/bin’ and rename cursor-tunnel to code-tunnel.

Sponge Command Cheetsheet

Permalink

go build -o $(which sponge) cmd/sponge/main.go
go build -o $(which protoc-gen-go-gin) cmd/protoc-gen-go-gin/main.go
go build -o $(which protoc-gen-go-rpc-tmpl) cmd/protoc-gen-go-rpc-tmpl/main.go
go build -o $(which protoc-gen-json-field) cmd/protoc-gen-json-field/main.go

Install a New Rails App in Rocky Linux 9.6 at Aliyun

Permalink

Disable SELinux

sudo vi /etc/selinux/config
grubby --update-kernel ALL --args selinux=0

Install htop and atop

sudo dnf update
sudo dnf install epel-release
sudo dnf install htop
sudo dnf install atop

Install nginx

sudo dnf install nginx

Install node.js v22

Using nodesource distribution

curl -fsSL https://rpm.nodesource.com/setup_22.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo yum install -y nodejs
sudo yum groupinstall 'Development Tools'

Install yarn

curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum install yarn

Install rbenv and ruby-build

whoami # should run as a ecs-user
git clone https://git.thape.com.cn/rails/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
~/.rbenv/bin/rbenv init # also edit ~/.bash_profile
# As an rbenv plugin
mkdir -p "$(rbenv root)"/plugins
git clone https://git.thape.com.cn/rails/ruby-build.git "$(rbenv root)"/plugins/ruby-build
git clone https://git.thape.com.cn/rails/rbenv-china-mirror.git "$(rbenv root)"/plugins/rbenv-china-mirror

Install Ruby 3.2.8

Ruby 3.2.8 need Rust to build JIT.

sudo dnf config-manager --enable crb
sudo dnf install libffi-devel libyaml-devel readline-devel
sudo dnf install zlib-devel openssl-devel gdbm-devel ncurses-devel bzip2-devel
sudo yum install -y rust # version 1.84.1
rbenv install -l
rbenv install 3.2.8
rbenv global 3.2.8
rbenv shell 3.2.8
echo "gem: --no-document" > ~/.gemrc
gem update --system

Prepare the capistrano deploy folder

whoami # should run as a ecs-user
cd /var/www
sudo mkdir harman
sudo chown ecs-user:ecs-user harman/

Add Credentials from the source site

vi .netrc
machine cnb.cool login cnb password asdasdas

Running IRuby Notebook in Cursor

Permalink

brew install ruby
brew install python3
brew install zeromq # require by ipykernel
/opt/homebrew/bin/python3 -m pip install ipykernel -U --user --force-reinstall --break-system-packages
gem install iruby
gem install rubygems-requirements-system
iruby register --force

Also install Jupyter in cursor.

To make mlx-engine running:

python3 -m pip install sentencepiece -U --user --force-reinstall --break-system-packages
python3 -m pip install outlines -U --user --force-reinstall --break-system-packages
python3 -m pip install outlines==1.1.1 --user --force-reinstall --ignore-requires-python --break-system-packages
python3 -m pip install datasets==3.6.0 --user --force-reinstall --ignore-requires-python --break-system-packages
python3 -m pip install mlx_vlm -U --user --force-reinstall --break-system-packages
python3 -m pip install mlx-lm -U --user --force-reinstall --break-system-packages

Install Open Project V16 in a Rocky Linux 9

Permalink

I already install an open project instance one and half year ago, but it’s retired to sync with the production server OS version, which is Rocky Linux 8.10. After Ruby 3.4 released, I found the nokogiri v1.18 version and grpc v1.71 version both need a new GLIBC_2.29 version which is unavailable in Rocky Linux 8 series.

So I decide install a new Open Project instance server for the new production.

Disable SELinux

vi /etc/selinux/config
grubby --update-kernel ALL --args selinux=0

Install htop and atop

sudo dnf update
sudo dnf install epel-release
sudo dnf install htop
sudo dnf install atop

Install nginx

sudo dnf install nginx

Install node.js v22

Using nodesource distribution

curl -fsSL https://rpm.nodesource.com/setup_22.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo yum install -y nodejs
sudo yum groupinstall 'Development Tools'

Install yarn

curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum install yarn

Install postgresql 16 client

Following DO manual

dnf module list postgresql
sudo dnf module enable postgresql:16
sudo dnf install postgresql-devel glibc-all-langpacks
sudo dnf install postgresql-contrib # pg_trgm btree_gist require by open project
sudo dnf install mysql-devel # if need to link to mysql server

Setup open_project user account

adduser open_project
cd /etc/sudoers.d/
echo "open_project ALL=(ALL) NOPASSWD:ALL" > 30-open_project-user
sudo su - open_project
mkdir .ssh
chmod 700 .ssh
vi .ssh/authorized_keys # and paste your public key
chmod 600 .ssh/authorized_keys

Install rbenv and ruby-build

whoami # should run as a open_project
git clone https://git.thape.com.cn/rails/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
~/.rbenv/bin/rbenv init # also edit ~/.bash_profile
# As an rbenv plugin
mkdir -p "$(rbenv root)"/plugins
git clone https://git.thape.com.cn/rails/ruby-build.git "$(rbenv root)"/plugins/ruby-build
git clone https://git.thape.com.cn/rails/rbenv-china-mirror.git "$(rbenv root)"/plugins/rbenv-china-mirror

Install Ruby 3.3.8

Ruby 3.3.8 need Rust to build JIT.

dnf config-manager --enable crb
dnf install libyaml-devel
yum install -y rust # version 1.79.0
dnf install clang-devel # for some gem like autocorrect-rb
rbenv install -l
rbenv install 3.3.8
rbenv global 3.3.8
rbenv shell 3.3.8
echo "gem: --no-document" > ~/.gemrc
gem update --system

Prepare the capistrano deploy folder

whoami # should run as a open_project
cd /var/www
sudo mkdir open_project
sudo chown open_project:open_project open_project/

Using mirror when deploy

Run in the release rails root folder

bundle config mirror.https://rubygems.org https://gems.ruby-china.com

Setting the open project settings

/etc/environment
OPENPROJECT_EDITION=bim
OPENPROJECT_APP__TITLE=天华项目全生命周期管理
OPENPROJECT_APP__SHORT__TITLE=PLM
OPENPROJECT_HOST__NAME=plm-staging.thape.com.cn
OPENPROJECT_EMAIL__DELIVERY__METHOD="smtp"
OPENPROJECT_SMTP__ADDRESS="smtp.thape.com.cn"
OPENPROJECT_SMTP__PORT="25"
OPENPROJECT_SMTP__DOMAIN="thape.com.cn"
OPENPROJECT_SMTP__AUTHENTICATION="login"
OPENPROJECT_SMTP__USER__NAME="plm"
OPENPROJECT_SMTP__PASSWORD=""
OPENPROJECT_SMTP__ENABLE__STARTTLS__AUTO="true"
OPENPROJECT_SMTP__OPENSSL__VERIFY__MODE="none"
OPENPROJECT_ENTERPRISE__TRIAL__CREATION__HOST="https://www.google-analytics.com"
GRUF_OP_SERVER="172.17.1.1:10009"
WX_TEMPLATE_ID=""
WX_WORK_PACKAGE_DETAIL="https://plm.thape.com.cn/work_packages/:id"
MP_QRCODE_ABS_PATH="/var/www/open_project/shared/public/static/mp_qrcode.jpg"
LOGO_ABS_PATH="/var/www/open_project/shared/public/static/logo_plm.png"
CSP_FRAME_SRC="https://ith-workspace.thape.com.cn"
CSP_CONNECT_SRC="https://analytics.thape.com.cn"
WECHAT_AUTH_JWT_SECERT=""
WECHAT_AUTH_ITH_URL="/ith/wechat/ppm/login"
/etc/systemd/system/puma_plm.service
[Unit]
Description=Puma HTTP Server for open_project (staging)
After=syslog.target network.target
[Service]
Type=simple
WatchdogSec=10
User=open_project
EnvironmentFile=/etc/environment
WorkingDirectory=/var/www/open_project/current
ExecStart=/home/open_project/.rbenv/bin/rbenv exec bundle exec puma -e production
ExecReload=/bin/kill -SIGUSR1 $MAINPID
# if we crash, restart
RestartSec=10
Restart=on-failure
StandardOutput=append:/var/www/open_project/shared/log/puma.log
StandardError=append:/var/www/open_project/shared/log/puma.log
SyslogIdentifier=puma_plm
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
bundle exec rake openproject:plugins:register_frontend
bundle exec rake i18n:js:export
bundle exec rake db:seed
sudo journalctl -u puma_plm # check system log and fix errors
sudo systemctl start puma_plm

Upload custom fonts

/var/www/open_project/shared/public
gzip -9r op_public_files.zip fonts/ static/ WW_verify_*.txt

Change IP

Rocky 8 network change:

vi /etc/sysconfig/network-scripts/ifcfg-ens192

Rocky 9 network change:

vi /etc/NetworkManager/system-connections/ens192.nmconnection
nmcli connection reload /etc/NetworkManager/system-connections/ens192.nmconnection
nmcli connection up /etc/NetworkManager/system-connections/ens192.nmconnection

Install the dependency

sudo yum install ImageMagick

Open the firewall

sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --add-service=https --permanent
sudo firewall-cmd --reload

Migrate DB From Redis 7.4 to 7.2 and Skip the RDB Version 12 Error

Permalink

After I copy redis dump.rdb from redis 7.4 to my Macbook homebrew redis 7.2 I got Can’t handle RDB format version 12 error:

# /opt/homebrew/opt/redis/bin/redis-server /opt/homebrew/etc/redis.conf
20066:C 17 Apr 2025 10:39:34.935 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
20066:C 17 Apr 2025 10:39:34.935 * Redis version=7.2.7, bits=64, commit=00000000, modified=0, pid=20066, just started
20066:C 17 Apr 2025 10:39:34.935 * Configuration loaded
20066:M 17 Apr 2025 10:39:34.935 * Increased maximum number of open files to 10032 (it was originally set to 256).
20066:M 17 Apr 2025 10:39:34.935 * monotonic clock: POSIX clock_gettime
Redis 7.2.7 (00000000/0) 64 bit
Running in standalone mode
Port: 6379
PID: 20066
https://redis.io
20066:M 17 Apr 2025 10:39:34.936 # WARNING: The TCP backlog setting of 511 cannot be enforced because kern.ipc.somaxconn is set to the lower value of 128.
20066:M 17 Apr 2025 10:39:34.936 * Server initialized
20066:M 17 Apr 2025 10:39:34.936 # Can't handle RDB format version 12
20066:M 17 Apr 2025 10:39:34.936 # Fatal error loading the DB, check server logs. Exiting.

Two option available, upgrade redis version via redis.io

Using high version

brew tap redis/redis
brew install --cask redis

The solution is ugly as redis will give you rc version of redis and it depend on the LLVM@18, which takes 1.7GB…

Stay redis 7.2

redis-cli shutdown
brew uninstall redis
brew untap redis/redis
# make sure your DB no need!
rm /opt/homebrew/var/db/redis/dump.rdb
rm /opt/homebrew/etc/redis-sentinel.conf
rm /opt/homebrew/etc/redis.conf
rm /opt/homebrew/etc/redis.conf.default
brew install redis
brew services start redis

Using redis-dump to dump and restore DB.

redis-dump -u 127.0.0.1:6379 -d 0 > db_db0.json
cat db_db0.json | redis-load -d 0

Make Tabnine Continue Work After Official Stop Support the Sublime Text

Permalink

Today I found my TabNine stop working and after 2 hours, I found it officially stop support Sublime Text

But if you having the API key here is how to make it continue work in local mode. Goto ‘/Users/[username]/Library/Application Support/Sublime Text/Packages’ and change ‘dl_binaries.sh’ as below.

Change targets to your platform if required.

#!/bin/sh
set -e
# This script downloads the binaries for the most recent version of TabNine.
version="4.4.25"
targets='aarch64-apple-darwin'
rm -rf ./binaries
echo "$targets" | while read target
do
mkdir -p binaries/$version/$target
path=$version/$target
echo "downloading $path"
curl -sS https://update.tabnine.com/bundles/$path/TabNine.zip > binaries/$path/TabNine.zip
unzip -o binaries/$path/TabNine.zip -d binaries/$path
rm binaries/$path/TabNine.zip
chmod +x binaries/$path/*
done
binariesver=$(grep -Eo '!binaries/.*' .gitignore | cut -c10-)
sed "s+$binariesver+/$version+g" .gitignore >.gitignore.tmp && mv .gitignore.tmp .gitignore

Run it to download, The 4.4.25 is the most stable version and 4.256.0 is the last known version works with sublime text 4 build 4196.

You need also block update.tabnine.com in hosts file to block TabNine auto upgrade, although codota says you can type TabNine::disable_auto_update.

Known model list and support language

  • Universal Small - ce94127b
  • Universal Medium - b8373e4b
  • cpp_specialized_model - b6e9f0da
  • python - 4caf976f
  • ruby_specialized_model - 29b87067
  • go - 598b1f5b
  • java - af421852
  • rust_specialized_model - 46f17fa1

C#, JS, CSS, HTML and PHP belongs to Universal model

A Rails Developer Installation Log on MacBook M4 Pro

Permalink

I got my fouth MacBook Pro today. It’s the second Apple Silicon CPU Mac. I bought in PDD and 48G 1T slightly high-end model.

Mac App Store install list

  • AdBlock Pro (11.2.3)
  • Affinity Designer (2.6.2)
  • Affinity Photo (2.6.2)
  • Affinity Publisher (2.6.2)
  • Aware (1.2.0)
  • Diagrams (2.2.0)
  • Elmedia Video Player (8.1)
  • iA Writer (5.6.16)
  • iMovie (10.3.1)
  • Jump Desktop (9.0.99)
  • Keynote (14.4)
  • LiquidText (2.10.36)
  • Logoist 5 (5.1.2)
  • MockFlow (2.7.9)
  • Numbers (14.4)
  • OwlOCR (4.9.2)
  • Pages (14.4)
  • Paper (95)
  • PasteNow (2.22)
  • Pixelmator Pro (3.6.17)
  • SimpleMind Pro (2.6.1)
  • SQLPro Studio (2025.9)
  • Tampermonkey (5.3.6218)
  • Texifier (1.9.31)
  • Things (3.21.6)
  • WeChat (3.8.10)
  • WeCom (4.1.33)
  • Xcode (16.3)

brew install cask list

  • aldente
  • hype
  • chromedriver
  • imageoptim
  • rapidapi
  • keybase
  • rar
  • zoom
  • cursor
  • rubymine
  • dash
  • google-chrome
  • sublime-merge
  • discord
  • google-cloud-sdk
  • obs
  • sublime-text

brew install console list

  • bash
  • fzf
  • gdu
  • gh
  • git
  • git-filter-repo
  • git-trim
  • go
  • highlight
  • imagemagick
  • jq
  • libpq
  • memcached
  • mysql-client
  • node
  • percona-server
  • poetry
  • postgresql
  • pytorch
  • redis
  • ruby
  • ruff
  • rust
  • smartmontools
  • tmux
  • vips
  • wget
  • yamllint
  • yarn
  • zoxide

bash-it setup

bash-it enable plugin zoxide proxy base
bash-it enable alias general
bash-it enable completion bash-it brew bundler capistrano cargo aliases export gcloud gem go npm rake ssh system yarn
zoxide init

Some not sign exe file

xattr -dr com.apple.quarantine /opt/homebrew/bin/rar
# put .rarreg.key to ~
xattr -dr com.apple.quarantine /opt/homebrew/bin/chromedriver

.profile

export PATH="/opt/homebrew/opt/ruby/bin:/opt/homebrew/lib/ruby/gems/3.4.0/bin:$PATH:/opt/homebrew/opt/postgresql@17/bin:$HOME/.local/bin:$HOME/.cargo/bin"
export HISTSIZE=80000
export ADBLOCK=true
export HOMEBREW_GITHUB_API_TOKEN=
export HOMEBREW_EDITOR="subl"
export HOMEBREW_NO_INSTALL_CLEANUP=1
export HOMEBREW_AUTO_UPDATE_SECS=1800
export LANG=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
export EDITOR="vim"
export BUNDLER_EDITOR="subl"
export GEM_EDITOR="subl"
export BASH_IT_HTTP_PROXY=http://127.0.0.1:6152/
export BASH_IT_HTTPS_PROXY=http://127.0.0.1:6152/
export GITHUB_APP_ID=
export GITHUB_APP_SECRET=
export NO_ORACLE_ENHANCED=1
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
export MANPATH=/usr/share/man:/opt/homebrew/share/ubuntu_man
export NODE_COMPILE_CACHE=/Users/guochunzhong/.cache/nodejs-compile-cache
export DEVISE_JWT_SECRET_KEY=
export WEFOCUSIN_WECHAT_APPID=
export WEFOCUSIN_WECHAT_SECRET=
export WEFOCUSIN_WECHAT_TOKEN=
export WEFOCUSIN_WECHAT_AES_KEY=
export OPENPROJECT_CORE=/Users/guochunzhong/git/sso/openproject
export DEEPSEEK_ACCESS_TOKEN=sk-
export SWARM_AGENT_DEFAULT_MODEL=deepseek-chat

Please notice ubuntu_man is used by Dash

.bash_profile

#!/usr/bin/env bash
source /Users/guochunzhong/.profile
alias bde='bundle exec'
alias bdc='bundle check'
alias bdpd='bundle exec cap production deploy'
alias glg="git log --graph --pretty=format:'%Cred%h%Crest -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
alias minio-server='minio server /usr/local/var/minio'
alias convert_screen_cast='ffmpeg -i Screencast.mov -vcodec h264 -acodec mp3 Screencast.mp4'
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return ;;
esac
# Path to the bash it configuration
export BASH_IT="/Users/guochunzhong/.bash_it"
# Lock and Load a custom theme file.
# Leave empty to disable theming.
# location "$BASH_IT"/themes/
export BASH_IT_THEME='inretio'
# Some themes can show whether `sudo` has a current token or not.
# Set `$THEME_CHECK_SUDO` to `true` to check every prompt:
#THEME_CHECK_SUDO='true'
# (Advanced): Change this to the name of your remote repo if you
# cloned bash-it with a remote other than origin such as `bash-it`.
# export BASH_IT_REMOTE='bash-it'
# (Advanced): Change this to the name of the main development branch if
# you renamed it or if it was changed for some reason
# export BASH_IT_DEVELOPMENT_BRANCH='master'
# Your place for hosting Git repos. I use this for private repos.
export GIT_HOSTING='git@git.domain.com'
# Don't check mail when opening terminal.
unset MAILCHECK
# Change this to your console based IRC client of choice.
export IRC_CLIENT='irssi'
# Set this to the command you use for todo.txt-cli
export TODO="t"
# Set this to the location of your work or project folders
#BASH_IT_PROJECT_PATHS="${HOME}/Projects:/Volumes/work/src"
# Set this to false to turn off version control status checking within the prompt for all themes
export SCM_CHECK=true
# Set to actual location of gitstatus directory if installed
#export SCM_GIT_GITSTATUS_DIR="$HOME/gitstatus"
# per default gitstatus uses 2 times as many threads as CPU cores, you can change this here if you must
#export GITSTATUS_NUM_THREADS=8
# Set Xterm/screen/Tmux title with only a short hostname.
# Uncomment this (or set SHORT_HOSTNAME to something else),
# Will otherwise fall back on $HOSTNAME.
#export SHORT_HOSTNAME=$(hostname -s)
# Set Xterm/screen/Tmux title with only a short username.
# Uncomment this (or set SHORT_USER to something else),
# Will otherwise fall back on $USER.
#export SHORT_USER=${USER:0:8}
# If your theme use command duration, uncomment this to
# enable display of last command duration.
#export BASH_IT_COMMAND_DURATION=true
# You can choose the minimum time in seconds before
# command duration is displayed.
#export COMMAND_DURATION_MIN_SECONDS=3
# Set Xterm/screen/Tmux title with shortened command and directory.
# Uncomment this to set.
#export SHORT_TERM_LINE=true
# Set vcprompt executable path for scm advance info in prompt (demula theme)
# https://github.com/djl/vcprompt
#export VCPROMPT_EXECUTABLE=~/.vcprompt/bin/vcprompt
# (Advanced): Uncomment this to make Bash-it reload itself automatically
# after enabling or disabling aliases, plugins, and completions.
# export BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE=1
# Uncomment this to make Bash-it create alias reload.
# export BASH_IT_RELOAD_LEGACY=1
# Load Bash It
source "$BASH_IT"/bash_it.sh
eval "$(/opt/homebrew/bin/brew shellenv)"
eval "$(zoxide init bash)"
export START_DIR="/Users/guochunzhong/git"
if [[ $PWD == $HOME ]]; then
cd $START_DIR
fi

Install macpm

brew install pipx
pipx install macpm

Install relative go tools used in cursor

brew install gopls
brew install staticcheck
brew install dlv