teleren/devto huggingface dataset:
Apache Age with PostgreSQL Example
Published: 2023-10-15 18:19:09

We are going to see an example of using Apache Age with PostgreSQL. Starting with:
**Creating a graph schema:**

```
CREATE TABLE person (id int PRIMARY KEY, name text);
CREATE TABLE knows (src int REFERENCES person(id), dst int REFERENCES person(id));
```

**Adding nodes and edges to the graph:**

```
INSERT INTO person (id, name) VALUES (1, 'Ammar');
INSERT INTO person (id, name) VALUES (2, 'Ahmad');
INSERT INTO knows (src, dst) VALUES (1, 2);
```

**Querying the graph using GSQL:**

```
SELECT p.name, k.dst FROM person p, knows k WHERE p.id=k.src;
```

This query returns the names of people who know each other.

**Visualizing the Graph with GAdmin**
Once you have created your graph schema and added nodes and edges to the graph, you can use GAdmin to visualize the graph. GAdmin provides a visual representation of the graph, with nodes and edges displayed as circles and lines. You can use the visualization to explore the relationships between nodes and edges, and to identify patterns in the graph data.

**Conclusion**
These are just a few examples of how you can use Apache Age with PostgreSQL to model, query, and visualize graph data. The possibilities are endless, and you can use Apache Age to model and query any type of graph data.

