Posts in category “Linux”

Ubuntu 22.04 fcitx-rime/ibus-rime wubin_pinyin 配置简入繁出

为啥用 fcitx 不用ibus呢.... 一开始我确实是用的ibus,但它老人家在 google doc 的网页里不显示候选文字框,等修复不知道要等到啥时候,我就扭头换 fcitx 了。

ibus-rime, fcitx-rime 已经内置这个功能,但它的默认配置里没有使用这个功能。废话不说,贴上我的配置文件

~/.config/fcitx 或 ibus/rime/default.custom.yaml 内容如下

patch:
 style:
  display_tray_icon: true
  horizental: false
  font_point: 14
 schema_list:
    - schema: wubi_pinyin
    - schema: pinyin_simp
 ascii_composer/switch_key:
  Shift_R: commit_code
  Shift_L: commit_code

~/.config/fcitx 或 ibus/rime/wubi_pinyin.custom.yaml 内容如下:

patch:
  switches:
    - name: ascii_mode
      reset: 0
      states: [ "中文", "西文" ]
    - name: full_shape
      states: [ "半角", "全角" ]
    - name: simplification
      states: [ "汉字", "漢字" ]

  simplifier/opencc_config: s2t.json
  engine/filters:
    - simplifier
    - uniquifier

How to let Supervisord wait 1 second before restarting my program?

It spent more than half an hour. Finally, I found this solution.... very simple!

#!/bin/bash
/usr/local/bin/noip2 -c /usr/local/etc/no-ip2.conf
sleep 1

noip sucks!

source

Database structure backup & Data dictionary automatically generation

Two bash script achieved the goals in this subject.

1. Exporting data dictionary

cat utils/exportDbDictionary 
if [ $# != 2 ] ; then
    echo "USAGE: $0 dbname tablename"
    echo " e.g.: $0 IDServer AspNetUsers"
    exit 1;
fi

document_path=/YourProjectName/documents/database

[ -d $document_path/$1 ] || mkdir -p $document_path/$1
mysqlshow $1 $2 | sed 's/+/|/g' | sed '1,2d' | sed '$d' | awk -F"[|]" '{print $2"|"$3"|"$5"|"$6"|"$7"|"$10}' | sed 's/ *$//g' > $document_path/$1/$2.md

People should always add comments to their field definitions. As soon as the definition of a table has been done, run this script could automatically generate a markdown table with the name of tableName.md.

2. export database structure without auto_incrment= statements

cat utils/backupDbStructure 
backupFile=/YourProjectName/documents/database/databaseStructure.sql
mysqldump -d --databases YourDB1 YourDB2 YourDB3 | sed 's/ AUTO_INCREMENT=[0-9]*//g' > $backupFile

When you made some changes to your database, run backupDbStruture script will automatically generate the latest table structure into one file. You could commit it later with your code change together.

Setting timezone for Linux system

sudo timedatectl set-timezone Asia/Shanghai 

Setting timezone for MySQL

add the line below to [mysqld] section in /etc/my.cnf

default=time-zone = "+8:00"

Let your Linux system use memory as much as possible instead of swap space.

$ sudo vim /etc/sysctl.conf

add the line below to the end of this file:

vm.swappiness = 10

save and exit. Execute 

$ sudo sysctl -p

vm.swappiness = 10 means that the Linux system will only start using swap space when your available physical memory is less than 10%.