Random Scripts

Here you find a collection of random scripts that I have written over the years and that I make available to you for free. Enjoy!

🧰 randomScripts /

Make sure to have "blueutil" via brew installed

Connect / Disconnect Bluetooth Devices 🔧

Toggles a bluetooth device connection

Tool: Connect / Disconnect Bluetooth Devices, Toggles a bluetooth device connection Video placeholderPlay Button

Show only active App (Heidi) 🔧

Hide all Apps except the one that is currently act... (Read more)

Tool: Show only active App (Heidi), Hide all Apps except the one that is currently active Video placeholderPlay Button

Simple Anthropic Chat 🔧

A simple chat interface using the Anthropic API

// Author: Eduard Uffelmann
// Linkedin: https://www.linkedin.com/in/euffelmann/
// Twitter: @schmedu_
// Website: https://schmedu.com

import Anthropic from "@anthropic-ai/sdk";

const anthropic = new Anthropic({
    apiKey: await env("ANTHROPIC_API_KEY", {
        hint: md(
            "Get your API key from https://console.anthropic.com/settings/keys"
        ),
    }),
});

let messages = [];
await chat({
    preview: "",
    ignoreBlur: true,
    onSubmit: async (input) => {
        if (input === "") {
            return;
        }

        try {
            let newMessage = {
                role: "user",
                content: [
                    {
                        type: "text",
                        text: input,
                    },
                ],
            };

            chat.addMessage("");
            let messageContent = "";
            // const response = await anthropic.messages
            anthropic.messages
                .stream({
                    model: "claude-3-opus-20240229",
                    max_tokens: 1000,
                    temperature: 1,
                    messages: messages.concat([newMessage]),
                })
                .on("text", (text) => {
                    messageContent += text;
                    chat.setMessage(-1, md(messageContent));
                })
                .on("message_stop", () => {
                    messages = messages.concat([
                        newMessage,
                        {
                            role: "assistant",
                            content: messageContent,
                        },
                    ]);
                });
        } catch (e) {
            console.log(e);
            chat.addMessage("");
            chat.setMessage(-1, md("Error: " + e.message));
        }
    },
    shortcuts: [
        {
            name: "Copy",
            key: `cmd+shift+c`,
            bar: "right",
            onPress: async () => {
                await copy(messages[messages.length - 1].content);
            },
        },
    ],
});

Get The Toolkit Now!

You can install the 'Random Scripts' Toolkit now and start using it today! It's free!