【 2023 】【 03 】所學

Stephen Chen
6 min readApr 3, 2023

最近在看薑餅資的YT,很有感觸。決定每個月要出一篇把自己這個月所學的東西記錄下來,想說就重這個月開始吧!

Google Excel 把欄位直轉橫, 橫轉直

Google Excel Slicer

Tableplus Tip

自己是使用這套軟體來看 SQL 相關的訊息,常常在使用上會重複一些指令,於是採用 History & Favorite 的功能來加速

此圖來源是 https://tableplus.com/blog/2018/05/11-tips-to-boost-productivity-with-tableplus.html

Laravel .env 檔案的更新以及新增

因為公司有很多專案需在 env 檔案新增 key value pair 。

寫了以下的 function 然後透過 command 以及 script 腳本來完成

#!/bin/bash

declare -a PROJECTS=(
/var/www/project1
/var/www/project2
/var/www/project3
)

for PROJECT in "${PROJECTS[@]}"
do
php artisan update:env
done

Laravel 優化 whereIn

最近發現這個 TIP,裏面提到使用 whereIntegerInRaw 來替代 whereIn

看源碼發現主要省去執行 addBinding 這行

Notion 一鍵按鈕

自己是 notion 重度使用者,很長需要重複做一些繁瑣且無聊無腦的事情。

於是透過 with the click of buttons 來幫自己省時間

取自 notion

前後端對於字數不同的問題

發生在前端假如限制 500 個字,但明明前端顯示 490 個字,但 php 這邊就會出 error 說字數已到,查明一下原因才發現

Laravel 的 max validation源碼 )是用 mb_strlen 來判斷的

  protected function getSize($attribute, $value)
{
$hasNumeric = $this->hasRule($attribute, $this->numericRules);

// This method will determine if the attribute is a number, string, or file and
// return the proper size accordingly. If it is a number, then number itself
// is the size. If it is a file, we take kilobytes, and for a string the
// entire length of the string will be considered the attribute size.
if (is_numeric($value) && $hasNumeric) {
return $this->trim($value);
} elseif (is_array($value)) {
return count($value);
} elseif ($value instanceof File) {
return $value->getSize() / 1024;
}

return mb_strlen($value ?? '');
}

前端是以下這樣判斷的

<textarea id="myTextarea"></textarea>

<script>
var textareaValue = document.getElementById("myTextarea").value;
var textLength = textareaValue.length;
</script>

這兩邊在判斷字數的時候會根據是否有特殊字元和空白…等的狀況而不同,所以要特別實驗去計算過。

十分鐘以內簡單 0 到 1 建立 wordpress 網站

Linode 有 marketplace 可以快速使用,架設完之後就可以使用

域名暫時先用 rDNS 提供的

ThemeForest 買 theme 或者 plugin 來安裝

會大概等一段時間才會好,網址路徑會是以下的規則 ( 詳情可以看 )

<your_domain>/wp-admin/
畫面如下

至於帳號密碼輸要先 ssh 登入到 server 去看帳密(詳情請看

使用 ap_admin_userwp_admin_pass 來完成上方的登入

當然 wordpress 絕不會這麼簡單就完成,這邊自己發現的一個非常快速的方案而已

加入讀書會看 system design 這本書學到

雖然自己因為私事沒參加三個禮拜,但在 design a url shortener 中使用 Back-of-the-envelope_calculation 還有看完此文章學到每種方式的優缺點,還認識到 Zookeeper

Anki

為了補足年紀的不足(疑),所以認識到 flush cards 這方法來提高記憶力,包含 decks、cloze、image occlusion enhanced

Anki 示意圖 cloze and image occlusion enhanced

--

--