Using Generative AI to Improve Image Filenames / / No Comments Last night I had an interesting thought. Many times I work with images that have vague filenames. For example, screenshot_1_24_12_23.jpg. Given that there are many APIs out there that can look at an image and provide a summary, what if we could use that to provide a better file name based on the content of the image? Here’s what I was able to find. As always, I began by prototyping in Google AI Studio. I apologize for stating this in basically every post on the topic, but I really want to stress how useful that is for development. I used a very simple prompt: Write a one sentence short summary of this image. The sentence should be no more than five words. And then did a quick test: If... more → Posted in: JavaScript Tagged with: Filenames, Generative, Image, improve, using
Fixing Cumulative Layout Shift Problems on DavidWalshBlog / / No Comments Over 50 thousand developers visit DavidWalshBlog every month from around the world to learn JavaScript tricks and fix problems in their code. Unfortunately, some of them have a slow experience on the site. David tracks the performance of his Core Web Vitals and overall performance with Request Metrics. Recently, we noticed that his CLS performance score was trending pretty slow for both desktop and mobile users. Wait, what is CLS? Cumulative Layout Shift (CLS) is one of the Core Web Vital performance metrics. It doesn’t measure load time directly, instead it measures how much a page shifts while it is being loaded. You’ve definitely seen this and been annoyed by it. These shifts... more → Posted in: JavaScript Tagged with: Cumulative, DavidWalshBlog, Fixing, layout, Problems, shift
Extract a Number from a String with JavaScript / / No Comments User input from HTML form fields is generally provided to JavaScript as a string. We’ve lived with that fact for decades but sometimes developers need to extract numbers from that string. There are multiple ways to get those numbers but let’s rely on regular expressions to extract those numbers! To employ a regular expression to get a number within a string, we can use \d+: const string = "x12345david"; const [match] = string.match(/(\d+)/); match; // 12345 Regular expressions are capable of really powerful operations within JavaScript; this practice is one of the easier operations. Converting the number using a Number() wrapper will give you the number as a Number type. The... more → Posted in: JavaScript Tagged with: Extract, from, JavaScript, Number, String
You Should Attend theJam.dev 2024! / / No Comments Next week, a very cool, and very free, online event is being held by the fine folks at Certified Fresh Events, theJam.dev 2024. This is a two-day online conference covering web development, AI, serverless, frameworks, and certainly more than just the Jamstack. Speakers include Cassidy Williams, Alex Russel, Zach Leatherman (creator of Eleventy!), Rizèl Scarlett, and more. I’ll be giving a quick lightning talk on generative AI and writing, and you can see the full schedule on the website. Did I mention it was free? Did I mention it was online? You’ve got no reason to miss this, so check it out! Raymond Camden… more → Posted in: JavaScript Tagged with: 2024, Attend, should, theJam.dev
Using GenAI to Classify an Image as a Photo, Screenshot, or Meme / / No Comments File this under the "I wasn’t sure if it would work and it did" category. Recently, a friend on Facebook wondered if there was some way to take a collection of photos and figure out which were ‘real’ photos versus memes. I thought it could possibly be a good exercise for GenAI and decided to take a shot at it. As usual, I opened up Google’s AI Studio and did a few initial tests: I then simply removed that image and pasted more info to test. From what I could see, it worked well enough. I then took the source code from AI Studio and began working. The Code # First, I grabbed some pictures from my collection, eleven of them, and tried to get a few photos, memes,... more → Posted in: JavaScript Tagged with: Classify, GenAI, Image, Meme, Photo, Screenshot, using
Date.now() / / No Comments Ask any software engineer and they’ll tell you that coding date logic can be a nightmare. Developers need to consider timezones, weird date defaults, and platform-specific date formats. The easiest way to work with dates is to reduce the date to the most simple format possible — usually a timestamp. To get the immediate time in integer format, you can use Date.now: const now = Date.now(); // 1705190738870 I will oftentimes employ Date.now() in my console.log statements to differentiate likewise console.log results from each other. You could also use that date as a unique identifier for an event in a low-traffic environment. The post Date.now() appeared first on David Walsh Blog. David... more → Posted in: JavaScript Tagged with: Date.now
Thoughts on Streaming Services: 2024 Edition / / No Comments Streaming services have revolutionized content delivery, sending linear media companies into a panic as they watch traditional cable services decay. “Cutting the cord” is a common practice these days, but the streaming landscape isn’t perfect. We’re a decade into streaming so I wanted to share my thoughts on the state of new media: first impressions, second thoughts, and the third degree! Netflix is king thanks to having first mover advantage, and making smart financial moves over the past six months, but Netflix’s content is unremarkable. Their recent wins are USA’s Suits and content licensed from Max…they need to do better… The biggest loser... more → Posted in: JavaScript Tagged with: 2024, Edition, Services, Streaming, thoughts
Using AI and PDF Services to Automate Document Summaries / / No Comments I first discovered Diffbot way back in 2021 when I built a demo of their APIs for the Adobe Developer blog ("Natural Language Processing, Adobe PDF Extract, and Deep PDF Intelligence"). At that time, I was impressed with how easy Diffbot’s API was and also how quickly it responded. I had not looked at their API in a while, but a few days ago they announced new support for summarizing text. I thought this would be a great thing to combine with the Adobe PDF Extract API. Here’s what I found. First off, if you want to try this yourself, you’ll need: Adobe PDF Services credentials. These are free and you get 500 transactions per month for free. For folks who may not know,... more → Posted in: JavaScript Tagged with: Automate, Document, Services, Summaries, using