-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpythonrc
30 lines (22 loc) · 798 Bytes
/
pythonrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import rlcompleter, readline, random, math, re, sys, os, inspect, time, struct
from base64 import b64encode, b64decode, urlsafe_b64encode, urlsafe_b64decode
from math import *
del pow
readline.parse_and_bind('tab:complete')
def disas(x):
print(inspect.getsource(x))
def tempcol(f): # 0 = red, 1 = green
cols = [2-f*2, 1, 2-f*2] if f >= 0.5 else [1, 2*f, 2*f]
return [min(max(round(x * 255), 0), 255) for x in cols]
def color(cols, fg=38):
r,g,b = tempcol(cols) if isinstance(cols, float) else cols
return f"\x1b[{fg};2;{r};{g};{b}m"
def bgcolor(f):
return color(f, 48)
def ftoi(x):
return struct.unpack(">I", struct.pack(">f", x))[0]
def itof(x):
return struct.unpack(">f", struct.pack(">I", x))[0]
def tofloat(x):
return itof(ftoi(x))
RESET = "\x1b[0m"