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 === "/") {
curiousTurquoiseDormousemain.tsx7 matches
4import { marked } from "https://esm.sh/marked@4.3.0";
56function ConfirmationModal({ isOpen, onClose }) {
7if (!isOpen) return null;
818}
1920function App() {
21const [sport, setSport] = useState("");
22const [skillLevel, setSkillLevel] = useState("");
323}
324325function client() {
326createRoot(document.getElementById("root")).render(<App />);
327}
662`;
663664async function server(request: Request): Promise<Response> {
665if (request.method === "POST" && new URL(request.url).pathname === "/generate-training") {
666const YOUTUBE_API_KEY = Deno.env.get("YOUTUBE_API_KEY2");
743const { email } = await import("https://esm.town/v/std/email");
744
745// Function to insert YouTube links into the training plan
746const insertYouTubeLinks = (plan, links) => {
747let modifiedPlan = plan;
805}
806807async function getYouTubeVideoId(query, sport, apiKey, useApiKey = true) {
808if (useApiKey) {
809try {
825}
826827function getFallbackYouTubeLink(query, sport) {
828const searchQuery = encodeURIComponent(`${sport} ${query}`);
829return `https://www.youtube.com/results?search_query=${searchQuery}`;
efficientAmberUnicornmain.tsx6 matches
6// ... (previous code remains unchanged)
78async function server(request: Request): Promise<Response> {
9if (request.method === "POST" && new URL(request.url).pathname === "/generate-training") {
10const YOUTUBE_API_KEY = Deno.env.get("YOUTUBE_API_KEY2");
46}
4748// ... (rest of the server function remains unchanged)
49}
5051async function getYouTubeVideoData(query, sport, apiKey, useApiKey = true) {
52if (useApiKey) {
53try {
84}
8586function isVideoRelevant(videoData, sport, query) {
87const relevanceScore = calculateRelevanceScore(videoData, sport, query);
88return relevanceScore > 0.6; // Threshold for relevance
89}
9091function calculateRelevanceScore(videoData, sport, query) {
92let score = 0;
93122}
123124function getFallbackYouTubeLink(query, sport) {
125const searchQuery = encodeURIComponent(`${sport} ${query}`);
126return `https://www.youtube.com/results?search_query=${searchQuery}`;
renderHTMLWithHonomain.tsx1 match
38});
3940export default async function(req: Request): Promise<Response> {
41return app.fetch(req);
42}
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();