From fecf482450401efafba30e912b3789b68f7c8054 Mon Sep 17 00:00:00 2001 From: Kamil Date: Mon, 7 Feb 2022 21:05:30 +0000 Subject: [PATCH 1/4] Create wolframalpha.nu Actually, I've received this code from a friend, the author is unknown but I thought it'd be nice to have it here --- api_wrappers/wolframalpha.nu | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 api_wrappers/wolframalpha.nu diff --git a/api_wrappers/wolframalpha.nu b/api_wrappers/wolframalpha.nu new file mode 100644 index 0000000..1f91483 --- /dev/null +++ b/api_wrappers/wolframalpha.nu @@ -0,0 +1,6 @@ +def wolfram [...query] { + let appID = #YOUR APP_ID + let query_string = ($query | str collect " ") + let result = (fetch ("https://api.wolframalpha.com/v1/result?" + ([[appid i]; [$appID $query_string]] | to url))) + $result + "" +} From 806956529a657c53b217ebac54059df4d4b90925 Mon Sep 17 00:00:00 2001 From: Kamil Date: Mon, 7 Feb 2022 21:35:02 +0000 Subject: [PATCH 2/4] Update wolframalpha.nu added fetching images from API that actually look like the website with all the important info --- api_wrappers/wolframalpha.nu | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/api_wrappers/wolframalpha.nu b/api_wrappers/wolframalpha.nu index 1f91483..686b3b9 100644 --- a/api_wrappers/wolframalpha.nu +++ b/api_wrappers/wolframalpha.nu @@ -4,3 +4,12 @@ def wolfram [...query] { let result = (fetch ("https://api.wolframalpha.com/v1/result?" + ([[appid i]; [$appID $query_string]] | to url))) $result + "" } + +def wolframimg [...query] { + let appID = #YOUR APP_ID + let query_string = ($query | str collect " ") + let filename = ($query_string + ".png") + let link = ("https://api.wolframalpha.com/v1/simple?" + ([[appid i]; [$appID $query_string]] | to url) + "&background=F5F5F5&fontsize=20") + fetch $link | save $filename + echo ("Query result saved in file: " + $filename) +} From aae15eecb13938c4f1fbd7aa53d62dacc139d83a Mon Sep 17 00:00:00 2001 From: Kamil Date: Mon, 7 Feb 2022 21:37:17 +0000 Subject: [PATCH 3/4] Update wolframalpha.nu documented commands --- api_wrappers/wolframalpha.nu | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api_wrappers/wolframalpha.nu b/api_wrappers/wolframalpha.nu index 686b3b9..a6cbd2f 100644 --- a/api_wrappers/wolframalpha.nu +++ b/api_wrappers/wolframalpha.nu @@ -1,11 +1,15 @@ -def wolfram [...query] { +#Fetch simple anwser from WolframAlpha API +def wolfram [...query #Your query +] { let appID = #YOUR APP_ID let query_string = ($query | str collect " ") let result = (fetch ("https://api.wolframalpha.com/v1/result?" + ([[appid i]; [$appID $query_string]] | to url))) $result + "" } -def wolframimg [...query] { +#Fetch image with full anwser from WolframAlpha API +def wolframimg [...query #Your query +] { let appID = #YOUR APP_ID let query_string = ($query | str collect " ") let filename = ($query_string + ".png") From 0ed7c5e49ff9e6abfdc53c362f427b294b77b76c Mon Sep 17 00:00:00 2001 From: Kamil Date: Mon, 7 Feb 2022 21:43:14 +0000 Subject: [PATCH 4/4] Update wolframalpha.nu intendation fix --- api_wrappers/wolframalpha.nu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api_wrappers/wolframalpha.nu b/api_wrappers/wolframalpha.nu index a6cbd2f..1cbb6b5 100644 --- a/api_wrappers/wolframalpha.nu +++ b/api_wrappers/wolframalpha.nu @@ -14,6 +14,6 @@ def wolframimg [...query #Your query let query_string = ($query | str collect " ") let filename = ($query_string + ".png") let link = ("https://api.wolframalpha.com/v1/simple?" + ([[appid i]; [$appID $query_string]] | to url) + "&background=F5F5F5&fontsize=20") - fetch $link | save $filename + fetch $link | save $filename echo ("Query result saved in file: " + $filename) }