Skip to content

Instantly share code, notes, and snippets.

View loxal's full-sized avatar
🍵
Enjoying jasmine tee while coding.

Alex O loxal

🍵
Enjoying jasmine tee while coding.
View GitHub Profile
@loxal
loxal / .config_nushell_config.nu
Created August 30, 2025 22:19
Run an AI query in the Comet/Chrome browser from the CLI
# 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
}
@loxal
loxal / AI_query_shortcut.applescript
Created August 30, 2025 21:36
macOS shortcut for doing an AI query in the Comet browser
-- 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
@loxal
loxal / .config_nushell_config.nu
Last active August 30, 2025 19:18
Grok Nushell Prompt via `? Who are you?`
# 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 }
],
@loxal
loxal / smoke-test-ui.main.kts
Created May 5, 2021 14:29
Testing web UI via HTML DOM
#!/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
https://loxal.net/gists-solution-toolbox.html
@loxal
loxal / InterviewQuestion.java
Last active July 21, 2016 11:36
Interview: Generics and Type Reification
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());