Extract a Number from a String with JavaScript

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

Mapping the Drift-backing of Refugees

‘Drift-back’ is a controversial practice which is used by some coast guard services, particularly in the Aegean Sea, to deter asylum seekers and prevent them from reaching their intended destination. It involves intercepting boats carrying asylum seekers within EU territorial waters, then forcing them back towards the country they departed from. This is sometimes allegedly done by loading Maps Mania… more →
Posted in: Interactive Maps

You Should Attend theJam.dev 2024!

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

Using GenAI to Classify an Image as a Photo, Screenshot, or Meme

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

The Interactive Turbulence Map

Are you hoping for a smooth flight? This map predicts turbulence on your flight, warning of potential bumpy patches on your journey. Enter your flight details into the map and it will provide real-time turbulence forecasts with color-coded severity levels, updated every 6 hours. The Interactive Turbulence Map shows you how much turbulence you can expect on your flight. Enter the name of Maps Mania… more →
Posted in: Interactive Maps

Date.now()

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

Using AI to Beat TimeGuessr

I am currently working on a project which requires me to identify the locations depicted in works of art (more about this, hopefully, very soon). In order to narrow down the exact locations shown in the paintings I have begun to use two AI image identification tools GeoSpy and Bard.The sketch shown at the top of this post is the ‘Tour de Montelban, Amsterdam’ by Maxime Lalanne. I downloaded Maps Mania… more →
Posted in: Interactive Maps

Thoughts on Streaming Services: 2024 Edition

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
1 26 27 28 29 30 190