2026年2月22日 星期日

在 arch linux 以 vLLM 使用輕量型 OCR 模型 GLM-OCR

看到報導說GLM-OCR 0.7B參數模型效果不錯,

https://github.com/zai-org/GLM-OCR

有個書本幾頁照片想要轉成文字,就可以用這個離線辨識圖片中的文字。

原本丟給 ChatGPT,但是每個對話第一個還算正確,第二個開始就ChatGPT自己解釋成和照片文字不同的內容。

2026年2月19日 星期四

在 MacOS 中以非管理者(Non-administrator)安全執行 Openclaw

以管理者權限執行 openclaw 很方便,但是相對的也讓 openclaw 能取得電腦上所有檔案,甚至雲端的所有檔案及服務。

如果以非管理者,就是一般使用者權限執行 openclaw,能限制 openclaw的使用範圍及能取得的資料。在只有一台電腦也想使用 Openclaw 的情況,能維持基本可控制的安全性。

關鍵是在有管理者權限帳號安裝必要程式,到新建立的一般使用者權限帳號安裝openclaw 及執行openclaw。

使用 nvm (node version manager) 安裝 node.js 可以讓 node.js 在使用者家目錄內執行,openclaw 也以這個 node.js 執行,就可以不需要管理者權限的情況下運作大部分功能。

2025年5月12日 星期一

在WLS中設定 git merge tool 為 winmerge.exe

因為工作時使用Windows Subsystem for Linux,

不像在原生Linux 中已經在安裝時設定好 git merge tool,

必須要自己手動設定。

在 WSL 中也缺少習慣的 GitGUI,

只能使用windows 中的去讀取 WSL 中的檔案。

 可以先用指令產生基本設定

git config --global merge.tool winmerge

git config --global merge.guitool winmerge

會在 ~/.gitconfig 中增加

[merge]
        tool = winmerge
        guitool = winmerge

 

意思合併時使用 winmerge 這個設定值

圖形化合併時,用 winmerge 這個設定值

 

之後手動增加 winmerge 設定值

#vim  ~/.gitconfig

 [mergetool "winmerge"]
            cmd = /mnt/c/Program\\ Files/WinMerge/WinMergeU.exe "$LOCAL" "$BASE" "$REMOTE" --output "$MERGED"
            trustExitCode = true

 

WinMerge

https://winmerge.org/?lang=zh_tw

2025年2月24日 星期一

在anaconda 中安裝 聯發科MediaTek Llama-breeze2 ( Linux )

看到新聞寫聯發科釋出新的LLM模型,還可以做圖像處理或文件處理,

找到在 huggingface 上的model 和簡易的使用方法

https://huggingface.co/MediaTek-Research/Llama-Breeze2-3B-Instruct

https://huggingface.co/MediaTek-Research/Llama-Breeze2-8B-Instruct

但是實際上還需要補上不少的python 套件

 

如果是另外新建立 anaconda 的環境,

會需要再安裝 jupiter-notebook

#conda install jupiter-notebook

 

#conda install anaconda-navigator

#conda install conda-forge::jupyter anaconda::ipywidgets

 

文件說明需要 transformers

#conda install transformers


所有安裝指令

==================

#conda install conda-forge::pytorch-gpu

#conda install -c conda-forge libstdcxx-ng

#pip install mtkresearch
#conda install pytorch torchvision torchaudio cudatoolkit=11.8 -c pytorch 
#conda install pytorch::pytorch-cuda  
#conda install timm einops accelerate

==================

逐步解說

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[2], line 3
      1 from transformers import AutoModel, AutoTokenizer
      2 from transformers import GenerationConfig
----> 3 import torch
      4 from mtkresearch.llm.prompt import MRPromptV3

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/torch/__init__.py:367
    365     if USE_GLOBAL_DEPS:
    366         _load_global_deps()
--> 367     from torch._C import *  # noqa: F403
    370 class SymInt:
    371     """
    372     Like an int (including magic methods), but redirects all operations on the
    373     wrapped node. This is used in particular to symbolically record operations
    374     in the symbolic shape workflow.
    375     """

