關於網路那些事...

Marketing, SEO, Web trends, Programming tutorial, Web design, and Life event...

介面 Interface

Interface

Interface 類別主要用於定義一些關鍵字及 public 的抽象方法,不需要定義方法的 body 及參數。

<?php
interface Logger{
    public function excute();
}

首先,針對未使用 Interface 的情況進行說明,

如果在大型專案只有使用 Class,例如以下範例,當我們要切換不同的 Log 方式時,就要透過手動方式在多處 constructor 處進行 hard-coded 變更,例如

<?php

class LogToDatabase {
    public function execute($message)
    {
        var_dump('log the message to a database :'.$message);
    }
}

class LogToFile {
    public function execute($message)
    {
        var_dump('log the message to a file :'.$message);
    }
}

class UsersController { 
    protected $logger;
    
    public function __construct(LogToFile $logger)
    {
        $this->logger = $logger;
    }
    
    public function show()
    { 
        $user = 'nahid';
        $this->logger->execute($user);
    }
}

$controller = new UsersController(new LogToFile);
$controller->show();

例如,目前在 UsersController 使用 LogToFile,

Continue Reading

Synology NAS 架站:如何設定 proxy 將對外 80 port 轉導到指定 Docker 服務

Synology NAS 設定 proxy 將對外 80 port 轉導到指定 Docker 服務

在 NAS 建立對外網站,通常會使用 proxy 方式來做轉導

本篇會預設你已經對於 Docker, NAS 有基礎的了解,並且知道如何在 NAS 新增 Docker 服務,以及設定網域指向的知識。

Continue Reading

Synology NAS 變更 預設 80 port 的方式

Synology NAS 變更 預設 80 port 的方式

Synology NAS 預設都會使用 80 port,且會轉導到 500x port

這裡將說明如何變更 80 port 。

變更 Synology 預設 80 port 的方式很簡單

首先 ssh 登入到 NAS

接著,修改 nginx 設定

vi /usr/syno/share/nginx/WWWService.mustache
vi /usr/syno/share/nginx/DSM.mustache
vi /usr/syno/share/nginx/server.mustache

接著 重啟服務

synoservicecfg --restart nginx

Continue Reading

[解決] GitLab 強制 push 到 master 出現錯誤 You are not allowed to force push...

[解決] GitLab 強制 push 到 master 出現錯誤 You are not allowed to force push…

在 GitLab 強制 push 到 master 時,

git push -f origin master

出現錯誤訊息:

remote: GitLab: You are not allowed to force push code to a protected branch on this project.

Continue Reading

Laravel 6.5 版本發佈功能

Laravel 6.5 版本發佈功能

LazyCollection

LazyCollection 可以調用 Memy() ,能記取計算過的值,在運算大數據過程,能避免大量消耗內存的狀況。

範例:

<?php ...
$users = User::cursor()->remember();

// No query has been executed yet.

$users->take(5)->all();

// The query has been executed, and the first 5 users have been streamed from the DB.

$users->take(20)->all();

// The first 5 users came from the cache. The rest continued the stream from the DB.

String Helper - afterLast(), beforeLast()

afterLast 可以取得字串中,“最後一個”指定字符 之後的文字

beforeLast 可以取得字串中,“最後一個”指定字符 之前的文字

Continue Reading

CentOS 設置靜態IP 方法

CentOS 預設是使用 DHCP 自動取得IP,因此IP位置會浮動,在假設主機來說,不太適合。

這裡說明如何將 IP 位置設定為靜態固定 IP :

Continue Reading

Vue - VSCode 基本配置 ESLine & Prettier 代碼自動風格化

Vue - VSCode 基本配置 ESLine & Prettier 代碼自動風格化

這裡記錄 Vue 初始設定會用到的一些基本設定

包括語法亮潔以及代碼自動風格化設定.

另外會提到如何在 VSCode settings.json 設定儲存自動將語法進行整理,風格化

Continue Reading

Terminal 複製 貼上 past 會出現 "00~" "01~" 或 "0~" "1~" 解決方式

在Terminal 使用vim 之後,若出現複製貼上會出現 00~, 01~0~, 1~

原因可能是你的Terminal 正處於bracketed黏貼模式( bracketed paste mode)

在一些尚未更新或較為老舊的terminal可能會出現00~ 01~ 的字段

解決方式是直接透過以下語法將 bracketed paste mode 關閉

printf "\e[?2004l"

Continue Reading

ElasticSearch 入門 - 功能及操作說明

ElasticSearch 入門 - 功能及操作說明

ElasticSearch 可以把數據透過 Index 索引的方式來儲存。

通常,一台機器可以運行多個 ElasticSearch,每一個都視為一個節點(Node)。

在 ElasticSearch 主要結構與關聯資料庫做對比的話,關係大致如下:

ElasticSearch 關聯資料庫
索引(Index) 資料庫(Database)
類型(Type) 資料表(Table)
文檔(Document) 數據行紀錄(Row)
域(Field) 數據列(Column)
參數映射(Mapping) 模式(Schema)

Continue Reading

Laradock 本地 local 環境新增 SSL Keygen 方式,及設定 Nginx 支援 Https

Laradock 本地 local 環境新增 SSL Keygen 方式,及設定 Nginx 支援 Https

在內部測試機測試瀏覽器錄音功能需要用到 Https,在這裡記錄如何在 localhost 環境安裝憑證及設定 https

Continue Reading

解決 GCP storage 取得資料發生 blocked by CORS policy

解決 GCP storage 取得資料發生 blocked by CORS policy

