hackerNewsDigestREADME.md1 match
456<img width="400px" src="https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/2661d748-d7a7-4d1e-85a4-f60fae262000/public" />
7
3435// Run generative model
36const generatedImage = await replicate.run(
37"rapfl/sdxl-zottify:caf6f0e13ef741de9353b0a06146797a4a55fbff3f5f4013e7fe755756a346e1",
38{
47);
4849const result = generatedImage[0];
50// Sending a card with the image in it
51return new Response(
52render(
imagesToPDFmain.tsx17 matches
1/**
2* This application creates a client-side interface for uploading multiple image files
3* and generating a PDF containing those images. It uses the following approach:
4*
5* 1. Create a simple HTML form for file input
6* 2. Use JavaScript to handle file selection and PDF generation
7* 3. Utilize the jsPDF library for PDF creation
8* 4. Use the FileReader API to read image files
9*
10* The application will not modify or convert the images, and each PDF page
11* will be sized according to the corresponding image dimensions.
12*/
1322<meta charset="UTF-8">
23<meta name="viewport" content="width=device-width, initial-scale=1.0">
24<title>Image to PDF Converter</title>
25<link rel="stylesheet" href="/styles.css">
26<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
29<body>
30<div class="container">
31<h1>Image to PDF Converter</h1>
32<input type="file" id="imageInput" accept="image/*" multiple>
33<button id="convertBtn">Convert to PDF</button>
34</div>
86const { jsPDF } = window.jspdf;
8788const imageInput = document.getElementById('imageInput');
89const convertBtn = document.getElementById('convertBtn');
909293async function convertToPDF() {
94const files = imageInput.files;
95if (files.length === 0) {
96alert('Please select at least one image file.');
97return;
98}
99100const [file0] = files;
101const img0 = await loadImage(file0);
102103const pdf = new jsPDF({
112for (let i = 0; i < files.length; i++) {
113const file = files[i];
114const img = await loadImage(file);
115116if (i) pdf.addPage([img.width, img.height]);
117pdf.addImage(img, 'AVIF', 0, 0, img.width, img.height);
118}
119120pdf.save('images.pdf');
121}
122130}
131132function loadImage(blob) {
133return new Promise((resolve, reject) => {
134const src = URL.createObjectURL(blob);
135const img = new Image();
136img.onload = () => resolve(img);
137img.onerror = (e) => reject(e);
bedtimeStoryMakermain.tsx8 matches
124role: "system",
125content:
126`Describe an image that depicts the ${adjective} children's story about a ${color} colored ${animal}: ${summary}.
127The description should be descriptive, but three short sentences.
128Just give me the instructions, don't make an image.`,
129},
130],
143// fast-lightning-sdxl
144const options = {
145"image_size": "square",
146"num_images": 1,
147"num_inference_steps": 6,
148"enable_safety_checker": true,
149};
150// {"num_images": 1,
151// "guidance_scale": 9.5,
152// "num_inference_steps": 20,
153// "expand_prompt": true }
154const result: any = await fal.run(`fal-ai/${falModel}`, { input: { prompt }, options });
155const url = result.images[0].url;
156157return url;
162title: ogData?.title || "Bedtime Story Maker",
163description: ogData?.description || "",
164image: ogData?.image || "",
165url: ogData?.url || `https://dthyresson-bedtimestorymaker.web.val.run/bedtime_stories}`,
166};
480title,
481description: summary,
482image: pictureUrl,
483url: `https://dthyresson-bedtimestorymaker.web.val.run/bedtime_stories/read/${id}`,
484};
generativeFillmain.tsx6 matches
10const lastMsg = req.query.at(-1);
11if (lastMsg && lastMsg.attachments.length !== 2) {
12yield events.replace("No image recieved");
13yield html;
14yield events.done();
15return;
16}
17yield events.replace("Generating image");
18let success = null;
19let error = null;
20const input = {
21image: lastMsg.attachments.at(0).url,
22mask: lastMsg.attachments.at(1).url,
23prompt: lastMsg.content.trim() || "cute kitty",
36let i = 0;
37while (!success && !error) {
38yield events.replace("Generating image (" + (i++) + ")");
39await sleep(1000);
40}
43if (success && Array.isArray(success)) {
44for (const url of success) {
45// yield markdown image
46yield `\n`;
47}
48}
bikeInventorymain.tsx19 matches
12const [year, setYear] = useState(bike?.year || "");
13const [lastMaintenance, setLastMaintenance] = useState(bike?.lastMaintenance || "");
14const [imageUrl, setImageUrl] = useState(bike?.imageUrl || "");
1516const handleSubmit = (e) => {
23year: parseInt(year),
24lastMaintenance,
25imageUrl
26});
27};
94</div>
95<div className="field-row-stacked" style={{width: '200px'}}>
96<label htmlFor="edit-image">Image URL</label>
97<input
98id="edit-image"
99type="url"
100value={imageUrl}
101onChange={(e) => setImageUrl(e.target.value)}
102/>
103</div>
198if (db && bikes.length === 0) {
199const initialBikes = [
200{ brand: "Trek", model: "Domane", type: "Road", year: 2022, imageUrl: "https://maxm-imggenurl.web.val.run/trek-domane-road-bike" },
201{ brand: "Specialized", model: "Stumpjumper", type: "Mountain", year: 2021, imageUrl: "https://maxm-imggenurl.web.val.run/specialized-stumpjumper-mountain-bike" },
202{ brand: "Cannondale", model: "CAAD13", type: "Road", year: 2023, imageUrl: "https://maxm-imggenurl.web.val.run/cannondale-caad13-road-bike" },
203{ brand: "Giant", model: "Trance", type: "Mountain", year: 2022, imageUrl: "https://maxm-imggenurl.web.val.run/giant-trance-mountain-bike" },
204{ brand: "Bianchi", model: "Oltre", type: "Road", year: 2023, imageUrl: "https://maxm-imggenurl.web.val.run/bianchi-oltre-road-bike" },
205{ brand: "Santa Cruz", model: "Hightower", type: "Mountain", year: 2021, imageUrl: "https://maxm-imggenurl.web.val.run/santa-cruz-hightower-mountain-bike" },
206{ brand: "Cervélo", model: "S5", type: "Road", year: 2022, imageUrl: "https://maxm-imggenurl.web.val.run/cervelo-s5-road-bike" },
207{ brand: "Yeti", model: "SB150", type: "Mountain", year: 2023, imageUrl: "https://maxm-imggenurl.web.val.run/yeti-sb150-mountain-bike" },
208{ brand: "Pinarello", model: "Dogma F", type: "Road", year: 2023, imageUrl: "https://maxm-imggenurl.web.val.run/pinarello-dogma-f-road-bike" },
209{ brand: "BMC", model: "Fourstroke", type: "Mountain", year: 2022, imageUrl: "https://maxm-imggenurl.web.val.run/bmc-fourstroke-mountain-bike" }
210];
211262<thead>
263<tr>
264<th>Image</th>
265<th>Brand</th>
266<th>Model</th>
275<tr key={bike.id}>
276<td>
277{bike.imageUrl && (
278<img src={bike.imageUrl} alt={`${bike.brand} ${bike.model}`} style={{ width: '50px', height: '50px', objectFit: 'cover' }} />
279)}
280</td>
sqliteExplorerAppREADME.md1 match
3View and interact with your Val Town SQLite data. It's based off Steve's excellent [SQLite Admin](https://www.val.town/v/stevekrouse/sqlite_admin?v=46) val, adding the ability to run SQLite queries directly in the interface. This new version has a revised UI and that's heavily inspired by [LibSQL Studio](https://github.com/invisal/libsql-studio) by [invisal](https://github.com/invisal). This is now more an SPA, with tables, queries and results showing up on the same page.
45
67## Install
lastlogin_demoREADME.md1 match
12
3
design32x32bitmapmain.tsx56 matches
4import { adjectives, animals, colors, Config, uniqueNamesGenerator } from "https://esm.sh/unique-names-generator";
56const DEFAULT_IMAGE_NAME = "untitled-<d><d>-<word>";
7const DEFAULT_SIZE = { width: 32, height: 32 };
8const SIZES = [
69setSize,
70clearCanvas,
71saveImage,
72imageName,
73setImageName,
74downloadImage,
75savedImages,
76loadImage,
77deleteImage,
78setShowSettings,
79brushSize,
101<div className="control-group">
102<button onClick={clearCanvas}>Clear</button>
103<button onClick={saveImage}>Save</button>
104</div>
105<div className="control-group">
106<input
107type="text"
108value={imageName}
109onChange={(e) => setImageName(e.target.value)}
110placeholder="Image name"
111/>
112<button onClick={() => downloadImage(imageName)} className="download-btn">
113<span className="download-icon">⬇️</span>
114</button>
118onChange={(e) => {
119if (e.target.value) {
120loadImage(e.target.value);
121e.target.value = "";
122}
123}}
124>
125<option value="">Load image</option>
126{savedImages.map((name) => (
127<option key={name} value={name}>
128{name}
133onChange={(e) => {
134if (e.target.value) {
135deleteImage(e.target.value);
136e.target.value = "";
137}
138}}
139>
140<option value="">Delete image</option>
141{savedImages.map((name) => (
142<option key={name} value={name}>
143{name}
158<h2>Settings</h2>
159<label>
160Default Image Name:
161<input
162type="text"
196const [isDrawing, setIsDrawing] = useState(false);
197const [isPainting, setIsPainting] = useState(false);
198const [imageName, setImageName] = useState(DEFAULT_IMAGE_NAME);
199const [savedImages, setSavedImages] = useState<string[]>([]);
200const [showSettings, setShowSettings] = useState(false);
201const [settings, setSettings] = useState({
202defaultName: DEFAULT_IMAGE_NAME,
203colorScheme: "pitaya",
204});
207208useEffect(() => {
209const saved = localStorage.getItem("savedImagesList");
210if (saved) {
211setSavedImages(JSON.parse(saved));
212}
213const savedSettings = localStorage.getItem("settings");
228229useEffect(() => {
230setImageName(generateName(settings.defaultName));
231}, [settings.defaultName]);
232308}, [size]);
309310const saveImage = useCallback(() => {
311const imageData = JSON.stringify({ name: imageName, size, pixels });
312localStorage.setItem(`image_${imageName}`, imageData);
313setSavedImages(prev => {
314const newSavedImages = [...new Set([...prev, imageName])];
315localStorage.setItem("savedImagesList", JSON.stringify(newSavedImages));
316return newSavedImages;
317});
318setImageName(generateName(settings.defaultName));
319}, [imageName, size, pixels, settings.defaultName]);
320321const loadImage = useCallback((name: string) => {
322if (confirm(`Are you sure you want to load "${name}"? This will overwrite your current work.`)) {
323const imageData = localStorage.getItem(`image_${name}`);
324if (imageData) {
325const { size: loadedSize, pixels: loadedPixels } = JSON.parse(imageData);
326setSize(loadedSize);
327setPixels(loadedPixels);
328setImageName(name);
329}
330}
331}, []);
332333const deleteImage = useCallback((name: string) => {
334if (confirm(`Are you sure you want to delete "${name}"? This action cannot be undone.`)) {
335localStorage.removeItem(`image_${name}`);
336setSavedImages(prev => {
337const newSavedImages = prev.filter(img => img !== name);
338localStorage.setItem("savedImagesList", JSON.stringify(newSavedImages));
339return newSavedImages;
340});
341}
342}, []);
343344const downloadImage = useCallback((customName: string) => {
345const canvas = document.createElement("canvas");
346canvas.width = size.width;
364const fileName = `${customName || generateName(settings.defaultName)}-1bit-${size.width}x${size.height}.bmp`;
365link.download = fileName;
366link.href = canvas.toDataURL("image/bmp");
367link.click();
368}, [pixels, size, settings.defaultName]);
401setSize={setSize}
402clearCanvas={clearCanvas}
403saveImage={saveImage}
404imageName={imageName}
405setImageName={setImageName}
406downloadImage={downloadImage}
407savedImages={savedImages}
408loadImage={loadImage}
409deleteImage={deleteImage}
410setShowSettings={setShowSettings}
411brushSize={brushSize}
589appearance: none;
590padding-right: 30px;
591background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3E%3Cpath fill='%230f0' d='M0 0l4 4 4-4z'/%3E%3C/svg%3E");
592background-repeat: no-repeat;
593background-position: right 10px center;
blob_adminREADME.md1 match
3This is a lightweight Blob Admin interface to view and debug your Blob data.
45
67Use this button to install the val: