teleren/devto huggingface dataset:
What Is Java?
Tags: java, programming
Published: 2020-11-09 17:38:41

In this tutorial, we will study <a href="https://usemynotes.com/what-is-java/">What is Java</a> and The features of java programming language and more.

Java, safe to say, is the most used programming language of this century. Probably, you can read this blog on this webpage because Java exists. It is the building block of almost all the modern IT applications we see around us these days. Perhaps the reason behind its popularity is its robust performance and comparatively easier to code programming language. Java is a multi-threaded secure language that helps the developer to create applications ranging from Banking to every sector you can probably think of or consider. Also, when it comes to processing a large pile of data, Java gets the job done with ease. 

The write once, run anywhere programming language has come a long way since its inception under the development by Sun Micro systems. It is quite similar to C, but on the other hand, easier than it. Java also goes well when combined with Node JS, Android, spring in line to develop a large-scale application that is bound to perform.

<h2>Where Is Java Used?</h2>
The application of Java is widespread. As said earlier, almost all the IT applications we depend on today, in turn, depends on some great codes written on Java to function optimally. 

Some of the most used application of Java are:

Development of Web Application: Java is the most go-to programming language when it comes to developing an ideal web application. So be it an eCommerce website or a streaming service platform you are looking to build, Java will surely come ideally helpful for you. 

Development of Android Application: Almost most of us are already aware of the fact that most of the mobile applications we use these days are developed on Java; thus it is another place where the programming language prospers brightly.

Other Sectors: Apart from only application development with Java, recent times are also witnessing Data scientists using the programming language to analyze large data sets. Additionally, the development of many essential software tools greatly depends on Java.

<h3>Strengths of Java</h3>
1. It comes for FREE; Java's greatest strength is that it comes for free to the developers. 

2. Java also comes with an open-source library giving developers the upper hand of better application creation. 

3. Java has an object-oriented approach that allows the developers to create new programs by simply reusing the codes. 

4. The learning curve of Java is also on the shorter side, making it much easier to debug, compile, and code with it. 

5. Java opens up the possibility for developers to access any API for their respective purposes. 

6. Java also has a wide variety of open-source development, giving developers more options to create.

<h3>Top Companies Using Java</h3>
Some of the top companies to implement Java for their development purposes are:

1. GitHub

2. Dzone

3. Stack Overflow

4. Leetcode

5. Coursera
Simple Filtering in DRF.
Tags: django, rest, python
Published: 2020-11-09 17:17:44

## Filtering
- The basic way to filter is by overwriting the `get_queryset` method of Generic Views.
> Note that Viewsets also have the generic view.
- Take a look at this example:
```python
class PurchaseList(generics.ListAPIView):
    serializer_class = PurchaseSerializer

    def get_queryset(self):
        """
        Request obj.: self.request
        How to get that parameters of get request.        
        1. username = self.kwargs['username']
        2. username = self.request.query_params.get('username', None)
        """
        username = self.request.query_params.get('username', None)
        return Purchase.objects.filter(purchaser__username=username)

```

## Search Filter Class
- Location: `form rest_framework.filters import SearchFilter`
```python
from rest_framework import filters

class UserListView(generics.ListAPIView):
    queryset = User.objects.all()
    serializer_class = UserSerializer
    filter_backends = [filters.SearchFilter]
    search_fields = ['username', 'email']
```
- When you make queries like: `http://example.com/api/users?search=russell`
- Then our view will try to `username` and `email` match with `russell`. 
- If you use ['=username'] then it'll try to match exact result.
- If you use ['^username'] then it'll try to match the results which starts with the given query.
A Gemini Client in Rust - 13 Conclusion
Tags: rust, tutorial, gemini
Published: 2020-11-09 17:13:50

Hello! We are now on our final chapter! We aren't going to be doing anything here so settle in and relax. We'll just go over the tutorial and go over some of my thoughts about it.

Thanks for sticking with me!

### Thoughts on the Gemini Client

We now have a very basic Gemini client and we can traverse Gemini space easily. We also now know exactly how our client works so when we run into something we don't like in it's behavior, we can fix it! This is a powerful ability.

