2018年1月13日 星期六

Ubuntu 16.4 x64 安裝 Lazaurs 1.8

1. 先下載 Lazaurs 1.8 安裝套件,下載連結 ,檔案包含如下:

  • lazarus-project_1.8.0-1_amd64.deb
  • fpc-src_3.0.4-2_amd64.deb
  • fpc_3.0.4-2_amd64.deb

2. 因為要使用 gdebi 進行套件安裝,所以Ubuntu需要有包含此套件,若沒有,則需要先進安裝。可以直接使用 Ubuntu Software 進行套件查詢及安裝。

3. 開始安裝 Lazarus前,需要先安裝 fpc套件
    $ sudo gdebi fpc_3.0.4-2_amd64.deb
    $ sudo gdebi fpc-src_3.0.4-2_amd64.deb

    安裝 lazarus-project_1.8.0-1_amd64.deb
    $ sudo gdebi lazarus-project_1.8.0-1_amd64.deb

    安裝後,建議重開機。




2017年11月28日 星期二

Ubuntu 設定網卡IP

1. 修改Ethernet網路IP

$ sudo vi /etc/network/interfaces  -> 進入修改編輯畫面

********************************************
auto lo
iface lo inet loopback

auto eth0   #網卡名稱
iface eth0 inet static   # static : 靜態IP, dhcp : 動態IP
address 192.168.0.10  # IP Address
netmask 255.255.255.0 # 網路遮罩
gateway 192.168.0.1 # 預設閘道

# 設定 DNS Server
dns-nameservers 8.8.8.8 168.95.1.1

********************************************

2. 設定DNS --> 在這邊設定,有時會遇到重啟後,設定就不見了

$ sudo vi /etc/resolv.conf

********************************************

nameserver 168.95.1.1 
nameserver 168.95.192.1

**********************************************

2. 修改後,重新啟動網卡

$ sudo /etc/init.d/networking restart

2017年11月7日 星期二

Oracle 帳號鎖定解除

Oracle預設在密碼連續錯誤10次時,該帳戶便會被鎖定,可以透過下列方式進行處理:

1. 使用sqlplus,透過 sysdba角色登入資料庫
    Ex: sqlplus system / as sysdba

2. 查詢帳戶被鎖定時間方式:
    /*  修改時間顯示格式,方便閱讀。 */
    alter session set nls_date_format = 'yyyy-MM-dd hh24:mi:ss' ; 
   /* 查詢帳號被鎖定的時間 */
   SELECTusername,lock_date FROM dba_users WHERE username like '帳號' ;

3. 解除帳號的鎖定:
    alter user MyAccunt account unlock ;
 
 

2017年6月21日 星期三

Delphi 判斷字串是否為中文字

可以透過 ByteType函式來判斷字串的內容,藉以辨識每個字節的型態。

function ByteType(const S: AnsiString; Index: Integer): TMbcsByteType;
function ByteType(const S: UnicodeString; Index: Integer): TMbcsByteType;

回傳內容:
mbSingleByte : 單字節字串
mbLeadByte   : 雙字節(中文字)字串的第一個字符
mbTrailByte  : 雙字節(中文字)字串的第二個字符

範例:
var
  Str, S1,S2 : String ;    // AnsiString
  I : integer ;
begin
  Str := '12判ew斷dd某一ccc個111' ;
  S1 := '' ;
  S2 := '' ;
  for I := 1 to Length(Str) do
  begin
    if ByteType(Str,I) = mbSingleByte then
      S1 := S1 + Str[I]
    else
    if ByteType(Str,I) in [mbLeadByte,mbTrailByte] then
      S2 := S2 + Str[I] ;

  end;
  // 輸出結果
  S1 -->  12ewddccc111
  S2 -->  判斷某一個
end ;

2017年2月7日 星期二

PowerShell 將主機設定允許遠端管理

PowerShell 將主機設定允許遠端管理

要使用PowerShell進行遠端主機管理時,被管理端必須要允許可以進行遠端管理,可以參考下列網址說明:
https://technet.microsoft.com/en-us/library/ff700227.aspx

節錄該網站部分內容如下:

You can verify the availability of WinRM and configure a PowerShell for remoting by following these steps: 
1. Start Windows PowerShell as an administrator by right-clicking the Windows PowerShell shortcut and selecting Run As Administrator. 

2. The WinRM service is confi gured for manual startup by default. You must change the startup type to Automatic and start the service on each computer you want to work with. At the PowerShell prompt, you can verify that the WinRM service is running using the following command: 
get-service winrm
The value of the Status property in the output should be “Running”.

3. To configure Windows PowerShell for remoting, type the following command: 
Enable-PSRemoting –force

In many cases, you will be able to work with remote computers in other domains. However, if the remote computer is not in a trusted domain, the remote computer might not be able to authenticate your credentials. To enable authentication, you need to add the remote computer to the list of trusted hosts for the local computer in WinRM. To do so, type: 
winrm s winrm/config/client '@{TrustedHosts="RemoteComputer"}'
Here, RemoteComputer should be the name of the remote computer, such as: 
winrm s winrm/config/client '@{TrustedHosts="CorpServer56"}'


另外,若是執行上述程序後,遠端連結到主機端,還是會出現 Access is denied (拒絕存取),很有可能是UAC的因素,依據網路上找到的說明,若是主機有啟用UAC,遠端連線控制所使用的帳戶,若是網域帳戶,且在Administrators群組,則不受影響,但若使用的帳戶是屬於LocalAccount,則UAC不允許遠端訪問WinRM服務,若需要使用,則需要建Registry中建置下列值DWORd設定為1,以允許LocalAccount執行WinRM服務

[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System] LocalAccountTokenFilterPolicy

或者透過系統管理員身分執行CMD,輸入下列指令新增Registry參數:

reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f" and then "winrm quickconfig


2016年10月18日 星期二

連線遠端主機-PowerShell

透過PowerShell可以連線到遠端主機進行維護,要連線到遠方主機,除了遠端主機要允許執行外,連線時所使用的帳號也不需要再Administrators群組內才行。
若要連線至遠端主機時,必須要先進行認證,一般可以採取下列做法來執行。

1. 先建立認證物件。

$username = "your account"
$password = "your password" | ConvertTo-SecureString -asPlaintext -Force    
$servername = "your ServerName or IP"
$credential = New-Object System.Management.Automation.PSCredential($username, $password)

2. 透過以建立之認證物件,連線至遠端主機進行維護,例如透過WMI的Win32_UserAccount來取得遠端主機帳號清單,如下:

Get-WmiObject -Class Win32_UserAccount -ComputerName $servername -Credential $credential


PowerShell更改網路類型

1. 開啟Powershell,輸入Get-NetConnectionProfile , Enter後,可以看到目前作用中網路的網路類型。


NetworkCategory欄位中便是目前嘎網卡的網路狀態,目前是Publie(公用網路)

2. 若要變更網路類型,可以透過Set-NetConnectionProfile指令來執行,如下範例:

    Set-NetConnectionProfile  -InterfaceIndex 9 -NetworkCategory Private ,Enter後,便將該網路類型更改為(私人網路)。

    注意,InterfaceIndex的參數值,需要參考實際網路類型中顯示的數值。