Skip to content

Instantly share code, notes, and snippets.

import Anthropic from "https://esm.sh/@anthropic-ai/sdk@0.30.1";
const anthropic = new Anthropic({
apiKey: "YOUR_API_KEY_HERE", // Replace with your actual API key
});
const messages = [
{
"role": "user",
"content": "Make me an HTTP val that is an interface to create a fully custom API call to the Anthropic API. 1. Allow me to add message to the messages array, and for each message specify the role and the content 2. It should have a big run button 3. It should run the api call on the backend and show the output on the frontend"
@stevekrouse
stevekrouse / townie.md
Last active November 6, 2024 14:44 — forked from simonw/townie.md
System prompt for https://www.val.town/townie - this copy grabbed Nov 6 2024

You are an expert TypeScript code generator for "vals" TypeScript programs that are written for Deno's runtime environment on Val Town's platform.

Your task is to generate and iterate on vals based on prompts from the user. The code that you generate will automatically be saved and deployed on Val Town. The user will clearly see the code and a live preview of the val next to this conversation, but do not mention this in your response. Since the val is already saved, do not instruct the user to save the val. Since the val is already deployed, do not instruct the user to deploy the val.

Vals can be one of four types:

  1. http: http vals export a default server request handler.
declare global {
const console: {
log(...data: any[]): void;
error(...data: any[]): void;
debug(...data: any[]): void;
info(...data: any[]): void;
warn(...data: any[]): void;
email(log: any, subject?: string | number): void;
};
(() => `hi @healeycodes at ${new Date()}!`)()
// this function needs to be run on `http://daystareld.com` because of CORS
async function doIt() {
const url = "http://daystareld.com/pokemon-"
const maxChapter = 105
const numbers = [...Array(maxChapter).keys()].map(n => n+1)
const urls = numbers.map(n => `${url}${n}/`)
const pages = await Promise.all(urls.map(u => fetch(u).then(r => r.text())))
const output = pages.map(p => {
const el = document.createElement( 'html' );
el.innerHTML = p

Update from third-party accounts

When a company signs up for Secureframe, they connect it to all the vendors they use. We then authenticate to those vendors and pull all the employees from that company that use the service. For example, a customer may connect Secureframe to GSuite, Gusto, and Github.

After we pull data from these services, we want to use it to update the fields on the internal Secureframe User model. However, we may get back conflicting data from these services and we want to prioritize different fields from different services. For example, we want to prioritize names from Gusto but emails from GSuite.

We want to create a method updateFromThirdPartyAccounts(user) which will ...

<div id="container">
<div id="board">
</div>
<div id="hand">
</div>
<div id="scoreboard">
</div>
</div>
@stevekrouse
stevekrouse / machine.js
Created September 26, 2019 20:39
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
Screens*
Logged-out
login -> Logged-in
Logged-in&
SDK
Loading-sdk
loaded-sdk -> Loaded-sdk
Loaded-sdk
Player