自由學習的風

幽夢影 張潮 少年讀書,如隙中窺月;中年讀書,如庭中望月;老年讀書,如臺上玩月。皆以閱歷之淺深,為所得之淺深耳。

轉:[教學文章] phpExcel常用方法詳解

2018年6月5日 星期二

參考網址:EMAN1214

操作excel

1.header
        header("Content-Type:application/vnd.ms-excel");
        header("Content-Disposition:attachment;filename=product.xls");
        header("Pragma:no-cache");
        header("Expires:0");

2.PHPExcel
        http://www.codeplex.com/PHPExcel
        http://www.phpexcel.net
        開發包Tests目錄有詳細使用實例
        支持中文,注意文件編碼,文件保存為utf-8
        寫excel
詳情參閱相關文件內容。

常用的 VSCode 套件(Alex宅幹嘛)

2018年6月1日 星期五

直接看直播影片教學 =>[ Alex 宅幹嘛 ] 👨‍💻開掛囉!!! VSCode 工作學習效率加倍術

  • ESLint
  • Git History
  • gitflow
  • gitignore
  • GitLess
  • indent-rainbow
  • Live Sass Compiler
  • Live Server
  • Markdonw Preview Github Styling
  • Node Exec
  • Path Intellisense
  • Prettier - Code formatter
  • Prettify JSON
  • Project Manager
  • SCSS Intellisense
  • SCSS Refactoring
  • Vetur
  • VS Live Share
  • vscode-icons

嗯!莫名踩雷了 mariadb-server

2018年5月31日 星期四

利用 MariaDb 架 nextcloud 平台,收集校務評鑑資料,一開始裝好了之後,用起來都很正常。
但是安全更新後把伺服器重新開機,就發現nextcloud 掛了,遠端登入後才發現是資料庫沒啟動,立馬手動執行
sudo systemctl restart mysqld.server
結果等了許多,跳出了另一個錯誤訊息
2018-05-29 13:46:04 139927905056960 [Note] Using unique option prefix 'myisam-recover' is error-prone and can break in the future. Please use the full name 'myisam-recover-options' instead.
2018-05-29 13:46:04 139927905056960 [Note] Using unique option prefix 'myisam-recover' is error-prone and can break in the future. Please use the full name 'myisam-recover-options' instead.
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: Uses event mutexes
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: Compressed tables use zlib 1.2.8
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: Using Linux native AIO
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: Number of pools: 1
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: Using SSE2 crc32 instructions
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: Completed initialization of buffer pool
2018-05-29 13:46:04 139927257839360 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: The first innodb_system data file 'ibdata1' did not exist. A new tablespace will be created!
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: Setting file './ibdata1' size to 12 MB. Physically writing the file full; Please wait ...
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: File './ibdata1' size is now 12 MB.
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: Setting log file ./ib_logfile101 size to 50331648 bytes
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: Setting log file ./ib_logfile1 size to 50331648 bytes
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: New log files created, LSN=45790
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: Doublewrite buffer not found: creating new
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: Doublewrite buffer created
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: 128 out of 128 rollback segments are active.
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: Creating foreign key constraint system tables.
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: Creating tablespace and datafile system tables.
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: Creating sys_virtual system tables.
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: Waiting for purge to start
2018-05-29 13:46:04 139927905056960 [Note] InnoDB: 5.7.22 started; log sequence number 0
2018-05-29 13:46:04 139927905056960 [Note] Plugin 'FEEDBACK' is disabled.
2018-05-29 13:46:04 139927905056960 [ERROR] Could not open mysql.plugin table. Some plugins may be not loaded
2018-05-29 13:46:04 139927905056960 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
2018-05-29 13:46:04 139927905056960 [Note] Server socket created on IP: '127.0.0.1'.
2018-05-29 13:46:04 139927905056960 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
本來以為是資料庫故障了,結果切換到 /var/lib/mysql 後,發現資料庫、資料表似乎都在,疑問之下,開啟  /var/log/syslog ,發現又一串錯誤訊息…
May 30 20:15:45 ubuntu systemd[1]: Starting MariaDB 10.2.15 database server...
May 30 20:15:46 ubuntu kernel: [97757.266462] audit: type=1400 audit(1527682546.054:13): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/12073/status" pid=12073 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=106 ouid=106
May 30 20:15:46 ubuntu kernel: [97757.266776] audit: type=1400 audit(1527682546.054:14): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=12073 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=106 ouid=0
May 30 20:15:46 ubuntu kernel: [97757.267025] audit: type=1400 audit(1527682546.054:15): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/12073/status" pid=12073 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=106 ouid=106
May 30 20:15:46 ubuntu kernel: [97757.357815] audit: type=1400 audit(1527682546.142:16): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/etc/mysql/mariadb.conf.d/" pid=12073 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=106 ouid=0
May 30 20:15:46 ubuntu mysqld[12073]: #007/usr/sbin/mysqld: Can't read dir of '/etc/mysql/mariadb.conf.d/' (Errcode: 13 "Permission denied")
May 30 20:15:46 ubuntu mysqld[12073]: #007/usr/sbin/mysqld: Can't read dir of '/etc/mysql/mariadb.conf.d/' (Errcode: 13 "Permission denied")
May 30 20:15:46 ubuntu mysqld[12073]: Fatal error in defaults handling. Program aborted

