teleren/devto huggingface dataset:
Effortlessly Highlight Active Links in Your Next.js Application with useActiveRouter Hook
Tags: nextjs, nextrouter, react
Published: 2023-05-07 15:41:39

Highlighting the active link in a Next.js application with multiple pages and navigation links can be a tedious and error-prone task. However, the useActiveRouter hook from the active-link-nextjs package can simplify this process. By defining a configuration object with the active class name and using the registerRoute function returned by the hook with the Link component, the active link can be easily highlighted.

## What is useActiveRouter?
useActiveRouter is a hook that can be imported from [active-link-nextjs](https://www.npmjs.com/package/active-link-nextjs) package. To install this package you can do

`npm install active-link-nextjs`
This hook takes a config object as parameter where you can define the name of active class to be auto applied to active link.
it returns an object containing href and className properties.

```tsx
import { useActiveRouter } from 'active-link-nextjs';
import Link from 'next/link';

const config = { activeClass: 'active' };

const MyComponent: React.FC = () => {
    const { registerRoute } = useActiveRouter(config);
        
    return (
        <nav>
        <Link {…registerRoute([''])}>Home</Link>
        <Link {…registerRoute(['about'])}>About</Link>
        <Link {…registerRoute(['blog'])}>Blog</Link>
        </nav>
    );
};
```

In this example, we first import the useActiveRouter hook from the `active-link-nextjs` package and the Link component from the `next/link` package. We then define a configuration object with an `activeClass` property set to `'active'`. This is the class name that will be added to the active link's a tag.

We then call useActiveRouter with the configuration object, which returns the `registerRoute` function. We can then use this function to generate the **`href`** and **`className`** properties for each navigation link.

Instead of using an a tag, we wrap the Link component around the result of the registerRoute function. This ensures that the link is pre-fetched by Next.js, which can improve the app's performance.

## Why use useActiveRouter and Link?
Using `useActiveRouter` and Link can simplify the process of adding an active class to the active link in a Next.js app. Instead of manually checking the current route and adding the class name, we can use the registerRoute function to handle this for us. This can save us time and reduce the chance of errors, especially if our app has many pages and nested routes.

## Conclusion
If you’re building a Next.js app with multiple pages and navigation links, useActiveRouter and Link can help simplify the process of highlighting the active link. By using the registerRoute function and Link component

Contributions and suggestions are welcome [Github](https://github.com/rishabhrpg/active-link-nextjs)
The built in types of C#
Tags: csharp, programming, beginners, learning
Published: 2023-05-07 15:16:36

Variables are an essential part of any programming language. Variables allow you to store and manipulate data during the execution of your code. 

In this post I will be writing about the built-in types in the C# language. These are known as integral numeric, floating point numeric, bool, and char. The aspects to these variables are declarations, initialization, scope, assignment, and modification. 

```
char firstLetter = 'a';
int age = 33;
double cost = 1337.00;
bool isOpen = false;
```
In the example above I have declared and initialized the four simple type variables in C#. It starts with first defining the type the variable will be, naming the variable, and assigning a value to the variable. You don't always need to assign a value to the variable upon declaring the variable. 

```
char firstLetter;
int age;
double cost;
bool isOpen;
```

In the examples above I have described how to define, initialize, and assign variables in C#. I have recently started a blog to help jot down my programming education / learnings that I have picked up over the last five years. I go more in depth on modification and scope of variables in C# in the latest post published today. If you are interested check it out. 

My blog: https://kylemartin0819.wordpress.com/ 

I plan on creating concise, short read, lessons here on Dev.to that summarize my blog posts as well so consider giving me a like and follow. Check out my GitHub where I have been storing C# code from online courses / books I have been digesting recently.

Thanks for reading!

Kyle
How Lambda will enhance your app scalability
Tags: javascript, webdev, beginners, aws
Published: 2023-05-07 15:06:22

Suppose you have an e-commerce site and you need to tune the consumer's behavior for the duration of their visit. You want to recognize how a lot time the purchaser spends on each web page and which pages they go to in what order. This information can help you examine the consumer's hobbies and possibilities and enhance their universal revel in on the website.

One way to reap that is by means of developing a Lambda feature that is caused every time a user visits a web page on your internet site. The function can record the user's consultation facts in a database or file. Here's a pattern code for the Lambda characteristic:


![AWS lambda](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3p9qohg2lyq02911hx7c.png)

In this case, the Lambda characteristic receives an occasion object that consists of the pageId and sessionId. The pageId is the identifier for the web page that the person is presently visiting, and the sessionId is a unique identifier for the consumer's consultation.

The feature then generates a timestamp and creates an item that includes the sessionId, pageId, and timestamp. It makes use of the AWS SDK to put in writing this object to a DynamoDB table named web page-visit-tracking. Finally, it logs a message indicating that the page visit has been recorded.

This Lambda function can be incorporated together with your internet site's frontend code to ship an occasion item to the Lambda function each time a consumer visits a web page. By doing so, you may music the person's conduct and benefit precious insights into their pursuits and preferences.
How to Inspect a Lot of Stored Procedures (SP) in MSSQL
Tags: sql, beginners, tutorial, sqlserver
Published: 2023-05-07 14:58:18

## Introduction
In this post, we'll guide you through inspecting multiple stored procedures in SQL Server using different methods. This is useful when you need to view the definition or check for the existence of a stored procedure in your database.

## Viewing Stored Procedure Definition
There are three different ways to view the definition of a stored procedure using a query in SQL Server:

- `sp_helptext`
- `OBJECT_DEFINITION`
- `sys.sql_modules`

### Using `sp_helptext`
To view the stored procedure using `sp_helptext`, use the following syntax:
```sql
USE database;  
GO  
EXEC sp_helptext N'procedure_name'; 
```

### Using `OBJECT_DEFINITION`
To view the stored procedure using `OBJECT_DEFINITION`, use the following syntax:
```sql
USE database;  
GO  
SELECT OBJECT_DEFINITION (OBJECT_ID(N'procedure_name')); 
```

### Using `sys.sql_modules`
To view the stored procedure using `sys.sql_modules`, use the following syntax:
```sql
USE database;  
GO  
SELECT definition  
FROM sys.sql_modules  
WHERE object_id = (OBJECT_ID(N'procedure_name'));  
```

## Checking for Stored Procedure Existence
We often need to check for the existence of a stored procedure in SQL Server. We can use the `IF EXISTS` clause in combination with different techniques:

- `sys.procedures`
- `sys.objects`

### Using `sys.procedures`
To check the existence of a procedure using `sys.procedures`, use the following syntax:
```sql
Copy code
USE database
GO
IF EXISTS(SELECT 1 FROM sys.procedures 
          WHERE Name = 'procedure_name')
BEGIN
    PRINT 'Stored Procedure Exists'
END
```

### Using `sys.objects`
To check the existence of a procedure using `sys.objects`, use the following syntax:
```sql
Copy code
use database
IF EXISTS (SELECT * FROM sys.objects
            WHERE object_id = OBJECT_ID(N'procedure_name')
                    AND type IN ( N'P')) 
BEGIN
    PRINT 'Stored Procedure Exists'
END
```

## Conclusion

In this post, we've shown you different ways to inspect multiple stored procedures in SQL Server, either by viewing their definitions or checking for their existence. These methods are helpful when working with a large number of stored procedures and when you need to perform various tasks such as updating, deleting, or creating new ones.

## Reference

[How to view stored procedure in SQL Server](https://sqlserverguides.com/view-stored-procedure-in-sql-server/)
Day 33-37: Joined Kaggle community
Tags: beginners, python, ai
Published: 2023-05-07 14:47:20

In today's post, I want to share a brief update on learnings. As I mentioned at the end of my previous post, I was thinking about joining kaggle.com.

For those who might not be familiar with Kaggle, it is an online community that offers a wealth of resources for learning about Machine Learning and Data Science. The platform welcomes users of all skill levels, from complete beginners with no programming background to expert Data Scientists and Machine Learning Engineers. Kaggle has tens of thousands of public notebooks and thousands of public datasets, providing lots of opportunities for hands-on learning.

Kaggle also offers free courses aimed at helping aspiring Data Scientists build their skills. Also, the platform hosts online competitions that challenge participants to push their learning even further and put their knowledge to the test.

Since joining Kaggle, I have completed three free courses and received online certificates for each:

- [Introduction to Programming](https://www.kaggle.com/learn/certification/johnenad/intro-to-programming)
- [Python](https://www.kaggle.com/learn/certification/johnenad/python)
- [Introduction to Machine Learning](https://www.kaggle.com/learn/certification/johnenad/intro-to-machine-learning)

The first two just served as a review for the Python concepts I've learned the past few weeks but the basics of Machine Learning was something entirely new. I'm excited to continue exploring Kaggle's offerings, as I believe it is an invaluable resource for anyone looking to break into the world of Machine Learning and Data Science or at least to understand what it is.

Since I have just started and have only been focusing on the free courses, I have yet to experience the online community aspect of Kaggle. It is supposed to provide a sense of collaboration and allows users to learn from one another. Hopefully, this supportive environment would help accelerate my personal growth and development in area.

In summary, if you're considering going into Machine Learning and Data Science, Kaggle is a wonderful place to start. With its extensive range of resources, courses, and competitions, the platform offers lots of opportunities for learning and growth.
"𝐀𝐮𝐭𝐨𝐦𝐚𝐭𝐞 𝐄𝐂𝟐 𝐒𝐭𝐚𝐫𝐭 𝐚𝐧𝐝 𝐒𝐭𝐨𝐩 𝐰𝐢𝐭𝐡 𝐀𝐖𝐒 𝐋𝐚𝐦𝐛𝐝𝐚 𝐅𝐮𝐧𝐜𝐭𝐢𝐨𝐧𝐬" | 𝐩𝐨𝐜 |
Published: 2023-05-07 14:45:38

#90daysofawschallenge



Hey, connections!!👋



🎯Let’s learn and grow together.



📢 📢 📢



🎯 Let’s Understand "𝐀𝐮𝐭𝐨𝐦𝐚𝐭𝐞 𝐄𝐂𝟐 𝐒𝐭𝐚𝐫𝐭 𝐚𝐧𝐝 𝐒𝐭𝐨𝐩 𝐰𝐢𝐭𝐡 𝐀𝐖𝐒 𝐋𝐚𝐦𝐛𝐝𝐚 𝐅𝐮𝐧𝐜𝐭𝐢𝐨𝐧𝐬" | 𝐩𝐨𝐜 |



Full video link click: https://lnkd.in/giZEUSTZ



Happy learning,

🍂🍂🍂🍂

Sources: Google



Follow me, Manikanta Suru, and Cloudnloud Tech Community on LinkedIn for more insightful knowledge & resources.
Using age-cda for Community Detection in Apache AGE with python
Tags: apacheage
Published: 2023-05-07 14:37:56

Community detection is a popular graph analysis technique used to identify groups of nodes in a network that are densely connected with each other but sparsely connected to other groups. Community detection has numerous applications, such as identifying groups of people with similar interests in social networks, finding clusters of related proteins in biological networks, and identifying clusters of related websites in web link networks.

Here, we will be discussing how to install and use the age-cda Python package for community detection in the AGE graph database.

## Installation

### Install via PIP
You can install the age-cda package using pip, which is the easiest way to install Python packages.
```cmd
pip install age-cda
```

### Build from Source
To build age-cda from source, you need to first install libeigen3-dev. You can install it on Ubuntu/Debian based systems using the following command:
```
sudo apt-get update
sudo apt-get install libeigen3-dev
```

Next, clone the Community-Detection-Modularity repository from Github, navigate to the directory, and run the following command:
```
python setup.py install
```
You also need to configure the GNU Scientific Library (GSL). You can follow the instructions in this tutorial to configure GSL on your system.

### Unit Test
You can run the unit tests using the following command:
```
python -m unittest test_community.py
```


## Instruction
### Import
To use age-cda in your Python project, import the Graph class from the age_cda package as shown below:
```py
from age_cda import Graph
```

### Create Graph
To create a graph, you need to pass two arguments to the Graph class constructor:

- Nodes: A list of nodes in the graph.
- Edges: A 2D list of edges in the graph represented as an adjacency list.

```py
nodes = [0, 1, 2, 3, 4, 5]
edges = [[0, 1], [0, 2], [1, 2], [2, 3], [3, 4], [3, 5], [4, 5]]
g = Graph.Graph()
g.createGraph(nodes, edges)
```

### Generate Community Assignment
To generate the community assignments, simply call the get_community() method on the graph object.
```py
res = g.get_community()
```
### Output Format
The get_community() method returns a list of communities, where each community is represented as a list of nodes.
```
[[3,4,5],[0,1,2]]
```
Each community is a list of nodes that belong to the community.

## Conclusion
Now you can use the [python AGE driver](https://github.com/apache/age/tree/master/drivers/python) to get all nodes and edges get the desired community. In this blog, we learned how to use `age-cda` for community detection in Python. We covered the installation process and provided examples of how to create a graph and generate community assignments. With age-cda, you can easily analyze the structure of graphs and identify communities of nodes that are highly interconnected.
What is the difference between frameworks and libraries?
Tags: beginners, codenewbie, learning, discuss
Published: 2023-05-07 14:16:04

As a developer, it's important to understand the difference between frameworks and libraries, as they both play a critical role in software development. 

In simple terms, a library is a collection of pre-written code that can be used to perform specific tasks, such as handling database connections, parsing XML data, or creating user interfaces. Libraries are typically standalone components that can be integrated into an application as needed, and developers are responsible for managing how the library is used and called.

On the other hand, a framework is a more comprehensive set of tools and components that provide a complete structure for building an application. A framework typically includes multiple libraries and other pre-built components and often defines a specific approach or methodology for developing software. Frameworks are designed to streamline development and provide a standardized structure for creating complex applications.

So, which one is better? Well, it depends on your project's specific needs and requirements. Libraries are great for specific, isolated tasks, whereas frameworks are better suited for larger, more complex projects that require a more comprehensive approach.

What are your thoughts on the difference between frameworks and libraries? Do you have any other insights or experiences to share? Let us know in the comments below!

Acknowledgment: this was written with the help of but not by ChatGPT.
Maximum of all subarrays of size k
Tags: algorithms, solution, geeksforgeek, heap
Published: 2023-05-07 13:52:16

> problem statement : https://practice.geeksforgeeks.org/problems/maximum-of-all-subarrays-of-size-k3101/1

Given an array arr[] of size N and an integer K. Find the maximum for each and every contiguous subarray of size K. 

Example 1:
```
Input:
N = 9, K = 3
arr[] = 1 2 3 1 4 5 2 3 6
Output: 
3 3 4 5 5 5 6 
Explanation: 
1st contiguous subarray = {1 2 3} Max = 3
2nd contiguous subarray = {2 3 1} Max = 3
3rd contiguous subarray = {3 1 4} Max = 4
4th contiguous subarray = {1 4 5} Max = 5
5th contiguous subarray = {4 5 2} Max = 5
6th contiguous subarray = {5 2 3} Max = 5
7th contiguous subarray = {2 3 6} Max = 6
```

Example 2:
```
Input:
N = 10, K = 4
arr[] = 8 5 10 7 9 4 15 12 90 13
Output: 
10 10 10 15 15 90 90
Explanation: 
1st contiguous subarray = {8 5 10 7}, Max = 10
2nd contiguous subarray = {5 10 7 9}, Max = 10
3rd contiguous subarray = {10 7 9 4}, Max = 10
4th contiguous subarray = {7 9 4 15}, Max = 15
5th contiguous subarray = {9 4 15 12}, 
Max = 15
6th contiguous subarray = {4 15 12 90},
Max = 90
7th contiguous subarray = {15 12 90 13}, 
Max = 90
```
Your Task:  
 You don't need to read input or print anything. Complete the function max_of_subarrays() which takes the array, N and K as input parameters and returns a list of integers denoting the maximum of every contiguous subarray of size K.

> **Expected Time Complexity: O(N)**

> **Expected Auxiliary Space: O(K)**

Constraints:
1 ≤ N ≤ 105
1 ≤ K ≤ N
0 ≤ arr[i] ≤ 107


## Solution
```
class Solution
{
    //Function to find maximum of each subarray of size k.
    static ArrayList <Integer> max_of_subarrays(int a[], int n, int k)
    {
        PriorityQueue<Integer> queue = new PriorityQueue<>(Collections.reverseOrder());
        ArrayList<Integer> res = new ArrayList<>();
        
        for(int i = 0; i < k-1; i++) {
            queue.offer(a[i]);
        }
        
        for(int i = k-1; i < n; i++) {
            queue.offer(a[i]); // considering new element
            res.add(queue.peek());
            queue.remove(a[i-k+1]); // removing the last left out element
        }
        
        return res;
    }
}
```
Exploring the Capabilities of Astro JS in Developing a Web 3D Configurator: A Bachelor Thesis Study
Tags: webdev, 3d
Published: 2023-05-07 13:47:17

Hello everyone!

I'm a Bachelor's degree student currently working on my thesis project, which focuses on creating a 3D configurator in Astro JS. I'm seeking the help of this community in completing my survey and gathering valuable insights.

The purpose of my research is to explore the capabilities of Astro JS in developing a web-based 3D configurator. I believe that this study will contribute to the development of better tools and techniques for creating interactive 3D models on the web.

I would greatly appreciate it if you could take a few minutes to complete my survey. Your responses will be anonymous and will be used solely for academic purposes. The survey link can be found below.

https://forms.gle/hnHBydKow8gEXTJG9

Also, if you have any experience with 3D configuration in Astro JS, I would love to hear from you. Please feel free to contact me at thomas.soetaert@student.howest.be.

Thank you in advance for your participation and for helping me advance my research. If you have any questions or concerns, please don't hesitate to reach out to me.
DEV Showcase #1
Tags: codenewbie, beginners
Published: 2023-05-07 13:33:00

---
title: DEV Showcase #1
published: true
description:Weekly thread where you can share what you've been working on and get feedback and encouragement from the DEV community.
tags: codenewbie, beginner
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-05-05 20:38 +0000
---
Welcome to the DEV Showcase - a weekly thread where you can share what you've been working on and get feedback and encouragement from the DEV community.

This is your chance to show off your latest project, share a cool hack or technique you've learned, or ask for advice and feedback from other developers. Whether you're a seasoned developer or just starting out, this is the place to connect with others and get inspired.

Here are a few questions to think about if you're stuck:
- What have you been working on lately?
- What tools or resources have you found helpful?
- Have you learned any new skills or techniques recently?
- What challenges have you faced, and how can the community help you overcome them?
- What are your goals for your project or your career moving forward?

Remember, this isn't a competition or a challenge - it's just a space to share and connect with others. So don't be shy! Share your work and get feedback and encouragement from the DEV community.

We're excited to see what you've been working on, and to support you as you continue to grow and develop your skills.
What Will Future Programming Look Like With AI & Chat GPT? (Real Programmer Point of View)
Tags: ai, beginners, programming, gpt3
Published: 2023-05-07 13:29:09


In this video, we explore the future of programming and what it will look like with the emergence of AI and Chat GPT technologies. As a real programmer, I offer my insights and opinions on what to expect in the programming industry in the coming years.

Artificial Intelligence (AI) is rapidly transforming the way we live our lives, and the programming industry is no exception. With AI, we can expect programming to change significantly, but what those changes could be?

Chat GPT is a type of AI that involves conversational models that can predict what users will say next. Will future programming become more conversational, more human-like, and easier to use for non-technical people?

So, what will programming look like in a few years from now? Join me in this video, as we explore the possibilities of programming in the coming years. Don't forget to subscribe to my channel for more insightful content on the future of programming, AI, and all things tech-related.

{% embed https://youtu.be/ggZlTQy_bek %}
Prompt engineering - Instruction based LLM
Tags: chatgpt, prompteng, webdev
Published: 2023-05-07 13:22:16

Prompt engineering is a technique used to fine-tune and customize language models such as OpenAI's GPT-3 for specific tasks. This technique involves crafting prompts or inputs that guide the model toward generating more relevant and accurate outputs. In this blog post, we will explore how prompt engineering can be used to enhance the performance of GPT-3 for various NLP tasks.

**Prompt engineering principle**:
1.Practice writing clear and specific instructions
2.Give the modal some time to think
Best prompt engineering can be achieved by an iterative process.

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

**Guideline**:
1. Be clear and specific
2. Analyze why the result does not give the desired output
3. Refine the idea and prompt
4. Repeat
To achieve the best result always refine the prompt with a batch of examples.

**Use cases for Prompt engineering:**
1.Summarizing text - For example, summarize meetings or summarize customer reviews on products.

2.Inferring - For example, extract the sentiment of the text. (Like Positive or negative reviews )

3.Transforming - For example - Take inputs in one language and transfer them to another language.

4.Spelling fix

5.Check review

6.Expand a sorter text to longer text

7.Chatbot -(Any chatbot like Tiffin service order chatbot)

And many more...

I hope this article will give some ideas of prompt engineering . In next article, How can we implement using python , open AI modal(3.5 turbo) , next Js, React ?