falDemoAppmain.tsx3 matches
5import { falProxyRequest } from "https://esm.town/v/stevekrouse/falProxyRequest";
67function App() {
8const [prompt, setPrompt] = useState("");
9const [imageUrl, setImageUrl] = useState("");
103}
104105function client() {
106createRoot(document.getElementById("root")).render(<App />);
107}
108if (typeof document !== "undefined") { client(); }
109110export default async function server(req: Request): Promise<Response> {
111const url = new URL(req.url);
112if (url.pathname === "/") {
geminiBboxmain.tsx39 matches
49import { marked } from "https://esm.run/marked";
5051// Add debounce function
52function debounce(func, wait) {
53let timeout;
54return function executedFunction(...args) {
55const later = () => {
56clearTimeout(timeout);
62}
6364// Combined function to fetch and handle images
65async function fetchImage(url, options = {}) {
66const { returnType = 'blob' } = options;
67
102}
103104// Update the image preview function to use the combined fetchImage
105async function updateImagePreview(url) {
106const imageContainer = document.getElementById('imageContainer');
107const canvas = document.getElementById('canvas');
118
119const img = new Image();
120img.onload = function() {
121// Remove spinner and restore container
122imageContainer.innerHTML = '<canvas id="canvas"></canvas>';
140}
141142// Helper function to show error state
143function showErrorState(canvas, ctx, message) {
144canvas.style.display = 'block';
145canvas.width = 400;
164});
165166function handleImageUrlClick(event) {
167console.log("IMAGE CLICK")
168event.preventDefault();
175176// Retrieves the API key from local storage or prompts the user to enter it
177function getApiKey() {
178let apiKey = localStorage.getItem("GEMINI_API_KEY");
179if (!apiKey) {
187188// Initializes and returns a Google Generative AI model instance
189async function getGenerativeModel(params) {
190const API_KEY = getApiKey();
191const genAI = new GoogleGenerativeAI(API_KEY);
194195// Converts a file to a GenerativePart object for use with the AI model
196async function fileToGenerativePart(file) {
197return new Promise((resolve) => {
198const reader = new FileReader();
208209// Applies a high contrast filter to the image on a canvas
210function applyHighContrast(canvas) {
211const ctx = canvas.getContext('2d');
212const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
233234// Resizes and compresses an image file, optionally applying high contrast
235function resizeAndCompressImage(file, maxWidth = 1000) {
236return new Promise((resolve) => {
237const reader = new FileReader();
238reader.onload = function(event) {
239const img = new Image();
240img.onload = function() {
241const canvas = document.createElement('canvas');
242const ctx = canvas.getContext('2d');
271272// Splits an image into a grid of smaller tiles
273function splitImage(file, rows, cols) {
274return new Promise((resolve) => {
275const reader = new FileReader();
276reader.onload = function(event) {
277const img = new Image();
278img.onload = function() {
279const tileWidth = Math.floor(img.width / cols);
280const tileHeight = Math.floor(img.height / rows);
314}
315316// Creates a delay promise for use in async functions
317function delay(ms) {
318return new Promise(resolve => setTimeout(resolve, ms));
319}
320321// Processes a single tile with the AI model, with retry logic
322async function processTileWithRetry(model, tile, prompt, delayMs, maxRetries = 3) {
323for (let attempt = 1; attempt <= maxRetries; attempt++) {
324try {
344}
345346// Main function to process the image and prompt, coordinating the entire detection process
347async function processImageAndPrompt() {
348const fileInput = document.getElementById('imageInput');
349const urlInput = document.getElementById('imageUrlInput');
437438// Extracts coordinate data from the AI model's response text
439function extractCoordinates(text) {
440console.log("Raw AI response text:", text); // Log raw AI response
441
442const cleanedText = text.replace(${markdownJsonRegex}, function(match, p1) {
443return p1.trim();
444});
459460// Displays the full image with bounding boxes drawn on a canvas
461function displayImageWithBoundingBoxes(file, coordinates, rows, cols) {
462const reader = new FileReader();
463reader.onload = function(event) {
464const image = new Image();
465image.onload = function() {
466const canvas = document.getElementById('canvas');
467const ctx = canvas.getContext('2d');
515516// Displays a single tile with its bounding boxes and grid
517function displayTileWithBoundingBoxes(tile, { coordinates }) {
518const reader = new FileReader();
519reader.onload = function(event) {
520const image = new Image();
521image.onload = function() {
522const padding = 80;
523const labelPadding = 40;
663664// Generates a description of the image using the AI model
665async function getImageDescription() {
666const fileInput = document.getElementById('imageInput');
667const urlInput = document.getElementById('imageUrlInput');
878</div>
879<script>
880function loadImage(event) {
881const file = event.target.files[0];
882const reader = new FileReader();
883reader.onload = function(e) {
884const canvas = document.getElementById('canvas');
885canvas.style.display = 'block';
886const ctx = canvas.getContext('2d');
887const img = new Image();
888img.onload = function() {
889canvas.width = img.width;
890canvas.height = img.height;
932</div>
933<script>
934function toggleThresholdInputs() {
935const checkbox = document.getElementById('highContrastCheckbox');
936const thresholdInputs = document.getElementById('thresholdInputs');
200let lastSavedText = ''; // Track the last saved text
201202function populateTextAreaFromHash() {
203const hash = window.location.hash.slice(1); // Remove the '#' character
204if (hash) {
209}
210211async function updateCounts() {
212const encoder = new TextEncoder();
213const utf8 = new Uint8Array(inputText.value.length * 3);
287}
288289async function tokenize() {
290const response = await fetch('/tokenize', {
291method: 'POST',
322}
323324function adjustTextareaHeight() {
325inputText.style.height = 'auto';
326inputText.style.height = inputText.scrollHeight + 10 + 'px';
341window.addEventListener('hashchange', populateTextAreaFromHash);
342343// Add the history functions:
344async function updateHistoryList() {
345const history = await db.history.reverse().limit(50).toArray();
346historyList.innerHTML = history.map(item =>
428});
429430function replaceEmojisWithCodePoints(text) {
431console.log("Replacing emojis with code points:", text);
432442}
443444function getTiktokenSegments(encoder, inputText) {
445try {
446const tokens = encoder.encode(inputText);
fullWebsiteVersionmain.tsx7 matches
1async function findBrokenLinks(websiteUrl) {
2console.log("Version: " + import.meta.url.match(/[?&]v=([^&]*)/)?.at(1));
3console.log(`Starting findBrokenLinks for website: ${websiteUrl}`);
7const allCheckedLinks = new Set();
8const allBrokenLinks = [];
9// Function to check if a URL is valid and accessible
10async function checkUrl(url) {
11console.log(`Checking URL: ${url}`);
12try {
26}
2728// Function to ensure URL is absolute and classify link type
29function processUrl(baseUrl, href) {
30try {
31if (
191}
192193export default async function(interval) {
194console.log(`Starting broken link check at ${new Date().toISOString()}`);
195const url = "https://dateme.directory/browse";
202console.log("External broken links:", JSON.stringify(results.brokenLinks.external, null, 2));
203} catch (error) {
204console.error(`Error in main function: ${error.message}`);
205}
206}
BBslackScoutmain.tsx10 matches
15}
1617export default async function(interval: Interval): Promise<void> {
18try {
19await createTable();
3839// Create an SQLite table
40async function createTable(): Promise<void> {
41await sqlite.execute(`
42CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
5051// Fetch Hacker news, Twitter, and Reddit results
52async function fetchHackerNewsResults(topic: string): Promise<Website[]> {
53return hackerNewsSearch({
54query: topic,
58}
5960async function fetchTwitterResults(topic: string): Promise<Website[]> {
61return twitterSearch({
62query: topic,
67}
6869async function fetchRedditResults(topic: string): Promise<Website[]> {
70return redditSearch({ query: topic });
71}
7273function formatSlackMessage(website: Website): string {
74const displayTitle = website.title || website.url;
75return `*<${website.url}|${displayTitle}>*
78}
7980async function sendSlackMessage(message: string): Promise<Response> {
81const slackWebhookUrl = Deno.env.get("SLACK_WEBHOOK_URL");
82if (!slackWebhookUrl) {
104}
105106async function isURLInTable(url: string): Promise<boolean> {
107const result = await sqlite.execute({
108sql: `SELECT 1 FROM ${TABLE_NAME} WHERE url = :url LIMIT 1`,
112}
113114async function addWebsiteToTable(website: Website): Promise<void> {
115await sqlite.execute({
116sql: `INSERT INTO ${TABLE_NAME} (source, url, title, date_published)
120}
121122async function processResults(results: Website[]): Promise<void> {
123for (const website of results) {
124if (!(await isURLInTable(website.url))) {
falProxyRequestmain.tsx1 match
1export async function falProxyRequest(req: Request) {
2const method = req.method;
3const body = method === "GET" || method === "HEAD" ? undefined : await req.text();
cerebras_codermain.tsx5 matches
6import { tomorrow } from "https://esm.sh/react-syntax-highlighter/dist/esm/styles/prism";
78function App() {
9const [prompt, setPrompt] = useState("hello llamapalooza");
10const [code, setCode] = useState("");
18>(null);
1920async function handleSubmit(e: React.FormEvent) {
21e.preventDefault();
22setLoading(true);
92}
9394function client() {
95createRoot(document.getElementById("root")!).render(<App />);
96}
100}
101102function extractCodeFromFence(text: string): string {
103const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
104return htmlMatch ? htmlMatch[1].trim() : text;
105}
106107export default async function server(req: Request): Promise<Response> {
108if (req.method === "POST") {
109const client = new Cerebras();
reqEvaltownmain.tsx4 matches
1import net, { AddressInfo } from "node:net";
23export default async function(req: Request): Promise<Response> {
4return serveRequest(
5req,
6`data:text/tsx,${
7encodeURIComponent(`
8export default async function(req: Request): Promise<Response> {
9return Response.json("I am within a worker!")
10}
14}
1516export async function serveRequest(req: Request, importUrl: string): Promise<Response> {
17let port = await getFreePort();
18const worker = new Worker(`https://esm.town/v/maxm/evaltownWorker?cachebust=${crypto.randomUUID()}`, {
55});
5657export async function isPortListening(port: number): Promise<boolean> {
58let isListening = false;
59const maxWaitTime = 2000; // ms
valtowntownmain.tsx5 matches
48await contentStore.init();
4950function Town() {
51return (
52<div
69}
7071function HomePage() {
72return (
73<html>
82<form method="POST" action="/submit">
83<textarea name="handler" rows={10} cols={50} autoFocus>
84{`export default async function(req: Request) {
85return Response.json("Hello, world!");
86}`}
95}
9697function ContentPage({ handler, id }: { handler: string; id: string }) {
98return (
99<html>
122let originalContent = textarea.value;
123124textarea.addEventListener('input', function() {
125if (textarea.value !== originalContent) {
126submitButton.style.display = 'inline-block';
ethereumAddressGeneratormain.tsx4 matches
4import { ethers } from "https://esm.sh/ethers@5.7.2";
56function CopyableField({ label, value }) {
7const copyToClipboard = () => {
8navigator.clipboard.writeText(value).then(() => {
22}
2324function App() {
25const [wallet, setWallet] = useState(null);
2651}
5253function client() {
54createRoot(document.getElementById("root")).render(<App />);
55}
57if (typeof document !== "undefined") { client(); }
5859export default async function server(request: Request): Promise<Response> {
60return new Response(`
61<html>