Skip to content

Instantly share code, notes, and snippets.

View ysl2's full-sized avatar
🐧
Working

Silas Yu ysl2

🐧
Working
View GitHub Profile
@ysl2
ysl2 / tmux_cheatsheet.markdown
Created February 8, 2023 14:31 — forked from henrik/tmux_cheatsheet.markdown
tmux cheatsheet

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@ysl2
ysl2 / 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
@ysl2
ysl2 / 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"
@ysl2
ysl2 / 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
@ysl2
ysl2 / README.md
Created March 11, 2022 06:54 — forked from shawnsi/README.md
Pacman Automatic Updates

Background

I may have let Arch go months without updates before. Its not advisable to apply them on a schedule either.

Solution

Providing regular prompts to apply updates seems like the best solution.

Schedule Download of Packages

This cronjob will download packages and cache locally. Put into root's crontab or run via sudo.

@ysl2
ysl2 / 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]
@ysl2
ysl2 / _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
@ysl2
ysl2 / 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()
@ysl2
ysl2 / ssh-copy-id.py
Created September 10, 2021 12:48 — forked from ceilfors/ssh-copy-id.py
ssh-copy-id for Windows
"""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
Basic
=====
[Shift]+[Mod]+[Enter] - launch terminal.
[Mod]+[b] - show/hide bar.
[Mod]+[p] - dmenu for running programs like the x-www-browser.
[Mod]+[Enter] - push acive window from stack to master, or pulls last used window from stack onto master.
[Mod] + [j / k] - focus on next/previous window in current tag.