teleren/devto huggingface dataset:
Making The Earth Greener With Project Gaia
Tags: atlashackathon
Published: 2022-01-13 22:53:49

### Overview

The Gaia project aims to help in the fight against global warming and deteriorating climate conditions; to help make the world "greener" and safer, by making it easier to engage "green" projects and foster growth for every project. 

The platform aggregates a list of projects directly involved with making a Earth "greener", and allows users to donate to the cause of a project that they find interesting or believe in.

![Gaia projects section](https://imgur.com/sm5b29M.png)

NGOs and other organisations with "green" projects can apply to create an account on Gaia, and raise the funding that they need to complete their project(s) in due time. This way we can help raise awareness about climate change, and make it easier for the average individual to be involved.

### How We Built Gaia
We wanted Gaia to be user friendly, and easily accessible so some design considerations had to be taken into account from the beginning, before we even started writing code. 

- Once we had a user-interface we all agreed with, work commenced on the frontend interface for which the ReactJs web framwork was used.

<br>

- The backend was written in python using the Flask web framework.

<br>

- User data, and projects' information were stored on a serverless instance via MongoDB atlas. We employed the use of MongoDB's very famous python client library (with its rich documentation) - "PyMongo" to interact with the serverless instance of the MongoDB database. For example, with PyMongo, we could "seed" data into the database instance as follows:

```python
projects = []
for card in cards_:
    project_url = requests.get(card.find('h3').find('a')['href']).text
    project_page = BeautifulSoup(project_url, 'html.parser')
    try:
        obj_ = {
            '_id':str(uuid.uuid4()),
            'project_headline': project_page.find('main').find('p').string,
            'paypal_value': card.find('form').find('input', attrs={'name': 'hosted_button_id'})['value'],
            "project_url": card.find('h3').find('a')['href'],
            "name": card.find('h3').find('a').string,
            "image_url": card.find('img')['src'],
            "paypal_url": card.find('form').get_attribute_list('action')[0]
        }
        db.project.insert_one(obj_)
        projects.append(obj_)
    except Exception:
        print(card, end="Has issue!")
```

### Submission Category: 

"Custom Adventure"


### Link to Code
- UI (Figma): https://www.figma.com/file/iBKIwWJ7O4NObpr5vNo4Rj/Project-Gaia

- Backend: https://github.com/Curiouspaul1/Gaia

- Frontend: https://github.com/Iamsheye/gaia

### Screenshots/demo
- Live URL: https://project-gaia.vercel.app

![Gaia project page](https://imgur.com/pmRDEWf.png)

<br><br>

![Gaia projects section](https://imgur.com/sm5b29M.png)

<br>

### Collaborators
- @chinaza0413 
- @iamsheye
Leetcode 174 Dungeon Game
Published: 2022-01-14 02:55:37

```java
import queue
from typing import List


class Solution:
    def calculateMinimumHP(self, dungeon: List[List[int]]) -> int:
        # M and N are dimensions of the dungeon
        M = len(dungeon)
        N = len(dungeon[0])
        # create a dp matrix for dungeon
        dp = [[0]*N for _ in range(M)]
        # from right-bot to left-top
        for i in range(M-1, -1, -1):
            for j in range(N-1, -1, -1):
                if i == M-1 and j == N-1:
                    # at (M-1, N-1) you at least need 1 hp left
                    dp[M - 1][N - 1] = 1
                elif i == M-1 and j != N-1:
                    # at (M-1, j) you need at least 1 hp to be alive, and you need prepare at least
                    # dp[i][j+1] - dungeon[i][j+1] hp to go right cell
                    dp[M-1][j] = max(1, dp[i][j+1] - dungeon[i][j+1])
                elif i != M-1 and j == N-1:
                    # at (i, N-1) you need at least 1 hp to be alive, and you need prepare at least
                    # dp[i+1][j] - dungeon[i+1][j] hp to go bot cell
                    dp[i][j] = max(1, dp[i+1][j] - dungeon[i+1][j])
                else:
                    # at (i, j) upi need at least dp[i + 1][j] - dungeon[i + 1][j] hp to go bot cell and 
                    # dp[i][j+1] - dungeon[i][j+1] hp to go right cell. Also at cell (i, j) you need at least 1 hp.
                    dp[i][j] = max(1, min(dp[i + 1][j] - dungeon[i + 1][j], dp[i][j+1] - dungeon[i][j+1]))
        # you must go through (0, 0) cell, which is not calculated above.
        return max(1, dp[0][0] - dungeon[0][0])

```
Leetcode 453 Minimum Moves to Equal Array Elements

Published: 2022-01-14 02:54:16

```python
class Solution:
    def minMoves(self, nums: List[int]) -> int:
        return sum(nums) - len(nums) * min(nums)
```
To understand this, we just think move is 1. add 1 to every element in the array, 2. minus 1 to a specific element
For example, To remove difference of [99, 98, 97, 96],
we only need to remove difference of [3,2,1,0]
and every move operation is "minus 1 to a specific element"
So to remove the difference, we need 3+2+1 operations
Leetcode 81 Search in Rotated Sorted Array II
Published: 2022-01-14 02:53:07

```java
import java.util.Arrays;

class Solution {
    public boolean search(int[] nums, int target) {
        return search(nums, target, 0, nums.length-1);
    }
    private boolean search(int[] nums, int target, int l, int r){
        if( l <= r){
            // here we start as a regular binary search
            int mid = (r-l)/2 + l;
            //if target equals to mid/left/right, return true
            // to avoid collision (e.g. difference of target < nums and target <= nums)
            // we do it for l, mid, and r
            if(target == nums[mid] || target == nums[l] || target == nums[r]){
                return true;
            }
            //here is if there is a rotation in this array/subarray, we call it "twisted" 
            if(nums[r]>nums[l]){ // if nums[r] > nums[l], nums[l:r] is not a twisted array 
                if(nums[l] <= target && target <= nums[r]){ // if target in this array, do normal binary search
                    if(target == nums[mid]){
                        return true;
                    }else if(target < nums[mid]){ 
                        return search(nums, target, l, mid-1);
                    }else{
                        return search(nums, target, mid+1, r);
                    }
                }
            //here are cases for twisted array  
            }else if(nums[mid] == nums[l]){ // if mid and l are the same, we cannot know whether the left is twisted or the right is twisted
                                            // For example, [1,1,1,2,1] has a twisted array at right and [1,2,1,1,1] has a twisted array at left
                                            // But they all satisfy nums[mid] == nums[l]
                                            // Here we can only do O(n) search.
                return search(nums, target, l, mid-1)||search(nums, target, mid+1, r);
            }
            else if(nums[mid] > nums[l]){//if nums[mid] > nums[l], at least left subarray is not twisted array
                if(nums[l]<target && target<nums[mid]){ // if target is at left
                    return search(nums, target, l,mid-1);
                }else{  //else
                    return search(nums, target, mid+1,r);
                }
            }else{//if nums[mid] > nums[l], at least right subarray is not twisted array
                if(nums[mid] < target && target < nums[r]){//if target is at right
                    return search(nums, target, mid+1, r); 
                }else{//else
                    return search(nums, target, l, mid-1);
                }
            }
        }
        return false;
    }

    public static void main(String[] args) {
        int[] nums = {1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1};
        System.out.println(new Solution().search(nums, 2));
    }
}
```
How stupid is Matlab function?
Tags: matlab, programming
Published: 2022-01-14 02:52:24

## Function definition in a script

### Python 
Filename: `the_amazing_file.py`
```python
def returnTrue():
    return True

print(returnTrue())
```

Here you define the function first, then call it. It's like how you do math with paper. You write down the formula, then you apply it.

### Matlab 

![Matlab motto](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5o5wpvg951hp6tkzhgfs.png)

So the language for math, the function should be defined first right?

Yeah no. 

Filename: `the_amazing_file.m`
```matlab
disp(returnTrue());

function y = returnTrue()
    y = true;
end
```

Seriously matlab, are you for math?

## Calling non-parameter function

Let say you have a function `foo()` which doesn't have parameters

```matlab
bar = foo() 
bar = foo
% Both are equivalent. 
```

But `foo()` and `foo` mean two different things. `foo()` means calling a function. `foo` means "I'm a variable". If you use Python, it's [passing functions as an argument](https://www.geeksforgeeks.org/passing-function-as-an-argument-in-python/). If you use C, it's [function pointer](https://www.geeksforgeeks.org/function-pointer-in-c/).

## Passing functions as argument vs Defining anonymous functions

Alright how to pass function as an argument in matlab? You use `@` I copied this example from [matlab function **doc**](https://www.mathworks.com/help/matlab/ref/function.html)
```matlab
% Compute the value of the integrand at 2*pi/3.
x = 2*pi/3;
y = myIntegrand(x)

% Compute the area under the curve from 0 to pi.
xmin = 0;
xmax = pi;
f = @myIntegrand;
a = integral(f,xmin,xmax)

function y = myIntegrand(x)
    y = sin(x).^3;
end
```

Guess what else use `@`? Anonymous functions
```matlab
sqr = @(x) x.^2;
```

If you look at the way anonymous function is defined and look at how non-parameter function (previous section), you may ask the following line 
```matlab
bar = foo;
```
could mean anything right? Yeah it could mean:
- calling a function without parameters
- assigning anonymous function to different variable.

The more confusing, the more we analyse.

Now you may argue, "I know my functions". Yeah but can you remember **other people** functions when reading a long file while trying to understand what it does? Can you?
Lovenotes - MongoDB Hackathon Submission
Tags: atlashackathon
Published: 2022-01-14 02:41:58

### Overview of My Submission

This project is my entry for the MongoDB hackathon. It's a fairly simple idea i came up with while thinking of the day of love coming up soon #Feb14 :D.

This project allows for lovers to openly declare their affections for and to each other. It uses MongoDB Atlas to save the data and mongodb native drivers to read the data.

Basically, a new love note is created by a user and sent to another. The love note is then automatically deleted thereafter.

- This is a React app project hosted on [Vercel](vercel.app)
- The design was created using Chakra UI
- This project was created with create react app
- The project uses Node.js native drivers for MongoDB
- The source code is hosted on github at [elcharitas/mongodb-hackathon](https://github.com/elcharitas/mongodb-hackathon)

### Submission Category: Choose Your Own Adventure

### Link to Code
{% github elcharitas/mongodb-hackathon %}

### Additional Resources / Info

Demo can be found here: https://mongodb-hackathon.vercel.app

#### Screenshots

![Home](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6g09ouhqm55pnnspn2fq.png)
![Create Note](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/419idptdrfah9io5ycnq.png)
New Year's Resolution - Dev Log 1
Tags: webdev, beginners, programming, computerscience
Published: 2022-01-14 02:36:30

`const disclaimer = () => {
    console.log("This is a quick dev log to get this blog caught up to my Reddit Posts")
}`

Basically, my new year's resolution is to create one or multiple websites that give me enough income per month to not need a job. The last dev log was a lot of background, this one is more focused on what I am actually doing in order to achieve my goal. This is a picture of the original post of Reddit:

![Reddit Post this blog is based off of](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/739ww2n8ie9yh4vxz7xq.PNG)
Those using screen readers fear not! Here is the rundown:

> Idea 1 - Job Board: I had started coding this back in December. Coded for a couple more hours today on it, got most of the UI done for the MVP. While I am not a great coder, I would be lying if I said I was not proud of it so far, the code could definitely be cleaner but I am having a good time so far. The last thing I need to finish on the UI is making the post a job page, which I am thinking of just making into a modal.

> Idea 2 - Paid Plugins: Currently in the research phase of this idea, I have been seeing a lot of people saying that WordPress plugins are the way to go. I personally do not see myself going this route, it seems pretty far from the workflows I am used to. Might decide to scrap this idea and continue with others.

> Idea 3 - SaaS: An obvious route to go for great monthly income. Currently thinking that this is the next move after I finish my Job Board and have time to code something else while doing more business/marketing work on the job board. Still trying to find a market/idea for the SaaS application.

> On a personal note, still excited to be productive and hopeful that on December 31st, 2022, I will make enough money from my own web applications that a job is not necessary (not that I could land one anyway lol).
コントローラでDictionary型のGETパラメータを受け取る
Tags: aspnet, csharp
Published: 2022-01-14 02:29:49

コントローラのアクションでDictionary型のGETパラメータを受け取るには、以下のようなフォーマットでパラメータを記述します。

```
https://example.com/api/Sample/SampleData?param[key1]=val1&param[key2]=val2&...
```

上記のリクエストを投げると、アクションで定義した`param`引数で以下のように値を受け取ることができます。

```csharp
[Route("api/[controller]")]
public class SampleController : Controller
{
    [HttpGet("[action]")]
    public Data SampleData(Dictionary<string, string> param)
    {
        var val1 = param["key1"];
        var val2 = param["key2"];
        return ...;
    }
}
```

## 注意点
先ほどの例で`param`パラメータ無しのリクエストを投げるとアクションが見つからずエラーが発生します。

```text:NG
https://example.com/api/Sample/SampleData
=> 500 Error
```

空のディクショナリを渡すには、以下のような値無しの`param`パラメータ付きのリクエストを投げる必要があります。

```text:OK
https://example.com/api/Sample/SampleData?param
```

```csharp
[HttpGet("[action]")]
public InitData Init(Dictionary<string, string> param)
{
    var _ = param.Count; // => 0
    return ...;
}
```

## 参考
- [c# - Is it possible to get Dictionary from query string? - Stack Overflow](https://stackoverflow.com/questions/22707788/is-it-possible-to-get-dictionary-from-query-string)
My Daily Reads - Tailored dev content delivered to your inbox.
Tags: atlashackathon, mongodb, javascript
Published: 2022-01-14 02:28:19

---
title: My Daily Reads - Tailored dev content delivered to your inbox.
published: true
description: My submission to the MongoDB Atlas Hackathon on DEV!
tags: atlashackathon, mongodb, javascript
// cover_image_old: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s4a14i69p05pp42jk4by.png
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wq3n1nfv6bbsvzi4kh0s.png
---

[Instructions]: # (To submit to the MongoDB Atlas Hackathon on DEV, please fill out all sections.)


### Overview of My Submission

I've enjoyed using Dev over the years and have learnt quite a lot here through the many invaluable submissions made by this wonderful community.

Over the last couple of months going through Dev to look for content that might interest me has felt like a toiling task with lots of content to choose from, titles of all kinds, with a limited time budget due to some other responsibilities of mine and at times I felt overloaded just going through the titles not knowing what to read that might be of value.

I thought that since this has been my experience there might have been some others that might have felt the same and this hackathon just felt like the right opportunity to automate this daily task while also giving me a first time experience to participate in a hackathon. 

**My Daily Reads** is a tool that compiles latest articles from developer content sites (currently only Dev, Hashnode content to be added) and delivers 5 titles in your inbox tailored to you.
Users provide their name, email and two keywords (e.g `javascript, rust`) on the My Daily Reads website and afterwards they'll start receiving 5 dev content tailored to the provided keywords.


### Submission Category: 

Automation Innovation


### Link to Code

{% github xinnks/my-daily-reads %}

**Live URL** - [My Daily Reads](https://my-daily-reads.netlify.app)


### Additional Resources / Info

- All data is stored on a [MongoDB Atlas Serverless](https://docs.atlas.mongodb.com/tutorial/create-new-serverless-instance/) database.
- Vue as the front-end framework.
- Hosted on [Netlify](https://www.netlify.com) with Netlify Serveless Functions as the back-end.
- Styling is done with the assistance of [tailwindcss](https://github.com/tailwindlabs/tailwindcss).
- Email layouts are inspired by [konsav/email-templates](https://github.com/konsav/email-templates)
- Emails are delivered via [Mailjet](https://github.com/mailjet)
- Data fetched from the [The DEV API](https://developers.forem.com/api)
- Content analyzed with the assistance of [cheerio](https://github.com/cheeriojs/cheerio).

### Screenshots

Home Page

![Home Page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n9l6w8hctgo9po4qchjp.jpg)
Smaisle - An Easier Way to Shop for Groceries
Tags: react, atlashackathon
Published: 2022-01-14 02:16:52

### Overview of My Submission
With everything that's going on in the world we don't have time to spend browsing in grocery stores for hours (and if you're like me, I go back and forth while I'm shopping because I never know where anything is). Smaisle is a simple website that helps users create their grocery list, and then helps them find the items in the store by section or aisle.
I am brand new to using MongoDB and pretty new to developing using React, so this project helped me learn lots! In MongoDB I used the Atlas Search capabilities for assisting users to find what they're looking for, as well as the RealmSDK to make database calls from within the website.

### Submission Category: 
I think this project would fall under the Choose your own adventure category.


### Link to Code

`https://github.com/scotthladun/smaisle`

### Demo
[Smaisle - Demo](https://main.d20jdf4o270eh5.amplifyapp.com/)
[Note] It is not mobile friendly at the moment

### Potential Future Features

**Browse and Compare Multiple Stores**
Right now users are only able to view the scraped data that I uploaded to the database from one grocery store. A potential update could be comparing prices and products from a variety of different stores in the user's area.

**Crowdsourcing Aisle Data**
Data on the aisles that products are kept in is not available online, and varies from store to store. It would be cool if users could scan a barcode of a product and update the location of it within a specific store to help others out.

### Additional Resources / Info

![Screenshot of the Homepage](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z8rxqhztp7i0ott1w7dz.png)

![Screenshot of the Product Page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t8pka5fs51tw2q4mldbq.png)


![Screenshot of User's List](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/izqddku3ul9gnbhdfz06.png)


**Thank you so much for taking the time to read my post!**
MongoDB #atlashackathon Submission and my first DEV post!
Tags: atlashackathon
Published: 2022-01-14 02:13:43

[Instructions]: # (To submit to the MongoDB Atlas Hackathon on DEV, please fill out all sections.)


### Overview of My Submission
Holla,
This is Dwaipayan here. I have created this app (Bib-Builder) as part of **MongoDB Atlas Hackathon on DEV, 2021-22 edition**.
Being involved in academic research, I have found that maintaining a bibliography becomes a real pain.
https://citation.crosscite.org/ has been a reliable companion ever since. So given the chance, I thought of an idea where we can leverage this wonderful resource along with maintaining a solid bibliography for the current project we get to work on.
This is a very initial draft and I wish to continue contributing to this project going forward.
By the way, though I am an avid follower of DEV articles, **this is my first DEV post!**


### Submission Category: 

Choose Your Own Adventure


### Link to Code

`{% github https://github.com/DiySane/bib-builder %}


### Additional Resources / Info

Here is a demo (without audio):
{% youtube https://youtu.be/MmTjnuJwm9o %}
Metro Rail Path Finder
Tags: atlashackathon
Published: 2022-01-13 22:53:26

[Instructions]: # (To submit to the MongoDB Atlas Hackathon on DEV, please fill out all sections.)


### Overview of My Submission
I made an **Express application which basically calculates the path from one station to another in a particular city's Metro rail map.**

It connects to the database on Mongodb Atlas. My database has collections based on maps of different cities.
The express app passes the User-preferences over to functions that query the database to find the route.

**The app is very easily scalable**, as to add a map, one only has to add a new collection in the database (containing Station names etc) and one option in the "Map Select" drop-down.
Everything else, including the functions and the drop-downs are designed to get updates from the database itself.

Here is the link to my [Github repository](https://github.com/mr-loop-1/metro-path-mongodb/).


### Submission Category: 

Choose Your Own Adventure


### Link to Code

{% github https://github.com/mr-loop-1/metro-path-mongodb/ %}

### Screenshots


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


![ss](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t9pwusvwamp7mqwr2m08.png)


### Additional Resources / Info

Technology Used: Express, Mongodb, Atlas
Contact: iabdulsamad1412@gmail.com
Build a social network app with ReactJS, Spring Boot and MongoDB
Tags: react, java, webdev
Published: 2022-01-14 02:07:30

I have developed a small social network web app for educational purpose and want to share this with the community. This app is built with ReactJS for frontend, Java Spring Boot for backend and MongoDB as the database.

The app tries to mimic a few functions of Twitter, including:

- Create post with text and image
- The number of characters in each post is limited to 200 characters
- Like, comment and re-post a post
- View the number of likes, comments and shares of a post
- Comments are toggle
- The number of character in each comment is limited to 100 characters
- Follow, un-follow someone
- See who are following us and follow them back
- Check who we are following
- View all posts of an individual
- View our own posts
- List all user accounts in the entire social network (due to the number of users are still small, I did not develop search user function)

Other functions:

- Due to limited storage space, client app compresses the uploaded image to the maximum of 250px (width or height)
- User avatar is created by hashing user id and convert that hash code into a hexagonal image
- Authentication and authorization use JWT
- Responsive frontend for desktop and mobile devices

Technical stack:

- Frontend: ReactJS, Redux Toolkit, React Router, React Bootstrap
- Backend: Java Spring Boot
- Database: MongoDB

If this project is useful for you , please give me a Github star ⭐ for my effort!

Source Code:
https://github.com/linhtch90/psn-social-network-public-source

Live Demo:
https://psn-social-network.herokuapp.com/#/