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
| require "informers" | |
| MODEL = "Snowflake/snowflake-arctic-embed-s" | |
| embedder = Informers.pipeline( | |
| "embedding", | |
| MODEL, | |
| dtype: "int8", | |
| device: "cpu", | |
| ) |
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 TinyTTS from 'tiny-tts'; | |
| const tts = new TinyTTS(); | |
| await tts.speak('Hello, welcome to Node Weekly.', { | |
| output: 'output.wav', | |
| }); | |
| await tts.dispose(); |
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
| # Fetch X bookmarks and output them as CSV. | |
| # | |
| # On first run, opens a browser for OAuth 2.0 authorization and stores | |
| # tokens in tokens-USERNAME.json. Subsequent runs reuse (and auto-refresh) | |
| # those tokens, so no further login is needed. Multiple users are supported | |
| # via separate token files. | |
| # | |
| # Usage: | |
| # ruby bookmarks.rb [--username USER] [--limit N] [--per-call N] | |
| # |
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 python3 | |
| import json | |
| import os | |
| import sys | |
| from mistralai import Mistral | |
| def format_time(seconds): | |
| minutes = int(seconds) // 60 |
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 bash | |
| set -euo pipefail | |
| if [ -z "${OPENAI_API_KEY:-}" ]; then | |
| echo "Error: OPENAI_API_KEY is not set" >&2 | |
| exit 1 | |
| fi | |
| if [ $# -ne 1 ] || [ ! -f "$1" ]; then | |
| echo "Usage: transcribe <audio-file>" >&2 |
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 ruby | |
| # A macOS GUI app written in Ruby, calling libobjc directly via Fiddle. | |
| # No gems. No Objective-C. Just Ruby and the runtime. | |
| require "fiddle" | |
| OBJC = Fiddle.dlopen("/usr/lib/libobjc.A.dylib") | |
| APPKIT = Fiddle.dlopen("/System/Library/Frameworks/AppKit.framework/AppKit") | |
| # Core runtime functions |
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
| // A macOS GUI app written in pure C, using the Objective-C runtime directly. | |
| // No Objective-C syntax anywhere. Just raw objc_msgSend and runtime calls. | |
| // This is cursed. Enjoy. | |
| // Compile with clang -Wall -Wextra -o hello_runtime hello_runtime.c \ | |
| // -framework Cocoa -lobjc | |
| #include <objc/objc.h> | |
| #include <objc/message.h> | |
| #include <objc/runtime.h> |
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
| # Just because the example in the docs doesn't seem to work outside of a Rails app | |
| require 'ruby_llm' | |
| RubyLLM.configure do |config| | |
| config.gemini_api_key = ENV['GEMINI_API_KEY'] | |
| end | |
| chat = RubyLLM.chat(model: "gemini-2.5-flash-image") | |
| reply = chat.ask("Cyberpunk city street at night, raining, neon signs") |
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
| require "openai" | |
| client = OpenAI::Client.new # assumes valid key in OPENAI_API_KEY | |
| begin | |
| resp = client.chat.completions.create( | |
| model: :"gpt-5-nano", | |
| reasoning_effort: :high, | |
| verbosity: :low, | |
| messages: [{ role: "user", content: "Tell me a joke" }] |
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 sys | |
| import requests | |
| import replicate | |
| from Pylette import extract_colors | |
| # YOU NEED A REPLICATE API TOKEN IN 'REPLICATE_API_TOKEN' | |
| prompt = sys.argv[1] if len(sys.argv) > 1 else "sandy beach" | |
| output = replicate.run( |
NewerOlder