teleren/devto huggingface dataset:
Functional Programming in Java: Lists, Lambdas, and Method References
Published: 2024-04-05 19:34:27

#Introduction

Functional programming has gained significant popularity in recent years, and Java, being a versatile language, embraces functional constructs. In this article, we’ll explore three essential aspects of functional programming in Java: lists, lambdas, and method references. Buckle up, fellow developers, as we embark on this functional journey!

#Lists: The Backbone of Collections

![Lists](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wdyboyhyfppomnc6j91g.png)
In this snippet, we create a list of fruits and use a lambda expression to iterate through them. The forEach method elegantly replaces traditional loops.


#Lambdas: Concise and Expressive

Lambdas are anonymous functions that allow us to treat code as data. They simplify our code by reducing boilerplate. Consider the following example:

![Lambdas](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9l9ea05y1ouzcaj5ephx.png)

Here, we use a lambda to filter even numbers from a list. The concise syntax makes our intent clear: “Give me the even numbers!”


#Method References: A Shortcut to Functionality

Method references allow us to refer to methods without invoking them. They’re especially handy when working with functional interfaces. Let’s see an example:

![Method references](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m9en9d8vf25uaryr7bxo.png)

In this snippet, we sort a list of names using the `compareToIgnoreCase` method. The `String::compareToIgnoreCase` syntax is a method reference, making our code cleaner and more readable.


#Conclusion

Functional programming in Java opens up exciting possibilities. Lists, lambdas, and method references empower us to write expressive, concise, and elegant code. As you explore functional constructs, remember that they’re not just buzzwords—they’re tools that can transform your Java development experience.

So go forth, embrace functional programming, and let your code dance to the rhythm of lambdas and method references!

Remember, functional programming isn’t just about syntax; it’s a mindset. Happy coding! 🚀🔥
Weekly Updates - Apr 5 2024
Tags: community, couchbase, database
Published: 2024-04-05 19:30:06

Hi Everyone!
I hope you had a great week! 

It is time for our weekly updates!

