關於網路那些事...

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

MySQL 鎖簡述

MySQL 鎖簡述

MySql 主要的鎖可以分為幾種類型:

MyISAM與 InnoDB 都支援表級別與行級別鎖: X 鎖、 S 鎖

InnoDB的表級別鎖:IX鎖、IS 鎖

Continue Reading

MySQL 主從式讀寫分離

MySQL 主從式讀寫分離

MySQL 在操作資料庫的部署方式,其中一種是採取主從式讀寫分離的方式處理。

主(master) 主要用於寫入資料,從(Slave)主要進行讀取。在一般情況,資料庫採取這樣的方式與傳統單一部署方式並不會有太大的差異,但是在百萬等級的操作時,就可以明顯的分擔資料庫的處理程序。

原因在於資料庫在寫入相關操作速度會有 X鎖及 S 鎖的競爭關係,速度較慢。

Continue Reading

PHP Unittest Mockery in Laravel

Singleton In laravel we usually use IoC to build our application, when we call one Class, all dependency in this class will involed. For testing this class, we can defined depencency in service container as singleton.

Continue Reading

PHP Unittest - An example of PHP Unittest in Laravel framework, include unit test and exception test

In this article, we will show an example of PHP Unittest in Laravel framework, include unit test and exception test.

Continue Reading

Getting started with PHP UnitTest

This article will introduce how to write a unit test. IDE is using Visual Studio Code.

Continue Reading

Apache 及 Nginx 主機設置 phpMyAdmin 訪問白名單方法

主機設置 phpMyAdmin 訪問白名單

正式網站使用 phpMyAdmin 建議一定要限制允許IP來源,避免目錄被訪問

這裡說明如何透過 Web Server 端來設置允許白名單

(建議!盡可能的不要使用 phpmyadmin)

Continue Reading

Laravel 5.8.18-17 新擴充功能說明

Laravel 5.8.18-17 新擴充功能說明

這裏分別針對 Laravel 5.8 (至今年五月)所發佈的一些功能項目進行說明,關於完整的發布紀錄可以參考這裡:

