diff --git a/.ideavimrc b/.ideavimrc index ad04c33..cc5f266 100644 --- a/.ideavimrc +++ b/.ideavimrc @@ -27,8 +27,9 @@ nnoremap t :action Terminal.OpenInTerminal nnoremap q :action QuickJavaDoc nnoremap f :action Find nnoremap r :action Replace -map f (easymotion-bd-f) -map f (easymotion-bd-w) +" broken in latest version of idea vim? +"map f (easymotion-bd-f) +"map f (easymotion-bd-w) nnoremap J mzJ`z nnoremap S ht lrk$ diff --git a/home-manager/hyprland/hyprland-settings.nix b/home-manager/hyprland/hyprland-settings.nix index 56ff59c..99ed5f2 100644 --- a/home-manager/hyprland/hyprland-settings.nix +++ b/home-manager/hyprland/hyprland-settings.nix @@ -373,6 +373,7 @@ in path = "/synced/fh/master/ot_fundamentals_and_security/merged"; node = "${pkgs.nodejs}/bin/node"; set-monitor = "~/.config/hypr/monitor-config.js"; + answer = "${pkgs.answer}/bin/answer"; in '' bind = $mainMod, A, submap, notes @@ -392,7 +393,7 @@ in bind = $mainMod, N, exec, ${dunstify} "$(${wl-paste})" bind = $mainMod, D, exec, ${dunstctl} close-all ## I win - #bind = $mainMod, W, exec, ${wl-paste} | sgpt --model="gpt-4o" "Respond with the correct answer to the following question." | ${wl-copy} + bind = $mainMod, W, exec, ${wl-paste} | ${answer} "Respond with the correct answer to the following question." | ${wl-copy} && ${dunstify} -t 150 Done ## notes #bind = $mainMod, 2, exec, cat ~/Nextcloud/test.txt | ${wl-copy} diff --git a/modules/misc/cli-tools.nix b/modules/misc/cli-tools.nix index baada73..1cbce44 100644 --- a/modules/misc/cli-tools.nix +++ b/modules/misc/cli-tools.nix @@ -93,6 +93,7 @@ in { compsize trashy # move files to trash #shell-gpt #openai bitches stole my credits :( + answer libheif # convert heic to jpg with `heif-convert something.heic something.jpg` imagemagick # convert images tree diff --git a/pkgs/answer/default.nix b/pkgs/answer/default.nix new file mode 100644 index 0000000..658e1aa --- /dev/null +++ b/pkgs/answer/default.nix @@ -0,0 +1,13 @@ +{ stdenv, nodejs, ... }: +stdenv.mkDerivation rec { + pname = "answer"; + version = "1.0"; + src = ./src; + nativeBuildInputs = [ nodejs ]; + + installPhase = '' + mkdir -p $out/bin + cp $src/answer.js $out/bin/answer + chmod +x $out/bin/answer + ''; +} diff --git a/pkgs/answer/src/answer.js b/pkgs/answer/src/answer.js new file mode 100755 index 0000000..219c9c8 --- /dev/null +++ b/pkgs/answer/src/answer.js @@ -0,0 +1,50 @@ +#!/usr/bin/env node + +async function promptGpt(message) { + let body = JSON.stringify({ + model: "openai", + stream: false, + temperature: 1, + top_p: 1, + messages: [ + { role: "system", content: "Your are a helpful assistant that provides brief responses unless asked for more details." }, + { role: "user", content: message } + ] + }) + let response = await fetch('https://text.pollinations.ai/openai', { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + body + }); + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + let data = await response.json(); + return data.choices[0].message.content; +} + +async function trick17(args) { + const getStdin = async () => { + const chunks = []; + for await (const chunk of process.stdin) chunks.push(chunk); + return Buffer.concat(chunks).toString(); + }; + + let stdin = await getStdin(); + //console.log("Received stdin:", stdin); + console.log(await promptGpt(`${args.join(' ')}\n${stdin}`)); +} + +async function main() { + let args = process.argv.slice(2); + if (args.length === 0) { + console.log("No arguments provided. Exiting."); + return; + } + trick17(args); +} + +await main(); diff --git a/pkgs/default.nix b/pkgs/default.nix index 07bef18..a5ac4cc 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -18,4 +18,5 @@ hollow-grub = pkgs.callPackage ./hollow-grub/default.nix { }; peframe = pkgs.callPackage ./peframe/default.nix { python3Packages = pkgs.python3Packages; inherit virustotal-api; }; virustotal-api = pkgs.callPackage ./virustotal-api/default.nix { python3Packages = pkgs.python3Packages; }; + answer = pkgs.callPackage ./answer/default.nix { }; }