beigeMandrillmain.tsx1 match
1export default async function (req: Request): Promise<Response> {
2const { searchParams } = new URL(req.url);
3
upgradeHTTPPreviewValsmain.tsx4 matches
3import OpenAI from "npm:openai";
45async function getVals(username, type, limit) {
6const res = await db.execute({
7sql: `
21}
2223async function checkHTTPPreviewUpgrade(code) {
24const openai = new OpenAI();
25const completion = await openai.chat.completions.create({
53content: `const number = Math.random();
54
55export default function(req: Request) {
56return Response.json(number);
57}`,
8081/* This example will return the contents of a documentID passed in as the path as JSON. */
82export default async function(req: Request): Promise<Response> {
83const docId = new URL(req.url).pathname.substring(1);
84
upgradeHTTPPreviewValsREADME.md5 matches
16"name": "harlequinChickadee",
17"probabilityUpgradeNeeded": true,
18"reason": "The current code structure has several functions and program logic outside the main handler, including word selection, game state management, and SVG generation. These parts would not re-run with the new runtime, potentially affecting functionality. They need to be moved inside the handler to ensure consistent behavior across requests."
19},
20{
31"name": "untitled_pinkRoundworm",
32"probabilityUpgradeNeeded": true,
33"reason": "The functions `addComment` and `getComments` as well as the initialization \nof the KEY variable perform actions that are intended to be run per request. These need to be moved \ninside the relevant HTTP handler to ensure the behavior remains consistent in the new runtime."
34},
35{
46"name": "untitled_maroonSwallow",
47"probabilityUpgradeNeeded": false,
48"reason": "All the code, including the check for authentication,\n is inside the handler function. This means the behavior will stay \n the same with the new runtime."
49},
50{
51"name": "wikiOG",
52"probabilityUpgradeNeeded": true,
53"reason": "The function `getWikipediaInfo` defined outside of the handler makes network requests and processes data for each request. In the new runtime, this function would only be executed once and cached. To ensure the same behavior in the new runtime, this function should be moved into the handler."
54},
55{
61"name": "discordEventReceiver",
62"probabilityUpgradeNeeded": false,
63"reason": "All the relevant code for handling requests and logging input is inside the handler.\n No code needs to be moved for the new runtime to function correctly."
64}
65]
sqliteExplorerAppREADME.md1 match
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query
1// import { Request, Response } from "./node_modules/express/index.js";
2export default async function(req: Request): Promise<Response> {
3console.log("Request received:", req);
4
89<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
90<script>
91document.addEventListener('DOMContentLoaded', function () {
92if (typeof THREE === 'undefined') {
93console.error('THREE is not defined. Make sure Three.js is loaded correctly.');
106const debugElement = document.getElementById('debug');
107108function createTextureCanvas() {
109const canvas = document.createElement('canvas');
110const ctx = canvas.getContext('2d');
130}
131132function init() {
133scene = new THREE.Scene();
134camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);
163}
164165function onMouseMove(event) {
166currentPoint.set(event.clientX, window.innerHeight - event.clientY);
167if (isPressed) {
172}
173174function onMouseDown(event) {
175isPressed = true;
176clickPoint.set(event.clientX, window.innerHeight - event.clientY);
181}
182183function onMouseUp() {
184isPressed = false;
185}
186187function updateUniforms() {
188if (material) {
189material.uniforms.uClickPoint.value = clickPoint;
194}
195196function onWindowResize() {
197const width = window.innerWidth;
198const height = window.innerHeight;
204}
205206function animate() {
207requestAnimationFrame(animate);
208
SagaImmoScrapermain.tsx2 matches
3import { JSDOM } from "npm:jsdom";
45export async function scrapeSAGA(
6areas: Area[],
7maxPrice: number,
59}
6061function parsePriceToNumber(priceString: string): number {
62const val = +priceString.replace(/[^0-9,]/g, "").replace(",", ".");
63return isNaN(val) ? 0 : val;
videoStoragemain.tsx6 matches
22)`);
2324export function rowObjects(data) {
25return data.rows.map(row => {
26return data.columns.reduce((obj, column, index) => {
37}
3839export async function createVideo(webhook: Mux.Webhooks.VideoUploadCreatedWebhookEvent) {
40const {
41environment,
65}
6667export async function updateVideoCreated(webhook: Mux.Webhooks.VideoUploadAssetCreatedWebhookEvent) {
68const sql = `
69UPDATE videos
8990// Just returns the sql statement itself so that we can use `batch` in our backfill script.
91export function backfillVideo(asset: Mux.Video.Asset) {
92const sql = `
93INSERT OR IGNORE INTO videos (
156// This is just an upsert in case somehow we get an asset created webhook from something other
157// than our direct upload process.
158export async function updateVideoReady(webhook: Mux.Webhooks.VideoAssetReadyWebhookEvent) {
159const sql = `
160INSERT INTO videos (
243}
244245export async function getAllVideos() {
246const data = await sqlite.execute(`select * from videos`);
247
89<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
90<script>
91document.addEventListener('DOMContentLoaded', function () {
92if (typeof THREE === 'undefined') {
93console.error('THREE is not defined. Make sure Three.js is loaded correctly.');
106const debugElement = document.getElementById('debug');
107108function createTextureCanvas() {
109const canvas = document.createElement('canvas');
110const ctx = canvas.getContext('2d');
130}
131132function init() {
133scene = new THREE.Scene();
134camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);
163}
164165function onMouseMove(event) {
166currentPoint.set(event.clientX, window.innerHeight - event.clientY);
167if (isPressed) {
172}
173174function onMouseDown(event) {
175isPressed = true;
176clickPoint.set(event.clientX, window.innerHeight - event.clientY);
181}
182183function onMouseUp() {
184isPressed = false;
185}
186187function updateUniforms() {
188if (material) {
189material.uniforms.uClickPoint.value = clickPoint;
194}
195196function onWindowResize() {
197const width = window.innerWidth;
198const height = window.innerHeight;
204}
205206function animate() {
207requestAnimationFrame(animate);
208
31the simplest way to achieve the goal, though you can add some inline comments to explain your
32reasoning (not for every line, but for major groups of lines). Don't use any environment variables
33unless strictly necessary, for example use APIs that don't require a key, prefer internal function
34imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
35functions where possible. Unless specified, don't add error handling,
36make sure that errors bubble up to the caller.
37There should be no comments like "more content here", it should be complete and directly runnable.
38The val should create a "export default async function main" which is the main function that gets
39executed on every HTTP request.
40`.replace("\n", " ");
4142// Your response should start with \`\`\`ts and end with \`\`\`.
43// The val should create a "export default async function main() {" which
44// is the main function that gets executed, without any arguments. Don't return a Response object,
45// just return a plain Javascript object, array, or string.
4683const writer = writable.getWriter();
84const textEncoder = new TextEncoder();
85function write(text) {
86writer.write(textEncoder.encode(text));
87}
149</div>
150<script>
151function updateValName(valName) {
152const valUrl = valName ? \`https://val.town/v/${username}/\${valName}\` : "";
153const previewUrl = valName ? \`https://${username}-\${valName}.web.val.run\` : "";
157document.getElementById('open-link').href = previewUrl;
158}
159function saveVal() {
160if (window.codeMirrorEditor) {
161document.getElementById("save-icon").classList.remove("hidden");
177return false;
178})
179function openTab(tab) {
180const tabButtonCode = document.getElementById("tab-button-code");
181const tabButtonPreview = document.getElementById("tab-button-preview");
197}
198}
199function toggleTab() {
200openTab(document.getElementById("tab-panel-code").style.visibility === "visible" ? "preview" : "code");
201}
255(() => {
256const scrollingElement = document.getElementById("conversation-container");
257const callback = function (mutationsList, observer) {
258scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
259};
328window.setCodeMirrorContent({ doc: '', old: ''});
329let fullStr = "";
330window.addToken = function(str) {
331fullStr += str;
332const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");