Skip to content

Instantly share code, notes, and snippets.

View thisissyu's full-sized avatar
🏫
Working...

This is S Yu thisissyu

🏫
Working...
  • Shandong University
  • Qingdao, China
  • 11:54 (UTC +08:00)
View GitHub Profile
@thisissyu
thisissyu / pacman-auto-update.service
Created March 11, 2022 07:00 — forked from raspi/pacman-auto-update.service
Arch Linux Pacman auto download updated packages
# 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
@thisissyu
thisissyu / mirror_update.hook
Created March 11, 2022 06:58 — forked from gr33n7007h/mirror_update.hook
Update mirrors.
[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"
@thisissyu
thisissyu / pacman.service
Created March 11, 2022 06:57 — forked from valeth/pacman.service
Pacman Updates
[Unit]
Description=Pacman system updates
After=network.target
[Service]
ExecStart=/usr/bin/pacman -Sy
@thisissyu
thisissyu / dilate_erode_MRI_data.py
Created January 26, 2022 02:49 — forked from ofgulban/dilate_erode_MRI_data.py
Simple morphological operations on MRI data (nifti).
"""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]
@thisissyu
thisissyu / _dice.py
Created January 16, 2022 01:53 — forked from brunodoamaral/_dice.py
Dice coefficient between two boolean NumPy arrays or array-like data. This is commonly used as a set similarity measurement (though note it is not a true metric; it does not satisfy the triangle inequality). The dimensionality of the input is completely arbitrary, but `im1.shape` and `im2.shape` much be equal. This Gist is licensed under the mod…
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
@thisissyu
thisissyu / tee.py
Created January 16, 2022 01:46 — forked from mike1026915/tee.py
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()
@thisissyu
thisissyu / rclone@.service
Created April 17, 2021 07:02 — forked from kabili207/Rclone systemd service.md
Rclone systemd user service
# 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