Last active 1 year ago
這段 PowerShell 腳本建立一個專案目錄,初始化基本的前端專案結構,包括 index.html、src 資料夾及子目錄,並透過 npm 安裝必要的依賴 (lit、vite、serve),最後列出目錄結構供檢查。
1 # 檢查是否提供了目錄名稱參數
2 if ($args.Length -eq 0) {
3 Write-Host "Usage: .\setup_project.ps1 <directory_name>"
4 exit 1
5 }
6
7 # 將參數設定為 PROJECT_DIR 變數
8 $PROJECT_DIR = $args[0]
9
10 # 嘗試建立目錄
Last active 1 year ago
這段程式碼是一個使用 Streamlit 和 SQLite 的範例應用程式,透過 JOIN 查詢顯示客戶與訂單的關聯資料,並在介面中使用 st.data_editor 允許編輯訂單日期,按下更新按鈕後會將修改內容同步至資料庫。
1 import sqlite3
2 import pandas as pd
3 import streamlit as st
4 from datetime import datetime, date
5
6 def initialize_database(conn):
7 cursor = conn.cursor()
8
9 # 建立 Customers 資料表
10 cursor.execute('''

timmy / Python 虛擬環境自動化設定

1 likes
0 forks
2 files
Last active 1 year ago
這段 Bash 腳本用於建立和管理 Python 虛擬環境,檢查虛擬環境是否存在,若不存在則建立並啟動環境,升級 pip,並自動安裝 requirements.txt 中的依賴(若檔案存在)。
1 #!/bin/bash
2
3 # 設定虛擬環境名稱
4 VENV_DIR="myenv"
5
6 # 檢查是否已經存在虛擬環境
7 if [ -d "$VENV_DIR" ]; then
8 echo "虛擬環境 '$VENV_DIR' 已經存在。"
9 else
10 echo "正在建立虛擬環境 '$VENV_DIR'..."
Last active 1 year ago
這是一個帶有固定導航欄的 HTML 範例,實現了頁面內導航、滾動高亮導航連結、區塊進入視窗時的動畫效果,以及返回頂部按鈕功能,並使用 JavaScript 自訂平滑滾動效果增強用戶體驗。
1 <!DOCTYPE html>
2 <html lang="zh-Hant">
3 <head>
4 <meta charset="UTF-8">
5 <title>增強版頁面內導航範例</title>
6 <style>
7 body {
8 font-family: Arial, sans-serif;
9 /* 移除 CSS 平滑滾動,使用 JavaScript 控制 */
10 margin: 0;

timmy / 台灣假日 API 查詢與快取

0 likes
0 forks
1 files
Last active 1 year ago
這段程式碼是一個節假日查詢工具,從指定 API 獲取節假日資料,支援緩存與分頁,並提供按年份篩選節假日、檢查特定日期是否為節假日的功能,同時以 Holiday 類別封裝每個節假日的詳細資訊,便於操作與顯示。
1 import requests
2 import os
3 import json
4
5 class HolidayAPI:
6 def __init__(self, base_url, cache_dir="cache"):
7 """
8 Initialize the HolidayAPI class.
9 :param base_url: The base URL for the API endpoint.
10 :param cache_dir: Directory to store cached data.

timmy / 前端專案初始化腳本

1 likes
0 forks
1 files
Last active 1 year ago
這段 Bash 腳本建立一個專案目錄,初始化基本的前端專案結構(包括 index.html 和 src/components 資料夾),並透過 npm 安裝 lit、vite 和 serve,最後輸出目錄結構(排除 node_modules)。
1 #!/bin/bash
2
3 # Check if the user provided a directory name as an argument
4 if [ -z "$1" ]; then
5 echo "Usage: $0 <directory_name>"
6 exit 1
7 fi
8
9 # Set the user-provided parameter to the PROJECT_DIR variable
10 PROJECT_DIR="$1"

timmy / 使用 tcpdump 捕獲 POP3/IMAP 流量

0 likes
0 forks
2 files
Last active 1 year ago
這兩段 Bash 指令都利用 tcpdump 監控 eth0 網卡上的郵件流量,第一個同時捕捉 POP3 (port 110) 與 IMAP (port 143) 的封包並存成 imap_pop3.pcap,而第二個則專門捕捉 POP3 (port 110) 流量並存成 pop3_traffic.pcap,方便後續進行網路分析或除錯。
1 #!/bin/bash
2
3 tcpdump -i eth0 port 110 or port 143 -w imap_pop3.pcap