顯示具有 軟體筆記 標籤的文章。 顯示所有文章
顯示具有 軟體筆記 標籤的文章。 顯示所有文章

2025-09-15

【軟體筆記】MobaXterm 取代 pietty

最近買了 ASUSTOR AS1102TL,看到 AppCentral 中可以安裝 python3,想嚐鮮,但又找不到【終端機】之類的方式能進到命令列文字模式。

想到 AS1102TL 是屬 Linux 系統,就試試看以 SSH 連進去。

老人家之前慣用的 pietty 在建立連線時出現了錯誤訊息


看似是 pietty 不支援新的加密協定,上 pietty 官網,最新的版本仍停留在 0.4.00,跟現在我手上的版本一樣。

於是問了 DeepSeek 推薦有什麼替代軟體,試用了覺得 MobaXterm 不錯,可以記錄多台主機連線,好像還能開多個頁籤,可惜沒有中文界面(或是我沒找到?因為 DeepSeek 說有...)

程式畫面左邊會列出它偵測到的同區網內可連線的裝置
→ 在欲連線的裝置按滑鼠右鍵
→ Edit session


→ 確認是圈選 SSH
→ 輸入【Remote host】、【Specify username
→ 點擊【OK】鈕
→ 提示要您輸入密碼
→ 第一次登入時,程式還會問您要不要儲存(記住)密碼,然後就登入了




















2023-05-01

【軟體筆記】將目錄下的檔名匯入至純文字檔內

開啟 命令提示字元(DOS 視窗)

 
# 切換至要匯出檔名的目錄
cd\dir1

# 以 dir 指令將檔名匯到指定的文字檔
dir /b  > c:\myfilelist.txt
 

2021-12-07

【Excel】NUMBERSTRING -- 數字轉中文

Numberstring 函式有 2 個引數

第 1 個引數是要轉換數字的儲存格

第 2 個引數有 3 種型態,如下:


在儲存格 A1 輸入數字 1234567890

型態 1:在 B1 輸入公式

=numberstring(A1, 1)

就會自動轉換為

一十二億三千四百五十六萬七千八百九十


型態 2:

=numberstring(A1, 2)

就會自動轉換為

壹拾貳億參仟肆佰伍拾陸萬柒仟捌佰玖拾


型態 3:

=numberstring(A1, 1)

就會自動轉換為

一二三四五六七八九○



2021-11-27

【Excel】利用 Windings2 字型製作 打勾/打叉 效果

在儲存格輸入 P(注意,要大寫) → 選擇字型 Windings2(這是一種特殊符號字型),就變成打勾了

下圖為 大寫英文Windings2 字型顯示的效果


有興趣的朋友也可以玩玩其他文字(例如小寫英文)

2021-06-12

【CentOS7】Visual Studio Code 無法啟動

老人家安裝在 CentOS 7Visual Studio Code 已經有一陣子無法運作了 -- 只要一啟動 vscode,就僵在啟動畫面,目前的版本為 1.57.0

 

暫時先下載安裝 Sublime 頂著用。

 

可是...我還是想用 vscode 啊...


爬文後,參考網友的做法,先到 Microsoft YUM repos 找到舊的 1.52.1 版,手動下載安裝,並停用自動更新。

 
* 移除目前的 vscode 1.57.0 版
[root]# yum remove code

* 切換到下載下來的 1.52.1 的目錄(我是下載到 /tmp)
[root]# yum install code-1.52.1-1608137084.el7.x86_64.rpm

* 停止 vscode 自動更新
[root]# vi /etc/yum.repos.d/vscode.repo
* 啟動了 vi, 按 i 進入編輯模式
* 將 enabled=1  改為 enabled=0
* 按 :x 存檔離開
 

重開機,就可以使用 vscode

 

如果重開機後,Gnome 的圖形界面功能表--"軟體開發" 內仍沒有 vscode 的圖示,則可以

開啟終端機視窗,輸入

/usr/share/code/code

手動啟動 vscode


2021-01-30

【VirtualBox】縮小 vdi 虛擬機磁碟檔

到 微軟官網 下載 sdelete,這是一個壓縮檔。


解壓縮後,視您的作業系統執行 sdelete 版本,老人家的是 Win7 64bit

C:\>sdelete64 -z  C:


有幾個硬碟就執行幾次


