joelanman, to webdev
@joelanman@hachyderm.io avatar

Got a Playwright question - in my tests I'm clicking a button which in the backend sends an email. I tried to use Jest to mock that function in the backend so it doesn't send an email, but that doesn't seem to work. Should it?

I could check for NODE_ENV in the backend and not send an email, but I'd like access to the email contents in my playwright test, but without actually sending an email.

Am I thinking about this all wrong?

aral, to SmallWeb
@aral@mastodon.ar.al avatar

So! Many! Kittens!

(Going to record a demo of the new interactive shell – REPL to some – and multi-page Settings this afternoon, just planning it out now.)

Oh and is that me creating and calling web routes interactively in the REPL on a live server? Why yes, yes it is.

:kitten:💕

aral, to SmallWeb
@aral@mastodon.ar.al avatar

:kitten: Kitten’s interactive shell (REPL) now saves session history scoped to your app so it will still be there when you next serve the same app.

https://codeberg.org/kitten/app#kitten-s-interactive-shell

I think I’m done with the REPL feature now.

Going to take a little break, step away from the computer, and make a plan for the next week of work on Kitten and Domain¹.

¹ https://codeberg.org/domain/app

aral, to SmallWeb
@aral@mastodon.ar.al avatar

Small update on Kitten’s new interactive shell (REPL). You can now access Kitten’s router via:

kitten.app.router

Also updated the section in the tutorial to fix typos in some of the code examples and use the new router key path:

https://codeberg.org/kitten/app#kitten-s-interactive-shell

:kitten:💕

virtulis, to programming
@virtulis@loud.computer avatar

Funsies: node-gyp is broken on latest kernel.

Likely some other libuv stuff as well. In case you're experiencing more weirdness than usual, consider a downgrade :blobcatthumbsup:​

https://github.com/nodejs/node/issues/53051

aral, to SmallWeb
@aral@mastodon.ar.al avatar

:kitten: 🎉

Kitten now has a lovely new multi-page Settings screen and… drumroll… a new 🐢 interactive shell (REPL) for you to play with the running state of your Small Web site/app/place and debug your app, inspect/manipulate its database, etc.

I plan on recording demos of each of them tomorrow but you can play with them now.

And here’s a little tutorial to get you started with the shell:

https://codeberg.org/kitten/app#kitten-s-interactive-shell

💕

Screenshot of Kitten running in terminal: 🌍 Domain https://localhost 📂 Source /var/home/aral/Projects/kitten/app/examples/file-uploads 💾 Databases /var/home/aral/.local/share/small-tech.org/kitten/databases 🐢 To launch an interactive shell, press the [s] key. Server is running and listening for connections… s 🐢 Launching interactive shell ctrl-d to exit; .help for assistance A good place to start is to run the .ls command to see the keys of the global kitten object: » 💡.ls is an alias for Object.keys(kitten) [ 'version', 'domain', 'port', 'app', 'databaseDirectory', 'projectIdentifier', 'deploy', 'WebSocket', 'html', 'libraries', 'page', 'events', 'css', 'js', 'markdown', 'md', 'safelyAddHtml', 'sanitise', 'uploadsDirectory', '_db', 'uploads', 'package', 'db' ] 🐱 💬 kitten.db.images[0] Proxy [ { path: '/uploads/1a6c2612-057d-435b-83c7-7157b4add982/', altText: 'Screenshot of Draw Together sketch that reads Free Gaza!' }, { get: [Function: bound getHandler], set: [Function: bound setHandler], defineProperty: [Function: bound definePropertyHandler], deleteProperty: [Function: bound deletePropertyHandler] } ] 🐱 💬

joe, to ai

LLaVA (Large Language-and-Vision Assistant) was updated to version 1.6 in February. I figured it was time to look at how to use it to describe an image in Node.js. LLaVA 1.6 is an advanced vision-language model created for multi-modal tasks, seamlessly integrating visual and textual data. Last month, we looked at how to use the official Ollama JavaScript Library. We are going to use the same library, today.

Basic CLI Example

Let’s start with a CLI app. For this example, I am using my remote Ollama server but if you don’t have one of those, you will want to install Ollama locally and replace const ollama = new Ollama({ host: 'http://100.74.30.25:11434' }); with const ollama = new Ollama({ host: 'http://localhost:11434' });.

To run it, first run npm i ollama and make sure that you have "type": "module" in your package.json. You can run it from the terminal by running node app.js <image filename>. Let’s take a look at the result.

Its ability to describe an image is pretty awesome.

Basic Web Service

So, what if we wanted to run it as a web service? Running Ollama locally is cool and all but it’s cooler if we can integrate it into an app. If you npm install express to install Express, you can run this as a web service.

The web service takes posts to http://localhost:4040/describe-image with a binary body that contains the image that you are trying to get a description of. It then returns a JSON object containing the description.

https://i0.wp.com/jws.news/wp-content/uploads/2024/05/Screenshot-2024-05-18-at-1.41.20%E2%80%AFPM.png?resize=1024%2C729&ssl=1

Have any questions, comments, etc? Feel free to drop a comment, below.

https://jws.news/2024/how-can-you-use-llava-and-node-js-to-describe-an-image/

ecmascript_news, to javascript
@ecmascript_news@mastodon.online avatar
thisismissem, to programming
@thisismissem@hachyderm.io avatar

Wrote my first programming related blog post in a little while: How to redirect the user back to the previously requested URL after login with Adonis.js:

https://medium.com/@thisismissem/adonis-js-returning-the-user-to-the-previously-requested-url-after-authentication-2b5199a19839

  • All
  • Subscribed
  • Moderated
  • Favorites
  • JUstTest
  • everett
  • magazineikmin
  • thenastyranch
  • Youngstown
  • osvaldo12
  • rosin
  • slotface
  • ngwrru68w68
  • cubers
  • khanakhh
  • kavyap
  • Durango
  • DreamBathrooms
  • provamag3
  • mdbf
  • InstantRegret
  • ethstaker
  • tacticalgear
  • normalnudes
  • cisconetworking
  • modclub
  • Leos
  • GTA5RPClips
  • tester
  • anitta
  • megavids
  • lostlight
  • All magazines