Skip to content

Instantly share code, notes, and snippets.

@AnchorBlues
AnchorBlues / dict_vs_XXX.py
Created May 19, 2021 02:34
辞書の代わりに用いることが出来るオブジェクト比較
from collections import namedtuple
from typing import NamedTuple
from dataclasses import dataclass, asdict
# Python 3.7.3 で検証
D = namedtuple('D', ('a', 'b', 'c'))
# 一部のメンバだけデフォルト値指定、というのができない? また、mypyに怒られる(正式な書き方じゃない?)。
D.__new__.__defaults__ = (1, None, 0)
@GrantBirki
GrantBirki / tarkov-time-python.py
Created March 1, 2022 07:49
Tarkov Time in Python
from datetime import datetime
# 7 seconds for every one second in real time
TARKOV_RATIO = 7
def real_time_to_tarkov_time(time, left = True):
"""
Convert real time to Tarkov time
:param time: Current UTC epoch in milliseconds -> int(datetime.datetime.utcnow().timestamp()) * 1000
:param left: True if left side, False if right side (Think eft in-game clock)
@tarleb
tarleb / interactive.lua
Last active October 21, 2022 11:02
Helper function for interactive Lua filters
function interactive (it, env)
local has_readline, RL = pcall(require, 'readline')
if not has_readline then
RL = {
readline = function (prompt)
io.stdout:write(prompt)
return io.read()
end
}