透過 GCP Storage 儲存檔案,在前端呈現時出現了 CORS 問題

錯誤訊息: Access to fetch at url from origin url has been blocked by CORS policy: NO ‘Access-Control-Allow-Origin’ header is present on the requested resource. …

原因是在於,GCP Storage 為了預防惡意取用而預設不開啟。

這裡紀錄如何透過 Gsutil 開啟 GCP storage 跨域請求

Continue Reading

Git - 無法偵測修改檔案或資料夾大小寫,解決方式

Git - 無法偵測修改檔案或資料夾大小寫,解決方式

在某些作業系統,Git 會忽略檔名或資料夾名稱大小寫。這樣的設定會造成在同專案若修改檔案或資料夾大小寫,在執行 ```git

針對這狀況有幾個建議做法

Continue Reading

總彙整 PHPStorm 快捷鍵(Mac, Linux, Mac)

總彙整 PHPStorm 快捷鍵(Mac, Linux, Mac)

Mac 符號

符號 解釋
Command
Shift
Control
Enter/Return
Option / Alt

Continue Reading

解決 push 發生 Someone has already registered that SSH key 問題

解決 push 發生 Someone has already registered that SSH key 問題

在 Bitbucket 設定 ssh 如果沒有在帳號 ssh 綁定,而是直接在 repository 綁定

但是,直接綁定在 Repository 的 SSH key ,該組 Key 只能用於 pull ,不能執行 push。

在後續維護專案需要在帳號綁定 ssh 時,會出現以下警示

Someone has already registered that SSH key

Continue Reading

中國區域 Zoom 問題排解

在中国的 Zoom 软件安装后,会分别有国内及国外两种选项,在近期因中国国家安全政策,考量Zoom 软件对外沟通方面因为无法确定是谁对国外发起会议,因此进行屏蔽。针对这个变动,在第一时间进行处理,帮助排除问题的解决方式进行纪录

Q: 如何确保软件有更新?

请检查相关装置的 Zoom 版本有高于以下版本: Windows 软件: 5.0.41687.0910 Apple 软件: 5.0.41687.0910 苹果 APP Store: 4.5.2 安卓: 4.5.3

Q: 如何卸载 Zoom 软件?

可以点选 Windows > 控制面板 > 卸载程序 > 在软件滑鼠右键点击出现卸载弹窗 > 点击卸载

https://jingyan.baidu.com/article/5d368d1eb2270f3f60c057b0.html

Q: 去哪儿下载Zoom 软件?

首先,卸载本地的 Zoom 软件,前往官方下载最新软件。 下载安装 Zoom : https://www.zoomvip.cn/download.html

Q: 遇到 Zoom 无法进入会议时,怎么办?

(1) 请家长提供 Zoom 软件登入会议的画面。 (2) 使用的装置型号,在提供给技术判断。 (3) 询问家长是否有其他装置可以先进入会议。

Q: 学生无法听到学霸声音?

(1) 请家长提供 Zoom 软件登入会议的画面。 (2) 手机或平板请检查是否关到静音键。 (3) 桌机请开启扬声器设置,检查 Zoom 软件扬声器是否开启。 (4) 询问家长是否有其他装置可以先进入会议。

Continue Reading

解決 Vim 貼上後,格式跑掉問題

Vim 如果直接接上代碼,出現格式跑掉(自動縮排)

則可透過以下方式解決

關閉縮排

:set paste

如果要開啟縮排,可以輸入

:set nopaste

Continue Reading

Laravel 上線環境設定

Laravel 上線環境設定

這裡記錄一下 Laravel專案上線常用設定

Continue Reading

推薦幾個 Python 深度學習入門 Libraries

推薦幾個 Python 深度學習入門 Libraries

最近在研究語音辨識,順帶看了一下 Python,這裡大概就介紹一下在學習 Python 深度學習推薦入門的幾個 Libraries。

簡介

Python 運用在深度學習算相當具有優勢,支援的 libraries 相當豐富,在這裡推薦幾個 Libraries ,進行介紹。

在了解及初次熟悉這些 Libraries 時,建議可以透過以下方式:

  • 透過 Jupyter Notebook 來引入 Library
  • 一步步的跟著文檔中的快速起步流程,先理解方向
  • 用30分鐘來閱讀文檔,來確實理解 Library 的 modules 用法

如果是透過 Anaconda 啟用 Jupyther Notebook ,則可以參考這部影片 https://www.youtube.com/watch?v=-MyjG00la2k

Continue Reading

推薦幾個 Python 資料科學計算入門 Libraries

推薦幾個 Python 資料科學計算入門 Libraries

最近在研究語音辨識,順帶看了一下 Python,這裡大概就介紹一下在學習 Python 資料科學計算推薦入門的幾個 Libraries。

簡介

Python 運用在科學資料計算相當具有優勢,支援的 libraries 相當豐富,在這裡推薦幾個 Libraries ,進行介紹。

在了解及初次熟悉這些 Libraries 時,建議可以透過以下方式:

  • 透過 Jupyter Notebook 來引入 Library
  • 一步步的跟著文檔中的快速起步流程,先理解方向
  • 用30分鐘來閱讀文檔,來確實理解 Library 的 modules 用法

如果是透過 Anaconda 啟用 Jupyther Notebook ,則可以參考這部影片 https://www.youtube.com/watch?v=-MyjG00la2k

Continue Reading

Centos7 新增靜態路由的幾種方法

Centos7 新增靜態路由的幾種方法

方法一、直接設定路由

vim cd /etc/sysconfig/network-scripts/route-eno1

增加內容

Continue Reading