Surprisingly I ended up with around 550 lines of code for the Gemini client and about 500 lines of code for the Gopher client. I had expected the difference to be larger. I thought the Gemini client was much harder, dealing with TLS, parsing Gemini pages and handling the statuses was all cognitively harder to get a hold on but the code count doesn't seem to show that. Gemini is a more complex protocol than Gopher but it is still relatively simple. You can definitely hold the entire spec in your head!

The hardest part of Gemini was indeed the TLS logic, it was likely because we used rust and rustls that it took longer than I thought it would. I'm curious how other languages and crates deal with TLS and if maybe I had made it more difficult for myself.

One thing I wish I did was to handle mime types earlier. Full disclosure, I had forgotten the mime types! If it was earlier I think I could have found a better place to handle them, currently it is a bit of hack. We do our processing in the visit function and then send back a message via the response.body. I don't like reusing parts of an object to send back messages. That isn't what that part of the object was intended for.

Some enhancement ideas, feel free to leave your own below as well!

- Support for arrow keys to go through a command history
- Command completion
- Different colours for valid and invalid commands
- Ability to follow a link and then when we do cd .. to go back, to have the page display from where we left off. 
- Display location in the prompt
- Word wrapping. I really like Gopher's 80 character style. 
- Instead of showing the next page, allow use for arrow keys for line by line

Making the Gopher client and the Gemini client was fun, the Gopher client was done in a weekend, the Gemini client I would say would take 2 weekends, maybe 3 if you run into problems with TLS. 

I still like Gopher more, the idea of everything being part of the filesystem I resonate with whereas Gemini feels a little too web like. But I need to give Gemini more of a chance.

I am enjoying working with Rust, and I think string handling and pattern matching I have a light handle on. File IO is straightforward and even web scraping is doable. It's not as intuitive as python or javascript but I think more time spent with rust as a primary language could be good.

Thank you for reading!
A Gemini Client in Rust - 11 Saving Gemini Pages
Tags: rust, tutorial, gemini
Published: 2020-11-09 17:13:29

Hello! Our journey is coming to an end! We are almost done now and I hope you'll build on our client as you use it. I think there is something very powerful about being able to modify your software to fit your very specific needs.

One such need for myself is to e-mail what I find in Gemini space. I can't exactly give someone a URL! So in this chapter we will implement a save function that will simply save the current page to a text file. If we wanted to get fancy, we could have the mailing happen right in our client!

### Saving a Gemini Page

``` rust
...
            "save" => {
                if cache.len() > 0 {
                    let page = cache.last().unwrap();
                    let file_name = format!("/home/nivethan/gemini/{}.txt", 
                        page.url.request().trim().replace("/", "-"));
                    let mut f = File::create(&file_name).unwrap();
                    for line in &page.lines {
                        writeln!(f, "{}", line).unwrap();
                    }
                    println!("Saved {}!", file_name);

                } else {
                    println!("Nothing to save.");
                }
            },
...
```

Here we have a very simple function to save the current page we're on. We get the page we're on from the cache and we create a file naming it the page's url (thought with the / replaced with -). We then write out the lines of the Gemini page into our newly created file.

Once again, you'll need to make sure the path exists!

Now that we have our client working the way we want it to, we still have one glaring piece we need to sort out. We have currently hard coded the mime types to be text/gemini. We did all our page processing and caching logic on that premise which may not always be true!

Let's fix that!
My First three month as a Machine Learning Engineer
Published: 2020-11-09 17:12:21

It's been about three months since I'm working as an MLE. The most frequent question I've been asked is that I don't have any ML research, how I am working! This is true that I've been working as an SWE since early 2019 and I have research in a distributed system for the automotive industry and yet not published! What I experienced in these three months is there is a good borderline between MLE and ML researchers. and obviously MLE vs SWE.

Firstly in SWE, everything is practical, you get immediate feedback on everything you do, It may be good or bad  ! whereas MLE is extremely ambiguous. The problem might be in data cleaning, hyperparameters tuning, wrong models selection, or even wrong data for training, etc.