- 📖  **New Blog - Improved Debuggability for SQL++ User-Defined Functions** Couchbase 7.6 introduces improvements that allow for more debuggability and visibility into UDF execution. [You can read the full blog post here >>](https://www.couchbase.com/blog/improved-debuggability-for-sql-user-defined-functions/)
&nbsp;

 
- 🛬 **If you're headed to Google Next in Las Vegas next week - come say Hi!** We will have a booth at the Google Next '24 event in Las Vegas, come say Hi! [Learn more and register here >>](https://www.couchbase.com/events/google-next-24/)
 &nbsp;


- 📝 **Virtual Event - NoSQL Made Easy with JetBrains and VSCode Plugins!** Learn how the Couchbase Plugin for JetBrains and VSCode can make your life easier and your database work more enjoyable. [Learn more and rsvp here >>](https://www.couchbase.com/blog/vector-search-at-the-edge-with-couchbase-mobile/)
&nbsp;

 
- 🎙️ **New Podcast Episode** Couchbase's Mark Gamble joins "The Generative AI Meetup Podcast" for a conversation around Generative AI and the significance of Couchbase's move into on-device vector storage. [Have a listen here >>](https://podcast.genaimeetup.com/e/couchbase-interview-on-device-vector-store-a-new-era-for-edge-computing/?blaid=5878898)
&nbsp;

 
- 🏗️ **How are you using Couchbase?** We want to see your projects! Come join our Community Discord and show us what you are working on. [You can join the Discord here >>](https://discord.gg/QzTeeWXS)
&nbsp;

 
- 😎 If you are observing the eclipse this coming week - don't forget to wear special eclipse glasses! Protect your eyes 👀
&nbsp;

 

Have a great weekend everyone!
Show Feed to ChatCraft users
Tags: opensource, ai, feed, cloudflarechallenge
Published: 2024-04-05 19:28:52


After [Generating a Custom RSS Feed with Cloudflare Workers](https://dev.to/wanggithub0/generating-a-custom-rss-feed-with-cloudflare-workers-a-step-by-step-guide-2m34), I introduced a new feature that allows users to share content effortlessly this week. This addition comes in two distinct implementations: a share feed button on the header and within the shareModal. Let's delve into these updates and discuss a crucial piece of advice from our collaborator regarding URL manipulation.

**Share Feed Button on the Header**
The first update I did is the integration of a share feed button prominently placed on the header of our website. This button is designed to be intuitive, ensuring that users can easily share the feed with just a click. The implementation was thoughtfully considered to enhance visibility and accessibility, encouraging more users to engage with and disseminate our content.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l7n9dsvf73htszilj7gr.png)



**ShareModal Integration**
The second place where I've added the share feed functionality is within our shareModal. This modal pops up when a user opts to share content, providing them with various options to disseminate the feed across different platforms. The integration within the shareModal is aimed at offering users a seamless sharing experience, directly from the interface where they're most engaged.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wbtj9p93801o2yesy62b.png)



**A Note on URL Manipulation**
During the development of these features, an important piece of advice came from my professor @humphd. The concern was raised regarding the manipulation of URLs as strings, specifically in the context of extracting the base URL using `const baseUrl = url.split("/api/")[0];`. This approach, while functional, can lead to potential issues and is not considered best practice.

The Recommended Approach
@humphd suggests utilizing the new URL() constructor for handling URLs. This method allows for a more robust and error-proof way of parsing and constructing URLs. By using new URL(), developers can easily access different parts of the URL, such as the pathname, and manipulate them safely. This approach not only enhances code reliability but also aligns with modern JavaScript best practices.

**Conclusion**
The integration of share feed functionality marks a significant step forward in our platform's evolution. I'm excited to see how these changes will positively impact our community and look forward to further innovations that enhance user engagement on our platform.
Getting error when starting Rancher Desktop on Mac.
Tags: devops, docker, opensource, howto
Published: 2024-04-05 19:22:53


Rancher Desktop is an open-source application that provides container management and Kubernetes on your local computers.

In case you’re trying to start Rancher Desktop on Mac with M1/M2/M3 processor you may face the following error:

```
'/bin/sh',
 '-c',
 'rm -f /usr/local/share/ca-certificates/rd-*.crt'
 ],
 stdout: '',
 stderr: '',
 code: 255,
 [Symbol(child-process.command)]: '/Applications/Rancher Desktop.app/Contents/Resources/resources/darwin/lima/bin/limactl.ventura shell - workdir=. 0 sudo /bin/sh -c rm -f /usr/local/share/ca-certificates/rd-*.crt'
}
```

The root cause:

M1/M2/M3 chips are incompatible with the version of QEMU included in Rancher Desktop; need to use VZ emulation

The solution:

You can do the cleanup with a factory reset and use VZ emulation:

```
/Applications/Rancher\ Desktop.app/Contents/Resources/resources/darwin/bin/rdctl factory-reset
/Applications/Rancher\ Desktop.app/Contents/Resources/resources/darwin/bin/rdctl start - experimental.virtual-machine.type vz
```
How to find the number of SELECTs, INSERTs, DELETEs, and UPDATEs on a specific table in PostgreSQL?
Tags: database, tutorial, devops, postgressql
Published: 2024-04-05 19:21:30

Knowing the ratio of SELECT, INSERT, DELETE, and UPDATE operations in PostgreSQL databases (or any other database management system) is crucial for several reasons, reflecting performance, optimization, and architectural planning.

To find the number of SELECTs, INSERTs, DELETEs, and UPDATEs on a specific table in PostgreSQL, you can utilize the pg_stat_all_tables view for basic DML statistics (INSERT, UPDATE, DELETE) but unfortunately, this view does not track SELECT operations directly.

For DML operations, you can query the pg_stat_all_tables view. This view provides counts for INSERTs, UPDATEs, and DELETEs, but not for SELECTs.

Here’s how you can get those counts for a specific table in a specific schema:

```
SELECT relname AS table_name,
schemaname AS schema_name,
coalesce(seq_scan, 0) + coalesce(idx_scan, 0) AS total_selects, 
n_tup_ins AS inserts,
n_tup_upd AS updates,
n_tup_del AS deletes
FROM pg_stat_all_tables
WHERE relname = 'your_table_name'
AND schemaname = 'public'
ORDER by (coalesce(seq_scan, 0) + coalesce(idx_scan, 0) + n_tup_ins + n_tup_upd + n_tup_del) DESC;
```

Here’s how you can get those counts for all the tables in a specific schema:

```
SELECT relname AS table_name,
schemaname AS schema_name,
coalesce(seq_scan, 0) + coalesce(idx_scan, 0) AS total_selects, 
n_tup_ins AS inserts,
n_tup_upd AS updates,
n_tup_del AS deletes
FROM pg_stat_all_tables
WHERE schemaname = 'public'
ORDER by (coalesce(seq_scan,0) + coalesce(idx_scan,0) + n_tup_ins + n_tup_upd + n_tup_del) DESC;
```

In these queries, seq_scan + idx_scan gives us an approximation of SELECT operations: it counts the number of sequential and index scans, which is not a direct measure of SELECT statements but can give you an idea of the reading activity on the table.
How do you check the top IOPs intensive queries in PostgreSQL DB?
Tags: database, devops, sql, performance
Published: 2024-04-05 19:20:03

IOPS stands for Input/Output Operations Per Second. It is a performance measurement used to benchmark computer storage devices like hard disk drives (HDDs), solid-state drives (SSDs), and storage area networks (SANs).

IOPS measures how many read or write operations a device can perform in a second. This metric is crucial for understanding the performance characteristics of storage systems, especially in environments where data must be accessed quickly and efficiently, such as in database servers, high-transactional systems, or any application that requires high-speed data access.

Checking IOPS for a PostgreSQL database instance is important for several reasons, as it directly impacts the performance, scalability, and overall efficiency of database operations. Like any database system, PostgreSQL relies heavily on disk I/O operations for reading from and writing to the database.

In this post, I’d like to demonstrate how to check the top IOPs intensive queries in the PostgreSQL DB Server.

Set PostgreSQL configuration parameter

```
track_io_timing = 1;
```

Query #1:

```
SELECT 
 (select datname from pg_database where oid=dbid) datname,
 query,
 blk_read_time + blk_write_time AS io_time
FROM pg_stat_statements
ORDER BY blk_read_time + blk_write_time DESC
LIMIT 20;
```

Query #2:

```
with
a as (select dbid, queryid, query, blk_read_time r, blk_write_time w from pg_stat_statements),
b as (select dbid, queryid, query, blk_read_time r, blk_write_time w from pg_stat_statements, pg_sleep(1))
select
 pd.datname as db_name, 
 substr(a.query, 1, 2000) as the_query, 
 round(sum(b.r-a.r)) as blk_reads_per_sec,
 round(sum(b.w-a.w)) as blk_writes_per_sec,
 round(sum(b.r-a.r) + sum(b.w-a.w)) as iops
from a, b, pg_database pd
where 
 a.dbid= b.dbid 
and 
 a.queryid = b.queryid 
and 
 pd.oid=a.dbid
group by 1, 2
having sum(b.r-a.r) + sum(b.w-a.w) > 0
order by 5 desc
limit 20;
```
PostgreSQL. How do you find potentially ineffective indexes?
Tags: database, postgres, sql, devops
Published: 2024-04-05 19:18:50

While indexes in PostgreSQL can significantly improve query performance, especially for read-heavy operations, they are not universally beneficial in every situation.

Having too many indexes on a PostgreSQL table can have several negative impacts on database performance and resource consumption.

The following query helps you find potentially ineffective indexes.

```
SELECT
 relid::regclass AS table,
 indexrelid::regclass AS index,
 idx_scan,
 idx_tup_read,
 idx_tup_fetch,
 pg_size_pretty(pg_relation_size(indexrelid::regclass)) AS index_size
FROM
 pg_stat_user_indexes
JOIN
 pg_index USING (indexrelid)
WHERE
 idx_scan < 50 AND idx_tup_read > 1000
ORDER BY
 pg_relation_size(indexrelid::regclass) DESC;
```

Low idx_scan combined with high idx_tup_read and significant index_size might indicate an index that’s not very useful.

Also, a significant gap between idx_tup_read and idx_tup_fetch can indicate inefficiencies too. It suggests that the index is being scanned, but many of the scanned entries don’t lead to relevant rows.

The idx_tup_read counter measures the number of index entries retrieved by index scans. This metric counts every entry retrieved as a result of an index scan, which includes both entries that eventually lead to fetching a table row (a successful match) and entries that don’t meet the query’s criteria upon further inspection.

For example, consider an index scan that looks for rows where the value is greater than 10. idx_tup_read will count all the index entries scanned during this operation, not just the entries that point to rows satisfying the condition.

The idx_tup_fetch counter, on the other hand, measures the number of live table rows fetched after scanning the index. This count reflects the number of times an index entry led to successfully fetching a row from the table that also met any additional filtering criteria. In other words, it’s a measure of how many of the index entries read (idx_tup_read) were used to fetch rows that are relevant to the query.

Using the same example as above, if an index scan examines 100 entries (idx_tup_read) but only 60 of those entries lead to rows that meet the query’s condition (>10), then idx_tup_fetch would be 60.

This situation can happen with non-selective indexes, where the indexed column(s) have a lot of duplicate values or the query’s criteria are not highly selective.

`ask_dima@yahoo.com`
Introducing the New GitHub Action for using Kit CLI on MLOps pipelines
Tags: devops, ai, github, tooling
Published: 2024-04-05 19:15:59

One of the goals of KitOps is streamlining AI integration with your existing DevOps practices. Our latest contribution on this evolving landscape is a GitHub Action that simplifies integrating Kit CLI into your existing CI/CD toolset. This development is particularly exciting for those looking to leverage ModelKits, our OCI-compliant AI project packaging, directly within their CI/CD pipelines.

With the [Setup Kit CLI](https://github.com/marketplace/actions/setup-kit-cli) action. Using Kit as part of your Github workflows is effortless. You can setup the latest version of the CLI to your workflow simply by adding the following to your workflow. 

```
steps:
  - uses: jozu-ai/gh-kit-setup@v1.0.0
    id: install_kit
```

[KitOps](https://kitops.ml) uniquely addresses a critical challenge in AI/ML development: the versioning and management of all project artifacts—including code, models, and data—under a unified framework. This integrated approach ensures that each component of an AI project is tracked and managed with precision, eliminating the common pitfalls associated with fragmented artifact management.

ModelKits, being OCI compliant, provide a standardized way to package AI projects, ensuring compatibility across your existing infrastructure. This standardization is vital for teams looking to deploy AI solutions in diverse operational landscapes without getting bogged down by compatibility issues.

To begin taking advantage of the streamlined AI project management KitOps offers, simply incorporate the Setup Kit CLI action into your GitHub workflows. For an in-depth understanding of all the features this action provides, visit the detailed documentation linked above.

As we continue to innovate and improve KitOps, your feedback is invaluable to us. Whether you're encountering challenges, have suggestions for new features, or simply want to share your success stories, we're all ears. You can provide feedback on our [GitHub repo](https://github.com/jozu-ai/kitops) or our [Discord channel](https://discord.gg/Tapeh8agYy).
10 steps to build a multi tenant webapp on AWS
Tags: developer, devrel, community, aws
Published: 2024-04-05 19:13:39

Here are 10 steps to build your next multi-tenant webapp on AWS:--

1. Define the requirements of your multi-tenant web app, including the features, functionality, and user roles.

2. Design the architecture of your multi-tenant web app, considering how to handle tenant isolation, authentication, authorization, and scalability using AWS Lambda.

3. Set up an AWS account and create an AWS Lambda function using the AWS Management Console or AWS CLI.

4. Develop the backend logic of your multi-tenant web app using AWS Lambda functions, using languages such as Node.js, Python, or Java.

5. Implement the necessary APIs and endpoints for your multi-tenant web app, considering how each tenant will interact with the application.

6. Configure your AWS Lambda functions to connect to other AWS services such as Amazon API Gateway, Amazon DynamoDB, Amazon S3, and Amazon RDS for data storage, processing, and management.

7. Test your multi-tenant web app thoroughly to ensure that it works as expected and meets the requirements of each tenant.

8. Secure your multi-tenant web app by implementing appropriate security measures, such as encryption, access controls, and monitoring.

9. Monitor and optimize the performance of your multi-tenant web app using AWS CloudWatch and other monitoring tools.

10. Consider implementing automated deployment and CI/CD pipelines to streamline the development and deployment process of your multi-tenant web app using AWS Lambda.

-Deepak(from www.Doc-E.ai)
PS: I don't work for Amazon
RAG Step-by-Step: Open Source Edition
Published: 2024-04-05 19:05:16

In a previous [post](https://dev.to/spara_50/rag-step-by-step-3fof), I demonstrated how to implement RAG using the [Load-Transform-Embed-Store workflow](https://www.linkedin.com/pulse/rag-architecture-deep-dive-frank-denneman-4lple/). I've updated the [RAG Step-by-Step repository](https://github.com/spara/RAG_step-by-step/) with an open-source example.

## Why open source?

The most common reason for using open source versus a service is cost. This is especially true with generative AI. Services often require a credit card to access their API, and every request costs. Charges are typically small and fractional but add up when writing and debugging code. Another reason is keeping your data private. For example, you may be working with data restricted to a particular [country](https://en.wikipedia.org/wiki/Personal_Information_Protection_and_Electronic_Documents_Act). Open source is one way to meet legal requirements. Finally, open source requires hands-on work, so you get a much deeper understanding of what the software is doing than when your code calls an API.

## What's the difference?

Building an open-source version of RAG Step-by-Step wasn't too different from building the SaSS version. Here's a list of changes.

- Instead of using OpenAI GPT3.5 and Pincone, I used the [localstack_ai](https://github.com/spara/localstack_ai) which is a containerized environment with Ollama, llama2, and PostgreSQL with pgvector.
- To create embeddings, [sentence-transformers](https://pypi.org/project/sentence-transformers/) was used instead of OpenAI's `text-embedding-3-small` model.
- PostgreSQL requires instantiating a database, adding the pgvector extension, and creating the table to hold the data and embeddings.
- The Streamlit app defines several SQL queries with different [simiarity metrics](https://www.imaurer.com/which-vector-similarity-metric-should-i-use/) supported by pgvector.
- The prompt uses the llama2 prompt instead of the OpenAI Chat prompt format.

## What's stopping you?

Open-source foundation models are released literally every week. The barriers to running a model have decreased significantly, allowing you to play and learn about generative AI quickly and with minimal cost and effort. SaSS or open source, give [RAG Step-by-Step](https://github.com/spara/RAG_step-by-step/) a spin.
Emerging trends in the Headless CMS market 📈
Tags: headlesscms, nuxt, nuxtstudio, webdev
Published: 2024-04-05 18:50:54

The world of development is buzzing about headless CMS, but how can you get the most out of it? 🤔

On the latest episode of **[The Session](https://youtube.com/playlist?list=PLZM252hbjzHEUwCZxb4sDu2L9lEP6aI7-&si=wwnSxzxxFryR-uSq)**, Garchi CMS Co-founder [Aditya Kadam](https://www.linkedin.com/in/adityakadam2194/) dives into headless CMS with [Ferdinand Coumau](https://www.linkedin.com/in/ferdinand-coumau-nuxt/), Head of Sales & Customer Success at [NuxtLabs](https://nuxtlabs.com/). 

**This episode is your one-stop shop for all things Headless CMS!** 🚀

- Learn about the biggest benefits companies are seeing with headless CMS.

- Discover how Garchi CMS bridges the gap between developers and marketers.

- Stay ahead of the curve with emerging trends in the headless CMS market.

- Get excited about upcoming features in Nuxt Studio that will make headless CMS even better.

- See how AI can supercharge your headless CMS implementation for ultimate efficiency.

**No matter your experience level**, this episode is packed with valuable insights.  Whether you're a seasoned developer or just starting with headless CMS, you won't want to miss it! 

**Watch now and discover the future of content management! Welcome to The Session!**

{% embed https://www.youtube.com/watch?v=tKivCA7e418&list=PLZM252hbjzHEUwCZxb4sDu2L9lEP6aI7- %}


**The episode also covers:**

- How to implement headless CMS in your existing system.

- How AI can take your headless CMS implementation to the next level.


**Want to learn more?**

- 
**Garchi CMS:** Built with developers in mind, but loved by marketers too. Garchi lets you build custom web experiences, manage content globally, and future-proof your projects.  Learn more about getting started with Garchi CMS here: [https://garchi.co.uk/documentation/1.0/headlessweb/getting-started](https://garchi.co.uk/documentation/1.0/headlessweb/getting-started)


- 
**Nuxt Studio:** The Git-based CMS for Nuxt. Edit content with a live preview and unlock collaboration between developers and copywriters. Nuxt Studio has a big release coming in April with exciting new features!  Visit the Nuxt Studio website here: [https://nuxt.studio/](https://nuxt.studio/)
Face Recognition Android SDK
Tags: android
Published: 2024-04-05 18:18:01

I have tested many face recognition android app, but this app is working perfectly, in addtion, they are providing face anti-spoof function which can prevent photo, video, and 3D silicon mask attacks, I am following their github repositories they are doing good work.
Please check below github link, and if you are satisfied with that, please give star!!

https://github.com/MiniAiLive/MiniAI-Face-Recognition-AndroidSDK