From e43eb1177872f52e949fb5f0f93396ed94b0d093 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sun, 2 Aug 2026 14:48:29 +0200 Subject: move to chezmoi --- home/dot_local/share/bin/executable_= | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 home/dot_local/share/bin/executable_= (limited to 'home/dot_local/share/bin/executable_=') 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) + -- cgit v1.2.3