Opengist

Explore

  • All gists
  • Topics
  • Users
Give feedback on the new UI Powered by Opengist ⋅ 163ms

user:thomas gists created by user

title:mygist gists with given title

description:sync gists with given description

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

all:systemctl search all fields

Login
s

setup

Recently created Least recently created Recently updated Least recently updated

timmy / Swap 檔案與分割區設定工具

Last active 5 hours ago management partition scripts setup swap swap-file

輕鬆設定與管理 Swap 檔案和分割區,讓系統更流暢運行。

0 0 0 3
1 # 檢查目前是否有 swap 啟用
2 swapon --show
3 free -h
4
5 # 建立 2GB 的 swap 檔案(如果 fallocate 不支援可改用 dd)
6 sudo fallocate -l 2G /swapfile
7 sudo dd if=/dev/zero of=/swapfile bs=1M count=2048
8
9 # 設定正確權限
10 sudo chmod 600 /swapfile

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

Last active 5 hours ago automation bash environment python script setup venv virtualenv

這段 Bash 腳本用於建立和管理 Python 虛擬環境,檢查虛擬環境是否存在,若不存在則建立並啟動環境,升級 pip,並自動安裝 requirements.txt 中的依賴(若檔案存在)。

1 0 0 2
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'..."