Skip to content

Instantly share code, notes, and snippets.

View jonaslsaa's full-sized avatar

Jonas jonaslsaa

View GitHub Profile
@jonaslsaa
jonaslsaa / tictactoe_vs.c
Created February 22, 2025 21:11
Tic-Tac-Toe tournament with two MCTS bots, OpenMP parallelization, and performance stats.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <omp.h> // Include OpenMP header
/**********************************************************
* DATA STRUCTURES
**********************************************************/
@jonaslsaa
jonaslsaa / lspclient.py
Created January 31, 2024 17:30
Simple LSPClient for Python
import os
# Define the path to the Python script you want to analyze
# path of this file
my_path = os.path.dirname(os.path.realpath(__file__))
file_path = os.path.join(my_path, 'main.py')
import subprocess
import json
class LSPClient:
# check ping and return ping
from pythonping import ping
import time
import re
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'
@jonaslsaa
jonaslsaa / AVLTree.py
Created September 7, 2021 10:38
Python implementation of AVL self-balancing BST
# AVL Tree by vox and kritjo
class AVLTree:
root = None
def left_rotate(self, z):
y = z.right
T = y.left
y.left = z
z.right = T
z.height = 1 + max(self.height(z.left), self.height(z.right))
@jonaslsaa
jonaslsaa / jackett.py
Created April 9, 2021 14:50
jackett.py for qBittorrent (fixed)
# VERSION: 3.6
# AUTHORS: Diego de las Heras ([email protected])
# CONTRIBUTORS: TheVoxcraft
# ukharley
# hannsen (github.com/hannsen)
import json
import os
import xml.etree.ElementTree
from urllib.parse import urlencode, unquote
@jonaslsaa
jonaslsaa / findingPrimesMulti.c
Created March 17, 2021 16:32
My multithreaded implementation in C of finding primes, 10x faster than PyPy implementation .
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <time.h>
#include <pthread.h>
#include <math.h>
struct thread_args{
int start_number;
int end_number;
import multiprocessing as mp
import time
#max number to look up to
max_number = 200_000
#four processes per cpu
num_processes = mp.cpu_count() * 6
def chunks(seq, chunks):
size = len(seq)
boolean trykketRiktig;
boolean tapt;
long startTid;
int G1=2;
int G2=3;
int G3=4;
int G4=6;
int G5=7;
int G6=8;
boolean trykketRiktig;
long startTid;
int G1=2;
int G2=3;
int G3=4;
int R1=5;
int G4=6;
int G5=7;
int G6=8;
@jonaslsaa
jonaslsaa / Vector3.py
Created August 8, 2017 14:41
Vector3 Class in python3
import math
class Vector3:
x = 0
y = 0
z = 0
def __init__(self, _x, _y, _z):
self.x = _x
self.y = _y
self.z = _z
def __add__(self, other):