Skip to content

Instantly share code, notes, and snippets.

Pagliacii / config.el
Created Mar 24, 2021
Auto-switch to relative line number if activating the visual mode. Doom Emacs.
View config.el
;; This determines the style of line numbers in effect. If set to `nil', line
;; numbers are disabled. For relative line numbers, set this to `relative'.
(setq display-line-numbers-type 'absolute)
;; Auto-switch to relative line number if entering the visual mode
(add-hook! 'evil-visual-state-entry-hook #'menu-bar--display-line-numbers-mode-relative)
(add-hook! 'evil-visual-state-exit-hook #'menu-bar--display-line-numbers-mode-absolute)
Pagliacii /
Last active Mar 10, 2021
Basic Nginx reverse proxy to forwarding requests from host to virtual machine local server.

This idea came from I am trying to access the local server inside a virtual machine from the browser on the host machine. Maybe you would ask why did I not use the Nat network port forwarding? The primary reason is that I want to keep my config files to be consistent for all machines. So I don’t need to change its contents when using those configs on virtual machines. *Click* Nice

Pagliacii /
Last active Feb 21, 2021
Quick insert file content into .org file. You can specify a history version of the file!
#+name: show-file-content
#+header: :exports none :tangle no :results value raw
#+header: :var path="./" :var revision="HEAD"
#+header: :var start=1 :var end=-1
#+begin_src emacs-lisp
    (format "git show %s:%s | sed -n '%d,%sp;d'"
Pagliacii / process_exists.ahk
Created Feb 9, 2021
This function checks if the specified name process exists and returns the unique ID (HWND) of the first matching window.
View process_exists.ahk
processExist(name) {
DetectHiddenWindows, On
existed := WinExist("ahk_exe" name)
DetectHiddenWindows, Off
Return existed
Pagliacii / add_menu_items.ahk
Created Feb 9, 2021
Add custom menu items to the AHK tray menu, which lets you can edit the current running script with your favored editor.
View add_menu_items.ahk
#NoEnv ; Recommended for performance and compatibility with future AutoHotKey releases.
SendModeInput ; Recommended for new scripts due to its superior speed and reliability.
#Persistent ; Keeps a script permanently running (that is, until the user closes it or ExitApp is encountered.
; This functions inserts your menu items before the standard menu
insertMenuItemsBeforeStandard() {
Pagliacii / which_command.ps1
Last active Feb 21, 2021
A which command implementation in PowerShell
View which_command.ps1
Function WhichCommand(
) {
try {
$Command = Get-Command -ErrorAction Stop $cmd
catch {
Write-Host -ForegroundColor Red ("{0} not found" -f $cmd)
Pagliacii /
Created Jan 15, 2021 — forked from timvisee/
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.


  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
Pagliacii / SendUnicode.ahk
Last active Nov 14, 2020
This function pops up the input box to ask the user to enter some Unicode to input the corresponding character into the current input area.
View SendUnicode.ahk
Sleep, 10
InputBox, Code, AutoHotkey, Enter the Unicode, , 320, 112
Send, {U+%Code%}
; Binding to CapsLock+x
CapsLock & x::getUnicodeFromInputBox()
Pagliacii /
Last active Feb 7, 2021
A shell script to run command behind the proxy.
#!/usr/bin/env bash
# 0. (Optional) Rename this script name to "proxy"
# 1. Replace the <protocol>, <ip> and <port> to the actual value of your proxy respectively.
# 2. Run this command `sudo chmod +x <path to proxy>` to make sure this script is executable.
# 3. Add this script path to the PATH environment variable.
# 4. Run your actual command like this: `proxy ping`.
export ALL_PROXY=<protocol>://<ip>:<port>
export HTTP_PROXY=<protocol>://<ip>:<port>
Pagliacii / AutoHotkey.ahk
Created Jul 31, 2020
Preventing the left mouse button double-click in the small period, because the microswitch of my left mouse button has some damages. Base on the AutoHotkey script.
View AutoHotkey.ahk
Sleep, 10
if !GetKeyState("LButton", "P")
n := 1
BlockInput, On
Loop {
Sleep, 10
if (n++ > 9)