Skip to content

Instantly share code, notes, and snippets.

View acheong08's full-sized avatar
🎯
Focusing

Antonio Cheong acheong08

🎯
Focusing
  • Cardiff University
  • Your computer
  • 20:15 (UTC +01:00)
View GitHub Profile
@acheong08
acheong08 / Sequences_calc.py
Last active April 3, 2022 10:32
Sequences and series calculator
def Quadratic():
option = int(input("Options: 1) Enter formula 2) Enter three terms"))
if option == 2:
terms = [None, None, None, None]
for i in range(1,4):
terms[i] = float(input(str("Enter term " + str(i) + ": ")))
diff1 = terms[2] - terms[1]
diff2 = terms[3] - terms[2]
quadiff = diff2 - diff1
a = quadiff / 2
@acheong08
acheong08 / benchmark.py
Last active March 26, 2022 10:06
Threaded CPU benchmark
# Importing modules
from time import perf_counter
from hashlib import md5
from random import randint
from multiprocessing import Pool
import sys
# Basic function to hash a string
def getMD5(plaintext):
m = md5()
@acheong08
acheong08 / RSAcrack.py
Created March 28, 2022 08:40
Threaded RSA cracker
# Importing modules
from time import perf_counter
from hashlib import md5
from random import randint
from multiprocessing import Queue, Process, Pool
import sys
# Global variables
q = Queue()
@acheong08
acheong08 / excel-to-sqlite.py
Last active September 21, 2022 20:58
Convert excel to SQLite database
# This program takes an excel documents and maps it to a sqlite database.
# It is designed to be used with the excel-to-sqlite.xlsx template.
#
import sqlite3
import xlrd
import sys
import logging
import openpyxl
def useOPENPYXL(excelFile, sqliteFile):
@acheong08
acheong08 / pyextract.py
Last active January 18, 2023 06:01
Extract classes and functions from Python files
import argparse
import json
import ast
from ast import parse,walk
from astor import to_source
def extract_functions(node,is_class=False):
"""Recursively extract function names and code from an AST node."""
functions = {}
for child in walk(node):
@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,
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 / 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
@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.