Apache-Age:(https://age.apache.org/)
GitHub:-https://github.com/apache/age
Pokedex web app in React using PokemAPI
Tags: webdev, react, api, opensource
Published: 2023-10-15 18:17:18

Hi folks!

This is just a small post about my new open-source repo where you can contribute under Hacktoberfest.

Hacktoberfest is going on.
Are you contributing to Open Soruce?

Here is an open source repository, [Pokedex](https://github.com/TheShiveshNetwork/Pokedex) a pokemon's web app where you can contribute.

This project is made with React, Tailwind and uses the PokeAPI.

Give the Repo a 🌟
And follow me on [Github](https://github.com/TheShiveshNetwork/)

Happy Hacking!!
Which programming language should I start with Python / Java / C++?
Tags: python, java, programming, datastructures
Published: 2023-10-15 17:48:38

No language is better than any other language it is based on one's use case which programming one should start with.

## Python

If one is new to programming and if he wants to start his programming journey he should start it with Python language. As Python is easy to use and its syntax is like the English language it will be easy to master it.

Python has tons of different libraries like Numpy, Pandas, TensorFlow, PyTorch etc which are heavily used in Data Science, Machine Learning, and AI.

So if one wants to go into these fields or wants to become a Python developer then Python would be the best language to start with.

But if one has to go for competitive programming then Python may not be a great language as it is considered as a slow language.

## C++

If one wants to go into core competitive programming then C++ would be the best language to be selected as it is faster than many other languages. As C++ is a core language it is easier to move from C++ to Python but it would be more challenging to do vice versa.

In C++ one has to implement all the things from scratch as compared to Python but it makes our base stronger.

For a newbie, C++ may be more challenging to start with due to its syntax but in the longer run it is going to be easier to switch to any language.

## Java

Java act as a mediator between C++ and Python. Java can be used even for competitive programming as well as for projects in Android development and Web development.

The demand for Java is also increasing day by day and mastering it also also easy as compared to C++. The concepts like pointers get reduced from Java which we would have to learn in C++.

Conclusion

So to conclude no language is better than any other language it's just based on the use case one should select it and start his programming.

As it is important to choose any one language and master it.
1584. Min Cost to Connect All Points
Tags: leetcode, mediu
Published: 2023-10-15 17:34:31

Problem: [1584. Min Cost to Connect All Points](https://leetcode.com/problems/min-cost-to-connect-all-points/description/)

<strong>Explain</strong>

Looking at the problem, we can identify this as a Graph problem. And in order to find the minimum cost to connect all points, we need to establish the minimum spanning tree.
We can either use Kruskal's or Prim's algorithm. I will go with Prim's algorithm for this solution.

For Prim's algo, we will create a minimum spanning tree by expanding from 1 node, adding new nodes which has the smallest edge and repeat until we reach the final result.
We will need a min heap to keep track of the edge with the smallest distance value.

In the code, you will see a while loop, the condition to break that is either the heap is empty or we already have all nodes marked as visited.



<strong>Solution</strong>
```java
class Solution {
    class Edge {
        int[] p1;
        int[] p2;
        int distance;
        int index1;
        int index2;

        public Edge (int[] p1, int index1, int[] p2, int index2) {
            this.p1 = p1;
            this.p2 = p2;
            this.distance = Math.abs(p1[0] - p2[0]) + Math.abs(p1[1] - p2[1]);
            this.index1 = index1;
            this.index2 = index2;
        }
    }
    
    public int minCostConnectPoints(int[][] points) {
        if (points.length == 1) {
            return 0;
        }
        // Start with any points, add all possible path into a Queue
        // take out the smallest distance in the queue such that one node is in the connected and on is not
        // only add the edges comes after the index

        PriorityQueue<Edge> pq = new PriorityQueue<>((a, b) -> a.distance - b.distance);
        int[] parents = new int[points.length];
        Set<Integer> visited = new HashSet<>();
        Set<Integer> notVisited = new HashSet<>();

        for (int i = 0; i < parents.length; i++) {
            parents[i] = i;
            notVisited.add(i);
        }
        visited.add(0);
        notVisited.remove(0);


        int result = 0;

        for (int i = 1; i < points.length; i++) {
            // create the Edge
            Edge edge = new Edge(points[0], 0, points[i], i);
            pq.add(edge);
        }

        while (!pq.isEmpty() && visited.size() < points.length) {
            // take the first pair
            Edge edge = pq.remove();

            // make sure they do not create a cycle.

            if (visited.contains(edge.index1) && visited.contains(edge.index2)) {
                continue;
            } else {
                result += edge.distance;
                for (int i: notVisited) {
                    Edge newEdge = new Edge(points[edge.index2], edge.index2, points[i], i);
                    pq.add(newEdge);
                }
                visited.add(edge.index2);
                notVisited.remove(edge.index2);
            }
        }

        return result;
    }
}
```
Art of Learning
Tags: beginners, webdev, programming, software
Published: 2023-10-15 17:24:46


Someone who has recently entered the field of computer science may be new to web development, problem solving, dev-ops, AI, and so on. A beginner can become confused about which Udemy course to purchase, which YouTube channel to subscribe to, and which language to learn. And if one day you decide to create your first project or website (mine was personal portfolio), holy cow, you could decide to first become proficient in CSS and HTML before getting started.
Since nobody wants to code while looking like a fool.
And despite of taking a ton of tutorials and courses, you still won't be able to decide what to do or where to begin.

I just started working on my first project, a vanilla portfolio, a few days ago.The most basic ones out there, but guess what? The YouTube tutorial was only 2 hours long, and it took me 3 days to complete it .
I immediately began to go into the self doubt spiral. However, I noticed something very strange: even though I appeared to be an absolute idiot during this, every 10–15 lines of codes later, my mind knew what to do next, commonly known as **Pattern recognition** which is quite important for your programming journey later on.
Is my first project a failure? Of course it's a failure, but as I go on to my next endeavor, I realized one thing: 

_**"You learn to do the job by doing the job"**_

So don't worry, you'll soon be able to do it in two hours, just like your favorite coder did. If you can't figure it out right away, keep going, and even if you don't feel prepared, start.


Coming up next-
**"How should your journey as a Web-dev look like?"**
Store your notes in your browser 😎🔥
Tags: webdev, javascript, html, css
Published: 2023-10-15 17:16:36

Hi Dev's, Today I'll be sharing one of my starter projects when I was learning web development. The one of the most useful tool for everyone which is a Notes app. We all want to store our notes so I just wanted to create a notes app without any backend just frontend. 

Interesting.... hmm...

It now more than 3 years I guess, that time I didn't knew the backend and was just exploring the frontend. Although there are several notes apps, but as a developer I wanted to learn the process and then I thought to create a mini project on this.

This stores your notes on your browser which is completely local, Offers a nice clean UI, Edit & Delete option and other handy features. 

3 years back, That day, I opened my VS Code and created this. [NoteFizz](https://notefizz.netlify.app/)

This is completely mobile friendly as well so you can use it from your mobile browser.

Just Try it out and rate it. What you guys think how it could more useful. 

![NoteFizz desktop image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t718f3sjdd9u9oglihl5.png)

![NoteFizz mobile image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n49gq4lg6x1ziagnrnhf.png)




Let me know in the comments, if any Ideas and suggestions you have. 😎
Neo4j, A Database on Crack 🚬
Tags: database, backend, sql, nosql
Published: 2023-10-15 17:08:37

## Lol What?
It's good. I mean it. You do not have SQL like rigid tables holding your data, foreign keys to map relation. It's not plain key-value pairs like Mongodb, either. Instead, you have this:

![Neo4j Overview](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aofsdiqpb1a491x56wwc.png)

The connecting line is the "Relation" between two objects (or Node), which is a *foreign-key* in sql, or *reference* in Mongodb. But the difference is, you define the relation just as is:

```sql
CREATE (you:Person)-[relation:LEARNING]->(js:Language)
```

## Any Superpowers?
Yes. It's relational, but at the same time free of the rigidity that comes with SQL tables. It's nosql (cypher), but free from the lacking of proper relationship in Mongodb. it's the best of the both worlds.

## Tell me more
Everything is a _Node_. You draw lines to connect them. And that's relationship. This is how a Node looks like:

![Neo4j Node](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t1w9mvkbwtl9c1tvh3ci.png)

This is how you connect these Nodes:


![Neo4j Relation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/286yg186z6wgum4n3zp3.png)


## Why isn't it everywhere?

- Performance sucks compared to Postgres and Mysql.

- Important features like Sharding and Live Backup - are behind a *very* expensive corporate license.

- Their cloud service (Aura) starts at 65$/month. The service was announced in 2021. It's fully managed, and getting good traction.

- No support for querying nested properties/fields like MongoDB. Manually parsing JSON string is the way to go.

## Give it a go

{% embed https://neo4j.com/docs/getting-started/cypher-intro/ %}
A Social Media That Doesn't Use Likes.
Tags: webdev, socialmedia, nextjs, showdev
Published: 2023-10-15 16:50:54

We are all used to all social media having some kind of a like feature. It might have a different name & symbol, but the functionality is the same. I personally don't like any posts on Instagram except my friends pictures, so it doesn't have effect for me. If I had to choose between two pictures & give my like to it, I would make more sense.
![What does this even mean?](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vv3zx6xkoj1q54v6pqk4.png)
 What does it even tell you, that a post has 5 thousand likes? That 5 thousand people like it? I don't think so.
I won't go into the issue of fake likes, even if all the likes were from real people it has little actual value.

When I discovered that almost social media sites use the same *like* feature I decided to build a social media site that simply wouldn't. 

So how? I could simply just not put the like button there and make it something like 4chan, but that misses the point. I want users to have express their opinion.
This excludes other ways to represent the level of engagement like stars or rating out of ten. 
What I though about is Tinder, the user action there is forced, thus becomes something like scrolling. But if the user *had* to choose between liking and disliking a post every post would have little dislikes since you don't have any reason to dislike a random post, so you just like it. This wouldn't work for simple posts and it's very iffy if it actually works on the before mentioned Tinder. 

![Tinder](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nn5v3wknt5h0wqd4gwkv.jpg)
The answer is choosing. The user gets displayed two images at once and they simply have to choose between one of them. The one they choose gets the point (like). Bad posts get a small amount of likes, good ones don't. This is a better system than the one other sites use. 

![Swipchoose screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/97rhbvc71f2ejvfvzo1q.png)
One possible problem of this system might be that the user uses their brain while using the site. Since they are thinking about which posts they like more they start thinking about other things: "Do I have something better to do?". This stops the dopamine feed and our brain activity monopoly is stopped.

![One more video](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/13lxfp33cclkmpgrtc7c.GIF)
But this site isn't the first one like this, for example *BeReal* already explicitly focuses on specifically this.

If you want to try the site out, it is here:
[Swipechoose](https://swipechoose.netlify.app/) 

I also made a quick Youtube video on this topic:
[Swipechoose video](https://www.youtube.com/watch?v=gdsBhg_c1Xg)

The code of the site is here:
[Github](https://github.com/divear/swipechoose-site)
Roadmap to master Data structures and Algorithms
Tags: programming, development, algorithms
Published: 2023-10-15 16:50:47

Data structures is one of the most important thing to master in order to crack job interviews and land a dream job in FANG. So this post will give a roadmap in order to master it from an experienced perspective.

## **Roadmap to master Data Structures and algorithms**
**1 Learn a programming language basics:**
     First you need to select a programming language according to your interest and choice. For example: learn JavaScript if you are interested in webdevelopment, learn python for machine learning, learn C++ for competitive programming, etc.
I would like to recommend an object oriented programming language 
to learn in the beginning. I will specifically recommend python which you can by comparing top courses on [Pacificmultiverse](https://pacificmultiverse.com/?s=python&post_type=product&type_aws=true)

**2 Learn the important data structures**
     The important data structures to focus on are:
1. Array: It is a collection of similar data types in a list form
2. String: It is an array used to store character data type
3. Linked list: List where pointers are used to point towards stored data.
4. Stack: Linear data structure which follows last in first out. 
5. Queue: Linear data structure which follows first in first out. 
6. Tree: Here data is stored in form of node.
7. Graph: Here data is represented in form of vertices and edges.

**3 Learn the important algorithms**
     The important algorithms I will recommend are:
1.Linear search: This algorithm starts from one end and ends at the other. 
2.Bubble sort: It works by repeatedly swapping the adjacent elements if not in the right order. 
3.Divide and conquer: Divide and Conquer is an algorithmic paradigm in which the problem is solved using the Divide, Conquer, and Combine strategy.
4.Breadth first search: It is used to search in graph structure.
5.Tree algorithms

**4 Learn time and space factors of code**
     Learn the Big-O Notation (Ο) which describes the worst case of the code's working. The factors are:
1.Time: It is used to see the execution speed of time
2.Space: It is used to measure the space consumption of the code.
These complexities are used to measure the time and space efficiencies of the code.

**5 Solve coding problems in various sites**
     There is a need to practice problems in order to master these concepts. For example one can use the practice sets in [Geekforgeeks site](https://practice.geeksforgeeks.org/explore?page=1&sortBy=submissions&itm_source=geeksforgeeks&itm_medium=main_header&itm_campaign=practice_header). There are many other sites like [Project Euler](https://projecteuler.net/), [Leetcode](https://leetcode.com/), etc. Choose the right one according to your coding comfort and their user interface.
Enable Mac Like 3 Finger / 4 Finger Touchpad Gesture on Linux Mint
Tags: linux
Published: 2023-10-15 16:47:11

If you're a Linux Mint user and you've always envied the smooth touchpad gestures available on Mac, you're in luck. With the help of a few simple commands, you can enable Mac-like touchpad gestures on your Linux Mint system. In this step-by-step guide, I'll walk you through the process. Let's get started:

**Step 1: Grant Input Permission**
```
sudo gpasswd -a $USER input
```

**Step 2: Install Required Packages**
```
sudo apt install python3 python3-setuptools xdotool python3-gi libinput-tools python-gobject
```

**Step 3: Install libinput-tools**
```
sudo apt-get install libinput-tools
```

**Step 4: Restart Your Computer**
It's essential to restart your computer after installing the packages to ensure everything takes effect.

⚠️ You have to restart your computer ⚠️

**Step 5: Clone libinput-gestures Repository**
```
git clone https://github.com/bulletmark/libinput-gestures.git
```

**Step 6: Navigate to the Cloned Repository**
```
cd libinput-gestures
```

**Step 7: Run the Installation Script**
```
sudo ./libinput-gestures-setup install
```

**Step 8: Autostart libinput-gestures**
```
libinput-gestures-setup autostart start
```

**Step 9: Return to the Parent Directory**
```
cd ..
```

**Step 10: Clone the gestures Repository**
```
git clone https://gitlab.com/cunidev/gestures.git
```

**Step 11: Navigate to the Cloned gestures Repository**
```
cd gestures
```

**Step 12: Check Out a Specific Commit (e46c743a)**
```
git checkout e46c743a
```

**Step 13: Install gestures**
```
sudo python3 setup.py install
```

**Step 14: Return to the Parent Directory**
```
cd ..
```
**Step 15: Create a Configuration File**
```
cd .config
```
```
touch libinput-gestures.conf
```
```
nano libinput-gestures.conf
```

**Step 16: Paste the following code into Configuration File**
```
# Generated by Gestures 0.2.2  -->  https://gitlab.com/cunidev/gestures
# Manual editing might result in data loss!


# Invalid lines


# Unsupported lines

# Swipe threshold (0-100)
swipe_threshold 0

# Gestures
gesture swipe up 3 xdotool key 0xffe3+0xFFEA+0xFF54
gesture swipe down 3 xdotool key super+d
gesture swipe left 3 xdotool keyup 0xffea
gesture swipe right 3 xdotool keydown 0xffea  + key 0xff09
gesture swipe up 4 xdotool key  0xffea+m
gesture swipe down 4 xdotool key  0xffe9+0xffc1
gesture swipe left 4 xdotool key  super+0xff51
gesture swipe right 4 xdotool key  super+0xff53
gesture pinch out 2 xdotool key  0xffe3+0x002b
gesture pinch in 2 xdotool key  0xffe3+0x002d
```

**Step 17: Save and Exit from `nano`**
`Ctrl + o -> Enter Key -> Ctrl + x`

**Final Step: Open Gestures**

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



For a list of xdotool key codes for more customized experience, you can refer to this link: https://gitlab.com/cunidev/gestures/-/wikis/xdotool-list-of-key-codes
Squashing and Amending Git Commits- OSD600/LAB-5
Published: 2023-10-15 16:43:12

In the LAB 5, we are discussing about git rebase, git amend and new modification to the code by the 3 changes

- We started our journey by improving the variable name in the Text2page.py code in this first commit. A key component of maintainable and effective programming is the use of clear, descriptive variable names: **Improved variable name for the Text2page.py function (Commit 1)**

- We got into the specifics of refactoring in the second commit. Markdown material and special characters can be handled by the HTML production code with ease. In addition, as a crucial first step in project improvement, we eliminated superfluous TOML settings and enhanced our file type handling: **Commit 2: The HTML generation was refactored to properly handle special characters and Markdown text. eliminated extraneous TOML settings. updated code for improved handling of file types.**

- Version control was emphasized in the third commit. The handling of tool versions was made simpler by removing the global VERSION variable and carefully positioning the tool version within the main function: **Commit 3: Display the tool version in the main function and remove the global VERSION variable.**

We used rebase to organize several commits into a more logical and seamless sequence as we progressed through the experiment. We were able to restructure our work using rebasing, bringing the core of many contributions together into a single, complete unit. This simplifying improves the transparency of our code's growth while also making the commit history simpler. When we recognized the value of concise commit statements, the technique of revising commits became clear. Collaboration in open source development depends on concise and informative commit messages. We improved and updated earlier commit messages using the "amend" functionality to make sure that each commit not only represented code changes but also clearly communicated the nature and context of the work done.