Skip to content

Instantly share code, notes, and snippets.

View TheVoxcraft's full-sized avatar

Jonas TheVoxcraft

  • University i Oslo (USIT)
View GitHub Profile
@TheVoxcraft
TheVoxcraft / 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'
@TheVoxcraft
TheVoxcraft / 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))
@TheVoxcraft
TheVoxcraft / jackett.py
Created April 9, 2021 14:50
jackett.py for qBittorrent (fixed)
# VERSION: 3.6
# AUTHORS: Diego de las Heras (ngosang@hotmail.es)
# CONTRIBUTORS: TheVoxcraft
# ukharley
# hannsen (github.com/hannsen)
import json
import os
import xml.etree.ElementTree
from urllib.parse import urlencode, unquote
@TheVoxcraft
TheVoxcraft / 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;
@TheVoxcraft
TheVoxcraft / 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):
@TheVoxcraft
TheVoxcraft / web_crawler.py
Created February 1, 2016 23:57
Web Crawler. NEEDS bs4 installed!
import requests
from bs4 import BeautifulSoup #NEEDS bs4 installed!
def trade_spider(max_page):
page = 1
while page <= max_page:
url = "http://www.finn.no/finn/realestate/homes/result?location=0%2F20061&page=" + str(page)
source_code = requests.get(url)
plain_text = source_code.text