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 / reservoir_sampling.py
Created September 15, 2023 01:44
Reservoir sampling for multiple sample sets
View reservoir_sampling.py
#!/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 (
"fmt"
"unsafe"
)
type Example struct {
Field1 int64
Field2 int32
@Pagliacii
Pagliacii / function-call.py
Created June 24, 2023 02:58
OpenAI function call example
View function-call.py
#!/usr/bin/env python3
# -*- coding=utf-8 -*-
import json
import requests
from loguru import logger
logger.remove()
logger.add('{time}.log')
@Pagliacii
Pagliacii / neovim-as-merge-tool.md
Last active June 17, 2023 10:49
Using Neovim as a merge tool
View neovim-as-merge-tool.md
@Pagliacii
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)
; DLL
@Pagliacii
Pagliacii / commands.sh
Created October 3, 2022 12:09
ufw config after install
View commands.sh
# 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 192.168.1.0/24 to any port 22 proto tcp
# enable the ufw
sudo ufw enable
@Pagliacii
Pagliacii / game.py
Last active November 7, 2021 06:09
An easy action adventure game based on text.
View game.py
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
"""An easy action adventure game based on text."""
import random
import time
import uuid
from typing import Dict, Generator, List, Protocol
@Pagliacii
Pagliacii / query.py
Created October 24, 2021 03:30
Query IP location based on QQWry.dat file
View query.py
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import mmap
import struct
import socket
import pathlib
from typing import Tuple
@Pagliacii
Pagliacii / 24-game.py
Last active October 24, 2021 03:43
Solutions to the 24 Game
View 24-game.py
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import itertools
from typing import Optional
from expression import Expr
from fraction import Frac