Skip to content

Instantly share code, notes, and snippets.

View voglster's full-sized avatar

James Vogel voglster

View GitHub Profile
import asyncio
import time
from auth.model import TokenData
from pymongo import ReadPreference
from driver.schema import DriverCache
from driver_schedule.endpoints import get_driver_schedule_ep
from driver_schedule.schema import DriverScheduleRequest
from order.modelv3 import OrderV3
import telnetlib
import sys
from loguru import logger
from data import tank_monitor_lookup
def get_data_telnet(host: str, port: int):
command = f"\x01I20100".encode("ascii")
@classmethod
async def find_by_loss(
cls, name: str, insurance_type: str, org_id: PydanticObjectId | ObjectId
):
# This is ugly but required to handle case-insensitive queries as beanie doesn't seem to
return [
Commission.parse_obj(x)
for x in await Commission.get_motor_collection()
.find(
{
@voglster
voglster / k.py
Last active June 28, 2022 18:58
Keeney apply
from pprint import pprint
from collections import defaultdict
import pandas as pd
data = [
{'item_code': "A1234", "contract_size": 1, "contract_number": 1},
{'item_code': "B1234", "contract_size": 3, "contract_number": 1},
{'item_code': "01234", "contract_size": 1, "contract_number": 2},
{'item_code': "X1234", "contract_size": 2, "contract_number": 2},
from pulp import LpVariable, LpProblem, LpMaximize, LpStatus, value, LpInteger
# abstract simple problem
prob = LpProblem("Flow Model", LpMaximize)
# decision variables
buy_d1 = LpVariable("buy_d1", 0, 60_000)
buy_d2 = LpVariable("buy_d2", 0, 60_000)
store_d1_d2 = LpVariable("store_d1_d2", 0, 50_000)
store_d2_d3 = LpVariable("store_d2_d3", 0, 50_000)
from itertools import count, cycle, repeat, islice
from PIL import Image, ImageDraw
class ArrayCursor:
position = 0, 0
def move_north(self):
self.position = self.position[0], self.position[1] + 1
def move_south(self):
# given an NxN array of colors (rgb) randomly distributed
# write an function that returns the largest area of the same color
# areas are defined as having a common side (no diagonals)
from random import choice
from typing import Tuple
colors = ("r", "g", "b")
def generate_array(size):
@voglster
voglster / foo.py
Last active November 9, 2021 18:00
from typing import List
from bol.model import Bol
from order.enums import MovementValidationType
from order.modelv2 import OrderV2
def get_extra_supply(order: OrderV2, bols: List[Bol]):
# union all supply from bols
bol_supply = set(supply for bol in bols for supply in bol.supply())
from math import cos, radians, sin
from random import randint
import pygame
from easing_functions import QuadEaseInOut
# from maze_test.sprite_sheet import SpriteSheet
FPS = 30
gravity = (0, 0.3)
from graphics import *
import time
# The given constants work well in a window that is at least 400 by 600.
# Gallows constants
GALLOWS_UPRIGHT = 150 #The x value of the upright for the gallows
GALLOWS_TOP_Y = 200
GALLOWS_BOTTOM_Y = 400
GALLOWS_BASE_LEFT_X = GALLOWS_UPRIGHT - 50