ImportError: libtorch_cpu.so: cannot enable executable stack as shared object requires: Invalid argument

https://anaconda.org/conda-forge/pytorch-gpu

#conda install conda-forge::pytorch-gpu

 

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[3], line 3
      1 from transformers import AutoModel, AutoTokenizer
      2 from transformers import GenerationConfig
----> 3 import torch
      4 from mtkresearch.llm.prompt import MRPromptV3

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/torch/__init__.py:290
    289 def _load_global_deps() -> None:
--> 290     if _running_with_deploy() or platform.system() == "Windows":
    291         return
    293     # Determine the file extension based on the platform

ImportError: /home/rexct/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/zmq/backend/cython/../../../../.././libstdc++.so.6: version GLIBCXX_3.4.30' not found (required by /home/rexct/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/torch/../../../libtorch_python.so)

 

#conda install -c conda-forge libstdcxx-ng

 

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[2], line 4
      2 from transformers import GenerationConfig
      3 import torch
----> 4 from mtkresearch.llm.prompt import MRPromptV3

ModuleNotFoundError: No module named 'mtkresearch'
 
#pip install mtkresearch 
 
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) Cell In[3], line 4 2 from transformers import GenerationConfig 3 import torch ----> 4 from mtkresearch.llm.prompt import MRPromptV3 File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/mtkresearch/llm/prompt.py:9 6 from datetime import datetime 7 from PIL import Image ----> 9 from mtkresearch.llm.image_process_v3 import load_image 12 def _removeprefix(content, prefix): 13 if sys.version_info[0] >= 3 and sys.version_info[1] >= 9: File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/mtkresearch/llm/image_process_v3.py:3 1 from PIL import Image 2 import torch ----> 3 import torchvision.transforms as T 4 from torchvision.transforms.functional import InterpolationMode 6 IMAGENET_MEAN = (0.485, 0.456, 0.406) ModuleNotFoundError: No module named 'torchvision' 


到下列網頁看最新cudatoolkit 版本,

目前是11.8

https://anaconda.org/conda-forge/cudatoolkit



#conda install pytorch torchvision torchaudio cudatoolkit=11.8 -c pytorch

如果出現以下錯誤,

表示 pytorch 和 torchvision 不合

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[4], line 4
      2 from transformers import GenerationConfig
      3 import torch
----> 4 from mtkresearch.llm.prompt import MRPromptV3

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/mtkresearch/llm/prompt.py:9
      6 from datetime import datetime
      7 from PIL import Image
----> 9 from mtkresearch.llm.image_process_v3 import load_image
     12 def _removeprefix(content, prefix):
     13     if sys.version_info[0] >= 3 and sys.version_info[1] >= 9:

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/mtkresearch/llm/image_process_v3.py:3
      1 from PIL import Image
      2 import torch
----> 3 import torchvision.transforms as T
      4 from torchvision.transforms.functional import InterpolationMode
      6 IMAGENET_MEAN = (0.485, 0.456, 0.406)

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/torchvision/__init__.py:10
      7 # Don't re-order these, we need to load the _C extension (done when importing
      8 # .extensions) before entering _meta_registrations.
      9 from .extension import _HAS_OPS  # usort:skip
---> 10 from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils  # usort:skip
     12 try:
     13     from .version import __version__  # noqa: F401

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/torchvision/_meta_registrations.py:163
    153     torch._check(
    154         grad.dtype == rois.dtype,
    155         lambda: (
   (...)
    158         ),
    159     )
    160     return grad.new_empty((batch_size, channels, height, width))
--> 163 @torch.library.register_fake("torchvision::nms")
    164 def meta_nms(dets, scores, iou_threshold):
    165     torch._check(dets.dim() == 2, lambda: f"boxes should be a 2d tensor, got {dets.dim()}D")
    166     torch._check(dets.size(1) == 4, lambda: f"boxes should have 4 elements in dimension 1, got {dets.size(1)}")

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/torch/library.py:654, in register_fake.<locals>.register(func)
    652 else:
    653     use_lib = lib
