2018/6/18

Java讀檔、寫檔

最少行數的寫檔:
private static void writeUsingFiles(String data) {
        try {
            Files.write(Paths.get("/Users/pankaj/files.txt"), data.getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
}

最少行數的讀檔:
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

    public static void main(String[] args) throws IOException {
        String content = new String(Files.readAllBytes(Paths.get("duke.java")));
    }

參考:
讀檔:
http://www.adam-bien.com/roller/abien/entry/java_8_reading_a_file
寫檔:
https://www.journaldev.com/878/java-write-to-file

2018/6/17

於Netbeans的Spring Boot重新載入程式

之前用Servlet開發,只要有改程式它就會重新載入,就不用重新部署重新啟動
現在換到Spring Boot發現竟然不會自動重載程式,每次一改程式就要整個重新啟動
於是找到了以下的連結,教你怎麼讓他自動重載程式:
http://sanprojects.eu/blog/spring-boot-hotswapping-with-netbeans

2018/6/10

FCF-手機選購案例的Flow

[
    {
        "id":"5496536b.ed791c",
        "type":"FCF-facebook-receive",
        "z":"9fdb8a20.7c04d8",
        "bot":"d43caf60.461aa",
        "x":90,
        "y":160,
        "wires":[
            [
                "15cd9267.0a04de"
            ]
        ]
    },
    {
        "id":"15cd9267.0a04de",
        "type":"FCF-DataCollection",
        "z":"9fdb8a20.7c04d8",
        "rules":[
            {
                "topic":"請問你要什麼品牌",
                "topic2":"brand"
            },
            {
                "topic":"請問你預算多少",
                "topic2":"price"
            }
        ],
        "collect":"query",
        "x":280,
        "y":160,
        "wires":[
            [
                "d636c838.51bf18"
            ],
            [
                "e62c9a56.7fd688"
            ]
        ]
    },
    {
        "id":"d636c838.51bf18",
        "type":"FCF-Message",
        "z":"9fdb8a20.7c04d8",
        "name":"",
        "message":[

        ],
        "answer":false,
        "track":false,
        "parse_mode":"",
        "x":460,
        "y":120,
        "wires":[
            [
                "a49695f.5ecca68"
            ]
        ]
    },
    {
        "id":"a49695f.5ecca68",
        "type":"FCF-facebook-send",
        "z":"9fdb8a20.7c04d8",
        "bot":"d43caf60.461aa",
        "track":true,
        "outputs":1,
        "x":620,
        "y":120,
        "wires":[
            [
                "5307cb55.73b9d4"
            ]
        ]
    },
    {
        "id":"e62c9a56.7fd688",
        "type":"FCF-Frame",
        "z":"9fdb8a20.7c04d8",
        "rules":[
            {
                "topic":""
            }
        ],
        "name":"1",
        "token":"",
        "outputs":1,
        "x":460,
        "y":200,
        "wires":[
            [
                "6ba01cd8.7e8a64"
            ]
        ]
    },
    {
        "id":"6ba01cd8.7e8a64",
        "type":"FCF-PullService",
        "z":"9fdb8a20.7c04d8",
        "rules":[
            {
                "topic":""
            }
        ],
        "URL":"https://script.google.com/macros/s/AKfycbwLxGc9PIFVK79F4dYbnt0zOBkesEvzPn8VvSt6CxtU0RQu2g/exec",
        "outputs":1,
        "x":610,
        "y":200,
        "wires":[
            [
                "515cb02.2a24b5"
            ]
        ]
    },
    {
        "id":"515cb02.2a24b5",
        "type":"FCF-Frame",
        "z":"9fdb8a20.7c04d8",
        "rules":[
            {
                "topic":""
            }
        ],
        "name":"1",
        "token":"",
        "outputs":1,
        "x":760,
        "y":200,
        "wires":[
            [
                "b3f912b.d4275f"
            ]
        ]
    },
    {
        "id":"b3f912b.d4275f",
        "type":"FCF-Message",
        "z":"9fdb8a20.7c04d8",
        "name":"",
        "message":[
            ""
        ],
        "answer":false,
        "track":false,
        "parse_mode":"",
        "x":900,
        "y":200,
        "wires":[
            [
                "767684e9.91a16c"
            ]
        ]
    },
    {
        "id":"767684e9.91a16c",
        "type":"FCF-facebook-send",
        "z":"9fdb8a20.7c04d8",
        "bot":"d43caf60.461aa",
        "track":true,
        "outputs":1,
        "x":1060,
        "y":200,
        "wires":[
            [
                "2ff8e685.c26d3a"
            ]
        ]
    },
    {
        "id":"f13f1278.b11e4",
        "type":"FCF-KeywordExtraction",
        "z":"9fdb8a20.7c04d8",
        "agentCredentials":"15994b6e.a30be5",
        "outputs":1,
        "x":270,
        "y":240,
        "wires":[
            [
                "e62c9a56.7fd688"
            ]
        ]
    },
    {
        "id":"8f304000.4203f",
        "type":"FCF-DataCollection",
        "z":"9fdb8a20.7c04d8",
        "rules":[
            {
                "topic":"請問您的姓名是?",
                "topic2":"name"
            },
            {
                "topic":"請問您的電話是?",
                "topic2":"phone"
            }
        ],
        "collect":"userData",
        "x":260,
        "y":340,
        "wires":[
            [
                "afab121e.cd96b"
            ],
            [
                "5af7e5f6.9ae44c"
            ]
        ]
    },
    {
        "id":"afab121e.cd96b",
        "type":"FCF-Message",
        "z":"9fdb8a20.7c04d8",
        "name":"",
        "message":[
            ""
        ],
        "answer":false,
        "track":false,
        "parse_mode":"",
        "x":440,
        "y":300,
        "wires":[
            [
                "fe813dc.0132fc"
            ]
        ]
    },
    {
        "id":"fe813dc.0132fc",
        "type":"FCF-facebook-send",
        "z":"9fdb8a20.7c04d8",
        "bot":"d43caf60.461aa",
        "track":true,
        "outputs":1,
        "x":620,
        "y":300,
        "wires":[
            [
                "698d1187.bd9b3"
            ]
        ]
    },
    {
        "id":"5af7e5f6.9ae44c",
        "type":"FCF-Frame",
        "z":"9fdb8a20.7c04d8",
        "rules":[
            {
                "topic":""
            }
        ],
        "name":"",
        "token":"",
        "outputs":1,
        "x":430,
        "y":380,
        "wires":[
            [
                "71c4de3e.63505"
            ]
        ]
    },
    {
        "id":"71c4de3e.63505",
        "type":"FCF-PullService",
        "z":"9fdb8a20.7c04d8",
        "rules":[
            {
                "topic":""
            }
        ],
        "URL":"https://script.google.com/macros/s/AKfycbw9QggKKq1JWmztN77EetPqo2w_aJBQER7Db13D4oBtdDaym2w/exec",
        "outputs":1,
        "x":610,
        "y":380,
        "wires":[
            [
                "806472e2.41f9"
            ]
        ]
    },
    {
        "id":"806472e2.41f9",
        "type":"FCF-Message",
        "z":"9fdb8a20.7c04d8",
        "name":"",
        "message":[
            ""
        ],
        "answer":false,
        "track":false,
        "parse_mode":"",
        "x":780,
        "y":380,
        "wires":[
            [
                "c8fadff.3ea792"
            ]
        ]
    },
    {
        "id":"c8fadff.3ea792",
        "type":"FCF-facebook-send",
        "z":"9fdb8a20.7c04d8",
        "bot":"d43caf60.461aa",
        "track":false,
        "outputs":0,
        "x":940,
        "y":380,
        "wires":[

        ]
    },
    {
        "id":"f7a039cb.dffd28",
        "type":"link in",
        "z":"9fdb8a20.7c04d8",
        "name":"",
        "links":[
            "5307cb55.73b9d4"
        ],
        "x":135,
        "y":100,
        "wires":[
            [
                "15cd9267.0a04de"
            ]
        ]
    },
    {
        "id":"5307cb55.73b9d4",
        "type":"link out",
        "z":"9fdb8a20.7c04d8",
        "name":"",
        "links":[
            "f7a039cb.dffd28"
        ],
        "x":735,
        "y":120,
        "wires":[

        ]
    },
    {
        "id":"1f54dcb8.8e7603",
        "type":"link in",
        "z":"9fdb8a20.7c04d8",
        "name":"",
        "links":[
            "c2790c.9a1a06f8"
        ],
        "x":135,
        "y":280,
        "wires":[
            [
                "f13f1278.b11e4"
            ]
        ]
    },
    {
        "id":"c2790c.9a1a06f8",
        "type":"link out",
        "z":"9fdb8a20.7c04d8",
        "name":"",
        "links":[
            "1f54dcb8.8e7603"
        ],
        "x":1355,
        "y":160,
        "wires":[

        ]
    },
    {
        "id":"d5a46457.00c978",
        "type":"link in",
        "z":"9fdb8a20.7c04d8",
        "name":"",
        "links":[
            "698d1187.bd9b3",
            "127d20a0.79f2df"
        ],
        "x":135,
        "y":340,
        "wires":[
            [
                "8f304000.4203f"
            ]
        ]
    },
    {
        "id":"127d20a0.79f2df",
        "type":"link out",
        "z":"9fdb8a20.7c04d8",
        "name":"",
        "links":[
            "d5a46457.00c978"
        ],
        "x":1355,
        "y":240,
        "wires":[

        ]
    },
    {
        "id":"2ff8e685.c26d3a",
        "type":"FCF-Dispatcher",
        "z":"9fdb8a20.7c04d8",
        "agentCredentials":"15994b6e.a30be5",
        "rules":[
            {
                "topic":"returnPhoneBrand"
            },
            {
                "topic":"returnthePhoneItsGood"
            }
        ],
        "outputs":2,
        "x":1230,
        "y":200,
        "wires":[
            [
                "c2790c.9a1a06f8"
            ],
            [
                "127d20a0.79f2df"
            ]
        ],
        "outputLabels":[
            "2",
            ""
        ]
    },
    {
        "id":"698d1187.bd9b3",
        "type":"link out",
        "z":"9fdb8a20.7c04d8",
        "name":"",
        "links":[
            "d5a46457.00c978"
        ],
        "x":735,
        "y":300,
        "wires":[

        ]
    },
    {
        "id":"d43caf60.461aa",
        "type":"FCF-facebook-node",
        "z":"",
        "botname":"PhoneBot"
    },
    {
        "id":"15994b6e.a30be5",
        "type":"FCF-DialogflowConfig",
        "z":"",
        "agentName":"\bSmartphoneBuyBot"
    }
]

2018/6/4

Javascript的物件

覺得這篇寫得蠻好的
https://developer.mozilla.org/zh-TW/docs/Learn/JavaScript/Objects/Basics
常常對js物件中的dot notation與bracket notation感到陌生、不解

2018/6/2

於Ubuntu 18.04安裝nginx與php-fpm與phpmyadmin

安裝的nginx為1.14.0版
安裝的phpmyadmin為4.8.1版
安裝的php-fpm為7.2版