Dulcie @ 2021 By : Template Sell.

Category: 未分類

雜七雜八

常見的命名規則(Camel Case, Snake Case, Kebab Case)

介紹幾種常見的命名規則 Camel Case因為單字的開頭大寫,看起來像是駝峰 XD可以進一步細分為 upper camel case (BrowserStack) 與 lower camel case (iPhone),差別在於開頭第一個字是否為大寫.另外,因為 upper camel case 又稱為 Pascal Case,因此有部分人泛指 Camel Case 為 lower camel case Camel case is named after the “hump” of its protruding capital letter, similar to the hump of common camels. Snake Case簡單來說是用 _ 來分隔單字的命名規則,像是 fibonacci_sequence起源來自 Ruby 社群的一句討論 BTW…what *do* you call that […]

[github] 免密碼 push/pull/clone 等操作專案

其實原理跟之前的免密碼登入一樣 透過公私鑰,可以建立彼此信任的連線。 首先在 windows/linux 輸入 ssh-keygen 產生公私鑰 預設會以 RSA 加密產生公私鑰 Enter file in which to save the key (/home/camel/.ssh/id_rsa): Enter(確認檔案放置位置) Enter passphrase (empty for no passphrase): Enter(不設定密碼) Enter same passphrase again: Enter(不設定密碼) PS. linux 會產生在家目錄、windows 則會產生在 C:\Users[username] 底下, .ssh 資料夾 產生公鑰:.ssh/id_rsa.pub 產生私鑰:.ssh/id_rsa 將公鑰的檔案內容貼至 github 的 settings。(如圖) 這樣就可以免帳密 pull/push/clone 專案了!

[IE] 修正輸入框提示 placeholder 在 focus 時消失 (placeholder disappears on focus)

使用 HTML 的 input 標籤中的提示( placeholder ),當使用者 focus 輸入框時(尚未輸入任何字) 在除了 IE 以外的瀏覽器( chrome、firefox及 edge 等),提示( placeholder )仍會存在。 但在 IE 瀏覽器上則會消失。 如此範例:(請在 IE 及 chrome 分別開啟並 forcus 輸入框則可看見差異) 在微軟的開發者討論區,也可以查到相關的問題,看起來好像不打算修了….。 因此,若希望修正 IE 此行為的話,以下則提供兩種在 IE 實作 placeholder 作法。 首先我們必須判斷瀏覽器是否為IE 直覺的當使用者 focus 時,先檢查裡面是否有值,若沒有的話自動填入 placeholer 該有的值(並且不能讓使用者編輯 placeholer,自動將游標移至開頭)。 直接看程式碼比較清楚: 第一種方法還要做移動游標,我們可以考慮在 input 上面蓋一個文字區塊,如 label。  

常用的 regex 正規表達式(定時更新)

紀錄一下自己常用到的正規表達式 網址:/(\b(https?):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig 網域: /^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$/ig 電子郵件:/^(([^<>()\[\]\.,;:\s@\”]+(\.[^<>()\[\]\.,;:\s@\”]+)*)|(\”.+\”))@(([^<>()[\]\.,;:\s@\”]+\.)+[^<>()[\]\.,;:\s@\”]{2,})$/i 排除(exclude)掉特定的字串: ^/(?!ignoreme|ignoreme2|ignoremeN)([a-z0-9]+)$   參考資料: https://stackoverflow.com/questions/2078915/a-regular-expression-to-exclude-a-word-string