Skip to content

Instantly share code, notes, and snippets.

View Torxed's full-sized avatar

Anton Hvornum Torxed

View GitHub Profile
@Torxed
Torxed / postgresql_perf_test.md
Last active February 2, 2024 21:47
PostgreSQL index Vs partitioning Vs inheritance

All tests were performed in a docker container, using the image postgres:15.4. All tests used the same test data, but with scrambled hash values.

Only deviation from postgresql default startup parameters were:

-c work_mem=2048MB
-c maintenance_work_mem=2048MB
-c max_wal_size=8GB
@Torxed
Torxed / cidr_to_netmask.py
Created January 7, 2022 15:39
Converts a CIDR notation to netmask
def cidr_to_netmask(cidr :int, bitlen=32) -> str:
netmask = ''
while cidr > 8:
netmask += '255.'
cidr -= 8
netmask += str(2 ** cidr - 1) # math.log(128, 2)
return netmask + ('.0' * (3 - netmask.count('.') if bitlen == 32 else 7 - netmask.count('.')))
import math
import pyglet
class Coordinate:
x = 0
y = 0
def __repr__(self):
return f'Coordinate(x: {self.x}, y: {self.y})'
from socket import *
sockets = {}
s = socket()
s.bind(('', 1234))
s.listen()
ns, na = s.accept()
sockets[na] = ns
import pyglet
import random
pyglet.resource.path = ["resources"]
pyglet.resource.reindex()
# sets the resource path
class Snake_Window(pyglet.window.Window):
import pyglet
key = pyglet.window.key
class main(pyglet.window.Window):
def __init__ (self, width=800, height=600, fps=False, *args, **kwargs):
super(main, self).__init__(width, height, *args, **kwargs)
self.x, self.y = 0, 0
<html>
<head>
<script>
for (let i=1; i <= 100; i++) {
let map = {3: "Fizz", 5: "Buzz"};
let output = ""
for (let key in map) {
output += i%key==0 ? map[key] : "";
}
#include <stdlib.h>
int main(int argc, char *argv[]) {
fd_set * poller;
FD_ZERO(poller);
}
import pyglet
from time import time
window = pyglet.window.Window()
last_update = time()
def update(*args):
global last_update
print('Update was called every:', time()-last_update,'seconds')
last_update = time()
DROP TABLE cars;
DROP TABLE people;
CREATE TABLE people (
id serial PRIMARY KEY,
fname varchar(80),
lname varchar(80),
address varchar(80),
postcode varchar(80),
city varchar(80),