2020年6月28日 星期日
sync Frontdoor to dropbox
1. setup rclone with dropbox
2. setup incrontab with the command:
incrontab -e
and add this line:
/home/pi/webcam IN_CREATE /usr/bin/rclone sync /home/pi/webcam mydropbox:webcam/FrontDoor
2020年6月16日 星期二
core_version_requirement
This version is not compatible with Drupal 9.0.0 and should be replaced.
- Drupal Core (8.x) (incompatible with version 9.0.0)
Edit my_custom_module.info.yml:
change
core: 8.x
to
core: 8.x
core_version_requirement: ^8 || ^9
for drupal 9.x
2020年6月12日 星期五
drupal_set_message deprecated in drupal 9
//---------------------------------------------------------
function drupal_set_message($message = NULL)
{
$messenger = \Drupal::messenger();
if (isset($message)){
$messenger->addMessage($message,'status',FALSE); }
}
//---------------------------------------------------------
Replace
drupal_set_message(array(
'#type' => 'markup',
'#markup' => $tle));
with these lines:
$this->drupal_set_message(array(
'#type' => 'markup',
'#markup' => $tle));
drupal 9 db_query deprecated
Replace db_query with \Drupal::database()->query, e.g.
//$res=db_query($sql) or die("Error: $sql");
$res=Database::getConnection()->query($sql) or die("Error: $sql");
Use the script to change:
#!/bin/bash
find ./ -type f -exec sed -i 's+db_query(+Database::getConnection()->query(+g' {} \;
2020年6月5日 星期五
Create drupal 9 with composer
$ mkdir /home/chiao/public_html/drupal9
$ composer create-project drupal/recommended-project:~9.0.0\
/home/chiao/public_html/drupal9
Go to/home/chiao/public_html/drupal9/web/sites.
Copy files to drupal9: Custom themes go to/home/chiao/public_html/drupal9/web/themes/custom/ Custom modules go to/home/chiao/public_html/drupal9/web/modules/custom/ Libraries go to/home/chiao/public_html/drupal9/web/libraries/ Your uploaded files and images go to/home/chiao/public_html/drupal9/web/sites/default/files/
Copy (using sudo cp -av) the following files and directories to new site:
settings.phpsites/default/settings.local.phpsites/default/sites/default/files/config_5cKxplPBXz7CfVTT9KjhZ3fJkIg1ygQ2hTdYEM64PUZQUPSy94TTCTcHuJ16-cOW_918dZ1kpw/asdfsd- sites/development.services.yml
/home/chiao/public_html/drupal9$ composer install
All done for creating new drupal 9.
2020年5月28日 星期四
2020年5月23日 星期六
2020年5月22日 星期五
Create new drupal from old drupal using composer
(For updating 8.9.x in kpci7, cf. https://kpchiaoo.blogspot.com/2018/09/update-drupal.html
When using:
composer update --dry-run "drupal/*"
This should show any available minor or patch update, however, my site didn't show any minor version for drupal.
So I follow this: https://www.drupal.org/docs/8/install/add-composer-to-an-existing-site
to create a new site and to transfer my old files to the new site.
1. Create a new drupal site, drupal_new:
cd /home/chiao/public_html
composer create-project drupal/recommended-project:~8.8.0 drupal_new --stability dev --no-interaction
2. Copy files to drupal_new:
Custom themes go to /var/www/sites/new_html/web/themes/custom/
Custom modules go to /var/www/sites/new_html/web/modules/custom/
Libraries go to /var/www/sites/new_html/web/libraries/
Your uploaded files and images go to /var/www/sites/new_html/web/sites/default/files/
3. Copy sites files:
cd /home/chiao/public_html/drupal_new/web/sites/default
sudo cp -av ~/public_html/drupal/sites/default/settings.php .
sudo cp -av ~/public_html/drupal/sites/default/settings.local.php .
sudo cp -av ~/public_html/drupal/sites/default/files/config_5cKxplPBXz7CfVTT9KjhZ3fJkIg1ygQ2hTdYEM64PUZQUPSy94TTCTcHuJ16-cOW_918dZ1kpw/ files/
cd /home/chiao/public_html/drupal_new/web/sites/
sudo cp -av ~/public_html/drupal/sites/development.services.yml .
change owner, www-data:
sudo chown -R www-data.www-data files/ settings.*
4. Edit composer.json in your new project root (e.g., /var/www/sites/new_html) and copy the list of packages from your old composer.json's "require" and "require-dev" sections to the new composer.jsonfile.
5. rm ~/public_html/drupal_new/composer.lock
composer install
6. All done for creating new druapl.
7. cd ~/public_html/drupal_new/
drush state:set system.maintenance_mode 1
drush cache-clear drush
composer update drupal/core-recommended --with-dependencies
drush updatedb
drush cache-clear drush
drush state:set system.maintenance_mode 0
drush cache:rebuild
2020年5月11日 星期一
Increase mp4 volume using FFMPEG
ffmpeg -i my.mp4 -vcodec copy -af "volume=25dB" my_25dB.mp4
Or,
for i in *.mp4; do \
ffmpeg -i $i -vcodec \
copy -af "volume=25dB" \
${i%.*}_25dB.mp4 ; \
done
2020年4月29日 星期三
2020年4月15日 星期三
2020年3月17日 星期二
Pulse Secure installation
- Download the Pulse Secure client:
https://its.wpi.edu/software/259/pulse-secure
https://drive.narlabs.org.tw/navigate/s/6C30CA2A0C7A47E48C2D4034C4A55630GUY
Pulse Secure Installer (Linux 64-bit)Ubuntu - sudo dpkg --install pulse-9.1R3.x86_64.deb
- sudo apt-get install libwebkitgtk-1.0-0
- sudo apt-get install libproxy1-plugin-webkit
- /usr/local/pulse/pulseUi
- Add new connection for AU using URL:
https://au.twaren.net/au/staff
2020年3月1日 星期日
CPU REAL TIME frequency watching
watch -n1 "lscpu | grep MHz | awk '{print $1}'";
cf: https://askubuntu.com/questions/916382/ubuntu-get-actual-current-cpu-clock-speed
2020年2月28日 星期五
replace xz with 7z with password
#!/bin/bash
for i in /BACKUP/kpchiao9600k/20200225_Ubuntu_18.04.4_LTS/*; do
xzcat $i | 7z a -mx=9 -mmt=4 -p-si "$(basename "$i" .tar.xz)_pwd_bsun.tar.7z"
done
#
# Decompress with the following command followed by the password.
# 7z x -so boot_efi_2020_02_25_pwd_bsun.tar.7z | tar tvf -
# Just key in the password, no prompt will be shown.
2020年2月27日 星期四
setup permission for mysqldump
- Create ~/.my.cnf, add these lines:
[mysqldump]
user=student
password=student
chmod 0600 ~/.my.cnf - Inside phpmyadmin, set 'Select' and 'LOCK TABLES' permission to database 'drupal' for 'student' as the following image:

- Then, dump drupal with the command without username and password:
mysqldump drupal > kpchiao9600k_drupal.sql
or
mysqldump -B drupal > kpchiao9600k_drupal.sql
The -B option will add the create database and use datatebase lines into dump file as:
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `drupal` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `drupal`;
2020年2月14日 星期五
2020年2月12日 星期三
Install nvidia driver ubuntu
- ubuntu-drivers devices
e.g. nvidia-driver-435 - distro non-free recommended
-
sudo ubuntu-drivers autoinstall or
sudo ubuntu-drivers nvidia-driver-435
reboot
2020年2月9日 星期日
mysql installation on ubuntu 18.04
- sudo apt update
- sudo apt install mysql-server
- sudo mysql_secure_installation
- sudo mysql, then issue the command:
SELECT user,authentication_string,plugin,host FROM mysql.user;
Originally, the root user is authenticated with the "auth_socket" plugin.
To configure the root account to authenticate with a password,
run the followingALTER USERcommand.ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';Replacing the 'password' with a new strong password.Note that this command will change the root password you set in Step 2.
2020年1月19日 星期日
Catalina on Virtualbox installation
These codes are critical. Issue these lines in user account (chiao) not sudo.
Note: replace "Your VM Name" in this commands line with your Virtual Machine Name in step 3, then type in the following code:
- cd "C:\Program Files\Oracle\VirtualBox\"
- VBoxManage modifyvm "Your VM Name" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
- VBoxManage setextradata "Your VM Name" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
- VBoxManage setextradata "Your VM Name" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
- VBoxManage setextradata "Your VM Name" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
- VBoxManage setextradata "Your VM Name" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
- VBoxManage setextradata "Your VM Name" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
Change the screen size (e.g. 1440x900):
VBoxManage setextradata "Your VM Name" VBoxInternal2/EfiGraphicsResolution 1440x900
2020年1月11日 星期六
screen useful commands
create new window
C-a crename current window C-a Asee window list C-a " (allows you to select a window to change to) | split display horizontally | C-a S |
| split display vertically | C-a | or C-a V (for the vanilla vertical screen patch) |
| jump to next display region | C-a tab |
| remove current region | C-a X |
| remove all regions but the current one | C-a Q |
Scrollback-buffer
In copy mode, one can navigate the scrollback buffer in various ways:| half page up | C-u | half page down | C-d | |
| back | C-b | forward | C-f | |
| cursor left/down/up/right | h/j/k/l |
2020年1月3日 星期五
vmware mac OS Catalina installation
- update vmware wordkstation to 15.5.1
- download unlocker 3.0.3, VERY IMPORTANT!, Edit lnx-install.sh,
Change the lines inside of lnx-install.sh from 'python gettools.py' to 'python3.7 gettools.py' - Create new guest : Select Guest Operation System: Apple OS X -> macOS 10.15
- After get into guest, then power off, close vmware workstation
- Edit vmx file: insert smc.version = "0"
- Open guest and click Options tab, Guest Operating System change to Microsoft Windows and Version to Windows 10 x64
- Power on guest, get into the page: macOS 工具程式,select:

- click it, then
- Then erase it and format as Mac OS 擴充格式 (日誌式)click 清除.
- Back into macOS 工具程式,then 安裝 macOS
- Wait ... couple of hours !
- After installation is ok, change Guest OS back to "macOS 10.15"
2020年1月2日 星期四
clone grade database
mysqldump -u chiao -h localhost -p grade_108_1 > grade_108_1_20200103.sql
2019年12月29日 星期日
2019年12月28日 星期六
If drupal cannot work after cloning, then ... try this
Some error messages:Error: Class 'DOMDocument' not found in Drupal\Component\Utility\Html::load() (line 286 of core/lib/Drupal/Component/Utility/Html.php) sudo apt-get install php-xmlsudo systemctl restart apache2
Using root login mysql with password
2019年12月6日 星期五
cwtex with bkai and bsmi fonts
LaTeX source file
\documentclass{extarticle}
\renewcommand{\familydefault}{\rmdefault}
\usepackage[T1]{fontenc}
\usepackage{CJKutf8}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=0.75in,bmargin=0.75in,lmargin=0.75in,rmargin=0.75in}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage[authoryear]{natbib}
\begin{document}
\begin{CJK}{UTF8}{}%
\section{\CJKencfamily{UTF8}{bkai}
\CJKencfamily{UTF8}{bsmi}這是本文
{\Huge{}這是本文(最大字)}{\Huge\par}
\end{CJK}
\end{document}
2019年12月5日 星期四
cwfsu61 trouble solved!
\CJKencfamily{UTF8}{cwfsu}
use
\CJKencfamily{UTF8}{cwfsc}
Also, inside text contents use
\CJKencfamily{UTF8}{cwkc}
2019年11月5日 星期二
Wireless wakeup on lan
iw phy0 wowlan show
sudo iw phy0 wowlan enable magic-packet disconnect
iw phy0 wowlan show
-
cf: https://ubuntuhandbook.org/index.php/2022/01/default-torrent-app-magnet-links-ubuntu/ Set “QBittorrent” as default app for magnet link,...
-
cf: https://stackoverflow.com/questions/54184707/warning-continue-targeting-switch-is-equivalent-to-break-did-you-mean-to-u Error while...
-
Put the lines at the first: #!/usr/bin/env python # coding: utf-8



