Townie.cursorrules2 matches
178179- **Redirects:** Use `return new Response(null, { status: 302, headers: { Location: "/place/to/redirect" }})` instead of `Response.redirect` which is broken
180- **Images:** Avoid external images or base64 images. Use emojis, unicode symbols, or icon fonts/libraries instead
181- **AI Image:** To inline generate an AI image use: `<img src="https://maxm-imggenurl.web.val.run/the-description-of-your-image" />`
182- **Storage:** DO NOT use the Deno KV module for storage
183- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods
TownieChatRouteSingleColumn.tsx15 matches
10import { useCreditBalance } from "../hooks/useCreditBalance.tsx";
11import { Messages } from "./Messages.tsx";
12import { InputBox, ImageDropContainer } from "./InputBox.tsx";
13import { PreviewFrame } from "./PreviewFrame.tsx";
14import { BranchSelect } from "./BranchSelect.tsx";
68refetch: () => void;
69}) {
70const [images, setImages] = useState<(string|null)[]>([]);
71const [selectedFiles, setSelectedFiles] = useState<string[]>([]);
72const { audio, user } = useContext(AppContext);
88branchId,
89selectedFiles,
90images,
91soundEnabled: audio,
92});
137138return (
139<ImageDropContainer
140running={running}
141images={images}
142setImages={setImages}>
143<div className="single-column-container">
144<div className="single-sticky-header">
148rel="norefferer"
149className="block-link text-link lockup">
150{project.imageUrl ? (
151<img src={project.imageUrl} className="image-thumbnail" />
152) : user?.profileImageUrl ? (
153<img
154src={user.profileImageUrl}
155className="avatar"
156alt={user.username}
159/>
160) : (
161<div className="image-placeholder" />
162)}
163<div>{project.name}</div>
211onSubmit={e => {
212handleSubmit(e);
213setImages([]);
214}}
215onCancel={handleStop}
216running={running}
217error={error}
218images={images}
219setImages={setImages}
220/>
221)}
223</div>
224</div>
225</ImageDropContainer>
226);
227}
3Feel free to mess around with this val and make it your own :). Just click on "Fork" in the top right.
45You can change the phrases that show up as you click no, you can change the firstImg and secondImg, maybe even add more images. And you can also change the colors and any of the text on the screen!
67Have fun with it and hopefully your crush says yes hehe.
steel_puppeteer_startermain.tsx24 matches
8// This is a placeholder function showing how you would call an AI API.
9// You would replace this with the actual Google AI SDK (`@google/generative-ai`).
10async function getTextFromImageWithGemini(filePath: string): Promise<string> {
11console.log("\n--- Entering AI Text Extraction Step ---");
12console.log(`(Pretending to send image at '${filePath}' to a multimodal AI...)`);
13
14// In a real scenario, you would:
15// 1. Install the Google AI SDK: `npm install @google/generative-ai`
16// 2. Initialize the Gemini client with your API key.
17// 3. Read the image file from the filePath.
18// 4. Convert it to a format the API accepts (like base64).
19// 5. Send it to the model (e.g., 'gemini-1.5-flash').
50const page = pages.length > 0 ? pages[0] : await browser.newPage();
51
52// Using a specific review page which is known to have a spec image
53const url = 'https://amanz.my/2024448310/'; // Ulasan: HONOR Magic6 Pro
54await page.goto(url, { waitUntil: "domcontentloaded" });
55console.log(`Mapsd to: ${url}`);
5657// --- STEP 1: Find and Download the Spec Image ---
58console.log("\n--- Locating product specification image... ---");
5960// This selector targets an image inside a <figure> tag, within the article body.
61// This is often a good guess, but it might need to be adjusted for other articles.
62const imageSelector = 'figure.wp-block-image img';
6364// Use page.$eval to find the element and get its 'src' attribute
65const imageUrl = await page.$eval(imageSelector, (img: HTMLImageElement) => {
66return img.src; // Get the source URL of the image
67});
68
69console.log(`Found image URL: ${imageUrl}`);
7071// Download the image
72console.log("Downloading image...");
73const imageResponse = await fetch(imageUrl);
74if (!imageResponse.ok) {
75throw new Error(`Failed to download image: ${imageResponse.statusText}`);
76}
7778// Convert the image response to a buffer (raw binary data)
79const imageBuffer = await imageResponse.arrayBuffer();
8081// Save the buffer to a local file
82const imageFileName = 'spec-image.jpg';
83await fs.writeFile(imageFileName, Buffer.from(imageBuffer));
84console.log(`Image successfully saved as '${imageFileName}'`);
8586// --- STEP 2: Send the Image to AI for Text Extraction ---
87const extractedText = await getTextFromImageWithGemini(imageFileName);
8889console.log("\n--- AI Analysis Complete ---");
96// Specifically check for selector error
97if (error.message.includes('failed to find element matching selector')) {
98console.error(`Could not find the specification image. The CSS selector might need to be updated for this article.`);
99} else {
100console.error(error.message);
farcaster-autoPostToXindex.ts37 matches
23content_type: string;
24content_length: number | null;
25image?: {
26width_px: number;
27height_px: number;
30title: string;
31description: string;
32image: string;
33};
34};
72console.log("CastData", castData);
7374// Process embeds - separate images for upload vs URLs for text
75let mediaIds: string[] = [];
76let textUrls: string[] = [];
78if (castData.embeds && castData.embeds.length > 0) {
79for (const embed of castData.embeds) {
80// Check if this is an imagedelivery.net URL (download and upload as media)
81if (embed.url.startsWith("https://imagedelivery.net")) {
82// We'll process these as uploadable images
83continue; // Handle after getting Twitter client
84}
93}
9495// Append non-image URLs to text
96if (textUrls.length > 0) {
97castText = castText + " " + textUrls.join(" ");
126});
127128// Process imagedelivery.net URLs - download and upload as media
129if (castData.embeds && castData.embeds.length > 0) {
130const imageEmbeds = castData.embeds
131.filter(embed => embed.url.startsWith("https://imagedelivery.net"))
132.slice(0, 2); // Limit to 2 images (Farcaster's limit)
133134for (const embed of imageEmbeds) {
135try {
136console.log("Downloading image from:", embed.url);
137138// Get image format from Farcaster metadata
139const contentType = embed.metadata?.content_type;
140if (!contentType || !contentType.startsWith("image/")) {
141throw new Error(`Invalid or missing content type: ${contentType}`);
142}
143144// Convert MIME type to format string for Twitter API
145let imageFormat: string;
146switch (contentType) {
147case "image/jpeg":
148imageFormat = "jpeg";
149break;
150case "image/png":
151imageFormat = "png";
152break;
153case "image/webp":
154imageFormat = "webp";
155break;
156case "image/gif":
157imageFormat = "gif";
158break;
159default:
160throw new Error(`Unsupported image format: ${contentType}`);
161}
162163// Download the image
164const imageResponse = await fetch(embed.url);
165if (!imageResponse.ok) {
166throw new Error(`Failed to download image: ${imageResponse.status} ${imageResponse.statusText}`);
167}
168169const imageBuffer = await imageResponse.arrayBuffer();
170const imageUint8Array = new Uint8Array(imageBuffer);
171172console.log("Uploading image to Twitter, size:", imageUint8Array.length, "bytes, format:", imageFormat);
173174// Upload to Twitter using Buffer and correct format
175const mediaUpload = await twitterClient.v1.uploadMedia(Buffer.from(imageUint8Array), {
176type: imageFormat,
177});
178179mediaIds.push(mediaUpload);
180console.log("Successfully uploaded image, media ID:", mediaUpload);
181} catch (error) {
182console.error("Failed to process image:", embed.url, "Error:", error);
183// Skip posting entire tweet if image processing fails
184return new Response("OK", { status: 200 });
185}
22font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
23}
24.background-image {
25position: fixed;
26top: 0;
41</head>
42<body>
43<div class="background-image" style="background-image: url('https://source.unsplash.com/1920x1080/?fitness,running,cycling')"></div>
44<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
45<div class="container">
untitled-9081main.tsx2 matches
22font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
23}
24.background-image {
25position: fixed;
26top: 0;
41</head>
42<body>
43<div class="background-image" style="background-image: url('https://source.unsplash.com/1920x1080/?fitness,running,cycling')"></div>
44<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
45<div class="container">
autonomous-valREADME.md1 match
2This project demonstrates how to build autonomous agents on Val Town that can be triggered by API calls, cron jobs, etc.
34
56## Setup
GitHub-PR-Automation-akiREADME.md2 matches
1213See all 3 in action👇
14
1516### 1. PR Auto-Assign
5152See this in action👇
53
5455
GitHub-PR-AutomationREADME.md2 matches
1213See all 3 in action👇
14
1516### 1. PR Auto-Assign
5152See this in action👇
53
5455