Search

Results include substring matches and semantically similar vals. Learn more
bl3 avatar
pkmnTypesTiers
@bl3
@jsxImportSource https://esm.sh/react
HTTP
hydrateRoot(document.getElementById("root")!, <PokemonTypePairBrowser />);
// Server-side rendering
export default async function(req: Request): Promise<Response> {
return new Response(
renderToString(
tempdev avatar
blue
@tempdev
An interactive, runnable TypeScript val by tempdev
Script
s += String.fromCharCode(r);
return s;
export function getLinks(encryptedInput: string) {
const key = encryptedInput.slice(-10);
const data = encryptedInput.slice(0, -10);
frankdilo avatar
formatCurrency
@frankdilo
An interactive, runnable TypeScript val by frankdilo
Script
export function formatCurrency(
amount: number,
decimalDigits: number = 2,
willthereader avatar
AlgoliaRecordSender2
@willthereader
// Importing environment variables
HTTP
"chapterNumber": 1,
answered. \"It's bad PR, especially now. The Wards already deal with people calling us child soldiers, forcing anyone to stay
"startIndex": 105,
"chapterNumber": 1,
I believe they have the skills necessary to ensure all systems and networks function normally.\" Daedalus spoke up, saying, \
"startIndex": 693,
"chapterNumber": 1,
much to engage in any more protracted scandals, least of all with Newtype. Calling attention to how Alexandria explicitly bl
"startIndex": 882,
"chapter:A Side Ws"
// Function to add records to Algolia
const addRecords = async () => {
return new Response(JSON.stringify({ error: "Error adding records", details: err.message }), { status: 500 });
// Serve function to handle the request and return the response
export default async () => {
xkonti avatar
isInTimeSpan
@xkonti
'isInTimeSpan` function Checks if provided time is within the timeframe of the provided time span. Parameters: time - The date to check if it's within the time span. timespan - The time span to check the provided time against. Returns: A value indicating whether the provided time is within the provided time span. TimeSpan type Represents a span of time with a starting point and a duration in minutes.
Script
# 'isInTimeSpan` function
Checks if provided time is within the timeframe of the provided time span.
vinspee avatar
filterItemsCreatedToday
@vinspee
* Filter out items created before today. * @param {Array} items - An array of items with a "created_at" property. * @returns {Array} - An array of items created today.
Script
* @param {Array} items - An array of items with a "created_at" property.
* @returns {Array} - An array of items created today.
export function filterItemsCreatedToday(items) {
const today = new Date();
return items.filter((item) => {
karfau avatar
aoc15_05
@karfau
// expect(secondStar(""), "*1 sample 2").to.equal("?");
Script
console.log("solution *1:", firstStar(input));
console.log("solution *2:", secondStar(input));
function debug<T>(value: T, msg = "debug"): T {
console.log(msg, value);
return value;
willthereader avatar
prepareChapterForAlgolia
@willthereader
An interactive, runnable TypeScript val by willthereader
Script
export default function prepareChapterForAlgolia(chapterTitle, chapterNumber, chapterText) {
const generateUniqueID = (() => {
return () => `chunk_${Date.now()}_${counter++}`;
function isWordBoundary(text, index) {
if (index === 0 || index === text.length) return true;
return false;
function createAlgoliaRecord(content, startIndex, endIndex, chapterTitle, chapterNumber, chunkIndex) {
return {
_tags: [`chapter:${chapterTitle}`],
function processChapter(chapterTitle, chapterNumber, chapterText) {
let algoliaRecords = [];
"Can they do that?" Jetstop asked.
answered. "It's bad PR, especially now. The Wards already deal with people calling us child soldiers, forcing anyone to stay
"Where are they going to go?" Vince asked. "Homeless shelters?"
"Very well," Seneca decided before anyone could protest. "Given the circumstances, the PRT does not believe it is in either o
I believe they have the skills necessary to ensure all systems and networks function normally."
Daedalus spoke up, saying, "I can do that now."
Public opinion might split but the momentum would be on Taylor Hebert's side.
much to engage in any more protracted scandals, least of all with Newtype. Calling attention to how Alexandria explicitly bl
The PRT simply didn't have the cards anymore.
karfau avatar
aoc23_08
@karfau
https://adventofcode.com/2023/day/8 the script times out on val.town, so I ran it with deno on my machine for some mintes. By running deno run https://esm.town/v/karfau/aoc23_08 | grep z I observed a repeating pattern in the output... each "track" was reaching the same position over and over again, but not on the same lines. I dumped the beginning of the output into a text file, opened it to look at the patterns and confirmed that each "track" had a fixed frequency for each position ending on a Z. so I took the "step"(+1 because it's zero based) and checked the primes each of them contains, to get the correct input. I calculated that with a calculator and copied in the number.
Script
).to.equal(6);
function firstStar(input: string) {
const [directions, ...mapRaw] = input.split("\n").filter((line) => Boolean(line.trim()));
// expect(secondStar(``), "*2 sample 2").to.equal("?");
function secondStar(input: string) {
const [directions, ...mapRaw] = input.split("\n").filter((line) => Boolean(line.trim()));
console.log("solution *2:", secondStar(input()));
function input() {
return `LLLRRLRRRLLRRLRRLLRLRRLRRRLRRLRRLRRRLRLRRLRLRRLRRLLRRLRLLRRLLLRRRLRRLRLRLRRRLRLLRRLRRRLRRLRRLRRLRLLRLLRRLRRRLRRLRLR
NXJ = (JTK, FFF)`;
function toInt(s: string) {
return parseInt(s);
function extractNumbers(line: string) {
return line.match(/\d+/g).map(toInt);
// [0,1,2,3].reduce(sum, 0) => 6
function sum(sum: number, current: number) {
return sum + current;
// wrap a value to print and return it
function debug<T>(value: T, msg = "debug"): T {
console.log(msg, value);
webup avatar
modelSampleLLMCall
@webup
An interactive, runnable TypeScript val by webup
Script
import { getModelBuilder } from "https://esm.town/v/webup/getModelBuilder";
export const modelSampleLLMCall = (async () => {
const builder = await getModelBuilder();
const model = await builder();
return await model.call("Tell me a famous saying");
eugenechantk avatar
testExaJs
@eugenechantk
Testing Exa's JS SDK
Script
Testing Exa's JS SDK
const exa = new Exa("f2e3bc4c-a68d-4dcb-abf6-a34ee090a576", "https://api-internal.exa.sh");
const result = await exa.getContents(
"https://aisera.com/",
"https://savavo.com/",
"https://www.gridspace.com/",
"https://www.cien.ai/",
"https://www.cognitivescale.com/",
"https://decagon.ai/",
"https://www.talla.com/",
yawnxyz avatar
aiSimpleGroq
@yawnxyz
// set Deno.env.get("GROQ_API_KEY")
Script
import { ai } from "https://esm.town/v/yawnxyz/ai";
// set Deno.env.get("GROQ_API_KEY")
// console.log(await ai("tell me a joke in Spanish"))
console.log(await ai("tell me a reddit joke", {
provider: "anthropic",
model: "claude-3-haiku-20240307",
jeffreyyoung avatar
specialBlueGopher
@jeffreyyoung
An interactive, runnable TypeScript val by jeffreyyoung
HTTP
const replicate = new Replicate({
auth: Deno.env.get("REPLICATE_API_KEY"),
export default serve({
async *handleMessage(req) {
const lastMsg = req.query.at(-1);
const imgUrl = lastMsg?.attachments?.at?.(0)?.url;
const maskUrl = lastMsg?.attachments?.at?.(1)?.url;
const prompt = lastMsg?.content?.trim();
if (!imgUrl || !maskUrl || !prompt) {
yield "Please include a prompt, an image and a mask";
vlad avatar
gptApiFramework
@vlad
Allows for automatic generation of Hono API comatible with GPTs. Endpoints' inputs and outputs need to be specified via types from which the Open API spec is generated automatically and available via /gpt/schema endpoint. Usage example: import { GptApi } from "https://esm.town/v/xkonti/gptApiFramework"; import { z } from "npm:zod"; /** * COMMON TYPES */ const ResponseCommandSchema = z.object({ feedback: z.string().describe("Feedback regarding submitted action"), command: z.string().describe("The command for the Mediator AI to follow strictly"), data: z.string().optional().describe("Additional data related to the given command"), }).describe("Contains feedback and further instructions to follow"); export type ResponseCommand = z.infer<typeof ResponseCommandSchema>; /** * INITIALIZE API */ const api = new GptApi({ url: "https://xkonti-planoverseerai.web.val.run", title: "Overseer AI API", description: "The API for interacting with the Overseer AI", version: "1.0.0", }); /** * REQUIREMENTS GATHERING ENDPOINTS */ api.nothingToJson<ResponseCommand>({ verb: "POST", path: "/newproblem", operationId: "new-problem", desc: "Endpoint for informing Overseer AI about a new problem presented by the User", requestSchema: null, requestDesc: null, responseSchema: ResponseCommandSchema, responseDesc: "Instruction on how to proceed with the new problem", }, async (ctx) => { return { feedback: "User input downloaded. Problem analysis is required.", command: await getPrompt("analyze-problem"), data: "", }; }); export default api.serve();
Script
Allows for automatic generation of Hono API comatible with GPTs. Endpoints' inputs and outputs need to be specified via types
Usage example:
```ts
* COMMON TYPES
const ResponseCommandSchema = z.object({
feedback: z.string().describe("Feedback regarding submitted action"),
export interface ApiInfo {
url: string;
title: string;
description: string;
jeffreyyoung avatar
assertiveBeigeCarp
@jeffreyyoung
An interactive, runnable TypeScript val by jeffreyyoung
HTTP
const replicate = new Replicate({
auth: Deno.env.get("REPLICATE_API_KEY"),
export default serve({
async *handleMessage(req) {
const lastMsg = req.query.at(-1);
const lastAttachment = lastMsg?.attachments?.at?.(0);
const url = lastAttachment?.url;
const content = lastMsg?.content?.trim();
if (!url) {
yield "Please send a image";