[root]# VBoxManage  modifymedium  disk  /vm所在目錄/sample.vdi  --compact


執行後原本 116G 的 vdi 縮成 111G


2019-12-06

【CentOS7】VirtualBox5 安裝 CentOS8

以預設值(Server with GUI) 安裝好幾次都失敗,上網爬了一會兒,官方說在 VirtualBox 5.x 要改選擇 "Workstation" 安裝。

雖然安裝過程最後螢幕仍會出現類似裝錯顯卡驅動程式而當機的畫面,但強制關機,將安裝光碟自虛擬機移除後,重新開機就正常了。



==== 2020.02.16 ====
VirtualBox 更新至 6.x
並安裝 CentOS 8.1
以預設值(含 GUI 的伺服器)就可順利安裝

2018-11-17

【VisualStudioCode】設定功能表語言為中文

Ctrl + Shift + P 螢幕中央上方會顯示一個小輸入欄



輸入 display 後按 ENTER 鍵

VS Code 會打開一個 locale.json 檔,輸入如下內容
 
{
    // 定義 VS Code 的顯示語言。
    // 如需支援的語言清單,請參閱 https://go.microsoft.com/fwlink/?LinkId=761051。
 
    "locale":"zh-tw" // 在重新啟動 VS Code 前,變更不會生效。
}
 
重新啟動 VS Code 就生效了。

2016-12-19

Google code-prettify

參考資料 ----
google/code-prettify




快速的用法:
 
<head>
...
...
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js?skin=sunburst"></script>
<style>
pre.prettyprint, code.prettyprint
{
    border-radius: 8px;
}
</style>
...
...
</head>
 

skindefaultdesertsunburstsons-of-obsidiandoxy 可選(全小寫)
本篇筆記的程式碼就是採 sons-of-obsidian 風;想預覽各種風格,請至

theme gallery


另外,我看到 doxy 風的程式碼區塊的四個角是圓角,很喜歡,也想套用,於是加上

border-radius: 8px;




要使用 prettify 的程式碼區塊寫法
 
<pre class="prettyprint [lang-語言] [linenums:數字]">

...
...

</pre>
 
[ ] 表示是選擇性參數,若不加 linenums,預設不會顯示行號。

想要顯示行號,則只要加 linenums,如果 linenums 後面沒接數字,則除了 sons-of-obsidian 外,其他風格都是只顯示 5 的倍數的行號。

另外,您可以看到,在本篇筆記,沒有行號的程式碼區塊背景是單純的黑色,而有行號的區塊則是深淺不同的黑色相間。

linenums 後面的數字代表程式碼第一行的行號,
例如:
linenums:8
表第一行的行號為 8,而 prettify 自第三行顯示行號 10,之後依序每隔 5 行顯示 15、20、25、...

如果真的想要每行都顯示行號,則可在網頁原始碼加入下述 CSS 指令
 
<style>
li.L0, li.L1, li.L2, li.L3,
li.L5, li.L6, li.L7, li.L8 {
  list-style-type: decimal !important;
}
</style>
 
或是去下載預設的 pretty.css 下來,自行修改,再放到您的網站。


而預設支援的程式語言有:C 家族, Java, Python, Bash, SQL, HTML, XML, CSS, JavaScript, Makefile, Rust ......等語言,而且 Google 說它會自行辨認。

