June Chiu

@june-notes

Joined on Dec 7, 2018

  • 使用 Google Cloud Run 定時執行任務 使用 Cloud Run,因為它支持容器化部署,可以包含 Playwright 所需的瀏覽器依賴。 Google Cloud Run 本身並不支援內建的排程,但可以結合 Google Cloud Scheduler 設定時間間隔來觸發 Cloud Run,例如每日執行一次。 步驟: 1. 部署 Cloud Run 來執行 Playwright 爬蟲並上傳檔案 Google Cloud Run 支持容器化部署,可以包含 Playwright 所需的瀏覽器依賴。 部署至 Cloud Run 的步驟: 撰寫 Dockerfile,定義包含 Playwright 和必要的 Node.js 程式碼的容器。
     Like  Bookmark
  • Ragic API Key Screenshot 2024-10-27 at 10.58.36 PM code const axios = require('axios'); const RAGIC_API_BASE_URL = 'https://www.ragic.com/your_account_name/api/your_sheet_id'; const RAGIC_API_KEY = process.env.RAGIC_API_KEY; // 確保將 Ragic API Key 設為環境變數 /**
     Like  Bookmark
  • 誤刪 default compute service account: 30 天內用 gcloud 加回來 gcloud iam service-accounts undelete "115754855009870202382" --project=play-and-swim https://cloud.google.com/compute/docs/troubleshooting/troubleshooting-default-service-accounts Cloud run 監聽偵測 Storage bucket 並 log 印出 function: const functions = require('@google-cloud/functions-framework');
     Like  Bookmark
  • Playwright 可以通過結合排程工具和離線運行模式實現自動化任務。例如,你可以使用 Node.js 的排程工具(如 node-cron)來定期執行 Playwright 腳本,並且 Playwright 可以在無頭模式下(headless 模式)運行,這意味著它可以在沒有顯示器的情況下(如伺服器或雲端)離線運行。 使用 node-cron 排程 Playwright 腳本 node-cron 是一個簡單易用的 Node.js 排程工具,可以幫助你定期執行 Playwright 爬蟲或自動化任務。 步驟 安裝必要套件安裝 playwright 和 node-cron:​​​​​npm install playwright node-cron 撰寫 Playwright 爬蟲代碼 下面是一個結合 node-cron 來定期執行 Playwright 爬蟲並抓取網頁數據的範例:
     Like  Bookmark
  • :::info v13 and up ::: :mag_right: Font :::success :bulb: Import google font from NextJs itself instead of css ::: :small_blue_diamond: Before
     Like  Bookmark
  • :::info :bulb: TanStack Query (FKA React Query) is often described as the missing data-fetching library for web applications, but in more technical terms, it makes fetching, caching, synchronizing and updating server state in your web applications a breeze. React Query 通常被描述为 React 缺少的数据获取(data-fetching)库,但是从更广泛的角度来看,它使 React 程序中的获取,缓存,同步和更新服务器状态变得轻而易举。[^TanStack] ::: // Before: function Example() { const [fetchData, setFetchData] = useState()
     Like  Bookmark
  • :::info :moneybag: Record some cool stuff in the project I invovled now. ::: About MUI :::success MUI is the organization behind popular open-source projects like Material UI, Base UI, MUI X. ::: MUI Core
     Like  Bookmark
  • https://www.w3schools.com/css/default.asp * width: 100px; margin: auto; align center * display: flex; justify-content: center; align-items: center; flexbox align center. justify-content align horizontally, align-items align vertically.
     Like  Bookmark
  • 使用 Playwright 作為爬蟲工具是一個很好的選擇,尤其是當你需要與 JavaScript 重的網頁進行交互時。以下是如何在 macOS 上使用 Playwright 來設置環境和爬取蝦皮的基本步驟: 安裝 Node.js: 如果你還沒有安裝 Node.js,你可以使用 Homebrew:brew install node 建立一個新的 Node.js 專案:mkdir shopee_crawler cd shopee_crawler npm init -y 安裝 Playwright:npm install playwright
     Like  Bookmark
  • # [Nightwatch 新手紀實] test case 生命週期 > 生命週期共有 [before、after、beforeEach、afterEach](https://nightwatchjs.org/guide/#using-before-each-and-after-each-hooks) 這四個 [hook](https://whatis.techtarget.com/definition/hook) 當作生命週期的方法,命名很直覺、使用上也很直覺。 ## 新手 我剛開始接觸 NightwatchJs 寫時,一個檔案寫一組生命週期,例如 **./test/xxx.js**: ``` module.exports = { before () { // xxx.js 開始執行時 console.log('start test') }, beforeEach(browser, done) { // 下面每個 test case 開始時 browser .maximizeWindow()
     Like  Bookmark
  • React Native project initial (更新:2019.03.13) === ## 摘要 >這份文件蒐集 react native 專案 initial 前置步驟。follow 一樣的步驟、和其他前輩建立同樣的環境,能加速日後(頻繁的)debug。 ## 目錄 [TOC] --- 一、環境: --- ### 1. iterm2 + oh-my-zsh https://pjchender.blogspot.tw/2017/02/mac-terminal-iterm-2-oh-my-zsh.html ### 2. nvm install (更新:2019.03.13) 照 nvm 官網 注意:要先安裝 zsh 再安裝 nvm, npm,否則 $PATH 仍會指向 bash,還要去調環境變數才抓得到 npm (更新:2019.03.13) ### 3. 安裝模擬器 照 react-native 官網 ### 4. 安裝 react-native-debugger https://github.com/jhen0409/react-native
     Like  Bookmark
  • j104 以 React 封裝 - 以表單為例 === ## 摘要 > 這份文件旨在封裝 j104 React 元件。因為使用 React 時,許多同樣的 j104 code,散落在每一個 single page 頁面。要維護同一個零件時,需要去各個地方修改。封裝後引入、維護上比較方便,例如說 j104 有upgrade 產生異動時,整個專案只需要改一個地方。 ## 目錄 [TOC] --- ## 一. 情境: 現在有三個表單頁面,如下: ![](https://i.imgur.com/hruFswu.png) 假設我決定**三頁**都要使用以下工具、動作: **A. React single page、 B. j104 form、 C. j104 tip、 D. 回收 j104** ## 二. 原本的寫法,同樣的 code 散落在每一頁 *註:以下圖中的 code,同一個字色,是代表同樣的 code。以下使用 pseudo code。* ### 步驟1. 我先新增 form: ![](https://i.imgur.com/vYtkx7p.png) ###
     Like  Bookmark
  • 後端實作:Header 上的公司名稱判斷問題 === 修改公司名稱 Debug 流程圖1 --- where is the issue: ```flow st=>start: 開始 e=>end: 結束 op=>operation: /admin/company op2=>operation: 公司顯示名稱修改 cond=>condition: header? cond2=>condition: ajax? op3=>operation: other ajax st->op->op2->cond op3->e cond(yes)->e cond(no)->cond2 cond2(yes)->e cond2(no)->op3 ``` ==:pushpin:fix ajax 沒 error 但 fail 後,仍 set company displayname 的 cookie== --- ### commit id: ab5470649ab3d6f5940013a51936d40ff5399e56 error === [updateCompanyByCid] Calling
     Like  Bookmark