This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "editor.fontSize": 15, | |
| "workbench.editor.empty.hint": "hidden", | |
| "editor.tabSize": 4, | |
| "editor.insertSpaces": true, | |
| "editor.detectIndentation": false, | |
| "editor.autoIndent": "full", | |
| "workbench.colorCustomizations": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import asyncio | |
| # 初始化 DataFrame | |
| df = pd.DataFrame(columns=['id', 'name', 'value']) | |
| # 模拟异步增删改查操作 | |
| async def add_row(name: str, value: float): | |
| global df | |
| new_id = len(df) + 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Download new packages but don't install them | |
| # Save in /etc/systemd/system/ | |
| [Unit] | |
| Description=Pacman Automatic Download (no install) service | |
| After=network-online.target | |
| [Service] | |
| # Wait time if process hangs | |
| TimeoutStopSec=5m |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Trigger] | |
| Operation = Upgrade | |
| Type = Package | |
| Target = pacman-mirrorlist | |
| [Action] | |
| Description = Updating pacman-mirrorlist with reflector and removing pacnew... | |
| When = PostTransaction | |
| Depends = reflector | |
| Exec = /bin/sh -c "reflector --protocol https --country 'United Kingdom' --score 10 --sort rate --save /etc/pacman.d/mirrorlist; rm -f /etc/pacman.d/mirrorlist.pacnew" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Unit] | |
| Description=Pacman system updates | |
| After=network.target | |
| [Service] | |
| ExecStart=/usr/bin/pacman -Sy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Dilation, erosion, opening, closing operations on binary nifti files.""" | |
| import os | |
| import numpy as np | |
| from scipy.ndimage import morphology | |
| from nibabel import load, save, Nifti1Image | |
| # Load data | |
| nii = load('/path/to/your/file.nii.gz') | |
| basename = nii.get_filename().split(os.extsep, 1)[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def dice(im1, im2, empty_score=1.0): | |
| """ | |
| Computes the Dice coefficient, a measure of set similarity. | |
| Parameters | |
| ---------- | |
| im1 : array-like, bool | |
| Any array of arbitrary size. If not boolean, will be converted. | |
| im2 : array-like, bool | |
| Any other array of identical size. If not boolean, will be converted. | |
| Returns |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| class Tee(object): | |
| def __init__(file_name, mode): | |
| self._file = open(file_name, mode) | |
| def __enter__(self): | |
| return self | |
| def __exit__(self): | |
| self.__close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # User service for Rclone mounting | |
| # | |
| # Place in ~/.config/systemd/user/ | |
| # File must include the '@' (ex rclone@.service) | |
| # As your normal user, run | |
| # systemctl --user daemon-reload | |
| # You can now start/enable each remote by using rclone@<remote> | |
| # systemctl --user enable rclone@dropbox | |
| # systemctl --user start rclone@dropbox |