--> 654 use_lib._register_fake(op_name, func, _stacklevel=stacklevel + 1)
    655 return func

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/torch/library.py:154, in Library._register_fake(self, op_name, fn, _stacklevel)
    151 else:
    152     func_to_register = fn
--> 154 handle = entry.abstract_impl.register(func_to_register, source)
    155 self._registration_handles.append(handle)

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/torch/_library/abstract_impl.py:31, in AbstractImplHolder.register(self, func, source)
     25 if self.kernel is not None:
     26     raise RuntimeError(
     27         f"register_fake(...): the operator {self.qualname} "
     28         f"already has an fake impl registered at "
     29         f"{self.kernel.source}."
     30     )
---> 31 if torch._C._dispatch_has_kernel_for_dispatch_key(self.qualname, "Meta"):
     32     raise RuntimeError(
     33         f"register_fake(...): the operator {self.qualname} "
     34         f"already has an DispatchKey::Meta implementation via a "
   (...)
     37         f"register_fake."
     38     )
     40 if torch._C._dispatch_has_kernel_for_dispatch_key(
     41     self.qualname, "CompositeImplicitAutograd"
     42 ):

RuntimeError: operator torchvision::nms does not exist

 

先移除 torchvision

#conda uninstall torchvision

#conda uninstall pytorch

安裝指定版 torchvision

#conda install pytorch::torchvision=0.17.2

#conda install pytorch torchvision torchaudio conda-forge::cudatoolkit=11.8 -c pytorch


執行檢查是否使用CUDA

import torch

torch.cuda.is_available()

有使用會輸出 True

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[8], line 4
      2 from transformers import GenerationConfig
      3 import torch
----> 4 from mtkresearch.llm.prompt import MRPromptV3

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/mtkresearch/llm/prompt.py:9
      6 from datetime import datetime
      7 from PIL import Image
----> 9 from mtkresearch.llm.image_process_v3 import load_image
     12 def _removeprefix(content, prefix):
     13     if sys.version_info[0] >= 3 and sys.version_info[1] >= 9:

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/mtkresearch/llm/image_process_v3.py:3
      1 from PIL import Image
      2 import torch
----> 3 import torchvision.transforms as T
      4 from torchvision.transforms.functional import InterpolationMode
      6 IMAGENET_MEAN = (0.485, 0.456, 0.406)

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/torchvision/__init__.py:6
      0 <Error retrieving source code with stack_data see ipython/ipython#13598>

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/torchvision/_meta_registrations.py:25
     20         return fn
     22     return wrapper
---> 25 @register_meta("roi_align")
     26 def meta_roi_align(input, rois, spatial_scale, pooled_height, pooled_width, sampling_ratio, aligned):
     27     torch._check(rois.size(1) == 5, lambda: "rois must have shape as Tensor[K, 5]")
     28     torch._check(
     29         input.dtype == rois.dtype,
     30         lambda: (
   (...)
     33         ),
     34     )

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/torchvision/_meta_registrations.py:18, in register_meta.<locals>.wrapper(fn)
     17 def wrapper(fn):
---> 18     if torchvision.extension._has_ops():
     19         get_meta_lib().impl(getattr(getattr(torch.ops.torchvision, op_name), overload_name), fn)
     20     return fn

AttributeError: partially initialized module 'torchvision' has no attribute 'extension' (most likely due to a circular import)

 

可能是因為之前一直測試重複import,

重啟後這個問題就消失了

 

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[2], line 2
      1 model_id = 'MediaTek-Research/Llama-Breeze2-3B-Instruct-v0_1'
----> 2 model = AutoModel.from_pretrained(
      3     model_id,
      4     torch_dtype=torch.bfloat16,
      5     low_cpu_mem_usage=True,
      6     trust_remote_code=True,
      7     device_map='auto',
      8     img_context_token_id=128212
      9 ).eval()
     11 tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True, use_fast=False)
     13 generation_config = GenerationConfig(
     14   max_new_tokens=2048,
     15   do_sample=True,
   (...)
     19   eos_token_id=128009
     20 )

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/transformers/models/auto/auto_factory.py:553, in _BaseAutoModelClass.from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
    551 if has_remote_code and trust_remote_code:
    552     class_ref = config.auto_map[cls.__name__]