May 30 20:15:46 ubuntu kernel: [97757.360216] audit: type=1400 audit(1527682546.146:17): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/etc/mysql/mariadb.conf.d/" pid=12073 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=106 ouid=0
May 30 20:15:46 ubuntu systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE

May 30 20:15:46 ubuntu systemd[1]: Failed to start MariaDB 10.2.15 database server.
May 30 20:15:46 ubuntu systemd[1]: mariadb.service: Unit entered failed state.
May 30 20:15:46 ubuntu systemd[1]: mariadb.service: Failed with result 'exit-code'.
本來以為是 DB 設定檔出了問題,也懷疑過 mariadb-common 和 mysql-common 這 2 個系統自己裝進來的套件,混在一起後有衝突,調整了許久還是無法啟動。
後來再仔細看了一下 log 內容,似乎是被 denied ,permission 不夠,苦搜了許久,終於把這雷也掃了,結論:
編輯   /etc/apparmor.d/usr.sbin.mysqld,增加下列內容,重新啟動服務後,正常!呼!
/etc/mysql/*.cnf r,
/{,var/}run/mysqld/mysqld.pid w,
/{,var/}run/mysqld/mysqld.sock w,
/usr/lib/mysql/plugin/ r,
/proc/*/status r,
/sys/devices/system/node/ r,
/sys/devices/system/node/node0/meminfo r,
/run/systemd/notify w,


Deepin / Debian ppa list

2018年5月29日 星期二

SMplayer (參考網址)

 for Debian 8
wget -nv https://download.opensuse.org/repositories/home:smplayerdev/Debian_8.0/Release.key -O Release.key
apt-key add - < Release.key
apt-get update
echo 'deb http://download.opensuse.org/repositories/home:/smplayerdev/Debian_8.0/ /' > /etc/apt/sources.list.d/home:smplayerdev.list
apt-get update
apt-get install smplayer

Visual Studio Code (參考網址)

curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
sudo apt-get update
sudo apt-get install code

 megaSync (參考網址)

echo deb http://mega.co.nz/linux/MEGAsync/Debian_8.0/ ./ | sudo tee /etc/apt/sources.list.d/megasync.list
wget https://mega.co.nz/linux/MEGAsync/Debian_8.0/Release.key && sudo apt-key add Release.key
sudo apt update
sudo apt install megasync

Nodejs(參考網址

Node.js v10.x:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt-get install -y nodejs
Node.js v8.x:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install -y nodejs



DBeaver 語系設定

2018年5月24日 星期四

DBeaver  若直接使用非安裝版本,會自動偵測系統環境相對的語系,不過,在中文上,好像只有簡體的語系, GUI  的介面沒有提供可修改的選項,解決的方法有 2 種:
1. 直接以命令列執行加參數
dbeaver -nl en
2. 修改 dbeaver.ini 設定檔
-Duser.language=zh_tw

[PHP] 網頁轉向

2018年5月2日 星期三

Opt 1:
$sec = 0;
$page = 'index.php';
header("Refresh: $sec; url=$page");

Opt 2:
$page = 'index.php';
header("Location: " . $page);
or
$page = 'index.php';
header("Location: " . $page, true, 301);

lftp 下載/上傳整個目錄

2018年4月23日 星期一

lftp 比 ftp 方便多了,特別當需要上傳或下載整個目錄時,特別方便。
下載整個目錄   mirror  <dir_name>
上傳整個目錄   mirror  -R  <local_dir_name>