teleren/devto huggingface dataset:
Supermemory - ChatGPT for your bookmarks
Tags: cloudflarechallenge, devchallenge, ai
Published: 2024-04-15 01:04:16

*This is a submission for the [Cloudflare AI Challenge](https://dev.to/devteam/join-us-for-the-cloudflare-ai-challenge-3000-in-prizes-5f99).*

## What I Built

<!-- Tell us what your app does! -->
I built a way to build your own second brain, using Cloudflare Vectorize and Workers AI. 

Here's the idea
Build your own second brain with supermemory. It's a ChatGPT for your bookmarks. Import tweets or save websites and content using the chrome extension (the extension on webstore is not updated, please use the one in the repo)

Well, here's the thing - me and @yxshv save a lot of content on the internet.

Twitter bookmarks, websites, snippets, etc.

But we never look back to it - to us, it's like throwing information in the void.

Supermemory fixes this.

## Demo

<!-- Share a link to your deployed solution on Workers or Pages, and add a screenshot or video embed of your app here. -->
Here's the deployed demo - https://supermemory.dhr.wtf 

And here's the demo video https://www.loom.com/share/23b56648da3d4d8080b542a60cb9c8b6

## My Code

<!-- Show us the code! Share a public link to your repo and be sure to include a README file with installation instructions. We also encourage you to add a license for your code.  --> 
{% embed https://github.com/Dhravya/supermemory %}

## Journey

It all started when I saw this company in YC batch 2024 (https://zenfetch.com) - I was determined that I can make something like that, even better, and open source it. 

So, over the weekend, I built the version 0 of supermemory (and i called it anycontext) - it wasn't great. Very buggy and far from useful. But the bottom line was - I built a competitor to zenfetch in just a weekend.

Then, one day, I opened dev.to and found out about the cloudflare dev challenge! Hell yes! I've been a big fan of cloudflare and winning this would be amazing. So, I reached out to @yxsh for his help. Yash is an amazing design engineer and was able to completely redesign and revamp the user interface in just about 15 days, even though he's fully busy with classes and studies!!!

We also revamped the entire database, vector store, and even the AI generation to make it as good as possible. Added support for notes and spaces. Added import twitter bookmarks option.

As we did, the architecture became more and more complex, and seeing everything work so perfectly was just such an amazing feeling.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6z5r14cyhtwbb2j9hjuq.png)



Now, Supermemory is the true second brain for both of us. Saving and forgetting content is a thing of the past.

So, are you ready to supercharge your memory? Go to https://supermemory.dhr.wtf and try it out for yourself!

Teammates:
@dhravya, @yxsh
New Job? Here's Your First 3-Week Action Plan
Tags: careeradvice, newjob
Published: 2024-04-15 00:13:10

## The First Three Weeks:  Make Your Mark or Move On

One of the toughest lessons I've learned recently? Don't waste time settling in at a new company.  The first three weeks are absolutely **critical**.  Here's why:

During this initial period, you have the opportunity to establish yourself as a **superhero**, an **average contributor**, or someone who might not be the **right fit** for the role. 

**The reality? If you can't land in the first two categories within those three weeks, it might be an uphill battle forever.**

**Here's the honest recommendation:** Don't waste those precious first weeks! Be **proactive** and make yourself as **visible** as possible. 

Here are some ways to do that:

* **Jump right in:** Ask questions, volunteer for projects, and show your eagerness to learn.
* **Network internally:** Meet your colleagues, understand their roles.
* **Don't try to impress:** Don't show you are trying to impress, there is a difference between self promoting and self branding.
* **Deliver early wins:** Look for opportunities to add immediate value, even if they seem small.
* **Communicate effectively:** Keep your manager and team updated on your progress and ask for feedback. 

**But what if you put in the hard work and still feel invisible?** 

That's a sign you might need to consider if this is the right environment for you. Don't be afraid to have an honest conversation with your manager about your concerns. 

**Remember, your career path is yours to define. Don't be afraid to make the call that's best for you!**

**#careeradvice #newjob #firstimpressions**
Contextual Conversation Worker
Tags: cloudflarechallenge, devchallenge, ai
Published: 2024-04-14 23:28:58

*This is a submission for the [Cloudflare AI Challenge](https://dev.to/devteam/join-us-for-the-cloudflare-ai-challenge-3000-in-prizes-5f99).*

## What I Built

I created a conversational AI chatbot that uses Cloudflare Workers and KV storage to provide users with a persistent, intelligent conversational experience. By leveraging the power of Cloudflare's distributed network and serverless execution environment, the chatbot is highly available and responsive, ensuring a seamless interaction for users.


## Demo
Experience the AI chatbot in action here: [Deployed Chatbot](https://contextual-conversation-worker.pages.dev/)
![Chatbot image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o9t4rhth97aze57omnna.png)


## My Code
Explore the code repository here:
https://github.com/tom-log/contextual-conversation-worker

## Journey

During the development process, I delved into the capabilities of Cloudflare Workers and AI models. I decided to focus on creating a chatbot that could store the context of a conversation, which introduced me to the use of Cloudflare KV storage system.

The documentation provided by Cloudflare was instrumental in helping me understand how to integrate AI models with serverless functions. Throughout this project, I improved my understanding of asynchronous JavaScript and how to interact with external APIs in a serverless environment.

What I'm particularly proud of is the chatbot's ability to maintain a conversation thread, which makes the interaction feel more natural and engaging.

**Multiple Models and/or Triple Task Types**

For this project, I focused on a single task type, which is conversational AI. The model used was `@cf/meta/llama-2-7b-chat-int8` for generating chatbot responses based on the conversation context stored in **Cloudflare KV**.

**If you'd like to share insights or pose any queries, the comments section awaits your valued input!**
How to add two numbers in JavaScript without using the "+" operator?
Tags: webdev, javascript, programming, productivity
Published: 2024-04-14 23:24:03

We can add two numbers in Javascript without using the **+** operator. Let me show you how to do this computation using JS functions.

Let's start by declaring a function name **add** and pass in **2 parameters (a,b)** to the function

```
const add = (a,b)=>{

}
```
After declaring the function, let's now add the logic in the function block that will do the computation.

```
const add = (a,b)=>{
for(i = 1; i <= b; i++ ){
a++
}
return a
}
```

We initiates a for loop. The loop starts with i equal to 1 and continues as long as i is less than or equal to b. i is incremented by 1 in each iteration.

```
a++
```
Inside the loop, **a** is being incremented by 1 in each iteration. This effectively adds 1 to a, b times.

```
return a;

```
After the loop finishes, the value of a is returned. This will be the original value of a plus b.

```
console.log(add(3, 5)); //output: 8

```

[Click here to watch the video on Youtube](How to add two numbers in JavaScript without using the "+" operator?)
Literally read YouTube videos
Tags: cloudflarechallenge, devchallenge, ai
Published: 2024-04-14 23:23:17

*This is a submission for the [Cloudflare AI Challenge](https://dev.to/devteam/join-us-for-the-cloudflare-ai-challenge-3000-in-prizes-5f99).*

## What I Built

<!-- Tell us what your app does! -->
I built a simple app that can help you consume your favorite YouTube videos even faster, by reading them or even summary about them! It's better to be something that fulfills you with [knowledge](https://www.youtube.com/watch?v=bDeHFYBOhUo) or motivation and a direct list of actions to improve you and your coding journey like [this](https://www.youtube.com/watch?v=cuuXvVfORfk&list=WL&index=3) 
But who am I to judge, I also like to procrastinate and watch some [cats](https://www.youtube.com/watch?v=W86cTIoMv2U)
## Demo


<!-- Share a link to your deployed solution on Workers or Pages, and add a screenshot or video embed of your app here. -->

![Demo of interaction with site](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bhniz9a18j155wwjviwz.gif)

[Demo on Cloudflare Pages](https://baed95e9.cloudflare-ai-challenge-front-end.pages.dev/)

## My Code

<!-- Show us the code! Share a public link to your repo and be sure to include a README file with installation instructions. We also encourage you to add a license for your code.  --> 
Backend: https://github.com/serafimsanvol/summarizer
Frontend: https://github.com/serafimsanvol/cloudflare-ai-challenge-front-end

## Journey

I wanted to participate in the "dev challenge" for already a long time but never wasn't able to plan my schedule properly and just dare to try. I'm still struggling with schedules (I'm writing this a few hours before the deadline). When I read about workers and what they can do I got the immediate idea to create an app for transcribing YouTube videos, summarizing them, and creating comics so it can be even easier to memorize important topics. I used "whisper" for audio transcribing and "bart-large-cnn" for summarizing. As you can notice I didn't add the comics generation part, but it can be the next version if I get feedback from users that it's quite a necessary feature. 
<!-- Tell us about your process, the task types and models you used, what you learned, anything you are particularly proud of, what you hope to do next, etc. -->

**Multiple Models and/or Triple Task Types**

This project utilizes multiple models for creating text summaries about videos

<!-- Let us know if your project utilized multiple models per task and/or if your project used three or more task types. If so, you may qualify for our additional prize categories! If not, please remove this section. -->

<!-- Don't forget to add a cover image or an additional tag to this post (if you want). -->

<!-- Thanks for participating! -->
Exploring Zod and the Benefits of Schema-Based Validation in TypeScript Projects
Tags: webdev, beginners, tutorial, fullstack
Published: 2024-04-14 22:49:40

## Introduction

This post explores Zod, a library that provides "TypeScript-first schema validation with static type inference". We'll explore how it works and why it's so useful.

## Manual Validation

If you've found yourself manually writing validation checks it can get tedious pretty quickly. For example, you might need to write checks to make sure that required fields are provided and data is in the correct format and/or fits certain parameters like a number being within a certain range.

```TypeScript
if (name === '') {
  errors.push('Name is required')
}

if (name.length < 3) {
  errors.push('Name must be at least 3 characters')
}

if (name.length > 30) {
  errors.push('Name must be 30 or fewer characters long')
}
```

## Schema Validation

This is where Zod comes in really handy. Here's an example of how we can define a `userSchema` where name, age, email are all required with their expected types and a min/max length for the name. To make it optional you will need to add `.optional()`.

```TypeScript
import { z } from 'zod';

// Define the schema with validation rules
const userSchema = z.object({
  name: z.string().min(3).max(30),
  age: z.number(),
  email: z.string().email()
});

// Infer TypeScript type from the schema
type User = z.infer<typeof userSchema>;

// Parse data using the schema and handle the result
const result = userSchema.safeParse({ name, age, email })

if (result.success) {
  // Everything looks good and valid
} else {
  // Invalid... handle using result.error
}
```

Using `z.infer` you can infer the TypeScript type from the Zod schema which is also really handy to avoid duplication and have it automatically update when the userSchema is updated.

Zod provides detailed validation messages which can also be customised like so:

```TypeScript
const name = z.string({
  required_error: "Name is required",
  invalid_type_error: "Name must be a string",
});
```

## Conclusion

Zod is a great tool to write cleaner and simpler code for validation. Share your experiences with these tools in the comments.
How I implemented Cloudflare Workers in my app
Tags: cloudflarechallenge, devchallenge, ai, nuxt
Published: 2024-04-14 22:47:06

*This is a submission for the [Cloudflare AI Challenge](https://dev.to/devteam/join-us-for-the-cloudflare-ai-challenge-3000-in-prizes-5f99).*

## What I Built

Nottia is a Nuxt 3 simple app that you can generate notes, dont forget your ideas, just create a note! xD

In this app you also have the option to generate notes by sending prompts to an AI and receiving a response based on that prompt.

**Generating a note based on user prompt:**
![Note generation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/494s8ppfpcaq8gtcy64c.gif)

**Generating a image based on user prompt:**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ithtq45kp8tm5ajdbblp.gif)

## Demo

See the demo right here: 

On Cloudflare Pages:
https://nottia.pages.dev/

On Vercel:
https://nottia.vercel.app/

## My Code

The source code of the app was split in two repositories: one for the front-end and another for the Cloudflare Worker.

**Nottia:**
{% embed https://github.com/cn-2k/nottia %}

**Nottia Worker:**
{% embed https://github.com/cn-2k/nottia-worker %}

## Journey

Initially this app was focused on register notes manually, with this challenge I saw the oportunitty for delve deeper into AI, Serverless Workers, and the entire Cloudflare platform. Integrating these models was a significant challenge for me, but in the end, they performed as expected.

Now I see space for integrate AI on any app, Cloudflare is amazing!

**Multiple Models and/or Triple Task Types**

The app use two AI Workers models from Cloudflare to generate text (@cf/meta/llama-2-7b-chat-fp16) and generate images (@cf/stabilityai/stable-diffusion-xl-base-1.0).
Open source CRM
Tags: opensource, crm, automation
Published: 2024-04-14 22:43:04

Hey Devs! At [JetSoftPro, a software development service](https://jetsoftpro.com/), we have been working with open-source CRM systems for a long time and 
explored a common challenge and its solutions. Are you agree, aren't you?

The Challenge: Customization vs. Maintenance
One of the key benefits of open-source CRM systems is their flexibility for customization. However, with great flexibility comes the challenge of maintaining a balance between customization and long-term maintenance.

🛠️ Customization:
Open-source CRM systems offer extensive customization options through plugins, extensions, and custom code.
Developers can tailor the CRM to meet specific business requirements, from UI tweaks to complex workflow automation.

💻 Maintenance:
Every customization introduces complexity and potential maintenance overhead.
Upgrades to the core CRM or dependencies may conflict with customizations, leading to compatibility issues.
Ensuring long-term stability and security requires proactive maintenance and periodic code reviews.
The Solution: Modular Architecture and Version Control
To tackle the customization-maintenance dilemma, adopt a modular architecture and robust version control practices:

🔧 Modular Architecture:
Design the CRM system with a modular architecture, separating core functionality from customizations.
Implement customizations as modules or plugins that can be easily added, removed, or updated without affecting the core system.

📝 Version Control:
Utilize version control systems like Git to track changes to the CRM codebase and customizations.
Maintain separate branches for core CRM updates and customizations to facilitate easier merging and conflict resolution.

🔄 Continuous Integration/Continuous Deployment (CI/CD):
Implement CI/CD pipelines to automate testing, integration, and deployment processes.
Ensure that customizations undergo thorough testing before deployment to production environments to prevent regressions.
WSL Error: no space left on device
Tags: webdev, wsl, vscode, debug
Published: 2024-04-14 22:20:40

Are you running Ubuntu or some kind of Linux distribution inside of Windows Operating System, and all of a sudden you're getting the error while you are on your code editor
```bash
nospc ENOSPC: no space left on device
```

Your code editor, let's say VS Code server, won't connect to WSL anymore and you're stuck with local changes you haven't yet commit to Github.

Run `wsl df -h /` in your Powershell and you shall see that the assigned virtual hard disk for your Linux distribution has reached 100% - it is time to expand the allowed space for file storage within the Linux environment. Learn to manage WSL disk space and resize virtual hard disk [here](https://learn.microsoft.com/en-us/windows/wsl/disk-space).

After you have expanded the virtual disk for the Linux distribution following the link above, when you are attempting to spawn VS Code from WSL using `code .`, you could encounter a module not found error if your VS Code closed unexpectedly as a downstream consequence of the no space left inside your WSL instance, an example of such error is
```bash
Loading "minimist" failed
Error: Cannot find module 'minimist'
```

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

The reason for this error could be that the remote WSL connection was closed off and killed the VS Code server on WSL, and then the module is removed/corrupted on the remote host.

You should first try to reboot and shutdown all wsl instances using `wsl --shutdown`. If none of that worked, you can delete the `.vscode-server` folder entirely in your WSL home directory, and then spawn VS Code from a WSL prompt as usual using `code .` to initiate a reinstallation of the VS Code remote.

Be aware that the deletion of `.vscode-server` folder **will remove all your extensions** as well, so it's better to keep a backup of the extensions before you remove the `.vscode-server` folder
```bash
mv ~/.vscode-server/extensions ~/.vscode-server-backup/extensions
```
```bash
rm -rf ~/.vscode-server
```


VS Code should now open up successfully from WSL, close it off so we can recover the extensions with the following commands.


Remove the new automatically created extensions folder:
```bash
rm -rf ~/.vscode-server/extensions
```
and copy over the backed up extensions:
```bash
mv ~/.vscode-server-backup/extensions ~/.vscode-server/extensions
```

Now if you start up VS Code again, it should connect and work as well as before.
Database Pool Management with Sidekiq and load_async
Tags: rails, backenddevelopment, sidekiq, db
Published: 2024-04-14 22:04:57

Recently I came across a very common issue after integrating a few Sidekiq jobs to a project. 

During this activity, I set the `pool` size in `database.yml` of the worker process equal to the concurrency I set for Sidekiq. Its recommended to have `pool` size equal to or greater than the concurrency setting otherwise, you can run into issues or even if there are no apparent errors, this will likely cause additional latency in the queues.

But strangely, I still ran into this error:

```
ActiveRecord::ConnectionTimeoutError <background job name>

could not obtain a connection from the pool within 5.000 seconds (waited 5.062 seconds); all pooled connections were in use
```

As the error suggests, the worker thread executing the job attempted to obtain a database connection but was not able to and after waiting for 5 seconds raised this exception. 

## Possible Reason??

In my case, the issue was not as straight forward as the `pool` size being less than the total concurrency set for Sidekiq.
 

### load_async

I searched for the codebase for `Thread.new` initially to see if there are any queries being executed in separate threads in any of the jobs, but the only occurrences I came across were not relevant.
Secondly I looked for `load_async` (which basically queries database asynchronously [details](https://www.rubydoc.info/github/rails/rails/ActiveRecord%2FRelation:load_async)) and actually found it being used by one of the classes that was being instantiated and used in one of the background jobs. 

And that was it, despite having a `pool` value equal to the concurrency that I have set in Sidekiq, having `load_async` in one of the jobs meant, this was an additional (unaccounted) thread that can consume a connection from the `pool` causing another thread to wait.

With the root cause of the issue established, I adjusted my `pool` size for the worker process (in `database.yml`) as recommended [here](https://edgeguides.rubyonrails.org/configuring.html#config-active-record-global-executor-concurrency)

```
pool = total_concurrency + global_executor_concurrency + 1
```
Where `global_executor_concurrency` refers to the number of asynchronous queries that can be executed concurrently and its default value is 4.

Which meant for me, the eventual value of the `pool` size I set was

```
pool = total_concurrency + 4 + 1
```

For me this was an interesting finding and hope it helps and save some time for you if you come across similar scenario.

Happy Coding!