2020年12月17日 星期四

時間是最珍貴的資源

時間是最珍貴的資源,不能管理時間,便什麼也無法管理。
Time is the scarcest resource and unless it is managed nothing else can be managed.
—— 彼得.杜拉克 - 管理學之父

2020年12月10日 星期四

Java system properties and environment variables

  • System properties are set on the Java command line using the -Dpropertyname=value syntax. They can also be added at runtime using System.setProperty(String key, String value) or via the various System.getProperties().load() methods.
    To get a specific system property you can use System.getProperty(String key) or System.getProperty(String key, String def).
  • Environment variables are set in the OS, e.g. in Linux export HOME=/Users/myusername or on Windows SET WINDIR=C:\Windows etc, and, unlike properties, may not be set at runtime.
    To get a specific environment variable you can use System.getenv(String name).

2020年12月3日 星期四

2020年11月8日 星期日

Windows 10 Clipboard 功能

Oreilly 程式設計師提升生產力秘笈一書有有提到CLICLI 剪貼簿可以看到歷史紀錄。Windows 10 也支援這個功能了.

 

image

可以按快捷鍵 Windows+V 開啟剪貼簿

image

2020年11月2日 星期一

MySQL relay-bin log error

MySQL Replication Server , 因空間滿了, 導致MySQL 無法登入.

這應該持續一段時間了, 檢查之後發現是 relay-bin log 滿了。

應該是年中時, 有大量的刪除及UPDATE 資料關係。

所以Replication 要重建。因為空間滿了無法啟動MYSQL, 所以只能刪掉一些檔案, 重啟slave 時發現下列錯誤.

ERROR 29 (HY000): File './#####-relay-bin.001416' not found (Errcode: 2 - No such file or directory)

 

處理方法

1. stop slave

2. reset slave

3. rm *.relay-bin*

4. restart mysql

5. CHANGE MASTER TO MASTER_HOST….略

6. start slave

 

完成收工.

2020年11月1日 星期日

Export SQL Server Agent Jobs

You can do all your Agent jobs in one go fairly easy:

1. Click on the "Jobs" section in the SQL Agent in SSMS

2. Hit the F7 key on your keyboard (opens the Object Explorer Details)

3. Highlight the jobs you want to export in the Object Explorer Details

4. Right-click the highlighted jobs and "Script Job As..." like you would for a single job

2020年10月25日 星期日

Eclipse Library Folder ClasspathContainer

Eclipse 設定資料夾下的jar files 為CLASSPATH

image

 

Name:Library Folder ClasspathContainer

Location:http://libcontainer.sourceforge.net/updates/

image

image

image

imageimageimageimageimage

image

 

 

 

 

image

 

image

 

 

image

2020年10月21日 星期三

Centos 7+ 停用網卡自動命名

已經很習慣使用ifcfg-eth0 來定義預設網卡,

自Centos 7 之後, 會自動命名網卡名稱, 非常不習慣.

 

解決這個方法可以在安裝Centos 7或8時, 多輸入下列的命令

net.ifnames=0 biosdevname=0

image

image

如此即可。

2020年10月13日 星期二

Eclipse java 8 latest version

目前Eclipse 出到2020-09 版,但必須使用JAVA 11 才可運作

 

這個連結 https://wiki.eclipse.org/Eclipse/Installation 可看到需要的JAVA版本。

最後一個支援JAVA 8 的Eclipse 4.16版(2020-06)

image

2020年10月8日 星期四

Java 正規表示式 (?s)

最近在作Tableau API response XML String parse.

找到這個Sample 可以把指定的Tag 過濾掉.

xml = xml.replaceFirst("(?s)]*>.*?</tagname[^>","");

不了解(?s) 的意思. 請Google 大神幫忙

  • (?i) makes the regex case insensitive.

  • (?s) for "single line mode" makes the dot match all characters, including line breaks.

  • (?m) for "multi-line mode" makes the caret and dollar match at the start and end of each line in the subject string.

