This file contains hidden or 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 json | |
def multi_json(s:str): | |
d = json.JSONDecoder() | |
i = 0 | |
while i < len(s): | |
if s[i] in ' \t\n': | |
i += 1 | |
else: | |
obj,i = d.raw_decode(s,i) |
This file contains hidden or 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
''' | |
basic utils for ansi escape codes in terminal | |
- foreground color | |
- background color | |
- font styles | |
- 8 bit color | |
- 24 bit rgb color | |
- cursor movement | |
- screen clearing | |
- scrolling |
This file contains hidden or 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
class _escm: | |
''' | |
internal class for ansi escape codes | |
only supports the 'm' command for text color/format | |
support concatenations with each other | |
support concatenations with strings | |
''' | |
def __init__(self, *l: int|list[int]): | |
self.l: list[int] = [] | |
for n in l: |
This file contains hidden or 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
RSA-100 = 1522605027922533360535618378132637429718068114961380688657908494580122963258952897654000350692006139 | |
RSA-100 = 37975227936943673922808872755445627854565536638199 | |
× 40094690950920881030683735292761468389214899724061 | |
RSA-110 = 35794234179725868774991807832568455403003778024228226193532908190484670252364677411513516111204504060317568667 | |
RSA-110 = 6122421090493547576937037317561418841225758554253106999 | |
× 5846418214406154678836553182979162384198610505601062333 |
This file contains hidden or 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
#define define const struct | |
#define operator(ReturnType, OperatorName, FirstOperandType, SecondOperandType) OperatorName ## _ {} OperatorName; template <typename T> struct OperatorName ## Proxy{public:OperatorName ## Proxy(const T& t) : t_(t){}const T& t_;static ReturnType _ ## OperatorName ## _(const FirstOperandType a, const SecondOperandType b);};template <typename T> OperatorName ## Proxy<T> operator<(const T& lhs, const OperatorName ## _& rhs){return OperatorName ## Proxy<T>(lhs);}ReturnType operator>(const OperatorName ## Proxy<FirstOperandType>& lhs, const SecondOperandType& rhs){return OperatorName ## Proxy<FirstOperandType>::_ ## OperatorName ## _(lhs.t_, rhs);}template <typename T> inline ReturnType OperatorName ## Proxy<T>::_ ## OperatorName ## _(const FirstOperandType a, const SecondOperandType b) | |
define operator(int, foo, int, int) { | |
return a + b; | |
} | |
#define foo <foo> | |
int main() { |
This file contains hidden or 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
YT-DLP helpful options cheat sheet | |
basics: | |
--version | |
-U,--update | |
-i,--ignore-errors | |
--flat-playlist (list videos, no download) | |
video selection: | |
--datebefore YYYYMMDD |
This file contains hidden or 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
Named Binary Tag specification | |
NBT (Named Binary Tag) is a tag based binary format designed to carry large amounts of binary data with smaller amounts of additional data. | |
An NBT file consists of a single GZIPped Named Tag of type TAG_Compound. | |
A Named Tag has the following format: | |
byte tagType | |
TAG_String name | |
[payload] |
This file contains hidden or 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
#include <stdint.h> | |
#define MP(p) ((1uLL << p) - 1) | |
uint64_t mod_m61(uint64_t a) | |
{ | |
uint64_t tmp = (a & MP(61)) + (a >> 61); | |
if (tmp >= MP(61)) | |
tmp -= MP(61); | |
return tmp; |
This file contains hidden or 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
typedef struct { uint64_t lo, hi; } mul64_t; | |
mul64_t mul64(uint64_t a, uint64_t b) | |
{ | |
mul64_t ret; | |
__uint128_t c = (__uint128_t) a * (__uint128_t) b; | |
ret.hi = c >> 64; | |
ret.lo = c; | |
return ret; |
This file contains hidden or 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
rolls = 38 | |
wpbase = 150 # wish percent boost | |
def wp(r): | |
ret = 0 | |
if r > 15: | |
ret += 10*(r-15) | |
r = 15 | |
if r > 5: | |
ret += 15*(r-5) | |
r = 5 |
NewerOlder