2024-04-18

Ollama - JS raw API call

_ask = async (model, prompt) => {

    try {

        const response = await fetch("http://localhost:11434/api/generate", {

            method: "POST",

            headers: {"Content-Type": "application/json"},

            body: JSON.stringify({ model, prompt, stream: false })

        });

        return await response.json();

    } catch (err) {

        console.error('error:', err);

    }

};

2024-03-21

MacOS - List all empty files recursively

find . -maxdepth 1 -type f -name '*.*' -empty

2024-03-03

JavaScript - Paint tables in the log console

 console.table([2,3,4,5,6]);

┌─────────┬────────┐

│ (index) │ Values │

├─────────┼────────┤

│    0    │   1    │

│    1    │   2    │

│    2    │   3    │

│    3    │   3    │

│    4    │   4    │

│    5    │   5    │

│    6    │   6    │

│    7    │   7    │

└─────────┴────────┘

2024-01-23

Bootstrap - Extend link to parent (stretched-link)

 <div class="card" style="width: 18rem;">

  <img src="..." class="card-img-top" alt="...">
  <div class="card-body">
    <h5 class="card-title">Card with stretched link</h5>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
    <a href="#" class="btn btn-primary stretched-link">Go somewhere</a>
  </div>
</div>


https://getbootstrap.com/docs/4.3/utilities/stretched-link/

2023-12-29

MongoDB - Remove a field from an array of documents

 db.collection_name.updateOne(

   {"array_of_docs.field_name": {$exists: 1}}, 

   {$unset: {"array_of_docs.$[].field_name": ""}}

);

2023-11-11