--> 553     model_class = get_class_from_dynamic_module(
    554         class_ref, pretrained_model_name_or_path, code_revision=code_revision, **hub_kwargs, **kwargs
    555     )
    556     _ = hub_kwargs.pop("code_revision", None)
    557     cls.register(config.__class__, model_class, exist_ok=True)

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/transformers/dynamic_module_utils.py:540, in get_class_from_dynamic_module(class_reference, pretrained_model_name_or_path, cache_dir, force_download, resume_download, proxies, token, revision, local_files_only, repo_type, code_revision, **kwargs)
    538     code_revision = revision
    539 # And lastly we get the class inside our newly created module
--> 540 final_module = get_cached_module_file(
    541     repo_id,
    542     module_file + ".py",
    543     cache_dir=cache_dir,
    544     force_download=force_download,
    545     resume_download=resume_download,
    546     proxies=proxies,
    547     token=token,
    548     revision=code_revision,
    549     local_files_only=local_files_only,
    550     repo_type=repo_type,
    551 )
    552 return get_class_in_module(class_name, final_module, force_reload=force_download)

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/transformers/dynamic_module_utils.py:403, in get_cached_module_file(pretrained_model_name_or_path, module_file, cache_dir, force_download, resume_download, proxies, token, revision, local_files_only, repo_type, _commit_hash, **deprecated_kwargs)
    401     for module_needed in modules_needed:
    402         if not (submodule_path / f"{module_needed}.py").exists():
--> 403             get_cached_module_file(
    404                 pretrained_model_name_or_path,
    405                 f"{module_needed}.py",
    406                 cache_dir=cache_dir,
    407                 force_download=force_download,
    408                 resume_download=resume_download,
    409                 proxies=proxies,
    410                 token=token,
    411                 revision=revision,
    412                 local_files_only=local_files_only,
    413                 _commit_hash=commit_hash,
    414             )
    415             new_files.append(f"{module_needed}.py")
    417 if len(new_files) > 0 and revision is None:

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/transformers/dynamic_module_utils.py:365, in get_cached_module_file(pretrained_model_name_or_path, module_file, cache_dir, force_download, resume_download, proxies, token, revision, local_files_only, repo_type, _commit_hash, **deprecated_kwargs)
    362     raise
    364 # Check we have all the requirements in our environment
--> 365 modules_needed = check_imports(resolved_module_file)
    367 # Now we move the module inside our cached dynamic modules.
    368 full_submodule = TRANSFORMERS_DYNAMIC_MODULE_NAME + os.path.sep + submodule

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/transformers/dynamic_module_utils.py:197, in check_imports(filename)
    194             raise
    196 if len(missing_packages) > 0:
--> 197     raise ImportError(
    198         "This modeling file requires the following packages that were not found in your environment: "
    199         f"{', '.join(missing_packages)}. Run `pip install {' '.join(missing_packages)}`"
    200     )
    202 return get_relative_imports(filename)

ImportError: This modeling file requires the following packages that were not found in your environment: timm, einops. Run `pip install timm einops`

 

#conda install timm einops


---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In[3], line 2
1 model_id = 'MediaTek-Research/Llama-Breeze2-3B-Instruct-v0_1'
----> 2 model = AutoModel.from_pretrained(
3 model_id,
4 torch_dtype=torch.bfloat16,
5 low_cpu_mem_usage=True,
6 trust_remote_code=True,
7 device_map='auto',
8 img_context_token_id=128212
9 ).eval()
11 tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True, use_fast=False)
13 generation_config = GenerationConfig(
14 max_new_tokens=2048,
15 do_sample=True,
(...)
19 eos_token_id=128009
20 )

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/transformers/models/auto/auto_factory.py:559, in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
557 else:
558 cls.register(config.__class__, model_class, exist_ok=True)
--> 559 return model_class.from_pretrained(
560 pretrained_model_name_or_path, *model_args, config=config, **hub_kwargs, **kwargs
561 )
562 elif type(config) in cls._model_mapping.keys():
563 model_class = _get_model_class(config, cls._model_mapping)

