Using Asynchronous Content in Leaflet Popups

Today in my <Code><Br> stream (I’ll share a link to the video at the bottom), I spent some time digging into Leaflet and worked on a demo that made use of the National Parks Service API. This is a fun API I’ve used many times in the past, especially at my last job at HERE. For the stream today, I wanted to build the following: Create a map that loads a geojson file of NPS parks. The geojson file contains the code and name for each park. On clicking one of the markers, use the NPS API to get more information about the park. In general, I’ve found everything in Leaflet to be stupid easy, but this particular aspect turned out to be a bit more difficult, which of course... more →
Posted in: JavaScript

Using PDF Content with Google Gemini – An Update

Way back in March of this year, I took a look at using Google’s Gemini APIs to analyze PDF documents ("Using PDF Content with Google Gemini"). At the time, the Gemini API didn’t support PDF documents, so I made use of our (Adobe) PDF Extract service to get the text content out from the document. This "worked" but was possibly less than ideal as my "glom all the text together" approach didn’t really represent the PDF well. The PDF Extract API returns information about text context (like if it is a header for example), but my method ignored that. I’m happy to share that Gemini now supports PDF files natively. Let’s take a look at how this... more →
Posted in: JavaScript

Working with Pasted Content in JavaScript

This began as me wanting to build an Alpine.js application that handled pasted input, but I realized before I looked into handling this with Alpine, it made sense to start with basic vanilla JavaScript at first. I’ve worked with the clipboard before, mainly storing information to it, but this was the first time I looked at handling input from the clipboard. The web platform handles it rather nicely, but as with most things, there are a few interesting things you need to be aware of. Here’s what I found. Listening To the Event # The first thing you need to do is actually listen to the event. While you probably listen on a part of a DOM, it made the most sense to me to listen at the... more →
Posted in: JavaScript

Creating a Content Assistant with Gemini and GenAI

One of the use cases for generative AI that I’ve discussed before is the idea of using the tool to aid in the writing process. I’m not talking about creating content so much as creating suggestions and providing feedback about the content you yourself have created. This past weekend I worked on a "general purpose" tool with this in mind and thought I’d share it to get your feedback. ("You" being the smart readers of this blog who keep me honest when I show something stupid. 😉 The Application # The application itself is rather straightforward. It asks two questions – first, what are you trying to accomplish with your writing and what are the desired... more →
Posted in: JavaScript

Using PDF Content with Google Gemini

Back in February Google announced Gemini 1.5, their latest, most powerful language model, and while access has been open via AI Studio, API access has only been available in the past few days. I thought I’d try out the new model and specifically make use of the larger context window to do prompts on PDF documents. I discussed something similar earlier this year(("Using AI and PDF Services to Automate Document Summaries")[https://www.raymondcamden.com/2024/01/08/using-ai-and-pdf-services-to-automate-document-summaries]) which made use of Diffbot, so I thought it would be interesting to build a similar experience with the Gemini API. At a high level, it’s not too difficult: Begin... more →
Posted in: JavaScript

Using Generative AI as Your Content Assistant

Last week I had the honor of presenting one at TheJam.dev. This was my first presentation on generative AI and I got to share what I thought was an interesting use case – helping with the writing process. Now to be clear, I don’t mean using GenAI to write blog posts, that would be a horrible idea. (IMO!) Instead, I looked at how it could help with some of the process. Let me back up a bit and give some background. I’ve been a fan of John Birmingham for many years now. He’s an author who writes in the military/sci-fi/etc genre and has some pretty fascinating ideas. I initially discovered him via his "Axis of Time" trilogy which dealt with the idea of a modern... more →
Posted in: JavaScript

Detect the Content Type in the Clipboard

A user’s clipboard is a “catch all” between the operating system and the apps employed on it. When you use a web browser, you can highlight text or right-click an image and select “Copy Image”. That made me think about how developers can detect what is in the clipboard. You can retrieve the contents of the user’s clipboard using the navigator.clipboard API. This API requires user permission as the clipboard could contain sensitive data. You can employ the following JavaScript to get permission to use the clipboard API: const result = await navigator.permissions.query({name: "clipboard-write"}); if (result.state === "granted" || result.state === "prompt") {... more →
Posted in: JavaScript

Related Content by Day of Year in Eleventy

Ok, chalk this up to something that is probably useful to one out of ten of my readers, but the idea’s been bouncing around my brain for a few months now and I finally took the time to build it out. Imagine a content site that’s been around for a while, for example, this blog (twenty years next February). It may be interesting to tie articles to content written in the past, specifically, on the same day in previous years. This requires a site with years of content and enough content such that there would actually be a decent chance of that happening, but I could see newspaper sites or other news organizations being able to meet that criteria. For... more →
Posted in: JavaScript
1 2