Skip to content

Instantly share code, notes, and snippets.

Avatar

Henrik Holst hholst80

View GitHub Profile
View app.py
import sys
import queue
import threading
import time
import datetime
import uuid
from concurrent.futures import ThreadPoolExecutor
import flask
View app.py
import sys
import queue
from concurrent.futures import ThreadPoolExecutor
import flask
app = flask.Flask(__name__)
executor = ThreadPoolExecutor(max_workers=3)
def format_sse(data, event=None):
@hholst80
hholst80 / Dockerfile
Last active Dec 30, 2020
Docker signal
View Dockerfile
FROM python:3 as base
FROM base as target2
COPY main2.py /
CMD python3 -u main2.py
FROM base as target1
COPY main.py /
CMD python3 -u main.py
View README.md

Largest submatrix problem

A problem found on Linkedin.

Find the submatrix with the largest sum.

Example given:

A =
@hholst80
hholst80 / sumprod.m
Created Aug 14, 2018
summa produkt pussel
View sumprod.m
K = 100;
A = zeros(K);
B = zeros(K);
for x = 2:K
for y = 2:K
A(x,y) = x + y;
B(x,y) = x * y;
end
end
View test.py
import time
import concurrent.futures
def worker(n):
time.sleep(n)
return 42
with concurrent.futures.ThreadPoolExecutor() as extor:
View README-dev.md

Python

pip install a github repository

pip install git+https://github.com/hholst80/gym-air

It is also possible to pip install from a private repository using deploy keys, see:

@hholst80
hholst80 / dos
Created Jan 28, 2017
Docker on Steriods
View dos
#!/bin/bash
# trap "{ echo killing $$ > $HOME/test.log; }" SIGHUP
CID=$(docker run -tid alpine:latest /bin/sh -c "/bin/sleep 3600")
trap "{ docker stop $CID && docker rm $CID; }" SIGHUP
docker attach $CID
View README-centos7.md
View OO_for_the_evil_enterprise.py
# Basic dumb abstraction.
class Base(object):
def name(self):
return self._name
# ....
# MegaBase: an abstraction that we can work with.
# Classic OO and derived from Base.