但若辨認不出來時,就得加 lang-語言 參數,語言參數則有下列
lang-sh(Bash)
lang-c(C家族)
lang-cc(C++)
lang-html
lang-java
lang-js(JavaScript)
lang-coffee(CoffeeScript)
lang-py(Python)
lang-sql
lang-lua
lang-vb(VBScript)
lang-hs(Haskell)
lang-el(Lisp)
lang-proto(Protocol Buffers)
lang-wiki(Wiki Syntax)
lang-css
lang-cs(C#)
lang-vhdl
lang-yaml
lang-scala
lang-go
lang-erlang
lang-rust
lang-pascal


若您熟悉 CSS,還可進一步自訂您的 prettify 風格,更多資訊,請參考筆記一開始的連結。


unit Unit1;
 
interface
 
// 注意要 uses ActiveX, ComObj
uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls, ActiveX, ComObj;
 
type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
function GetStatusCodeStr(statusCode:integer) : string;
begin
    case statusCode of
        0    :  Result := 'Success';
        11001:  Result := 'Buffer Too Small';
        11002:  Result := 'Destination Net Unreachable';
        11003:  Result := 'Destination Host Unreachable';
        11004:  Result := 'Destination Protocol Unreachable';
        11005:  Result := 'Destination Port Unreachable';
        11006:  Result := 'No Resources';
        11007:  Result := 'Bad Option';
        11008:  Result := 'Hardware Error';
        11009:  Result := 'Packet Too Big';
        11010:  Result := 'Request Timed Out';
        11011:  Result := 'Bad Request';
        11012:  Result := 'Bad Route';
        11013:  Result := 'TimeToLive Expired Transit';
        11014:  Result := 'TimeToLive Expired Reassembly';
        11015:  Result := 'Parameter Problem';
        11016:  Result := 'Source Quench';
        11017:  Result := 'Option Too Big';
        11018:  Result := 'Bad Destination';
        11032:  Result := 'Negotiating IPSEC';
        11050:  Result := 'General Failure'
    else
        result := 'Unknow';
    end;
end;
 
 
function Ping(const Address:string; BufferSize:Word): string;
var
    FSWbemLocator : OLEVariant;
    FWMIService   : OLEVariant;
    FWbemObjectSet: OLEVariant;
    FWbemObject   : OLEVariant;
    oEnum         : IEnumvariant;
    iValue        : LongWord;
 
    PacketsReceived : Integer;
    Minimum         : Integer;
    Maximum         : Integer;
    Average         : Integer;
begin
    PacketsReceived := 0;
    Minimum         := 0;
    Maximum         := 0;
    Average         := 0;
 
    FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
    FWMIService   := FSWbemLocator.ConnectServer('localhost', 'root\CIMV2', '', '');
 
    FWbemObjectSet:= FWMIService.ExecQuery(Format('SELECT * FROM Win32_PingStatus where Address=%s AND BufferSize=%d',[QuotedStr(Address),BufferSize]),'WQL',0);
    oEnum         := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;
    if (oEnum.Next(1,FWbemObject,iValue)=0) then
    begin
        if FWbemObject.StatusCode=0 then
            begin
                // ping 成功
                Inc(PacketsReceived);
 
                result := 'ping 的到';
            end
        else
            if not VarIsNull(FWbemObject.StatusCode) then
                result := GetStatusCodeStr(FWbemObject.StatusCode)
            else
                result := 'Error processing request';
    end;
    FWbemObject := Unassigned;
    FWbemObjectSet := Unassigned;
 
end;
 
 
procedure TForm1.Button1Click(Sender: TObject);
var
    str: string;
begin
    try
        CoInitialize(nil);
        try
            str := Ping(Edit1.Text, 32);
            showmessage(str);
        finally
            CoUninitialize;
        end;
    except
        on E:Exception do
            showmessage('意外錯誤: ' + E.Classname + ':' + E.Message);
    end;
end;
 
end.

2016-12-04

【CentOS】讓 Linux 系統為自己的 PHP 程式寫 log

參考資料 ----
認識與分析登錄檔
rsyslogd - Linux man page
php.net - syslog

Linux 超強的 log 記錄功能,其實也有開放給管理者,我們可以透過 rsyslog 將自己程式的執行過程記錄下來。

您可以自行決定放置 log 檔的位置,但建議為了一致性,還是將 log 檔放在 /var/log

假設,要將自己的程式 log 檔放在 /var/log/myphplog/

先建立存放 log 檔的目錄

[root]# cd /var/log
[root]# mkdir myphplog


設定自己的程式要透過 Linux 系統記錄 log

[root]# vi  /etc/rsyslog.conf
 
...
...

# 註解:我的 PHP 程式 log
# Linux 開放 local0 ~ local7, 也就是 8 個自定 log,給管理者使用
# 所以您最多可以有 8 組程式可以記錄

local0.*         /var/log/myphplog/myphp.log
 


編輯 log 檔輪替的規則

[root]# vi /etc/logrotate.d/myphplog
 
# 註解:我的 PHP 程式 log 輪替規則
# 可以參考同目錄下其他 daemon 的設定寫法

# log 檔位置
/var/log/myphplog/myphp.log
{
    # 每日輪替, 也就是說每天產生一個 log 檔
    daily

    # 舊的 log 檔名後面帶西元日期
    dateext

    # 自 CentOS7 才有的參數, 舊的 log 檔名後面帶昨天的西元日期
    dateyesterday

    # 舊 log 保留檔案數 10 個檔, 即使有 dateext 參數也一樣要宣告
    rotate 10

    # 不壓縮
    nocompress

    # 執行 logrotate 時, 若自己的 log 檔還沒產生, 可忽略不管
    missingok


    # 重新啟動 rsyslog
    # 這步驟一定要做, 否則 rsyslog 會一直寫進舊的 log 檔, 即使舊 log 檔已輪替多日
    # 比方說, 您自 2016/01/01 開始啟用, 則 myphp.log 輪替成舊檔後, 檔名會變成 myphp.log-20160101
    # 若沒做重新啟動 rsyslog 這個動作, 即使到 2016/12/31, log 依然會寫進 myphp.log-20160101
    postrotate
        # 二擇一
        # 方法一, 網路上看到的多為這指令, 看起來應該是正規做法
        /bin/kill -HUP 'cat /var/run/rsyslogd.pid 2> /dev/null' 2> /dev/null || true

        # 方法二, 看似有點暴力的土法, 目前不知有何後遺症
        service rsyslog restart
    endscript
}
 

重新啟動 rsyslog,讓您寫的設定檔生效

[root] # service  rsyslog  restart


寫一支小程式做測試
 
<?php
date_default_timezone_set('Asia/Taipei');
openlog("myphplog", LOG_CONS, LOG_LOCAL0);

// 第二個參數, 要寫入的訊息
syslog(LOG_INFO,"test log --".date('Y-m-d H:i:s'));
closelog();
?>
 


檢查是否有產生 log

[root]# cd  /var/log/myphplog
[root]# ls


果然生成一個 log 檔了


再看一下 log 檔內容

[root]# cat  /var/log/myphplog/myphp.log
 
Dec  4 16:48:43 主機名 myphplog: test log --2016-12-04 16:48:43
Dec  4 16:48:45 主機名 myphplog: test log --2016-12-04 16:48:45
Dec  4 16:48:49 主機名 myphplog: test log --2016-12-04 16:48:49
Dec  4 16:48:55 主機名 myphplog: test log --2016-12-04 16:48:55
 

2016-11-25

【軟體筆記】建立 / 新增 Windows Server 遠端桌面連線使用者

參考資料 ----
設定遠端桌面服務連線的權限
如何在 Windows Server 2012 設定遠端桌面連線
Microsoft 遠端桌面用戶端
在 Android 上的遠端桌面用戶端快速入門


開始
→ 控制台
→ 系統管理工具
→ 終端機服務設定
→ 連線
→ RDP-Tcp
→ 右鍵 → 內容
→ "使用權限" 頁籤
→ "新增" 鈕
→ 輸入使用者帳號
→ 完成

2016-10-28

【軟體筆記】停用 Windows 201x 密碼原則

參考資料 ----
密碼必須符合複雜性需求
停用密碼複雜度
Windows 2008 Server AD 停用密碼複雜度


叫出命令提示字元,輸入

gpedit.msc

會出現 "本機群組原則編輯器"
→ 展開 Windows 設定
→ 展開 安全性設定
→ 展開 帳戶原則
→ 點擊 密碼原則
→ 雙擊 右方的 "密碼必須符合複雜性需求"
→ 將設定值改為 "停用"

就立即生效


2016-10-20

【database】查詢 MS SQLServer 的版本

參考資料 ----
如何判斷版本、 SQL Server 的版本,並更新層級和其元件


開啟 Enterprise ManagerSQL Server Management Studio

查詢語法
 
SELECT  @@version
 




2016-09-12

【VirtualBox】關閉虛擬機 guest OS

列出虛擬機(guest OS)



vboxmanage list vms


關閉虛擬機
 
vboxmanage controlvm 虛擬機名 acpipowerbutton


2016-08-06

【Linux】關閉 webmin https 加密連線模式

新版的 webmin 預設是 https 加密連線模式,若要關閉,則修改 /etc/webmin/miniserv.conf

[root]# vi  /etc/webmin/miniserv.conf



ssl=1

改為

ssl=0

:x 存檔離開

重新啟動 webmin

[root]# service  webmin  restart

2016-07-23

【Delphi】LibreOffice/OpenOffice Calc 試算表 API 操作

參考資料 ----
API - OpenOffice
ISO 639
ISO 3166
Creating A Border In Calc Using VB 



注意:
現在 LibreOfficex86x64 版本,若您的程式是以 delphi32 編譯,就要搭配安裝 libreoffice x86 版本。

本篇筆記以 Delphi XE6 編譯 32 位元程式,搭配 LibreOffice_5.1.4_Win_x86


 
uses
    // 主要要有 uses 這兩個
    ... System.Variants, comobj;

procedure TForm1.Button1Click(Sender: TObject);
var
    ServiceManager, StarDesktop, Document, args, Sheets, Sheet, myCol, Control,
    Range, cell, NumberFormats, LocalSettings, LineBorder,
    Border, TopLine, BottomLine, LeftLine, RightLine: Variant;
    col, row, i: integer;
    NumberFormatString: string;
    NumberFormatId: long;
begin
    ServiceManager := CreateOleObject('com.sun.star.ServiceManager');
    StarDesktop := ServiceManager.createInstance('com.sun.star.frame.Desktop');
    args := VarArrayCreate([0,1],varVariant);
    Document := StarDesktop.LoadComponentFromURL('private:factory/scalc','_blank',0, args);
    Sheets := Document.Sheets;
    
    // 第 1 張工作表的位置為 0
    // 插入一張新工作表, 參數 1 為工作表名稱, 參數 2 為工作表的位置順序
    // 當指定的位置大於現有的工作表數量時, 就是最後一張工作表
    Sheets.insertNewByName('oneMore',0);
    Sheets.insertNewByName('twoMore',4);
    Sheets.insertNewByName('threeMore',4);
    Sheets.insertNewByName('fourMore',4);
    Sheets.insertNewByName('五',4);
    Sheets.insertNewByName('六',3);

    // 移除工作表
    Sheets.removeByName('twoMore');

    // 顯示/隱藏 工作表
    Sheet := Sheets.getByName('oneMore');
    Sheet.IsVisible := false;

    Sheet := Sheets.getByName('工作表1');
    // Calc 的欄、列是以 0 為起點
    col := 0;    // 第 1 欄
    row := 9;    // 第 10 列
    Sheet.getCellByPosition(col,row).string := 'test';

    // 水平文字對齊
    // 0: STANDARD - 預設值
    // 1: LEFT - 靠左對齊
    // 2: CENTER - 置中
    // 3: RIGHT - 靠右對齊
    // 4: BLOCK - 左右對齊
    // 5: REPEAT - 重覆
    Sheet.getCellByPosition(0,0).string := '水平文字對齊-預設';
    Sheet.getCellByPosition(0,0).HoriJustify := 0;
    Sheet.getCellByPosition(1,0).string := '水平文字對齊-靠左對齊';
    Sheet.getCellByPosition(1,0).HoriJustify := 1;
    Sheet.getCellByPosition(2,0).string := '水平文字對齊-置中';
    Sheet.getCellByPosition(2,0).HoriJustify := 2;
    Sheet.getCellByPosition(3,0).string := '水平文字對齊 - 靠右對齊';
    Sheet.getCellByPosition(3,0).HoriJustify := 3;
    Sheet.getCellByPosition(4,0).string := '水平文字對齊 - 左右對齊';
    Sheet.getCellByPosition(4,0).HoriJustify := 4;
    Sheet.getCellByPosition(5,0).string := '水平文字對齊 - 重覆';
    Sheet.getCellByPosition(5,0).HoriJustify := 5;

    // 垂直文字對齊
    // 0: STANDARD - 預設值
    // 1: TOP - 靠上對齊
    // 2: CENTER - 置中
    // 3: BOTTOM - 靠下對齊
    Sheet.getCellByPosition(0,1).string := '垂直文字對齊 - 預設值';
    Sheet.getCellByPosition(0,1).VertJustify := 0;
    Sheet.getCellByPosition(1,1).string := '垂直文字對齊 - 靠上對齊';
    Sheet.getCellByPosition(1,1).VertJustify := 1;
    Sheet.getCellByPosition(2,1).string := '垂直文字對齊 - 置中';
    Sheet.getCellByPosition(2,1).VertJustify := 2;
    Sheet.getCellByPosition(3,1).string := '垂直文字對齊 - 靠下對齊';
    Sheet.getCellByPosition(3,1).VertJustify := 3;

    // 自動調整欄寬
    // 第 1 種寫法
    myCol := Sheet.Columns.getByIndex(0);
    myCol.OptimalWidth := true;
    // 第 2 種寫法
    Sheet.Columns.getByIndex(0).OptimalWidth := true;

    // 凍結窗格
    Control := Document.getCurrentController;
    Control.freezeAtPosition(0,1);

    // 合併儲存格
    Sheet.getCellByPosition(0,5).string := '合併儲存格';
    Range := Sheet.getCellRangeByName('A6:B10');
    Range.Merge(true);

    // 畫儲存格框線
    LineBorder := ServiceManager.Bridge_GetStruct('com.sun.star.table.BorderLine');
    LineBorder.Color := RGB(0, 0, 0);
    // 目前只要 OuterLineWidth 和 InnerLineWidth 同時存在
    // 就畫不出框線, 只好先 disable 其中一個
    LineBorder.OuterLineWidth := 5;
    // LineBorder.InnerLineWidth := 1;
    // LineBorder.LineDistance := 50;
    Border := ServiceManager.Bridge_GetStruct('com.sun.star.table.TableBorder');
    Border.IsTopLineValid := true;
    Border.IsBottomLineValid := true;
    Border.IsLeftLineValid := true;
    Border.IsRightLineValid := true;
    Border.TopLine := LineBorder;
    Border.BottomLine := LineBorder;
    Border.LeftLine := LineBorder;
    Border.RightLine := LineBorder;
    Range.TableBorder := Border;

    // 上框線
    TopLine := ServiceManager.Bridge_GetStruct('com.sun.star.table.BorderLine');
    TopLine.Color := RGB(255, 0, 0);
    TopLine.OuterLineWidth := 15;
    // 下框線
    BottomLine := ServiceManager.Bridge_GetStruct('com.sun.star.table.BorderLine');
    BottomLine.Color := RGB(0, 255, 0);
    BottomLine.OuterLineWidth := 15;
    // 左框線
    LeftLine := ServiceManager.Bridge_GetStruct('com.sun.star.table.BorderLine');
    LeftLine.Color := RGB(0, 0, 255);
    LeftLine.OuterLineWidth := 15;
    // 右框線
    RightLine := ServiceManager.Bridge_GetStruct('com.sun.star.table.BorderLine');
    RightLine.Color := RGB(255, 255, 0);
    RightLine.OuterLineWidth := 15;
    // 指定範圍內的水平框線
    Border.HorizontalLine := LineBorder;
    Border.IsHorizontalLineValid := true;
    // 指定範圍內的垂直框線
    Border.VerticalLine := LineBorder;
    Border.IsVerticalLineValid := true;

    Border.TopLine := TopLine;
    Border.BottomLine := BottomLine;
    Border.LeftLine := LeftLine;
    Border.RightLine := RightLine;
    Sheet.getCellRangeByName('D10:F15').TableBorder := Border;

    // 區域文字對齊
    // 0: 靠左
    // 1: 告右
    // 2: 自動折行
    // 3: 置中
    Range.ParaAdjust := 3;

    // 以名稱方式指定 儲存格
    cell := sheet.getCellRangeByName('A1');
    // Cell 背景色
    // LibreOffice 的 RGB 剛好和 Delphi 順序相反, 是 B-G-R
    cell.CellBackColor := RGB(0,0,255); // 紅色
    // Cell 字體顏色
    cell.CharColor := RGB(0,255,0); // 綠色
    // Cell 英數字體高度, 對中文字無效
    cell.CharHeight := 50;


    // 設定數字格式
    LocalSettings := ServiceManager.Bridge_GetStruct('com.sun.star.lang.Locale');
    LocalSettings.Language := 'zh';
    LocalSettings.Country := 'tw';

    NumberFormats := Document.NumberFormats;
    NumberFormatString := '#,##0.00';

    NumberFormatId := NumberFormats.queryKey(NumberFormatString, LocalSettings, True);
    if (NumberFormatId=-1) then
        NumberFormatId := NumberFormats.addNew(NumberFormatString, LocalSettings);

    // 以名稱方式指定 儲存格, 並輸入數字
    Sheet.getCellRangeByName('A15').Value := 13579;
    Sheet.getCellRangeByName('A15').NumberFormat := NumberFormatId;
    Sheet.getCellRangeByName('A16').Value := -24680;
    Sheet.getCellRangeByName('A16').NumberFormat := NumberFormatId;
    // 輸入公式
    Sheet.getCellRangeByName('A17').Formula := '=SUM(A15:A16)';
 

2016-07-11

【VirtualBox】加大 CentOS 虛擬機影像檔硬碟空間

參考資料 ----
鳥哥 - 邏輯捲軸管理員 (Logical Volume Manager)


* 先將虛擬機關機

[root]# VBoxManage  modifyhd  虛擬機影像檔  --resize  新容量(以 MB 計算)
例如:
將影像檔的硬碟空間擴增為 500GB
[root]# vboxmanage   modifyhd  centos6.vdi  --resize  512000

(經實驗證明:VBoxManage 大小寫沒差)



* 下載 GParted Live CD 並存放在  /tmp
[user]$ wget https://sourceforge.net/projects/gparted/files/gparted-live-stable/0.26.1-1/gparted-live-0.26.1-1-amd64.iso /tmp/

* 建立新虛擬機器, 注意:在系統 --> 主機板 --> 要勾選 "啟用 EFI 模式"




掛載 Gparted iso 檔並以 Gparted 開機


在要增大的磁區點滑鼠右鍵,選 resize



拉箭頭往右移動,將全部未使用磁區都佔滿,然後按 Resize



Apply 使生效



關閉虛擬機,記得把 EFI 打勾取消,重新啟動虛擬機


df -T 檢視硬碟的檔案系統格式





再以 lvdisplay 檢視要加大的 LVM 分區名



[root]# lvresize  -l  +100%FREE  /dev/centos/root

接下來要注意


CentOS6(含)之前的版本, 預設檔案系統是 ext2/3/4,要以 resize2fs 指令放大

[root]# resize2fs  /dev/vg_centos6/lv_root


CentOS7 預設檔案系統是 XFS, 所以要以 xfs_growfs 放大,並且,是不支援 resize 縮小 的。

[root]# xfs_growfs  /dev/centos/root

確認檔案系統 ext2/3/4XFS 空間已放大

[root]# df -h

2016-06-14

【Linux】釋放 VirtualBox 虛擬機未使用的磁碟空間 縮小 vdi 影像檔

參考資料 ----
Compacting VirtualBox Disk Images - Linux Guests


注意:
據說此動作有風險,所以在執行前,請先將虛擬機停機,並做影像檔備份。並且將欲縮小的磁區 umount。


以 "動態大小" 建立的 VirtualBox 虛擬機影像檔,當您塞了很多檔案進去後,影像檔就會變大,但當您刪除檔案後,影像檔並不會跟著變小,需要額外的動作才能使其縮小。



指令語法

dd  if=/dev/zero  of=輸出檔名  bs=1M

例如:

[root]# cd  /
[root]# dd  if=/dev/zero  of=zerofile  bs=1M


執行完畢時,會出現下述訊息。

dd: writing 'zerofile': No space left on device


檢查根目錄下是否有生成 zerofile。若有生成 zerofile,以 ls -lh 指令 觀察,會看到 zerofile 相當大。

刪除 zerofile

[root]# rm  -f  zerofile

再以 VBoxManage 縮小影像檔


[root]# VBoxManage modifyhd  虛擬機檔名.vdi  --compact

2016-04-05

【Linux】CentOS 7 安裝 Google Chrome 瀏覽器

參考資料 ----
Install Google Chrome with YUM on Fedora 15/14, CentOS/Red Hat (RHEL) 6


建立 repo

[root]# vi  /etc/yum.repos.d/google.repo
 
[google64]
name=Google - x86_64
baseurl=http://dl.google.com/linux/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
 

:x 存檔離開
 

[root]# yum  install  google-chrome-stable




2016-02-14

【CentOS 7】LibreOffice 變更為中文界面

LibreOffice 預設是英文界面,要變更為中文界面,需安裝中文語言套件。

[root]# yum install libreoffice-langpack-zh-Hant (注意大小寫)


若要知道 LibreOffice 還有提供哪些語言,可以透過 provides 參數查詢

[root]# yum provides libreoffice-langpack*