Skip to content

Instantly share code, notes, and snippets.

View Pagliacii's full-sized avatar

Jason Huang Pagliacii

View GitHub Profile
Pagliacii /
Last active February 25, 2024 20:40
Use ctypes to call WIndows API
#!/usr/bin/env python3
# _*_ coding:utf-8 _*_
import ctypes
import os
from ctypes import windll, wintypes
from typing import Optional
NULL: int = 0
Pagliacii /
Last active February 17, 2024 14:28
Using Neovim as a merge tool


Using diffview.nvim

# ~/.gitconfig
  tool = diffview
  prompt = false
Pagliacii / .zshrc
Created October 14, 2023 02:56
Diff your repo files via FZF
View .zshrc
# ----------------------------------
# Function: gdcp
# Description:
# This function allows you to interactively select a file from the list of modified files
# in a Git repository, view the diff, and copy it to the clipboard.
# Parameters:
# None
# Returns:
Pagliacii /
Created September 15, 2023 01:44
Reservoir sampling for multiple sample sets
#!/usr/bin/env python3
# coding=utf-8
import random
import time
def get_elems(total):
for i in range(total):
yield {
View main.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef char *sds;
typedef struct String {
int len;
int free;
char data[];
View alignment.go
package main
import (
type Example struct {
Field1 int64
Field2 int32
Pagliacii /
Created April 28, 2020 08:51
Use gnash and ffmpeg to convert *.swf to *.mp4
trap cleanup EXIT
set -eux
set -o pipefail
RAWFILE=$(cat /dev/urandom | tr -dc 'a-zA-Z' | fold -w 32 | head -n 1).raw
WAVFILE=$(cat /dev/urandom | tr -dc 'a-zA-Z' | fold -w 32 | head -n 1).wav
Pagliacii /
Created June 24, 2023 02:58
OpenAI function call example
#!/usr/bin/env python3
# -*- coding=utf-8 -*-
import json
import requests
from loguru import logger
Pagliacii / AutoHotKey.ahk
Created March 25, 2023 11:32
Make your life easy when you're using Windows
View AutoHotKey.ahk
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; 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).
; Globals
DesktopCount = 2 ; Windows starts with 2 desktops at boot
CurrentDesktop = 1 ; Desktop count is 1-indexed (Microsoft numbers them this way)
Pagliacii /
Created October 3, 2022 12:09
ufw config after install
# check status
sudo ufw status
# deny all incoming
sudo ufw default deny incoming
# allow from a specific source IP address or entire subnet to connect to our port 22
sudo ufw allow from to any port 22 proto tcp
# enable the ufw
sudo ufw enable