This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pathlib | |
import pyais | |
from pyais.tracker import AISTrackEvent | |
def do_something(track): | |
# called every time an AISTrack is created or updated | |
print(track.mmsi, track) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WAS_SPACE = 0 | |
NEW_LINE = 1 | |
NEW_WORD = 2 | |
WAS_WORD = 3 | |
SPACES = [9,10,11,12,13,32] | |
NEWLINE = 10 | |
def init_table(): | |
# 0 => was space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.11-slim | |
WORKDIR /multi | |
COPY . . | |
CMD ["python", "./sender.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from llama_index.llms import HuggingFaceLLM | |
from llama_index.prompts import PromptTemplate | |
selected_model = 'mistralai/Mixtral-8x7B-Instruct-v0.1' | |
SYSTEM_PROMPT = """You are an AI assistant that answers questions in a friendly manner, based on the given source documents. Here are some rules you always follow: | |
- Generate human readable output, avoid creating output with gibberish text. | |
- Generate only the requested output, don't include any other language before or after the requested output. | |
- Never say thank you, that you are happy to help, that you are an AI agent, etc. Just answer directly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
def row2int(row: str) -> list[int]: | |
return list(map(int, row.strip().split(' '))) | |
def rows2list(fd): | |
l = [] | |
for row in fd: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""An example demonstrating the limitations of the GIL (CPython). This example | |
increments a counter for a given challenge so that the first N bits of the SHA1 | |
hash of the challenge are all zeros (0). The computational effort increases | |
exponentially with the number of bits required to be zero. | |
This demo illustrates that this task cannot be sped up by parallelizing the | |
computation.""" | |
import base64 | |
import hashlib | |
import threading |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
import datetime | |
import hashlib | |
import string | |
import random | |
YYMMDDhhmm = '%y%m%d%H%M' | |
YYMMDDhhmmss = '%y%m%d%H%M%S' | |
ASCII_LETTERS = string.ascii_letters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List | |
class Solution: | |
def firstMissingPositive(self, nums: List[int]) -> int: | |
return 0 | |
if __name__ == '__main__': | |
assert Solution().firstMissingPositive([2,1,0]) == 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Requires sqlalchemy and sqlalchemy_mixins. Install via pip | |
""" | |
import pathlib | |
import typing | |
from sqlalchemy import ForeignKey, Text, create_engine, Column, Integer, String | |
from sqlalchemy.orm import create_session, relationship, declarative_base | |
from sqlalchemy_mixins import ReprMixin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ast | |
import operator as op | |
DEFINED_OPS = { | |
ast.Add: op.add, | |
ast.Sub: op.sub, | |
ast.Mult: op.mul, | |
ast.Div: op.truediv, | |
ast.USub: op.neg, |
NewerOlder