從 excel 到 sql ,遇到 line feed (LF) 的處理步驟。
場景 MySQL/MariaDB。
在 excel 中,要把 LF(line feed) 換成 "\n",然後變成 SQL 的資料。
1.先把原有資料中的 "\",換成 "\\"
2.再把 LF(line feed) 換成 "\n"
公式是 =SUBSTITUTE(SUBSTITUTE(A1, "\", "\\"), CHAR(10), "\n")
在 Raspberry Pi 4 上安裝 box64
# 安裝必要套件
sudo apt update
sudo apt install git cmake build-essential
# 下載 Box64 原始碼
cd ~
git clone https://github.com/ptitSeb/box64
cd box64
# 建立 Build 目錄並設定編譯
mkdir build
cd build
cmake .. -DRPI4=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo
# 編譯並安裝
make -j$(nproc)
sudo make install
# 測試
這時候輸入 box64 [Enter] 就可以看出是否安裝完成
# 讓 Box64 自動執行 x86_64 應用程式(可選)
sudo systemctl restart systemd-binfmt
# 還需要安裝 wine64 (非ARM版的wine64,要用不同方法,非常複雜)
# (字形還要另外再安裝)
# 在樹莓派4上面,運作緩慢,而且許多程式會用到 32 bit(wow模式),造成失敗!
# 不論是網路 ATM 亦或是 notepad++ 都非常不理想
# 請放棄
Raspberry Pi 4 Model B 8GB - 安裝
Raspberry Pi 4 Model B - 8GB RAM - 256GB micro sd 卡
01.使用 Raspberry Pi Imager
機器:Raspberry Pi 4
系統:Raspberry Pi OS(64bit)
初始設定
hostname, Username/Password, SSID/Password
Wireless LAN country:TW
Time zone:Asia/Taipei
Keyboard layout:tw
Enable SSH, Use password authentication
02.將記憶卡放入 Raspberry Pi 4 裡面,開啟電源
03.切換GUI模式
terminal
sudo raspi-config
→6 Advanced Options→A6 Wayland→W1 X11→Ok→Ok→Finish→Yes
04.調整設定
樹莓圖示→Preferences→Raspberry Pi Configuration
◎Localisation
Locale(Language:zh(Chinese), Country:TW(Taiwan), Character Set:UTF-8)→Ok
Keyboard(Model:Generic 104-key PC, Layout: Taiwanese, Variant:Taiwanese)→Ok
→OK→Yes
05.調整設定
樹莓圖示→偏好設定→Raspberry Pi 設定
◎介面 (VNC→On)
◎Display (過掃描→On, Headless Resolution:1920x1080)
◎系統 (Browser:Firefox)
→OK→Yes
06.調整設定
樹莓圖示→偏好設定→外觀設定
◎桌面 勾選 Documents
◎選單列 選取 底部
→OK
07.新增酷音輸入法(類似注音輸入法)
樹莓圖示→偏好設定→Add/Remove Software
輸入 fcitx 並按下 enter
勾選 fcitx5-5.0.21-3(64位元)
勾選 fcitx5-chewing-5.0.13-1(64位元)
→OK→輸入密碼→確定
樹莓圖示→登出→Reboot (這樣開機後,輸入法就可以套用)
開啟 geany (或其他記事本之類的軟體)
在 keybaord 圖示上面按滑鼠右鍵→設定→附加元件→經典使用者介面
→(字體、功能表字體、托盤字體 都改為 36)→確定→關閉
這樣候選字就可以很大,看得清楚了。
08.調整遠端遙控軟體
在 Real VNC 圖示上面按滑鼠右鍵→Options→
(Encryption:Prefer off)(Authentication:VNC Password)
→Apply→(輸入 Password, Confirm Password 並勾選 Allow connections from legacy VNC Viewer users)
→OK→OK
09.更新
[terminal] sudo apt update
[terminal] sudo apt upgrade -y
10.安裝辦公室軟體
[terminal] sudo apt install libreoffice -y
------到此為止,一台簡單的文書機已完成------
11.安裝 apache2
terminal
sudo apt install apache2
sudo geany /etc/apache2/apache2.conf
拿掉目錄瀏覽功能
在 <Directory /var/www/> 區塊
把 Options Indexes FollowSymLinks 改成 Options FollowSymLinks
sudo service apache2 restart
cd /var/www
sudo chmod 777 -R html
sudo chown pi:www-data -R html
apache2 的組態檔案路徑如下
/etc/apache2/
|-- apache2.conf
| `-- ports.conf
|-- mods-enabled
| |-- *.load
| `-- *.conf
|-- conf-enabled
| `-- *.conf
|-- sites-enabled
| `-- *.conf
12.安裝 php + composer
terminal
sudo apt install php
sudo apt install php8.2-xml
sudo apt install php-mbstring
sudo apt install php-gd
sudo geany /etc/php/8.2/apache2/php.ini
display_errors = On (從 Off 改成 On,可以顯示錯誤狀況)
session.auto_start = On (從 0 改成 On,自動開啟 session)
date.timezone = "Asia/Taipei"
儲存,離開。
sudo service apache2 restart
sudo apt install composer
13.安裝 curl
terminal
sudo apt install curl
sudo apt install php8.2-curl
sudo service apache2 restart
14.安裝 mariadb
terminal
sudo apt install mariadb-server
若您在 terminal 輸入 mysql -u root -p 遇到 Access denied for user 'root'@'localhost'
則須要下面修正
sudo mysql
use mysql
alter user 'root'@'localhost' identified with mysql_native_password using password('your_password');
------
sudo apt install php8.2-mysql
sudo geany /etc/php/8.2/apache2/php.ini
extension=mysqli 要啓用
sudo service apache2 restart
用 phpinfo(); 就可以知道是否啓用成功!
15.關閉螢幕保護模式
terminal (預設路徑就是家目錄 e.q. /home/pi)
新增一文件,檔案名稱為 .xsessionrc
裡面加上指令並儲存 (括號內的文字不用輸入)
xset s off (關閉螢幕保護模式)
xset -dpms (關閉電源節能管理)
登入時,會自動執行指令
16.調整數位時鐘設定
滑鼠移到右上方時間的位置,按下右鍵,點選「數位時鐘 Settings」
在時鐘格式的地方,填入 %A %F %T,然後點選 OK 即可。
參數部份,可參考下面說明。
https://livingthelinuxlifestyle.wordpress.com/2020/01/07/display-the-date-and-time-using-codes-in-linux/
%A: Display the full name of the day of the week
%a: Display the abbreviated name of the day of the week
%B: Display the full name of the month
%b: Display the abbreviated name of the month
%C: Display the abbreviated year
%c: Display the abbreviated day, date, and month, and full year and time
%D: Display the full date in numeric format
%d: Display only the date
%e: Display the abbreviated date, single numeral preceded with a space
%F: Display the full date in numeric format, year first
%H: Display the hour only
%I: Display the abbreviated hour
%j: Display the day of the year (1 – 365)
%k: Display the abbreviated hour, single numeral preceded with a space
%l: Display the abbreviated hour, single numeral preceded with a space, 12 hour
%M: Display the minute, numerical format
%m: Display the month, numerical format
%N: Display nanoseconds
%n: Display a new line
%P: Display AM or PM, lowercase
%p: Display AM or PM, uppercase
%r: Display time in 12 hour format
%R: Display time in 24 hour format
%S: Display seconds
%s: Display seconds since 01/01/1970 00:00:00
%T: Display time in %H:%M:%S format
%t: Display tab
%U: Display week of year, numerical format
%V: Display number of day of the week, with Monday as 01
%W: Display number of the day of the week, with Monday as 00
%w: Display number of the day of the week, with Sunday as 0
%X: Display time, HH:MM:SS format
%x: Display date, MM/DD/YYYY format
%Y: Display year
%y: Display last two digits of year
%Z: Display time zone, alphabetical %z: Display time zone, numerical (-0600)
%:z: Display time zone, numerical (-06:00)
%::z: Display time zone, numerical (-06:00:00)
17.安裝 sshfs, filezilla, freecad
sudo apt install sshfs
sudo apt install filezilla
sudo apt install freecad
raspberry pi 5 用 x11 時,強制螢幕休眠
底下程式執行,螢幕就休眠,一動鍵盤或滑鼠,就會恢復螢幕畫面。
這是用 python 來執行。
import os
os.system("xset dpms force off") # 關閉螢幕(休眠)
事實上,最重要的是這一行指令,在 terminal 底下一執行就可以
xset dpms force off
用 js 抓出所有可用的多媒體裝置
●test.htm (要放在有 https 的地方)
<!doctype html>
<html lang="zh-Hant-TW">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=classDevice-width, initial-scale=1.0">
<title>裝置媒體裝置列舉</title>
<style>
body
{
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
button
{
padding: 10px 15px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover
{
background-color: #45a049;
}
.classDevice
{
padding: 10px;
margin: 5px 0;
background-color: #f5f5f5;
border-radius: 4px;
}
.classDeviceList
{
margin-top: 20px;
}
.classDeviceCategory
{
margin-bottom: 30px;
}
</style>
</head>
<body>
<h1>媒體裝置列舉</h1>
<p>此頁面將列出所有可用的攝影鏡頭和麥克風裝置。</p>
<button id="btnRefresh" onclick="funcEnumerateDevices();">重新整理裝置列表</button>
<div class="classDeviceList">
<div class="classDeviceCategory">
<h2>攝影鏡頭</h2>
<div id="divVideoInputDevices"></div>
</div>
<div class="classDeviceCategory">
<h2>麥克風</h2>
<div id="divAudioInputDevices"></div>
</div>
</div>
<script>
async function funcEnumerateDevices()
{
try
{
// 請求使用者權限(這會觸發瀏覽器的權限對話框)
await navigator.mediaDevices.getUserMedia({ audio: true, video: true });
// 列舉所有媒體裝置
const oDevices=await navigator.mediaDevices.enumerateDevices();
// 過濾並顯示攝影鏡頭
const oVideoInputDevices=oDevices.filter(oDevice => oDevice.kind==='videoinput');
funcDisplayDevices(oVideoInputDevices, 'divVideoInputDevices');
// 過濾並顯示麥克風
const oAudioInputDevices=oDevices.filter(oDevice => oDevice.kind==='audioinput');
funcDisplayDevices(oAudioInputDevices, 'divAudioInputDevices');
}
catch(oError)
{
console.error('列舉裝置時發生錯誤:', oError);
alert('列舉裝置時發生錯誤: ' + oError.message);
}
}
function funcDisplayDevices(oDevices, strElementId)
{
const oContainer=document.getElementById(strElementId);
oContainer.innerHTML='';
if(oDevices.length === 0)
{
oContainer.innerHTML='<div class="classDevice">未找到裝置</div>';
return;
}
oDevices.forEach(
oDevice =>
{
const oDeviceElement=document.createElement('div');
oDeviceElement.className='classDevice';
const strDeviceId=oDevice.deviceId || '無ID';
const strDeviceLabel=oDevice.label || '未命名裝置';
oDeviceElement.innerHTML
='<strong>名稱:</strong> '+strDeviceLabel+'<br>'
+'<strong>ID:</strong> '+strDeviceId+'<br>'
+'<strong>類型:</strong> '+oDevice.kind+'';
oContainer.appendChild(oDeviceElement);
}
);
}
</script>
</body>
</html>