Skip to content

Instantly share code, notes, and snippets.

View acheong08's full-sized avatar
🎯
Focusing

Antonio Cheong acheong08

🎯
Focusing
  • Cardiff University
  • Your computer
  • 05:58 (UTC +01:00)
View GitHub Profile
@acheong08
acheong08 / makeKeyHash.js
Last active August 17, 2023 08:04
Extracted hash function from Obsidian Vault. It is used at https://api.obsidian.md/vault/create and vault keyhash in websocket.
const crypto = require("crypto");
function B(e) {
return e.slice(e.byteOffset, e.byteOffset + e.byteLength);
}
async function _(e) {
const t = await j(e);
return G(t);
}
@acheong08
acheong08 / tunbypass.sh
Last active August 13, 2023 16:12
Linux script to allow certain IPs to bypass VPN
#!/bin/bash
if [ "$EUID" -ne 0 ]; then
echo "This script must be run as root."
exit 1
fi
if [ "$#" -lt 1 ]; then
echo "Usage: sudo tunbypass <add/del/list> [server_ip]"
exit 1
@acheong08
acheong08 / cmd.md
Created July 20, 2023 07:42
YouTube download command

yt-dlp $(xclip -o) -f m4a -o "%(id)s.%(ext)s"

from yt_dlp import YoutubeDL
from mutagen.easymp4 import EasyMP4
import os
ydl = YoutubeDL()
# List files
files = os.listdir()
# Filter out non-m4a files
files = [f for f in files if f.endswith(".m4a")]
@acheong08
acheong08 / reverse_character_ai.md
Created May 27, 2023 10:58
A guide on how to reverse engineer character.ai

Authentication:

  • Set cookies from your browser

Step 1: GET https://beta.character.ai/chat/curated_categories/characters/. It returns JSON. You are looking for external_id of the character you want. This will be used for all following steps (external_id or character_external_id)

Step 2: POST https://beta.character.ai/chat/character/info/ with {"external_id":"..."} as payload. Keep track of identifier from the response as tgt for step 4

Step 3: POST https://beta.character.ai/chat/history/create/ with the same payload as step 2. Keep track of external_id in the response as history_external_id.

@acheong08
acheong08 / del.py
Last active May 17, 2023 00:59
Delete files recursively. I used this to delete all Spanish/German copies of text from my past papers archive.
import os
import fnmatch
import sys
def delete_files(patterns, directory="."):
if len(patterns) == 0:
print("No patterns specified.")
sys.exit(1)
if not os.p
Prime Minister President
Head of government Head of state
Elected by the legislature Elected by the people
Appointed by the head of state Elected by the people or by a special body
Represents the country on the international stage Has the power to veto laws passed by the legislature and to appoint judges to the supreme court
May be removed from office by a vote of no confidence in the legislature May be removed from office by impeachment or by the expiration of their term of office
@acheong08
acheong08 / screenshot_dylib.c
Created March 26, 2023 03:37
gcc -dynamiclib -framework ApplicationServices src/screenshot.c -o dylib/screenshot_c.dylib
#include <ApplicationServices/ApplicationServices.h>
#include <stdio.h>
__attribute__((constructor))
void takeScreenshot() {
CGImageRef screenShot = CGDisplayCreateImage(kCGDirectMainDisplay);
CFURLRef fileURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
CFSTR("screenshot.png"),
kCFURLPOSIXPathStyle,
false);
CGImageDestinationRef dest = CGImageDestinationCreateWithURL(fileURL,