aboutsummaryrefslogtreecommitdiff
path: root/home/dot_local/share/bin/executable_=
diff options
context:
space:
mode:
Diffstat (limited to 'home/dot_local/share/bin/executable_=')
-rw-r--r--home/dot_local/share/bin/executable_=45
1 files changed, 45 insertions, 0 deletions
diff --git a/home/dot_local/share/bin/executable_= b/home/dot_local/share/bin/executable_=
new file mode 100644
index 0000000..5e69f91
--- /dev/null
+++ b/home/dot_local/share/bin/executable_=
@@ -0,0 +1,45 @@
+#!/bin/python3 --
+from sys import argv as _argv
+from os import environ as _environ, path as _path
+from math import *
+
+_ans_path = _path.join(_environ["XDG_CACHE_HOME"], "calc_ans")
+try:
+ _ans_file = open(_ans_path, "r+")
+except:
+ _ans_file = open(_ans_path, "w+")
+_exit_code = 0
+
+ans = 0
+try:
+ _ans_str = _ans_file.read()
+ if "." in _ans_str:
+ ans = float(_ans_str)
+ else:
+ ans = int(_ans_str)
+except:
+ pass
+
+deg = pi / 180
+
+MIN = min
+MAX = max
+BIT = lambda n: 1 << n
+GENMASK = lambda h, l: (BIT(MAX(h, l) + 1) - 1) ^ (BIT(MIN(h, l)) - 1)
+KB = lambda x: x << 10
+MB = lambda x: x << 20
+GB = lambda x: x << 30
+
+try:
+ ans = eval(" ".join(_argv[1:]))
+ print(ans)
+except:
+ pass
+
+_ans_file.truncate(0)
+_ans_file.seek(0)
+_ans_file.write(str(ans))
+_ans_file.close()
+
+exit(_exit_code)
+