As configured in my dotfiles.
start new:
tmux
start new with session name:
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 |
As configured in my dotfiles.
start new:
tmux
start new with session name:
# 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 |
[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" |
[Unit] | |
Description=Pacman system updates | |
After=network.target | |
[Service] | |
ExecStart=/usr/bin/pacman -Sy |
I may have let Arch go months without updates before. Its not advisable to apply them on a schedule either.
Providing regular prompts to apply updates seems like the best solution.
This cronjob will download packages and cache locally. Put into root's crontab or run via sudo.
"""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] |
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 |
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() |
"""ssh-copy-id for Windows. | |
Example usage: python ssh-copy-id.py ceilfors@my-remote-machine | |
This script is dependent on msysgit by default as it requires scp and ssh. | |
For convenience you can also try that comes http://bliker.github.io/cmder/. | |
""" | |
import argparse, os | |
from subprocess import call |