Counting Words with Intl.Segmenter

Yesterday, I gave my presentation on Intl, the browser’s built-in support for internationalization. I’ve been using this for a while now, but while researching the spec for my presentation, I ran into multiple cool aspects of it I wasn’t aware of. One feature I thought was particularly interesting was the Segementer object. MDN’s description is nice and succinct: The Intl.Segmenter object enables locale-sensitive text segmentation, enabling you to get meaningful items (graphemes, words or sentences) from a string. In particular, I thought the ability to get words would be an interesting use case. In the past, I’ve either done a lame split on " ", or used... more →
Posted in: JavaScript

Links For You (11/11/2024)

The last seven days have been… difficult. I don’t think I need to go into why (even for my non-American readers), but I am doing my best, as are a lot of people, to take things day by day. Honestly, as a white hetero man, I’m not so much worried for myself, but I’m deeply concerned about my family and friends who are LGBTQ+ and other minorities. I don’t talk a lot about my children here as I want to ensure their privacy is maintained, but seven of my kids are adopted and Asian and my usual worry for them has risen quite a bit. Normally, my links here are almost always tech-related, but today I’m going to do something different. The links below are resources... more →
Posted in: JavaScript

Executing Dynamic Code in a Reveal.js Presentation

Please take what follows with a Titanic-sized grain of salt and do your best not to do what I did, but despite that, I thought this little hack was interesting and I figured I’d share it anyway. I typically use Reveal.js for my presentations, especially when talking about the web platform, as it makes it easy to do slides and demos, all in my browser. Usually when I want to embed live code in a slide, I just use a CodePen embed. While this works well, sometimes it feels like overkill for real short code samples. I wondered if it would be possible to execute code directly in the slide itself such that I could show a one-liner in the slide, and then the result after. This is what I came up... more →
Posted in: JavaScript

Automatically Posting to Bluesky on New RSS Items

Hey folks – just a quick warning. This post is kind of a mashup/update of two earlier posts. Back almost two years ago I talked about this process but used Twitter and Mastodon: "Automatically Posting to Mastodon and Twitter on New RSS Items". Earlier this year I first talked about using the Bluesky API, with a very appropriately named post: "Using the Bluesky API". As I said, this post is going to mash up bits from both, and include new things I’ve not covered before, but for those of you who have been around here for a while, some of this may be repetition. For this solution, I’m using Pipedream. I’ve blogged for years now and love it. Their free... more →
Posted in: JavaScript

Adding Translation with a Web Component and Chrome AI

A few days ago, I blogged about using Chrome’s built-in generative AI features (which are still super duper too early to even consider for production) to add on-device translation capabilities to a web app. It got me thinking, what if we could do translation automatically via a web component? If for some reason it failed, that would be fine as the original text would still be there, but in cases where it could work, it would be automatic. Here’s what I built. First, I whipped up a quick HTML demo of the text I’d like translated: <translate-text>Congress shall make no law respecting an establishment of religion, or prohibiting the free exercise thereof; or abridging the... more →
Posted in: JavaScript

Next Code Break – Blogging with Eleventy

Hey folks – my next <Code><Br> will not be this Tuesday as I’ll be presenting at API World (assuming American gets me there today) so I’ve pushed back the livestream till Thursday, November 7th. Usual time – 12PM CST. You can read more about the event here: https://cfe.dev/talkshows/codebreak-11072024/ I’m going to be discussing Eleventy and building a basic blog. I’ve wanted to cover Eleventy on my show for a while but was waiting for 3.0 to come out. Now that it has – I can’t wait to introduce it to folks. Hope to see you there! Raymond Camden… more →
Posted in: JavaScript

Links For You (10/28/2024)

This post was meant to go out on the weekend, but I got sucked into video games, baking cookies, and, well, watching the Saints suck. I’ve mentioned this already I think, and I’m pretty sure I talked about it on my stream, but my anxiety which had taken a bit of a back seat for nearly a month has come raging back in. November is going to be kind of a crazy month for me – I’ve got two trips, six presentations total, and a major holiday. I’m also just a teeny bit worried about, oh you know, the entire country going to hell, but for today, today I’m just going to focus on tackling things one by one. And with that… your lnks. Converting HTML to Image in Node.js First... more →
Posted in: JavaScript

Using Chrome AI for Translation

I’ve done a couple blog posts now on Chrome’s efforts to bring generative AI to the browser. It’s still somewhat of a rough process (remember, you can sign up for access to test and learn more at the intro post from the Chrome engineers), but it’s getting better over time. One thing I mentioned in my last post ("Using Chrome AI to Rewrite Text") was how the Chrome team is shipping focused APIs for specific purposes, not just general Q and A. In that previous post, I demonstrated an example of the Rewriter API. As yet another example of this, you can now test out on device translation. As with everything else I’ve shared in this space, you should consider... more →
Posted in: JavaScript
1 2 3 87