Skip to content

Instantly share code, notes, and snippets.

View Pagliacii's full-sized avatar
🎯
Focusing

Jason Huang Pagliacii

🎯
Focusing
View GitHub Profile
@Pagliacii
Pagliacii / AutoHotkey.ahk
Created July 31, 2020 08:23
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.
debounceLeftClick()
{
Sleep, 10
if !GetKeyState("LButton", "P")
{
n := 1
BlockInput, On
Loop {
Sleep, 10
if (n++ > 9)
@Pagliacii
Pagliacii / SendUnicode.ahk
Last active November 14, 2020 07:30
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.
getUnicodeFromInputBox()
{
Sleep, 10
InputBox, Code, AutoHotkey, Enter the Unicode, , 320, 112
Send, {U+%Code%}
}
; Binding to CapsLock+x
CapsLock & x::getUnicodeFromInputBox()
@Pagliacii
Pagliacii / falsehoods-programming-time-list.md
Created January 15, 2021 04:31 — forked from timvisee/falsehoods-programming-time-list.md
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.

Falsehoods

  • 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
Pagliacii / swf_header.py
Last active January 26, 2021 11:58
Parsing and getting the header of SWF files. [Adobe SWF File Format Specification](https://www.adobe.com/content/dam/acom/en/devnet/pdf/swf-file-format-spec.pdf)
#!/usr/bin/env python3
# _*_ coding:utf-8 _*_
"""
Author: Pagliacii
Copyright © 2020-Pagliacii-MIT License
"""
import math
from struct import unpack
@Pagliacii
Pagliacii / add_menu_items.ahk
Created February 9, 2021 06:37
Add custom menu items to the AHK tray menu, which lets you can edit the current running script with your favored editor.
#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.
insertMenuItemsBeforeStandard()
;
; This functions inserts your menu items before the standard menu
;
insertMenuItemsBeforeStandard() {
@Pagliacii
Pagliacii / process_exists.ahk
Created February 9, 2021 07:29
This function checks if the specified name process exists and returns the unique ID (HWND) of the first matching window.
processExist(name) {
DetectHiddenWindows, On
existed := WinExist("ahk_exe" name)
DetectHiddenWindows, Off
Return existed
}
@Pagliacii
Pagliacii / which_command.ps1
Last active February 21, 2021 14:53
A which command implementation in PowerShell
Function WhichCommand(
[String]$cmd
) {
try {
$Command = Get-Command -ErrorAction Stop $cmd
}
catch {
Write-Host -ForegroundColor Red ("{0} not found" -f $cmd)
Return
}
@Pagliacii
Pagliacii / insert-file-content.org
Last active February 21, 2021 17:30
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="./README.org" :var revision="HEAD"
#+header: :var start=1 :var end=-1
#+begin_src emacs-lisp
(substring
  (shell-command-to-string
    (format "git show %s:%s | sed -n '%d,%sp;d'"
            revision
@Pagliacii
Pagliacii / reverse-proxy.org
Last active March 10, 2021 04:34
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
Pagliacii / config.el
Created March 24, 2021 06:23
Auto-switch to relative line number if activating the visual mode. Doom Emacs.
;; 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)