diff options
author | Marvin Borner | 2023-01-04 15:06:49 +0100 |
---|---|---|
committer | Marvin Borner | 2023-01-04 15:06:49 +0100 |
commit | 8e3a7a0d5b0096a0e7bea934fa55ee910a7a3f0a (patch) | |
tree | 1962cadbb135d5d1c3e8a48eb126cc485cbbc32e | |
parent | b1e8ffead806a10c8d6ac6912103dc6655d4d523 (diff) |
Added broogle
best name amirite
-rwxr-xr-x | broogle.sh | 48 | ||||
-rw-r--r-- | research/dat_k.csv | 36 | ||||
-rw-r--r-- | research/dat_n.csv | 36 | ||||
-rw-r--r-- | research/root.py | 36 |
4 files changed, 48 insertions, 108 deletions
diff --git a/broogle.sh b/broogle.sh new file mode 100755 index 0000000..3742731 --- /dev/null +++ b/broogle.sh @@ -0,0 +1,48 @@ +#!/bin/env bash +# MIT License, Copyright (c) 2023 Marvin Borner +# TODO: jq is quite slow tbh hmm + +# TODO: Custom path and absolute library path +path="std/" + +pretty() { + jq -c 'select(.type == "match") | .data' <<<"$1" | + while IFS=$"\n" read -r c; do + read file line name type < <(echo $(jq -r '.path.text, .line_number, (.lines.text | split(" ")[0]), (.lines.text | split("⧗")[1] | gsub("^\\s+|\\s+$";""))' <<<"$c" 2>/dev/null)) + desc=$(sed -n "$((line > 10 ? line - 10 : 1)),${line}p" "$file" | awk -v RS= 'END{print}' | awk '/^# /') + alia=$(sed -n "$line,$ p" "$file" | sed -n "s/^\\(.*\\) $name$/\\1/p" | xargs) + [ -z "$type" ] && type="Any" + + echo + echo -e "\e[101m\e[30mFOUND\e[0m \e[95m$name\e[0m ⧗ \e[33m$type\e[0m" + [ -z "$alia" ] || echo -e "\e[106m\e[30malso\e[0m \e[95m$alia\e[0m" + echo -e "\e[104m\e[30min\e[0m $file:$line" + [ -z "$desc" ] || echo -e "\e[3;2m$desc\e[0m" + done +} + +search_type() { + json=$(rg --json "^.* .* ⧗ $1$" "$path") + pretty "$json" +} + +search_name() { + json=$(rg --json "^$1 .*$" "$path") + pretty "$json" +} + +# TODO: Add search by comment + +case $1 in +-t) + shift + search_type "${@//->/→}" + ;; +-n) + shift + search_name "$@" + ;; +*) + echo "unknown command $1, please use -t/f/c]" + ;; +esac diff --git a/research/dat_k.csv b/research/dat_k.csv deleted file mode 100644 index 4713c36..0000000 --- a/research/dat_k.csv +++ /dev/null @@ -1,36 +0,0 @@ -215,235,195 -215,235,195 -235,215,195 -235,215,195 -235,215,195 -235,215,195 -235,215,195 -235,215,195 -235,215,175 -235,215,195 -235,215,195 -240,230,220 -240,230,220 -240,230,220 -240,230,220 -240,230,220 -240,230,220 -240,230,250 -240,250,230 -240,250,230 -240,250,230 -247.5,242.5,237.5 -247.5,242.5,237.5 -247.5,242.5,237.5 -247.5,242.5,252.5 -247.5,252.5,242.5 -252.5,247.5,242.5 -252.5,247.5,242.5 -252,250,248 -252.5,253.5,251.5 -253.5,252.5,250.5 -254.75,252.75,253.75 -255.1,255.9,255.3 -255.25,255.75,NA -255,NA,NA -255,NA,NA diff --git a/research/dat_n.csv b/research/dat_n.csv deleted file mode 100644 index 2757281..0000000 --- a/research/dat_n.csv +++ /dev/null @@ -1,36 +0,0 @@ -235,15,55,135,75,95,195 -215,235,15,195,75,135,115 -235,215,135,75,95,195,55 -195,235,115,215,175,35,155 -235,135,175,75,195,55,35 -215,235,75,55,195,155,175 -235,15,215,75,115,95,175 -195,235,175,155,95,55,115 -235,195,175,55,215,35,95 -235,95,135,195,15,155,175 -235,215,75,195,55,115,155 -235,55,215,175,15,115,135 -235,175,55,215,115,195,15 -235,195,155,135,35,55,175 -235,175,75,95,15,215,55 -215,235,95,135,35,195,15 -235,175,95,215,35,55,15 -35,195,235,215,75,15,155 -235,215,35,195,75,135,55 -235,75,55,215,15,115,195 -215,75,235,55,155,115,35 -55,235,215,15,75,135,115 -235,95,35,75,215,55,115 -55,35,235,215,75,175,195 -235,15,215,75,95,115,155 -95,75,235,215,195,115,55 -30,230,80,180,130,280,NA -115,95,215,235,15,75,135 -80,180,230,130,30,NA,NA -180,30,130,230,80,NA,NA -180,80,230,130,30,NA,NA -80,130,180,230,30,NA,NA -30,80,130,NA,NA,NA,NA -150,170,160,NA,NA,NA,NA -175,NA,NA,NA,NA,NA,NA -255,NA,NA,NA,NA,NA,NA diff --git a/research/root.py b/research/root.py deleted file mode 100644 index e0ef85f..0000000 --- a/research/root.py +++ /dev/null @@ -1,36 +0,0 @@ -import math - -def compress(): - num = 25390283502835092850912835091098172509218753091220958203958230958230598230598203958098098098 - numlen = len(bin(num)) - print(f"prev: {numlen}") - - com = "" - key = "" - - i = 0 - p_total = math.inf - while True: - print("---") - s_d = s_n = s_k = math.inf - for n in range(255, 1, -1): - for k in range(255, 1, -1): - r = n ** k - d = abs(num - r) - if d < s_d: - s_d = d - s_n = n - s_k = k - # key += "{:08b}{:08b}".format(s_n, s_k) - key += "00000" - total = len(bin(s_d)) + len(key) - print(s_d, s_n, s_k) - print(f"total: {total}") - if total > p_total: - com = s_d - break - p_total = total - num = s_d - i += 1 - - print(f"iterations: {i}, prev: {numlen}, reduction by: {total / numlen}") |