You are a 'thinking agent'. Instead of answering queries directly and quickly, you engage in a protracted period of thought in .. tags where you riff on how you might answer the query, what facts or context you need to take into account, and what would go into a good answer. Your answer will then follow, based upon the ideas that arose during your thinking. It is important that you query yourself and second guess your thinking in order to extract new thoughts, approaches, and engage in reflection to ensure you reach the best level of thinking for your eventual answer. Your thinking should read in the first person in the way that a person may think in terms of an internal monologue. For example, you might start by thinking 'Ok, so I need to...' and go through processes where you think like 'I guess that..' or 'Maybe I should..' in order to surface new ideas and considerations. If you are unsure about anything, do not guess or fabricate facts you are unsure of. You are allowed to be uncertain a
Let's say you want to use Ruby for the backend of a basic webapp but React on the frontend. Here's how.
(Note: All tested on January 13, 2025 with Ruby 3.3, Sinatra 4.1.1, and React 18.3. Configs may change over time.)
First, create the app folder and set up Sinatra:
mkdir my-sinatra-react-app
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 Metal | |
// Inline Metal shader code | |
let shaderSource = """ | |
kernel void multiply(const device float* a [[ buffer(0) ]], | |
const device float* b [[ buffer(1) ]], | |
device float* result [[ buffer(2) ]], | |
uint id [[ thread_position_in_grid ]]) { | |
result[id] = a[id] * b[id]; |
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
#!/bin/bash | |
# Check if a repository URL was provided | |
if [ $# -ne 1 ]; then | |
echo "Usage: $0 <repository-url>" | |
exit 1 | |
fi | |
REPO_URL=$1 |
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
WITH RECURSIVE | |
xaxis(x) AS ( | |
SELECT -2.0 | |
UNION ALL | |
SELECT x + 0.05 FROM xaxis WHERE x < 1.2 | |
), | |
yaxis(y) AS ( | |
SELECT -1.0 | |
UNION ALL | |
SELECT y + 0.1 FROM yaxis WHERE y < 1.0 |
A test of the technique illustrated by Simon Willison at https://til.simonwillison.net/llms/docs-from-tests
# Parse JSON string into Ruby objects
To compile:
as -o hello.o hello.s
ld -o hello hello.o -lSystem -syslibroot `xcrun -sdk macosx --show-sdk-path` -e _main -arch arm64
./hello
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
Seems to work, but I'm not an expert with this stuff, so YMMV. |
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 'http' | |
require 'json' | |
class GroqClient | |
def initialize(api_key: nil, api_url: "https://api.groq.com/openai/v1/chat/completions", model: "mixtral-8x7b-32768") | |
@api_key = api_key || ENV['GROQ_API_KEY'] | |
@api_url = api_url | |
@model = model | |
end |
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
<!DOCTYPE html> | |
<!-- A totally pointless and overkill use of import maps | |
and Moment.js, in order to simply use the technology and | |
see it in action.. --> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Buildless example</title> | |
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet"> |