This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Run from the Nushell terminal: `?? Who are you?` | |
| def --wrapped "??" [...user_prompt_phrase: string] { | |
| let user_prompt = ($user_prompt_phrase | str join " ") | |
| osascript ~/my/cfg/cli_ai_query.applescript $user_prompt | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- The macOS Shortcut should contain two items: | |
| -- 1) "Ask for `Text` with `Prompt`" followed by | |
| -- 2) "Run AppleScript with `Ask for Input`" | |
| on run {input, parameters} | |
| -- Get the first (text) item from Shortcuts input | |
| set userText to "Show me the time!" | |
| try | |
| if class of input is list then | |
| if (count of input) > 0 then set userText to (item 1 of input) as text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Sample prompt for the custom Nushell command below: `? Who are you?` with a rather deterministic response like "I am Grok, an AI built by xAI." | |
| def ? [...user_prompt_phrase: string, --model (-m): string = "grok-code-fast-1"] { | |
| let antrophic_ai_endpoint = "https://api.x.ai/v1/chat/completions" | |
| let user_prompt = ($user_prompt_phrase | str join " ") | |
| let body = { | |
| model: $model, | |
| messages: [ | |
| { role: "system", content: "You answer as short as possible, with one word if possible. The response is intended to be rendered in a Nushell terminal." }, | |
| { role: "user", content: $user_prompt } | |
| ], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env kotlin | |
| /* | |
| * Copyright 2021 Alexander Orlov <[email protected]>. All rights reserved. | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * https://www.apache.org/licenses/LICENSE-2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| https://loxal.net/gists-solution-toolbox.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.sql.SQLException; | |
| public class Mocker<T extends Exception> { | |
| private void pleaseThrow(final Exception e) throws T { | |
| throw (T) e; | |
| } | |
| public static void main(String[] args) { | |
| try { | |
| new Mocker<RuntimeException>().pleaseThrow(new SQLException()); |