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
#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 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 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 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 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 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 |
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
#include <cassert> | |
#include <cstdint> | |
#include <cstdlib> | |
#include <cstring> | |
// represents a totally unimodular matrix packing each number into 2 bits | |
// includes checking that operations never result in values other than -1,0,1 | |
class TUMatrix | |
{ | |
private: |
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
open all the art images in new tabs | |
1. use developer menu to search ".jpg" and find the first image of importance to get the class name | |
2. paste this into the developer console (using the class name found) | |
[].slice.call(document.getElementsByClassName('WorkImage__StyledImage-gl8mvm-1')).forEach(a => window.open(a.src,'_blank')) |
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 sys | |
DIGITS = int(sys.argv[1]) | |
assert DIGITS > 0 and DIGITS <= 6 | |
outfile = open(sys.argv[2],'w') | |
# use sliding window of digits | |
offset = 1 | |
window = sys.stdin.read(DIGITS) | |
assert len(window) == DIGITS |
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 fractions import Fraction as Frac | |
import math | |
# each is a single variable polynomial | |
# list of fractions for x^0,x^1,x^2,... terms | |
# length must be >= 1, zero polynomial is a list containing only 0 | |
# index p represents power sum with exponent p | |
formulas: list[list[Frac]] = [] | |
formulas.append([Frac(0),Frac(1)]) # p = 0 | |
#formulas.append([Frac(0),Frac(1,2),Frac(1,2)]) # p = 1 |
NewerOlder