File ~/.conda/envs/mtk-breeze2/lib/python3.12/site-packages/transformers/modeling_utils.py:3318, in PreTrainedModel.from_pretrained(cls, pretrained_model_name_or_path, config, cache_dir, ignore_mismatched_sizes, force_download, local_files_only, token, revision, use_safetensors, *model_args, **kwargs)
3314 raise ValueError(
3315 "DeepSpeed Zero-3 is not compatible with `low_cpu_mem_usage=True` or with passing a `device_map`."
3316 )
3317 elif not is_accelerate_available():
-> 3318 raise ImportError(
3319 "Using `low_cpu_mem_usage=True` or a `device_map` requires Accelerate: `pip install accelerate`"
3320 )
3322 # handling bnb config from kwargs, remove after `load_in_{4/8}bit` deprecation.
3323 if load_in_4bit or load_in_8bit:

ImportError: Using `low_cpu_mem_usage=True` or a `device_map` requires Accelerate: `pip install accelerate`
 
#conda install accelerate
 
 FlashAttention2 is not installed.

#conda install pytorch::pytorch-cuda
可能會遇到相依性問題,
找出樹狀圖中的 cuda-toolkit 版本,
到下列網址中複製對應的版本執行 
https://anaconda.org/nvidia/cuda-toolkit
#conda install nvidia/label/cuda-12.4.1::cuda-toolkit
#conda install pytorch torchvision torchaudio cudatoolkit=11.8 -c pytorch 
 
參考:
https://ithelp.ithome.com.tw/articles/10282119 

https://stackoverflow.com/questions/48152674/how-do-i-check-if-pytorch-is-using-the-gpu


2024年12月29日 星期日

Yii2:使用 eseperio/yii2-url-shortener 建立短網址 ( short url )

適用沒有放到 https://asset-packagist.org 的以 composer 安裝的套件。

找到這個Yii短網址套件,

到套件的 composer.json 看,

套件名稱是 eseperio/yii2-url-shortener

$ composer require "eseperio/yii2-url-shortener:~1.0.0"

顯示找不到套件

Root composer.json requires eseperio/yii2-url-shortener, it could not be found in any version, there may be a typo in the package name.

所以找以本地目錄安裝的方法。

2024年9月15日 星期日

Archlinux 打包 Linux kernel 中特定 module 的 package

繼半手動編譯 funUV dvb dongle USB電視棒 Linux modules後,

搞定打包Archlinux package 檔案的 PKGBUILD

以後只要以

#uname -a

查 linux kernel 的版本,

配合替換目標版本 linux PKGBUILD 檔中 checksum

https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/commits/main

就能完成FunUV dvb dongle 的 archlinux package。

2024年8月4日 星期日

Linux 開機時以 udev rules 移除裝置

以移除沒使用的網路卡裝置為例,

因為libvirt的自動預設網路將流量導到沒使用的網路卡。 

2024年7月27日 星期六

2024年7月13日 星期六

Android ADB wifi connect

先取消Wifi內的亂數 mac address,

再選擇兩種方式(QRcode或配對碼 adb pair )的一種註冊電腦,

之後再用 adb connect 連線。

2024年2月11日 星期日

在 archlinux 編譯特定 kernel module ( Funuv TV1520 DTV-T USB dongle )



因為 Funuv TV1520 DTV-T USB dongle使用 rtl28xxu kernel module,

但是 vendor ID 和 product ID 都沒有在module 資料內,

所以修改程式碼加上去。


之前用 AUR 中的 v4l-dvb package 修改編譯,

但是原始碼來源因為向前修改越來越複雜,

所以已將沒有繼續針對新 kernel 更新。

2023年11月18日 星期六

開機自動設定好額外插的網路卡

因為主機板上的網路裝置好像故障,

連線沒幾秒就開始沒回應,

換插 PCI-e 網路卡。

但是每次開機後都不會自動設定好,

要手動啟用加請求 DHCP。

# ip link set new_net_interface_name up

# dhcpcd -n new_net_interface_name

2021年11月18日 星期四

在 Linux bash 寄 gmail 信附加檔案

固定時間要備份資料庫檔案,

