teleren/devto huggingface dataset:
Setting Up Your Database (Next.js)
Tags: webdev, nextjs, database
Published: 2024-04-04 19:07:48

Here, I am setting up a PostgreSQL database using `@vercel/postgres`.

## Vercel

In Vercel, select and import a GitHub repository. Name your project and click Deploy. Connecting your GitHub repository will automatically redeploy your application, whenever you push changes to your main branch.

## Create a Postgres database

Click Continue to Dashboard and select the Storage tab from your project dashboard. Select `Connect → Store → Create New → Postgres → Continue`.

Assign a name to your database and set the region. Place your database in a nearby region to reduce latency for data requests. Learn more about latency [here](https://developer.mozilla.org/en-US/docs/Web/Performance/Understanding_latency).

Tip: You cannot change the database region once it has been initialized. To use a different [region](https://vercel.com/docs/storage/vercel-postgres/limits#supported-regions), set it before creating a database.

Once connected, navigate to the `.env.local` tab, click `Show secret` and `Copy Snippet`. Paste the contents into your code editor.

## Database Secrets

Important: Don't expose database secrets when you push to GitHub. In `.gitignore`, make sure `.env` is in the ignored files. Finally, `run npm i @vercel/postgres` to install the [Vercel Postgres SDK](https://vercel.com/docs/storage/vercel-postgres/sdk)

## Seed the database

Seeding the database allows you to have some data to work with as you build the dashboard.

`/scripts/seed.js` uses SQL to create the tables. The data from `placeholder-data.js` file populates them.

In `package.json`

```js

"scripts": {
  "build": "next build",
  "dev": "next dev",
  "start": "next start",
  "seed": "node -r dotenv/config ./scripts/seed.js"
},
```

This is the command that will execute `seed.js`.

### Troubleshooting:

- Make sure to reveal your database secrets before copying it into your `.env` file.
- The script uses `bcrypt` to hash the user's password, if `bcrypt` isn't compatible with your environment, you can update the script to use `bcryptjs` instead.

If you want to run the script again, you can drop any existing tables by running `DROP TABLE tablename` in your database query interface.

### Warning

Be careful, this command will delete the tables and all their data. Do not run this command in a production app.

## Exploring your database

In Vercel click `Data` on the sidenav. By selecting each table, you can view its records and ensure the entries align with the data from `placeholder-data.js` file.

## Executing queries

Switch to the `query` tab to interact with your database. This section supports SQL commands.

### You can view my commits on GitHub:

- [Add postgress](https://github.com/Samuel-Lubliner/nextjs-dashboard/commit/75902d2771381dfc4cc659f149a0e469faf34931)

- [Add seed](https://github.com/Samuel-Lubliner/nextjs-dashboard/commit/1f63d2285c45c20170b3d462fda9cae98d012eb3)
pdfkit 0.15 released
Tags: pdf, javascript, node
Published: 2024-03-24 21:07:21

Just released [version 0.15](https://github.com/foliojs/pdfkit/releases/tag/v0.15.0) of [pdfkit](https://github.com/foliojs/pdfkit), a library to create pdf files in Node and browsers.

Alongside the bug fixes and performance tweaks, support for long time obsolete environments (hello Node v6 and IE11!) was dropped.

I'd like to thanks everyone that contributed submitting code.

The main changes:

- Add subset for PDF/UA
- Fix for line breaks in list items (#1486)
- Fix for soft hyphen not being replaced by visible hyphen if necessary (#457)
- Optimize output files by ignoring identity transforms
- Fix for Acroforms - setting an option to false will still apply the flag (#1495)
- Fix for text extraction in PDFium-based viewers due to invalid ToUnicodeMap (#1498)
- Remove deprecated write method
- Drop support for Node.js < 18 and for browsers released before 2020

Looking forward, in short time, i plan to improve the testing infrastructure and docs generation (broken for now).

On the other side, making pdfkit portable to browser (drop requirement of bundler) and other JS runtimes is a project i'm holding until find proper funding.
User-defined function in Azure Bicep
Tags: azure, iac, bicep, cloud
Published: 2024-04-04 18:42:57

Bicep allows you to define your functions for your bicep deployment. These functions can ease standardization expressions frequently used or perform some calculations. Think about naming conventions where you need to concatenate several strings to form a name. 
Bicep user-defined functions are similar to user-defined functions in ARM templates but far more simpler. 
To declare a function, you simply need to use the “func” statement followed by a list of parameters (if any) with their type, the data type returned by the function, and an expression, the corpus of the function. 
Func (param1, param1Type, param2, param2Type, …) functionType => Function Expression
Just like in the ARM template function, the expression can only use the function parameters, it can't access any variable or parameter present in the bicep project. 
A simple example to understand.

```
func sayMyName(firstName string, lastName string) string => '${firstName} ${lastName}'

output myName string = sayMyName('Olivier', 'Miossec')
```

The function sayMyName takes two parameters, firstName and lastName both using the string type. The function returns a string, which is the concatenation of the two parameters separated by a space. 
As you see user user-defined function is Bicep can help to enforce naming conventions. Imagine you want to ensure that a resource name is defined by the name of the application, an increment, and the resource type. 

```
func resourceName (appName string, increment int, resourceType string) string => toLower('${appName}-${increment}-${resourceType}')

output name string = resourceName('app',2, 'vnic')
```

The function creates a name by concatenating parameters with ‘-‘

User-defined functions can't use variables and cannot use the reference function to retrieve. 
They can only use one single expression, so it can be challenging to create a complex calculation. But you overcome this limitation by creating several user-defined functions, as you can call any other functions inside your functions. 

```
func returnParam (myParam string) string  => '${myParam}'

func addPrefix (prefix string, appName string) string => concat(prefix, '-', returnParam(appName))

output name string = addPrefix('vm', 'web')
```

You can’t surcharge a user-defined function by changing the type of a parameter or the number of parameters. You will get an error; Bicep will only try to evaluate the first expression. So, if you have an operation that can use several types you will need to use several functions.
Por que Ter um Site para Sua Empresa é Essencial nos Dias de Hoje
Published: 2024-04-04 19:02:08

Nos dias de hoje, com a internet tornando-se cada vez mais parte integrante das nossas vidas, ter uma presença online forte é crucial para o sucesso de qualquer empresa. Uma das melhores maneiras de estabelecer essa presença é através de um site bem desenvolvido. Se você ainda não possui um site para o seu negócio, aqui estão alguns motivos convincentes para considerar:

**1. Visibilidade e Acessibilidade 24/7**

Um site permite que sua empresa seja acessível para clientes potenciais 24 horas por dia, 7 dias por semana. Mesmo quando sua loja física está fechada, seu site continua funcionando, permitindo que os clientes conheçam seus produtos e serviços a qualquer momento, de qualquer lugar do mundo.

**2. Credibilidade e Profissionalismo**

Um site bem projetado transmite credibilidade e profissionalismo para os clientes em potencial. É sua vitrine digital, onde você pode exibir suas conquistas, mostrar depoimentos de clientes satisfeitos e destacar suas certificações e prêmios.

**3. Marketing e Promoção**

Um site oferece uma plataforma poderosa para marketing e promoção. Você pode usar seu site para publicar conteúdo relevante, como blogs, vídeos e infográficos, que atraiam e engajem seu público-alvo. Além disso, você pode integrar seu site com as mídias sociais para ampliar seu alcance e interação com os clientes.
**
4. Expansão do Mercado**

Com um site, você não está limitado pela sua localização física. Você pode alcançar clientes em todo o mundo e expandir seu mercado de maneiras que seriam impossíveis apenas com uma loja física.

**5. Facilidade de Atendimento ao Cliente
**
Um site pode servir como um canal conveniente para o atendimento ao cliente. Você pode fornecer respostas às perguntas mais frequentes, disponibilizar formulários de contato e até mesmo oferecer suporte ao cliente em tempo real através de chats online.

**Conclusão**

Em resumo, ter um site para sua empresa não é mais um luxo nos dias de hoje - é uma necessidade. É uma ferramenta poderosa que pode impulsionar o crescimento do seu negócio, aumentar sua visibilidade online e melhorar a experiência do cliente. Se você ainda não deu o próximo passo para estabelecer sua presença online, agora é a hora de começar.

Se você estiver interessado em criar um site para o seu negócio, estamos aqui para ajudar. Entre em contato conosco hoje mesmo para saber mais sobre nossos serviços de desenvolvimento web.


Cover Image by FreePik
📱✨ iPhone 15 Pro Max Giveaway! ✨📱
Published: 2024-04-04 15:38:49

[](https://sites.google.com/view/winiphone15-2024/home)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qylcyko788lezh3088ey.jpg)Hey, tech lovers! 🎉 We're super thrilled to roll out our [iPhone 15 Pro Max giveaway](https://sites.google.com/view/winiphone15-2024/home)! Here's your golden opportunity to get your hands on this stunning piece of tech. 🌟

How to Enter:

1️⃣ Follow Us - Make sure you're following our page.

2️⃣ Like this Post - Double tap to show some love.

3️⃣ Tag Your Squad - Mention 3 friends who'd love to win this too! 👯‍♀️

4️⃣ Share on Your Story - Spread the word and tag us for an extra sprinkle of luck! 📣

Bonus Entry: Subscribe to our newsletter via the link in bio! 💌

Giveaway Details:

🌍 **[Open worldwide](https://sites.google.com/view/winiphone15-2024/home)**.

📅 Giveaway ends on [20.04.2024].

📅 Winner will be announced on [21.04.2024]

👩‍👩‍👧‍👦 Must be 18+ or have parental permission.

📩 Winner will be DM'ed and announced on our story.

🚫 Not affiliated with Instagram or Apple.

Wishing everyone the best of luck! 🍀 Let the entries begin! 💫
#iPhone15ProMaxGiveaway #TechLove #GivewayTime

[Win iPhone 15 Pro Max](https://sites.google.com/view/winiphone15-2024/home)
Nexus: Genisis
Tags: node, javascript, p2p, network
Published: 2024-04-04 18:32:53

Welcome to the launch of Project Peerplex, also known as Nexus! 🚀

Project Peerplex is an ambitious endeavor to create an all-encompassing peer-to-peer network that addresses various needs, including transactions, storage, messaging, routing, and beyond. With this project, we aim to revolutionize the way decentralized systems operate and pave the way for a more interconnected and efficient digital world.

In this exciting journey, I'll be sharing regular updates and insights into the development process, along with articles covering various aspects of the project. Whether you're a developer, enthusiast, or simply curious about the future of peer-to-peer networks, this is the place to be.

Stay tuned for groundbreaking developments and join us in shaping the future of decentralized technology with Project Peerplex! 🌐 ✨
Nexus: Genisis
Tags: node, javascript, p2p, network
Published: 2024-04-04 18:32:49

Welcome to the launch of Project Peerplex, also known as Nexus! 🚀

Project Peerplex is an ambitious endeavor to create an all-encompassing peer-to-peer network that addresses various needs, including transactions, storage, messaging, routing, and beyond. With this project, we aim to revolutionize the way decentralized systems operate and pave the way for a more interconnected and efficient digital world.

In this exciting journey, I'll be sharing regular updates and insights into the development process, along with articles covering various aspects of the project. Whether you're a developer, enthusiast, or simply curious about the future of peer-to-peer networks, this is the place to be.

Stay tuned for groundbreaking developments and join us in shaping the future of decentralized technology with Project Peerplex! 🌐 ✨
Ideation of Game
Tags: gamedev, design, csharp, unity3d
Published: 2024-04-04 18:28:46

# Introduction
The last post showed our research for multi-player game like tools, level design, and counter play. Based on that, we are going to create multi-player game. This post will show the ideation of the game. 

Table of contents

- Game world and setting
- Game & multi-player Mechanics, level design
- Characters and enemies, collectibles, Items
- Feature Outline
- Progress Tracking

## Game world and setting

### Story
In the future century, one crazy scientist found Mirror World. He built a house linked to Mirror World in his Lab as the experimental site to test.

### Setting

- Hunting Game
- 1 Survivor vs 3 Hunters
- **Survivor** aims to get out of Mirror world
- **Hunters** aim to capture the survivor


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

Designed by our team's designer

## Game Mechanics & Level design

### Mirror

There are mirrors in a building. Both **hunters** and **survivor** travel through them. 

Each mirror will be broken after using. 

Mirror will refresh after a few seconds.

### Other Mechanics

- Barriers
- Items 
- Movement
- Time to kill
- Health 
- Weapon

### Game Level

There are two floors in total.


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

Designed by our team's designer

## Player characters

### Survivor 

Use **multiple items** to survive from the hunt.

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

### Hunters

Damage with their **spikes**, they can detect survivor when they activate the **goggle**.

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

## Feature Outline

To implement mirror world and mirror, we will create two identical terrain maps. When players use the mirror, they will move to the same position on the other map.

## Progress Tracking

We use Discord to communicate and Spreadsheet to track our game project. 


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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qvjtjybl0z8isr1wlvt8.png)
Day 4/366
Tags: 1percentplusplus, 100daysofcode
Published: 2024-04-04 14:36:09

🚀 **Today's Learning:**

🌟 DSA

- Two Sum - Leetcode 1
- Reverse Linked List - Leetcode 206

🌟 Dev

- Difference between inline and block elements.
- What is difference between display:none and display:hidden.
- Flex and Grid which layout approach should you use and when to use.
- Media Queries.

🔍 **Some Key Highlights:**

DSA

**Two Sum -** Leetcode 1

Brute force → Iterate through each element → for each element check for the compliment (target - nums[i]) in rest of the elements → if found push both the current element’s index and the complement’s index in ans array. (T.C. O(n^2) | S.C. O(1))

Optimized Approach → take an unordered map and fill it with element and index key-value pairs. Iterate through the nums array → for each element find the compliment (target - nums[i]) in map, which takes constant time to search → If compliment found push both current element index and compliment index in `ans` array (Note: Also while finding compliment ensure that compliment’s index should not be same as current element’s index. (T.C. O(n) | S.C. O(n))


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

**Reverse Linked List - Leetcode 206**

Approach 1 (Brute Force)  

Take an extra auxiliary array → copy all linked list data in this array → reverse travel the array and replace linked list data. (Time: O(n) | Space: O(n) - coz of extra array)

Approach 2 (Optimized for space - In place solution - Reversing links)

Take 3 pointers p, q and r → these are sliding pointers (order: r, q, p) → at each pass slide all three to one step right → use q to reverse the link → do this untill p reaches null → At this time q would be at last node → make head point this last node.
(Time: O(n) | Space: O(1) )


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

DEV

1. **Inline vs. Block Elements:**
    - Block elements are like big building blocks, stacking on top of each other and taking up the full width.
    - Inline elements are smaller and fit within a line of text, like links or emphasis.
2. **Background Image with Opacity and Text Overlay:**
    - Use CSS to set a background image on a container and add text on top of it.
    - Apply opacity to the background image without affecting the text by using RGBA colors or the opacity property.
3. **Display:none vs. Display:hidden:**
    - `display:none` completely removes an element from the layout.
    - `display:hidden` hides an element from view but still occupies space in the layout.
4. **Flexbox vs. CSS Grid Layout:**
    - Flexbox is great for simpler, one-dimensional layouts like navigation menus.
    - CSS Grid is perfect for more complex, two-dimensional layouts with rows and columns.
5. **Media Queries:**
    - Media queries allow you to adapt your website's layout and styles based on different devices and screen sizes.
    - They help ensure your website looks fantastic across various devices, from laptops to smartphones.
Find Bottom Left Tree Value | LeetCode | Java | 2 Methods (BFS & DFS)
Tags: java, leetcode, beginners, algorithms
Published: 2024-04-04 18:24:38

**BFS Solution :**

``` java
class Solution {
    public int findBottomLeftValue(TreeNode root) {
                
        Queue<TreeNode> queue = new LinkedList<>();
        
        int leftValue = 0;
        
        if(root==null)
            return 0;
        
        queue.add(root);
        
        while(!queue.isEmpty()){
            int size = queue.size();
            for(int i=0; i<size; i++){
                TreeNode temp = queue.remove();
                
                if(i==0)
                    leftValue = temp.val;
                        
                if(temp.left!=null)
                    queue.add(temp.left);
                
                if(temp.right!=null)
                    queue.add(temp.right);
            }
        }
        return leftValue;
    }
}
```

<hr>

**DFS Solution:**

``` java
class Solution {
    int leftVal = 0;
    public int findBottomLeftValue(TreeNode root) {
        
        int maxDepth = maximumDepth(root);
        leftMostVal(root, 1, maxDepth);
        return leftVal;
    }
    
    int maximumDepth(TreeNode node){
        if(node==null)
            return 0;
        
        return 1 + Math.max(maximumDepth(node.left), maximumDepth(node.right));
    }
    
    void leftMostVal(TreeNode node, int level, int maxDepth){
        if(node==null)
            return;
        
        if(maxDepth==level){
            leftVal = node.val;
            return;
        }
        
        leftMostVal(node.right, level+1, maxDepth);
        leftMostVal(node.left, level+1, maxDepth);
        
    }
}
```

_Thanks for reading :)
Feel free to comment and like the post if you found it helpful
Follow for more 🤝 && Happy Coding 🚀_

If you enjoy my content, support me by following me on my other socials:
https://linktr.ee/tanujav7
Introducing Geoglify
Tags: javascript, programming, opensource, webdev
Published: 2024-04-04 18:24:16

We're thrilled to announce that we've finalized the architecture of Geoglify! The design is streamlined and focused, promising efficient performance without unnecessary complexity. With this solid foundation in place, we're ready to move forward with organizing code and implementing functionalities.

![Geoglify Logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/41yffoskrz5vnd6d9rbz.gif)

### What is Geoglify?

Geoglify is an innovative open-source project dedicated to exploring the vast realm of ships, maritime data, planning, and related statistics. Our primary goal is to provide a centralized platform for the analysis and visualization of data related to the sea. We aim to offer valuable insights into the shipping industry, maritime planning, and associated statistics, promoting a comprehensive understanding of the marine environment.

![Maritime Data Visualization](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/35widc2vnqwknaytf35x.png)

### Our Mission

At Geoglify, we are committed to revolutionizing how maritime data is analyzed and utilized. By leveraging cutting-edge technologies and fostering a collaborative community, we strive to empower researchers, policymakers, and enthusiasts to make informed decisions and drive innovation in the maritime sector.

### Get Involved!

Join us on our journey to transform maritime data analysis. Whether you're a developer, data scientist, designer, or maritime enthusiast, there's a place for you in the Geoglify community. Explore our [GitHub repository](https://github.com/geoglify/geoglify) to contribute code, share ideas, and collaborate with like-minded individuals.

Stay Connected!
Need help from experienced people.
Published: 2024-04-04 18:13:37

Hi, i m self learner. I started coding in 2023. I have learned java core, oops, exception handling and multi threading basic concepts with some DSA. I also just completed html css and js and now really confused between MERN and Java full stack. In my area most of people are unaware about coding and stuff so i dont have any fellow who can guide me. As a fresher please suggest which should i choose. My plan is to get a job in July 2024. Thank you.
Why Use AWS: Advantages and Benefits
Tags: aws, beginners, productivity
Published: 2024-04-04 18:12:16

[Amazon Web Service](https://unlimitech.cloud/services/cloud-infrastructure/)s (AWS) is the most popular cloud computing platform in the world. It offers a wide range of services that enable businesses of all sizes to scale and improve their operations.

In this article, we will present some of the reasons why using AWS might be a better option for your company:


**Wide Range of Services**:
AWS offers a wide variety of services to cover the needs of any business, from basic infrastructure such as servers and storage to more advanced tools like data analytics, artificial intelligence, and machine learning.


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

**Scalability and Flexibility**:
AWS allows you to scale your resources quickly and easily based on your needs. You only pay for what you use, which helps you save costs and optimize your budget.

**Reliability and Security**:
AWS provides robust and secure infrastructure with high availability. Your data will be protected with industry-leading security practices.

**Continuous Innovation**:
AWS is constantly innovating, releasing new services and features regularly. This allows you to stay at the forefront of technology and leverage the latest trends.

**Global Community**:
AWS has a large community of users and partners who can help you find solutions to your problems and learn how to use the platform effectively.


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

**Examples of AWS Advantages**:

- Cost Savings: AWS can help you save costs on [infrastructure, software](https://unlimitech.cloud/services/cloud-infrastructure/), and personnel.

- Performance Improvement: AWS can help you improve the performance of your applications and increase your team's productivity.

- Greater Agility: AWS allows you to be more agile and adaptable to market changes.

- Innovation: AWS enables you to leverage the latest technologies to innovate and improve your business.