Skip to content

Instantly share code, notes, and snippets.

View zw963's full-sized avatar
๐Ÿ 
Working from home

Billy.Zheng zw963

๐Ÿ 
Working from home
View GitHub Profile
@zw963
zw963 / .wezterm.lua
Last active February 5, 2024 17:30
The best emacs like editor for use in terminal. (e.g. docker/remote vps)
-- Pull in the wezterm API
local wezterm = require 'wezterm'
local act = wezterm.action
local mux = wezterm.mux
-- This table will hold the configuration.
local config = {}
-- In newer versions of wezterm, use the config_builder which will
-- help provide clearer error messages
@zw963
zw963 / add_capslock_ctrl.sh
Last active August 8, 2023 12:40
A script which change Capslock to Ctrl, and change rightAlt to Capslock for GNOME + Wayland for Arch linux.
#! /bin/bash
if ! fgrep -qs 'ctrl:new_ctrl = +new_ctrl(new_ctrl)' /usr/share/X11/xkb/rules/evdev; then
sudo sed -i.bak '/ctrl:nocaps[[:blank:]]*=[[:blank:]]*+ctrl(nocaps)/a\
ctrl:new_ctrl = +new_ctrl(new_ctrl)
' /usr/share/X11/xkb/rules/evdev
fi
cat <<'HEREDOC' |sudo tee /usr/share/X11/xkb/symbols/new_ctrl
partial modifier_keys
@zw963
zw963 / flycheck-eglot.el
Created March 5, 2022 19:37
flycheck works with eglot (Stolen from doom)
(defvar-local +lsp--flycheck-eglot--current-errors nil)
(defun +lsp--flycheck-eglot-init (checker callback)
"CHECKER is the checker (eglot).
CALLBACK is the function that we need to call when we are done, on all the errors."
(eglot-flymake-backend #'+lsp--flycheck-eglot--on-diagnostics)
(funcall callback 'finished +lsp--flycheck-eglot--current-errors))
(defun +lsp--flycheck-eglot--on-diagnostics (diags &rest _)
(cl-labels
@zw963
zw963 / em_fiber.rb
Last active December 9, 2022 03:46
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# ๆœ‰ๅ…ณ Fiber ็š„่งฃ้‡Š: (ๆŒ‰็…งๆ•ฐๆฎๆต็š„ๆ–นๅ‘ๅˆ†ไธบไธค้ƒจๅˆ†)
# ๅœจ `ไธป็บฟ็จ‹' ไธญไฝฟ็”จ resume ๆ–นๆณ•ๆฅๅฏๅŠจ(ๆˆ–็ปง็ปญๆ‰ง่กŒ)ไธ€ไธช `็บค็จ‹'.
# 1. ็ฌฌไธ€ๆฌก่ฐƒ็”จ fiber.resume, ไผšๅฏๅŠจไธ€ไธช็บค็จ‹,
# ๅฆ‚ๆžœ resume ่ฐƒ็”จๆ—ถๆไพ›ไบ†ๅฎžๅ‚, ไผšไฝœไธบไปฃ็ ๅ—ๅฝขๅ‚ไผ ๅ…ฅไปฃ็ ๅ—.
# 2. ๅฆ‚ๆžœ้ž็ฌฌไธ€ๆฌก่ฐƒ็”จ fiber.resume, ๅณ, `ๆขๅค' ไธ€ไธช็บค็จ‹, ไผšๅšไธคไปถไบ‹:
# - ไปŽไธŠๆฌก็ฆปๅผ€็บค็จ‹็š„้‚ฃไธชไฝ็ฝฎ(่ฐƒ็”จ Fiber.yield ็ฆปๅผ€็บค็จ‹็š„้‚ฃไธชไฝ็ฝฎ), ๆขๅค็บค็จ‹็š„ๆ‰ง่กŒ.
(require 'gist)
(provide 'gist_init)
;;; gist_init ends here
#!/bin/bash
# ensure add this rm script's $PATH before system /usr/bin/rm command.
# a linux rm (wrapper) script which can only use -rf/-r/-f option immediately following rm command.
# e.g.
# rm ~/.cache -rf # failed! with rm: -rf: No such file or directory
# rm -rf ~/.cache # success!
case "${@:(-1)}" in
#! /bin/bash
USE_COPY=
function readlink1() {
(cd "$1" && pwd -P)
}
function backup () {
mv $* $*_bak-$(date '+%Y-%m-%d_%H:%M')
(require 'multi-vterm)
(defun toggle-drop-down-term ()
"Open a drop-down terminal in the same directory as the current file."
(interactive)
(require 'multi-vterm)
(let ((win (get-local-window-for-buffer-name "*vterminal")))
(if win
(delete-window win)
(let ((vterm-buffer
(require 'multi-vterm)
(defun toggle-drop-down-term ()
"Open a drop-down terminal in the same directory as the current file."
(interactive)
(require 'multi-vterm)
(let ((win (get-local-window-for-buffer-name "*vterminal")))
(if win
(delete-window win)
(let ((vterm-buffer
(require 'multi-vterm)
(defun toggle-drop-down-term ()
"Open a drop-down terminal in the same directory as the current file."
(interactive)
(require 'multi-vterm)
(let ((win (get-local-window-for-buffer-name "*vterminal")))
(if win
(delete-window win)
(let ((vterm-buffer