Skip to content

Instantly share code, notes, and snippets.

View erewok's full-sized avatar

Erik erewok

View GitHub Profile
@erewok
erewok / README.md
Last active December 1, 2024 19:56
Implementation of Control Flow Analysis from the Paper

Interval Creation Process:

  • The algorithm starts at the entry node and creates the first interval.
  • It adds nodes to the current interval if ALL of their predecessors are already in the interval.
  • When a node is found that doesn't satisfy this condition, it becomes a new header node, starting a new interval.

Key Stopping Condition: The crucial part of stopping node addition to an interval is the all_preds_in_interval check.

Specifically:

  • If all predecessors of a node are already in the current interval, the node is added to that interval.
@erewok
erewok / ConnectionPooling.tla
Last active November 25, 2024 23:46
Azure Python SDK Connection Pooling (Sharing)
---- MODULE ConnectionPooling ----
EXTENDS Integers, FiniteSets, Sequences
CONSTANTS
\* Maximum number of connections in the pool (usually <10)
MaxPoolSize,
\* Maximum number of clients per connection (arbitrary, e.g. 10 or 100)
MaxClientsPerConnection
@erewok
erewok / pyproject.toml
Last active March 7, 2023 22:37
Azure service-bus Receiver with Opentelemetry Tracing Bug
[tool.poetry]
name = "service-bus-otel-test"
version = "1.0.0"
description = "Service Bus otel test"
authors = ["Erik Aker <[email protected]>"]
[tool.poetry.dependencies]
python = "^3.11"
azure-core = "^1.26.3"
azure-servicebus = "7.8.2"
@erewok
erewok / compose.py
Last active August 17, 2022 20:34
Python function composition
"""compose.py - Function composition in Python
"""
# Python module for function composition
from functools import reduce, wraps
from itertools import chain
from typing import Callable, Generic, TypeVar
#!/bin/bash
while [ ! -f /var/lib/cloud/instance/boot-finished ]; do
echo "Cloud Init is still configuring the server."
sleep 1
done
echo "Cloud Init config complete. Lets build some apps!"
@erewok
erewok / Dockerfile
Created August 15, 2020 19:32
Cabal-stack Dockerfile
FROM debian:stretch-slim as base_os
## ensure locale is set during build
ENV LANG C.UTF-8
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
build-essential \
@erewok
erewok / streaming_streaming_base_middleware.py
Last active August 4, 2020 15:32
Example Starlette app to test different scenarios with BaseHttpMiddleware
import asyncio
import json
import uvicorn
from starlette.applications import Starlette
from starlette.middleware.base import BaseHTTPMiddleware
from starlette.background import BackgroundTask
from starlette.responses import JSONResponse, PlainTextResponse, StreamingResponse
class TransparentMiddlewareNoStreaming(BaseHTTPMiddleware):
@erewok
erewok / flask_app.py
Last active June 27, 2024 09:37
JSON Logging Inside a Flask Application: configuration for producing JSON logs under a Flask app running under gunicorn
"""
flask application
"""
import logging
import logging.config
import os
from flask import Flask
import structlog
@erewok
erewok / servant_custom_error.hs
Last active April 28, 2017 14:51
Custom Error as JSON from inside Handler
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
module Api.Post
(
PostApi
@erewok
erewok / install_stack.sh
Created April 25, 2017 05:10
install stack for travis
set -o errexit -o verbose
if test -f "$HOME/.local/bin/stack"
then
echo 'Stack is already installed.'
else
echo "Installing Stack for $TRAVIS_OS_NAME..."
URL="https://www.stackage.org/stack/$TRAVIS_OS_NAME-x86_64"
curl --location "$URL" > stack.tar.gz
gunzip stack.tar.gz