Generating Relevant Random JSON with Chrome AI / / No Comments A few weeks ago I blogged a demo where I used Chrome’s on-device AI feature to parse a "generic template language" and return random strings. If you’re so inclined (and of course you are), you can read that post here: "Creating a Generic Generative Language with Chrome AI". The idea was to give the AI model a template string that described what was random, and how it was random (this is a name, this is a number, this is a color, etc) and have the model fill in the blanks with appropriate values. At work, I’ve been digging into our platform and trying to learn as much as possible. One of the cooler features of Webflow is the CMS. You define a collection (type... more → Posted in: JavaScript Tagged with: Chrome, Generating, JSON, Random, Relevant
Get a Random Array Item with JavaScript / / No Comments JavaScript Arrays are probably my favorite primitive in JavaScript. You can do all sorts of awesome things with arrays: get unique values, clone them, empty them, etc. What about getting a random value from an array? To get a random item from an array, you can employ Math.random: const arr = [ "one", "two", "three", "four", "tell", "me", "that", "you", "love", "me", "more" ]; const random1 = arr[(Math.floor(Math.random() * (arr.length)))] const random2 = arr[(Math.floor(Math.random() * (arr.length)))] const random3 = arr[(Math.floor(Math.random() * (arr.length)))] const random4 = arr[(Math.floor(Math.random() * (arr.length)))] console.log(random1,... more → Posted in: JavaScript Tagged with: Array, Item, JavaScript, Random
V8 Javascript Fixes (Horrible!) Random Number Generator – Hackaday / / No Comments Hackaday V8 Javascript Fixes (Horrible!) Random Number GeneratorHackadayTo quantify the above observations, the official V8 Javascript post that I linked above notes that the coverage is only 232 values out of the possible 252 uniformly-distributed values that a 64-bit float can represent. This is a huge failure of the …and more » JavaScript – Google News… more → Posted in: JavaScript Tagged with: Fixes, Generator, Hackaday, Horrible, JavaScript, Number, Random