(?s) equals Pattern.DOTALL

    2020年10月7日 星期三

    程式碼格式測試



    package com.melin.lab01;
    
    import java.time.Duration;
    import java.time.LocalDateTime;
    import java.time.format.DateTimeFormatter;
    
    public class LocalDateTime01 {
    	public static void main(String[] args) {
    		String startedAtStr = "2020-09-07T19:32:35Z";
    		String endedAtStr = "2020-09-07T19:32:48Z";//結束時間
    		String format = "yyyy-MM-dd'T'HH:mm:ss'Z'";
    		LocalDateTime now = LocalDateTime.now();
    		DateTimeFormatter df = DateTimeFormatter.ofPattern(format);
    		System.out.println(now);
    		LocalDateTime startedAt = LocalDateTime.parse(startedAtStr, df);
    		LocalDateTime endedAt = LocalDateTime.parse(endedAtStr, df);
    		Duration secs = Duration.between(startedAt, endedAt);
    		
    		System.out.println(secs.getSeconds());
    	}
    }
    
    
    package com.melin.lab01;
    import java.time.Duration;
    import java.time.LocalDateTime;
    import java.time.format.DateTimeFormatter;
    
    public class LocalDateTime01 {
    	public static void main(String[] args) {
    		String startedAtStr = "2020-09-07T19:32:35Z";
    		String endedAtStr = "2020-09-07T19:32:48Z";//結束時間
    		String format = "yyyy-MM-dd'T'HH:mm:ss'Z'";
    		LocalDateTime now = LocalDateTime.now();
    		DateTimeFormatter df = DateTimeFormatter.ofPattern(format);
    		System.out.println(now);
    		LocalDateTime startedAt = LocalDateTime.parse(startedAtStr, df);
    		LocalDateTime endedAt = LocalDateTime.parse(endedAtStr, df);
    		Duration secs = Duration.between(startedAt, endedAt);
    		
    		System.out.println(secs.getSeconds());
    	}
    }
    

    Linux mount Windows shared folder

    AP Server需要mount Windows shared folder

    環境為Linux Centos 5.*

     

    mkdir /mnt/devmnt

    mount -t cifs -o username="administrator",password="********" //IP/Desktop /mnt/devsmb

     

     

    Docker 常用指令

    Container指令基礎

    Docker有關Container的指令是最多樣的,而光一個docker run就有非常非多的參數。我們在這邊先將最基本的Container指令列出,讓讀者們能先能感受一下Docker的強大。

    這邊列出Docker有關Container指令的分類方便讀者查詢,粗體表示常用指令,會有講解說明。

    Container和映像檔之間的操作
    • commit:將Container的改變存入映像檔
    • export:將Container存成快照
    • import:從Container快照恢復成映像檔
    Container執行時的操作
    • create:建立Container並執行指令
    • run:同create
    • kill:刪除執行中的Container,但Container還是存在,只是死了。
    • rm:刪除Container(停止或運行中都行),Container就從這世上消失了
    • pause:暫停執行中的Container,仍暫有記憶體停,服務不中斷
    • unpause:恢復暫停中的Container
    • stop:停止執行中的Container,但不暫有記憶體,服務中斷
    • start:啟動停止中的Container
    • restart:重新啟動Container
    • wait:讓Container暫停直到Container停止為止
    • rename:更名Container
    Container的狀態
    • inspect:檢查Container的狀態(非常常用)
    • stats:查看Container的CPU、記憶體及網路使用
    • port:查看Container的通訊埠使用
    • ps:查看Container使用狀態
    • top:查看Container在主系統中的記憶體使用
    • dip:查看Container的IP
    • dpid:查看Container的pid
    Container執行時的操作
    • attach:連接Container的標準輸出輸入端
    • exec:在外部向Container內執行指令
    • denter:進入Container
    • logs:將Container內的輸出顯示到螢幕上
    Container和主系統之間的操作
    • cp:複製Container內的檔案到主系統
    • diff:列出兩個Container之間檔案系統差異
    • events:列出某個時間點之前或之後的事件
    和Linux的指令配合使用

    Docker的執行常常和Linux的內部指令配合使用,如grepawkxargs等,會在需要的時候提及。下面的例子就是列出所有Container的狀態(docker stats預設只會列出指定Container的狀態)。

    docker ps | awk 'NR>1 {print $NF}'| xargs docker stats

    $ docker stats $(docker ps | awk 'NR>1 {print $NF}')
    CONTAINER           CPU %               MEM USAGE/LIMIT     MEM %               NET I/O
    web12               0.00%               8.742 MiB/128 MiB   6.83%               131.2 KiB/150.8 KiB
    web14               0.01%               38.43 MiB/128 MiB   30.02%              181.6 KiB/211.9 KiB

    Open Live Writer TEST

    以Open Live Writer 上稿測試

     

    貼一張圖
    image

    2020年6月21日 星期日

    Eclipse String equals( 自動變為 contentEquals(

    最新使用新版的Eclipse 遇到一個問題
    When I type somestring.equals( , auto change to somestring.contentEquals(
    "Java Proposals (Task-Focused)" checked in Preferences > Java > Editor > Content Assist > Advanced?

    If so, please try disabling it and using the official "Java Proposals" instead.


    Ads

    Seo Services