之前想到到用 rclone 備份到 google drive,

但是要設定時要進行2步驟認證,

還有權限會可以讀寫帳號內整個 google drive,

有點不安全。

就改成換用寄 email 附加資料庫檔案,

但是要用 systemd timer 定期執行,

用 bash 指令會比較適合



指令:

echo "content text" | mutt -a "/attachment/file.7z" -s "subject text" -- my.email@gmail.com

2021年8月27日 星期五

Linux 不透過 Display manager 完成自動登入及執行 startx 進入 xwindow 圖形界面

某台電腦需要自動登入及進入 xwindow 才能啟動要用的功能,

找到下方這篇文章可以透過 systemd 的本機自動登入功能,

再加上登入後自動執行 startx 完成自動進入 xwindow 圖形界面環境。

Autologin and startx without a display manager.

https://forums.bunsenlabs.org/viewtopic.php?id=5544

2021年8月15日 星期日

Git gui 使用有 passphrases 的 ssh key 連到 GitHub

因為 2021/08/13 後,github 不給用 https 加密碼方式連線,

只能用 ssh key 的方式。

但是照著步驟一直失敗

Pushing to ssh://github.com/myname/project.git
myname@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

在archlinux 中使用 clonezilla 備份非系統磁碟

因為系統開機中,不想重開啟使用 Clonezilla live USB。

有個方法是開 VirtualMachine 用 Clonezilla Live ISO 開機後再連接要備份的和

儲存的裝置,但是感覺還是有點麻煩。

所以想直接拿出 Clonezilla live ISO 檔案內的相關檔案,利用 chroot 改變根目錄直接執行。

因為 ram 夠大,所以全部在 /dev/shm 下操作

2021年7月21日 星期三

Android kotlin 備份及還原 app 的 sqlite database

因為在 Android Q (API 29) 後有 getExternalStoragePublicDirectory is deprecated 的狀況,所以最後終於東拼西湊出可以複製。

下列程式是用在 Fragment,如果是Android Q以上,會有檔案選取頁面選擇要儲存備份的檔案位置和自訂檔名,在還原時也可以自行選擇還原檔案。其他較低的Android 則在備份時直接以指定檔名儲存到 Download 資料夾,還原時也從 Download 資料夾讀取指定檔名。

2021年7月16日 星期五

Python imaplib 讀取 gmail 內文及附件(python gmail attachment download)



想要自動化取得 gmail 的附件,再自動做其他用途。

可以用 imaplib 方式

未完成功能:message_from_string 取得的 subject 和 from 轉成 utf-8

2021年7月14日 星期三

解決 web server 連線出現 The page isn’t redirecting properly 問題

問題點就是出在 Apache 設定檔中

 <VirtualHost *:443>

....

ServerName me.afreeddns.org

....

RewriteCond %{SERVER_NAME} =me.afreeddns.org
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

</VirtualHost>

因為 ServerName 和 RewriteCond 一樣,

導致 redirect 變成迴圈,

把 RewriteCond 改成和 ServerName 不同就好,例如:

RewriteCond %{SERVER_NAME} =www.me.afreeddns.org

2021年7月11日 星期日

安裝 NextCloud docker image 及 maps app 顯示照片拍攝位置

因為 Gooogle 教育帳號縮水,要逃難了。

之前架設過 NextCloud ( 實際上是從 OwnCloud 開始後來轉成NextCloud)

但是覺得當時手動設定太麻煩了,

用 docker image 應該就方便多了。

主要想法是把 container 的 port 80 映射到 host,

並且讓 Nextcloud 的檔案資料夾和設定資料夾都對應到 Host 的實體資料夾。

弄了一個下午,卡最久的就是編譯 map app 。

現在安裝的 NextCloud 是 22 版,

比3年前用的截面好太多了,

app 也更豐富。

2021年3月13日 星期六

Linux 系統執行中完整備份(on-line backup)

因為有台主機每停機一秒就會少賺一秒,

但是現在用的硬碟要拿去做別的用途,

就試試看在執行中複製整個系統,

並讓複製後的系統是可直接開機的狀態 。

把停機時間減少成只有換硬碟時間。