[v5.8.18](https://laravel-news.com/laravel-5-8-18?utm_medium=email&utm_campaign=Laravel v5818 Laracon Australia 2019 PHP Array Redactor and more - 258&utm_content=Laravel v5818 Laracon Australia 2019 PHP Array Redactor and more - 258+CID_a921ac9032531484d27f82e90d45f469&utm_source=email marketing&utm_term=Read More)

v5.8.17

或者參閱完整的 v5.8 更新歷程

Continue Reading

Laravel - PHP Insights

PHP Insights 介紹

PHP Insights 可以用來分析PHP專案的程式品質,可以很簡單的方式從 terminal 直接進行分析。

支援 PHP 7.2+ 以上版本。 並且適用於 Laravel, Symfony, Yii, WordPress, Magento2, 等架構。

這裏主要針對 安裝及 Laravel 使用方式進行說明。

Continue Reading

Laravel - Request Lifecycle

Laravel - Request Lifecycle

簡單整理一下 Laravel request 的生命週期

Continue Reading

Laravel 測試使用 SQLite 配置方式

Laravel 測試環境使用 in Memory DB - SQLite

在執行 phpunit 時,透過 sqlite 可以快速的執行測試,而避免掉需要建立關聯資料庫的流程

在 Laravel 設置方式如下

設置 .env.testing

將資料庫連線設定為 sqlite,以及

DB_CONNECTION=sqlite
DB_HOST=localhost
DB_PORT=8000
DB_DATABASE=':memory:'

Continue Reading

NodeJs 在正式環境運行的對應方式

在這裡要探討關於 node 到底適不適合在正式環境運行,在一開場首先說明我**“過去”**對於這個問題的看法,答案是:不適合。

原因在於,過去有見過幾個專案是由 node 開發,最終都因為穩定性不佳造成極大的損失的案例

當然,這經驗確實是我常建議團隊不要輕易決定使用 node 的原因。

事實上,為什麼 node 不適合在正式環境運行。針對這個問題其實真的探討過的人很少。

這裡參考 Burke Holland 所彙整的一些方法,進行來聊聊這個議題:

首先,關於造成 node 不適合的一些狀況進行探討:

如果透過 Express server 直接運行主機環境

Continue Reading

Docker daemon startup failed [解決]

目前使用 mac 本機直接安裝的 Dockder 環境,但就在近期運行 Docker 會發生了 Docker daemon startup failed 錯誤。 這裡記錄一下處理方式 首先點選 Reset Docker to factory defaults Resetting factory defaults… 接著會看到以下訊息,請點擊 Restart 按鈕 Docker has reset successfully. The application will restart now.

Continue Reading

parent 與 child 資料結構

公司新專案,在執行學習測驗完成後,需要跳出一個問券讓使用者填寫, 問券的架構必須要在選取特定選項後,再展開相關對應的題目, 大致示意如下:

Continue Reading

Command Substitution 簡介

Command Substitution

Command Substitution 大致的結構如下

$()
或者
``

Continue Reading

iptables

iptables

在 Linux 系統內建多數使用 iptables 作為防火牆,用來過設定允許的封包清單,進行安全防護。

iptable 可以用來設定安全 IP 白名單,封鎖 IP 黑名單,以及可以進一步設計程防止 DDos 攻擊用途。

Continue Reading

API Blueprint

API Blueprint

API Bluepirnt 是一個 API 描述語言,可以在開發 API 的過程,使用 markdown 方式快速彙整出 API 文件。

標準的 API Blueprint 是以 .apib 作為副檔名(media 類型為 text/vnd.apiblueprint),當拓展到 Github 上,會直接顯示對應的 Heightlight 。

Continue Reading

Laravel 建立 package 流程

這裡記錄如何建立 Laravel 可使用的 packages,以及如何透過私人 git repositroy 來透過 composer 安裝。

首先,建立 Laravel Project 來做示範:

composer create-project --prefer-dist laravel/laravel getter

建立 package 相關資料夾

Continue Reading

防駭,資料庫遭入侵勒索的安全應對機制

近期,公司營運多年的舊有專案,十幾套系統發生同時無法連線問題,查明原因發現資料庫被入侵,資料被清空,root密碼被更改,以及留下一個 PLEASE_READ_ME_MXG 資料表,內容如下:

WARNING
To recover your lost data : Send 0.05 BTC to our BitCoin Address and Contact us by eMail with your server IP Address or Domain Name and a Proof of Payment. Any eMail without your server IP Address or Domain Name and a Proof of Payment together will be ignored. Your File and DataBase is downloaded and backed up on our servers. If we dont receive your payment,we will delete your databases.

Bitcoint_Address
xxxxxxxxxxxxxxxxxxxxxxxxxx

Email
xxx@hello-database.xyz

在搜尋過相關類似攻擊 Your File and DataBase is downloaded and backed up on our servers 的真實性不高,事實上,在連線後資料就已經被刪除 ref

所以,如果你也遇到同樣遭遇,千萬別充值!

回歸到話題,關於系統資料庫由於每天都有做雲端備份,所以接下來要復原其實不是太大的問題。

慘痛之中,還是必須保持鎮定,掌握處理的步調

先開出任務清單,召集幾個 MIS 進行研擬狀況及對策,進行處理

Continue Reading

CSS3 將背景圖套用在文字上的做法 (文字作為圖片遮罩)

CSS3 -webkit-background-clip:text;

CSS3 -webkit-background-clip:text; 將背景套用在文字上的做法,首先透過外層設定背景圖片,內部文字顏色調整為透明 color: transparent; ,即可達成文字作為 mask 遮罩裁剪圖片,呈現出文字樣式。

Continue Reading

GCP 輪動更新,haproxy 鎖定固定 IP 方式

在我們現有產品中,GCP 的測試機IP是固定的,輪動更新則會變動IP 這裡透過 haproxy 讓輪動更新的 3306 都會指向測試機,再由測試機連向 SQL SQL 只要將白名單設定為測試機IP即可

Continue Reading