Secondly, ML researcher are smart people who can build interesting models, insights, predictions and also use some libraries on the other hand  MLE can write maintainable, sustainable code, efficient way to store the data, and deploy the models so that it can be accessed from almost every machine and at the same time should understand the models, basic understanding of the maths behind the model.

These are my experience, correct me if I am wrong. One thing I mentioned first about academic research or advance higher degree. To some extent, I think it will be beneficial to do Msc in applied mathematics or specialization in ML if an experienced MLE wants to pursue more.
LEGB Rule for Python Scope
Tags: python, legb, scope
Published: 2020-11-09 16:53:46

Though I have coded in Python for pretty long time, the concept of **scopes** in Python is still a little unclear for me. Today, I studied a little bit the scopes in Python. To better illustrate what I've understood, I drew a sketch as shown below.  
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/qnjej0u6cvxdivuq85fw.png)


The 4 letters in LEGB stand for **Local**, **Enclosing**, **Global**, and **Built-in**. Python interpreter shall look up a variable content sequentially in following order: local -> enclosing -> global -> built-in.  

Below are some snapshots of my tests:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/zlmdzlo0vnmizbetp3i5.png)


refrence of this post:
1. [https://realpython.com/python-scope-legb-rule/](https://realpython.com/python-scope-legb-rule/)
Handling Secrets in Django.
Tags: django, python, security
Published: 2020-11-09 16:50:27

# Handling Secrets in Django.

## Method 1:

### Pre Steps:
- Create a virtual enviroment.
- Create a file with name `.env` then add the secrets like. 
```bash
export DB_PASSWORD='XYZABZ'
export SUPER_SECRET='OMG!!'
```

### Post Step
- Then
```bash
echo 'set -a; source .env; set +a' >> ./env/bin/activate
```
- This will append the line to activate file now everytime you activate the env you can access these secret variables.

- Now, you can use the below code to access the variables inside python.

```python
import os

os.getenv('NAME_HERE')
```

## Method 2:

### Pre Steps:
- Create a virtual enviroment.
- Create a file with name `.env` then add the secrets like. 
```bash
export DB_PASSWORD='XYZABZ'
export SUPER_SECRET='OMG!!'
```

### Post Step
- Then install `python-dotenv` package using `pip install python-dotenv`.
- Open `wsgi.py` and add these lines.

```python
...
from dotenv import load_dotenv
from django.conf import settings

:
:

load_dotenv(os.path.join(settings.BASE_DIR, '.env'))
...

```

- Now, you can use the `os.getenv('NAME_HERE')` to access the variables inside python.

- [@vivekascoder](https://instagram.com/vivekascoder)
Unique tip for CSS ✨
Tags: webdev, css, design
Published: 2020-11-09 16:45:55

Hello guys, I've found a very useful tip I didn't know before and I would like to share it with you.

Have you tried before to make a shadow for a transparent picture and the final outcome became something like that😒

[![F3HEaj.md.png](https://iili.io/F3HEaj.md.png)](https://freeimage.host/i/F3HEaj)


and you want it to be something like that🤩


[![F3HXwB.md.png](https://iili.io/F3HXwB.md.png)](https://freeimage.host/i/F3HXwB)


Ok here's the way you can achieve the awesome result✨

###instead of 

 **box-shadow: 2px 4px 6px #ff8429**


###do it like this

**filter: drop-shadow(2px 4px 6px #ff8429)**



That's it, have a productive day❤️
[7] React Native and my current state of affairs
Tags: codenewbie, webdev, reactnative, react
Published: 2020-11-09 16:03:27

In the last few weeks, I was a little tired of learning React and JavaScript. Therefore, I decided to try some new things. I do not know if it is a negative impact of that notorious “JavaScript fatigue”. In any case, there are also good sides. At least I widened my horizons a bit by learning new technologies.

First, I took a [Design for Developers](https://frontendmasters.com/courses/design-for-developers/) course by Sarah Drasner from the FrontendMasters. It gave me some inspiration to implement alternative approaches in the design of web applications. I have also refreshed my knowledge of Grid and CSS in general.

Then I had a brief (very brief) look at the [Svelte](https://frontendmasters.com/courses/svelte/) course by [Rich Harris](https://twitter.com/Rich_Harris) himself. I find Svelte to be a very promising and intriguing framework, and I will definitely go back to learn it when I will have more time.

Further, I was interested in React Native because of its flexibility and the option to develop both Android and iOS applications at the same time. That way, I started with a [React Native](https://frontendmasters.com/courses/react-native-v2/) course by Kadi Kraman. This course was good enough for starting with React Native, but on the other hand, it was too short and left me with a lot of questions and concerns. For that reason, I bought an Udemy [React Native – The Practical Guide](https://www.udemy.com/course/react-native-the-practical-guide/) course by Maximilian Schwarzmüller, which is much more complete and comprehensive.

At the moment, I have passed about 20% of the course (it is 30+ hours long). I also made my first React Native App, which is a to-do app, just like my last [React project](https://create-react-app.com/react-todo-app/). I will try to develop it during the course, and my goal would be to make a simple and useful application with a clear design. Currently, the code of the project can be found on my [GitHub](https://github.com/villivald/todo_app_react_native_2020).

***

[Original post 22.08.20 @ create-react-app.com](https://create-react-app.com/7-react-native/)

Site https://proj.create-react-app.com/
GitHub https://github.com/villivald
Payment integration is so simple... don't wait and monetize your business right now
Published: 2020-11-09 16:39:31

Lately, we worked on the payment integration on our https://owwly.com website using Stripe. It turned out to be so simple, so I regret we haven't done that much earlier. If you think about that now. Don't wait any longer. Do it right now to monetize your business as soon as possible to have the power 🚀 to make it better in the future! 💪
PM2 listening on port 443 shows EADDRINUSE: address already in use :::443
Tags: help, node, pm2
Published: 2020-11-09 16:34:28

---
title: PM2 listening on port 443 shows EADDRINUSE: address already in use :::443
published: true
description: I want my Express app running on 4000 to run on 443 but having problems with PM2
tags: help, node, pm2
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/9uafyc3n1gaz851vzjjz.png
---
 
I have a Node/Express app running on an AWS Lightsail instance with PM2 as a process manager. The app is currently running on port 4000. The IP address for the instance is attached to a subdomain that has a valid SSL certificate and automatically redirects from HTTP to HTTPS. Visiting https://example.com at the moment shows the 'Congratulations! You are now running Bitnami Node.js 12.18.3 in the Cloud.' page. 

Currently, all the Express endpoints are only accessible through http://example.com:4000/endpoint, but I want the Express app to run on port 443 so that the endpoints are accessible immediately on https://example.com/endpoint.

I read that PM2 is able to listen on ports 80 and 443 and tried the method mentioned in the [documentation](https://pm2.keymetrics.io/docs/usage/specifics/#listening-on-port-80-w-o-root), but whenever I change the port number in the .env file to 443 and reload the app using `pm2 reload app`, I get the following error:

```
0|app    | Error: listen EADDRINUSE: address already in use :::443
0|app    |     at Server.setupListenHandle [as _listen2] (net.js:1313:16)
0|app    |     at listenInCluster (net.js:1361:12)
0|app    |     at Server.listen (net.js:1447:7)
0|app    |     at Function.listen (/opt/bitnami/apache/htdocs/node_modules/express/lib/application.js:618:24)
0|app    |     at Object.<anonymous> (/opt/bitnami/apache/htdocs/app.js:44:5)
0|app    |     at Module._compile (internal/modules/cjs/loader.js:1137:30)
0|app    |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
0|app    |     at Module.load (internal/modules/cjs/loader.js:985:32)
0|app    |     at Function.Module._load (internal/modules/cjs/loader.js:878:14)
0|app    |     at Object.<anonymous> (/opt/bitnami/node/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23) {
0|app    |   code: 'EADDRINUSE',
0|app    |   errno: 'EADDRINUSE',
0|app    |   syscall: 'listen',
0|app    |   address: '::',
0|app    |   port: 443
0|app    | }
```

App.js
```javascript
const express = require('express');
const dotenv = require('dotenv');

const app = express();
app.use(express.json()); // for parsing POST bodies
dotenv.config();

app.get("/hello", (req, res) => res.send("Hello World!"));

app.listen(process.env.PORT, () => {
    console.log(`🥁 App listening on port ${process.env.PORT}!`);
});

```

.env
```
PORT=443
```

The output of `pm2 status` at the moment:
![aSXDK](https://dev-to-uploads.s3.amazonaws.com/i/hpjf14ei44tqxv9i2lvh.png)
 
Any help would be appreciated!
Data is undefined - Apollo Client ..!!
Tags: react, graphql
Published: 2020-11-09 16:32:20

I am getting data undefined when I goto to localhost:3000:/someslug/

Is there i am doing something wrong in this ?

`import React from 'react';
import Layout from "@components/layout";
import Loader from "@components/Loader";
import Products from "@components/Products";
import { useQuery } from "@apollo/react-hooks";
import * as Constants from '../config/constants';
import { withApollo } from '../config/withApollo';
import gql from "graphql-tag";
import styles from '../components/Products/products.module.scss';

const CATEGORY_QUERY = gqlquery CategoryQuery($slug: String!) { categoryBySlug(slug: $slug) { url slug productCount } };

const Category = ({ slug }) => {
const { loading, error, data } = useQuery(CATEGORY_QUERY, {
variables: { slug },
});

console.log(data);

if (error) return <h1>Error</h1>;
if (loading) return <Loader />;
return (
  <Layout>
    <div className={styles.product_wrapper}>
        {/* {data.allProducts.length
            ? data.allProducts.map(product => <Products key={product.uuid} product={product} />)
            : ""
        } */}
    </div>
  </Layout>
);
}

export default withApollo({ ssr: true })(Category);`
Reddit RSS
Tags: showdev, go, rss
Published: 2020-11-09 16:20:48

A tiny project I have been maintaining since April 2020 is an alternative rss feed for Reddit called [reddit-rss](https://github.com/trashhalo/reddit-rss). At the time I was getting into using [Feedly](https://feedly.com/) to read the news and found reddit's native rss feed to be pretty lackluster.

## If you are interested in using it

1. Go to a subreddit or meta feed you like example: https://www.reddit.com/r/Android/
2. Add .json onto the end: https://www.reddit.com/r/Android.json
3. Change the domain name to, reddit.0qz.fun like: https://reddit.0qz.fun/r/android.json
4. Subscribe to ^^^ that url in your favorite feed reader.

## Useful features

* Links directly to the content not to reddit.
* Extracts a readable version of articles and embeds it into the feed.
* Embeds high quality images and videos directly into the feed.
* Extra [query params](https://github.com/trashhalo/reddit-rss#query-params) to narrow search results to your liking.

## How its built

Its golang http server that uses a forked version of [cameronstanley/go-reddit](https://github.com/cameronstanley/go-reddit) to parse reddit content. Then it inspects each link and decides how to build the feed. Article text content extracted using [go-shiori/go-readability](https://github.com/go-shiori/go-readability). Feeds are created using [gorilla/feeds](https://github.com/gorilla/feeds)

Deployments are managed through [shipit](https://github.com/shipitjs/shipit) which has been meh. Do not recommend.
Props from Child to Parent Component - Hack (video)
Tags: javascript, react, tutorial
Published: 2020-11-09 16:07:11

In this video, I show you a hack on how to pass props from your Child Component, to you parent component using React Hooks.

If you did like this video, please hit the Like and Subscribe button so I know to make more!

Twitter: https://twitter.com/ania_kubow
YouTube: https://youtube.com/aniakubow
Instagram: https://instagram.com/aniakubow

{% youtube UrpNtB61qyo %}

#react #reacthooks
Week Plan 11/08/2020
Published: 2020-11-09 15:55:50

**Easy Algorithm Problems**

 * https://leetcode.com/problems/is-subsequence/ 
[Status: Moved from last week]
 * https://leetcode.com/problems/fibonacci-number/ 
[Status: Moved from last week]

**Azure Fundamentals (AZ-900)**
 * Azure Core-Services:
https://docs.microsoft.com/en-us/learn/paths/distinguish-microsoft-azure-core-services/