teleren/devto huggingface dataset:
From Node to Go | Part 1
Tags: go, node, codenewbie, webdev
Published: 2021-05-09 14:20:48

Hi Reader! Welcome to the `From Node to Go` series. 

This series is basically for all the Node.js developers who want to switch to or learn Golang. But since I am starting this from very very basics of Nodejs as well, this can be used to learn web dev in Node.js as well. 

PRE-REQUISITE for this series: You should know how to run node and go programs and you know the basics of Go. If not, I would recommend doing a quick walk through [here] (https://gobyexample.com/)  (Excellent stuff)

2 - in - 1 !! Oh Yeah!

END-GOAL of this series: Writing microservices in Go! with all the jargon like Auth, Async Communication, etc included. 

In this part, we will be focusing on creating a simple HTTP server in Node (NO EXPRESS, just plain simple Node.js) and Golang.

So let's dive in.

Creating `HTTP server` in Nodejs is simple. You import the HTTP module and call `createServer`  function. `.listen` tells you on which port you want your HTTP server to listen to.

```
var http = require('http');

http.createServer(function (req, res) {
  res.write('Hello World!'); 
  res.end(); 
}).listen(8080); 
```

Now go to your browser and open `http://localhost:8080/`, you should be able to see the Hello World message there.

Now let's do the same thing in Golang.

```
package main

import (
	"fmt"
	"net/http"
)

func main() {
	http.HandleFunc("/", HelloWorld)
	http.ListenAndServe(":8081", nil)
}

//HelloWorld Handler
func HelloWorld(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintf(w, "Hello, World!")
}
```

Run this go program and now go to your browser and open `http://localhost:8081/`, you should be able to see the Hello World message there.

We imported 2 packages:
**fmt:** Format I/O  (For further reading: [fmt package] (https://golang.org/pkg/fmt/))
**net/http:** Importing HTTP package which is a sub-package inside `net` package (does all the networking stuff) (For further reading [HTTP package](https://golang.org/pkg/net/http/))

**Define a handler function for the particular route** - We defined `HelloWorld` handler here. 

In ListenAndServe function we passed the address and `nil`, we will discuss this `nil` in the next part of this series.

The HTTP Handler takes 2 arguments here 
- An object of type `ResponseWriter` which is an `interface` in Go (For further reading: [ResponseWriter](https://golang.org/pkg/net/http/#ResponseWriter)
- A pointer to `Request` which is a `struct` in Golang (For further reading: [Request](https://golang.org/pkg/net/http/#Request))

You should probably be having [this](https://stackoverflow.com/questions/13255907/in-go-http-handlers-why-is-the-responsewriter-a-value-but-the-request-a-pointer) question in mind right now!

So that's it. That's how you create a plain simple HTTP server in Node and Golang. Stay tuned for the next parts.
Laravel 8 - NuxtJS - Sanctum - Fortify - SPA
Tags: laravel, nuxt, sanctum, spa
Published: 2021-05-09 14:19:36

---
title: Laravel 8 - NuxtJS - Sanctum - Fortify - SPA
published: true
description: 
tags: laravel, nuxtjs, sanctum, spa
cover_image: https://res.cloudinary.com/practicaldev/image/fetch/s--OHpv5lU6--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/i/kcpz6vliglwkwzvu8xzp.png
---
If you are interested in building SPA with Laravel and NuxtJS this is good starting point.


Features:

Laravel 8
NuxtJS
Sanctum SPA Auth
Fortify
Nuxt Laravel Integration m2s/laravel-nuxt
BootstrapVue

[https://github.com/frizikk/laravel-nuxtjs-sanctum-fortify](https://github.com/frizikk/laravel-nuxtjs-sanctum-fortify)
i3 Ricing
Tags: linux, ubuntu
Published: 2021-05-09 14:12:25

Hello guys!!!
Recently I have riced my entire **Linux Mint 20.1 XFCE** using the **i3-window manager**. Developers mostly use upgraded ricing tools like the Awesome window manager for their ricing models. Ricing in Arch-based systems is comparatively easier than in Ubuntu-based systems. Although, I preferred i3-window manager as it is **good for beginners and we get to build the ricing model from scratch**. 

My Ricing model is uploaded on YouTube on my friend's channel:
 [i3-riced model](https://youtu.be/-WyIyqiNpBk) 

{% youtube -WyIyqiNpBk %}

The configuration file for the ricing model is uploaded on GitHub: 
 [i3-config-files](https://github.com/RitabrataDas343/i3_Ricing)

{% github RitabrataDas343/i3_Ricing %}

I hope you can try it and publish your ricing models too. 

Other references:
* [i3wm-guide](https://i3wm.org/docs/userguide.html)
* [My GitHub Gist for Keybindings](https://gist.github.com/RitabrataDas343/e2cd532cbc7be330d58b58364bff0b07)

Happy Ricing!!!
May the Source be with you 🐧💗.
How to approach Dynamic Programming?
Tags: computerscience, programming, productivity, codenewbie
Published: 2021-05-09 14:08:07

Dynamic Programming(DP) itself sounds so huge that coders try to avoid it as far as possible. But big companies like Nutenix, Flipkart, Amazon love those coders who can code a solution that is both optimised and have a minimum time complexity.

##Wondering what this post is about? 
The title suits this post well, today we'll talk about how a noob coder can identify a DP problem and then approach towards solving it. 

####Firstly, let me tell you that DP is all about recursion:

                         DP = Enhanced Recursion

where Enhanced Recursion is basically calling a function itself with a simpler input.

Parent of a DP problem is Recursion. What do I mean by parent here? Every DP problem can be solved using recursion so it really matters for you to learn recursion first. Clear your concepts on Recursion then proceed to DP.

###Secondly, identifying the question of DP
Keep these two things in mind while identifying:
a) Choice will be given like in a Knapsack problem which element to include and which one element shouldn’t be included.
b) Optimal Questions like those questions covering topics about Minimal, Maximum, Largest, Maximum Profit.

###From recursion, Overlapping Recursion is a DP problem. 
Now you must be wondering what is this overlapping recursion? Well it's basically a tree-like structure of a recursion function getting called two or more times and then overlapping each other while getting called up. 
If the function is called and the program gets executed without even touching other recursion functions then that is called overlapping problem in recursion.

###Let's get to the approach that should be used for solving a DP problem:
If you don't know this approach: 
[#Recursive Solution---> Memoization] 
then do not I repeat DO NOT use this approach to solve your question that is using a "Top down approach which means forming a matrix initially and then filling up the boxes assuming some conditions"

As a developer in making I would really like to add that without knowing Recursion, proceeding to DP is stupidity. You should have a recursive approach to proceed to a top down solution.
 
###The standard form to solve any DP question is this:
  
Recursive Solution ---> Memoize ---> Top-Down Approach

The only difference between various DP variations question lies in the recursive code.

###BONUS POINT
Different questions that you can try out learning are:
1) 0 1 Knapsack Problem(6)[this 6 means the different questions that includes variation with 0 1 knapsack]:
- Subset Sum
- Equal Sum Partition
- Count of Subset Sum
- Minimum Subset sum difference
- Target Sum(Leet Code Problem)
- Count number Of Subset with a given difference

2) Unbounded knapsack(5)
3) Fibonaaci(7) 
4) LCS(Longest Common Sub-sequence)(15)
5) LIS(Longest Increasing Sub-sequence)(10)
6) Kadane's Algorithm(6)
7) Matrix Chain Multiplication(7)
8) DP on Grids(4)
9) DP on trees(14)
10) Others(5)

Ending this post while reminding you all to take care of yourselves and keep coding 💜
Worry about managing databases at backend. Don't worry PAGECLIP is for you.
Tags: webdev, pageclip, database, watercooler
Published: 2021-05-09 13:58:10

Are you a *Front end developer* but sometimes struck when it comes about adding forms and accessing it data and storing it.
I have a great site for you i.e. **Pageclip**.

#### What is **Pageclip**? 
A server for your HTML forms.
*Collect info from users without a server—Pageclip is your server. Lead capture forms, surveys, newsletter forms, contact forms, etc. Setup any form in seconds.*

#### This site is very helpful for student developer
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xxia7vw4x6ihwjus1ckq.png)

### How to add data here.
```
<form action="https://send.pageclip.co/abc123def456">
  <input type="text" name="name" value="Roscoe Jones"/>
  <input type="text" name="email" value="roscoe@example.com"/>
  <input type="submit" value="Send">
</form>
```
Its quite simple to add data here.
**Uses:**
* Collect Leads for Your New Product
* Setup a Contact Form
* Capture Emails for a Newsletter

### Plan and Pricing
**Most demanding thing:**
* Free-> One site, One form, 1000 submissions
* Basic-> One site, Unlimited form , 20000 submissions(Use github student developer pack for accessing this pack.) or (get it at $9)

**Rest are standard one which are useful for companies.**

### Just make an account or signup from [**Here**](https://pageclip.co/signup)

Just visit official [**Pageclip**](https://pageclip.co/) site for getting started with it and for more information.

Thanks for reading.
**Rishabh Dwivedi**
Visit [**Projectron**](http://projectron.tech/) my early startup.
Internet of Things (IoT) | What is IoT | How it Works | IoT Explained
Tags: machinelearning, python, programming, architecture
Published: 2021-05-09 13:57:54

You may have listened to the term "Internet of Things" many times before from the past few years. But, do you know what is the Internet of Things (IoT)? How IoT works?

> Sponsored by: [pcredcom.com](https://pcredcom.com/blog/computo/tipos-de-computadoras/)

Why the Internet of Things even exists? Here in this video, I've explained the whole IoT with easy to understand examples.

Watch more: https://bit.ly/3uDiFUs
Join Discord: https://discord.gg/aGC3vMPuQp

Read more about IoT:
https://www.oracle.com/in/internet-of-things/what-is-iot/

7 Mind-Blowing Future Inventions:
https://bit.ly/Mind-BlowingFutureInventions

Buy me a coffee: https://imjo.in/4AvD73

Let's talk:
Instagram: https://instagram.com/amisouvikpaul
Twitter: https://twitter.com/thesouvikpaul
Facebook: https://fb.com/thesouvikpaul
Facebook Page: https://fb.com/amisouvikpaul

Thanks for watching!
Getting into Git
Tags: github, git
Published: 2021-05-09 13:57:17

## What is Git?

Git is a software that tracks changes across a set of files, and is used in coordinating work among programmers simultaneously working on different parts of the same project. Git manages changes that were made so you can return to a previous point of your code, save new things you were working on that you haven’t completed, and update what you’re working on with the changes someone else made, among many other things we’ll get into.

## Why use Git?

Git is currently the most commonly used version control system.

* In teams with multiple developers git will likely be used as it makes it easy to collaborate and merge changes.

* If you work independently but not always on the same computer: it allows you to easily retrieve changes you made on your other system as well as keep track of when you did what.

* You have the ability to go back to a previous version of the code in the case of changes you (or someone else) made ‘breaking’ the project.

* Or marking what changes were made that broke it so you can focus on just what was changed instead of the entire code.
How to use git?

Before you can start using git, you will need to install it. Check out the documentation for details

After initializing git on a set of files, you’ll want to set up your files with a repository that can manage your code for you on a location that isn’t your device.

Using a remote repository will give you more freedom to collaborate with others, set up hosting for your code, and share your code for use or as a portfolio.

Generally you’ll find with git you’ll stage changes that were made and push them to update your main branch in the repository. When you have more things you want to work on or have additional people working on the same code base you’ll want to use branches. I’ll be writing more going over the specific commands and how to use them in more detail in later posts!

## Remote Repository?

Repositories are central locations where data is stored and managed. Having locations other than your device will give you more protection to save your data in the case anything happens to your device.
With git, there are a lot of hosts you can use for the repositories: often at no cost. Some you might run into include:
* [GitHub](https://github.com/)
* [GitLab](https://gitlab.com/)
* [BitBucket](https://bitbucket.org/)
* [SourceForge](https://sourceforge.net/)
* [LaunchPad](https://launchpad.net/)
* [Phabricator](https://phacility.com)

There are also Self-Hosted solutions to host your repository including:
* [Gogs](https://gogs.io/)
* [Gitea](https://gitea.io/en-us/)
* [Apache Alura](http://allura.apache.org/)

There’s no need to work with just one either. Try a few, and see what works for you. Git commands will be the same no matter which repository you use. Graphic User Interface (GUI) does change depending on what you’re using, but once you have a handle on one it will be easy to switch over to another host if you need (or want) to later.
Auto Route Generator for Laravel
Tags: laravel, routing, router
Published: 2021-05-09 13:56:39

While working on a project with Laravel, I thought that *“I wish all these routes were created automatically”*. Then, I’ve started to research a package about that but I couldn’t find a package I want.

I’ve decided to make a simple package for that. I’ve made some research about how can I create a new Laravel package because I’d not created any package for Laravel before. I’ve been using Laravel about 5 years, but this would be my first package for Laravel.

With this package; you will be able to generate routes automatically and configure some options about the Package by using its config file. Now, you can check the example for the Package below.

Firstly, you must install the package via the Composer command:
```
composer require izniburak/laravel-auto-routes
```

After that, you should add a new route definition by using `auto` method that will come from `laravel-auto-routes` package.

```php
# in routes/web.php or routes/api.php 
Route::auto('/test', TestController::class);
```

Just route prefix and the Controller file are enough for definition. If you want to change some options like `namespace`, `middleware` or `name`, you can use the third parameter of the auto method.

After that, you can add a new controller:

```php
namespace App\Http\Controllers;

use Illuminate\Http\Request;

class TestController extends Controller
{
    /**
     * URL will be converted to "/test/foo-bar"
     */
    public function fooBar(Request $request)
    {
        // your codes
    }
   /**
    * URL will be converted to "/test/bar-baz"
    */
    public function barBaz(Request $request)
    {
        // your codes
    }
}
```


That’s all. All methods in your Controller will be generated to compatible endpoints automatically.

You can use parameters, HTTP methods, and more in your Controller. If you want to learn more details about the package, you can check the Github page:

Github: [**laravel-auto-routes**](https://github.com/izniburak/laravel-auto-routes)
*Auto Route Generating Package for Laravel.*

I hope this package would be useful to everyone and help them. If you have any suggestions or ideas about the package, Please feel free to give them. I’d love to hear your feedback.

Thanks,
İzni Burak.
Daily Developer Jokes - Sunday, May 9, 2021
Tags: jokes, dailydeveloperjokes
Published: 2021-05-09 13:43:12

---
title: "Daily Developer Jokes - Sunday, May 9, 2021"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Sunday%2C%20May%209%2C%202021"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1259a6b60d2.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit.*

<!-- 
Joke text:
What's the best tool for automatically ignoring long email threads about tech buzzwords?

"Block-chain"
 -->
A Really Simple Intro to localStorage in React
Tags: react, state, hooks, webdev
Published: 2021-05-09 13:37:49

Saving information to local storage can be incredibly useful and can make for a far better user experience in your apps. Imagine if you had to log in from scratch every time you wanted to look at Twitter! 

By using the localStorage method in React, we can make save certain information to the user's machine to save them re-entering it whenever they use our app.

I'll take you through a very simple example of saving a name and username from a form. 

We'll begin with two input fields and a submit button, like so -

![Name and username input fields](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/whacr8munnkds5mgc9fn.jpg)

You can find the starting code <a href="https://github.com/LauraToddCode/local-storage-blog/tree/starter-code/src">here</a>.

Add onChange and onSubmit event listeners to the input fields and the form as would normally.

![Form with input fields and submit button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rbumqo3hvh54c5due9o6.png)

In the constructor, initialise the state for 'name' and 'username'.

![initialisation of name and username](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a0sevxudrnd2ljnf4u02.png)

Then, create the onChange handler functions, allowing them to set the state of 'name' and 'username' to the input values.

![handler functions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ycj9tml4yj69lg2vr5k.png)

Next, create the onSubmit handler function.

![submit handler function](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y411h47iw8u69acnotja.png)

In the first line, we use a destructured array to assign this.state.name and this.state.username to the 'name' and 'username' variables. Then, we use the localStorage.setItem() method store those values as 'name' and 'username' to be accessed by the local storage later. 

Make sure that you bind all three functions in the constructor.

![Bind functions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ha1cfz1mwyxfp5jtlpxm.png)

Finally, we can use the localStorage.getItem() method within ComponentDidMount() to access the stored values and assign them to this.state.name and this.state.username on initialisation. 

![component did mount](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fd4l1a1wm4vb8e9opvcm.png)

That's it! Now, when you enter values into the input fields and refresh the page, those values should remain in the fields.

You can check your finished code <a href="https://github.com/LauraToddCode/local-storage-blog/tree/main/src" data-type="URL" data-id="https://github.com/LauraToddCode/local-storage-blog/tree/main/src">here</a>.
From Web to App
Tags: app, development, web
Published: 2021-05-09 13:35:14

---
title: From Web to App
published: true
description: How should I start?
tags: app, development, web,
//cover_image: https://direct_url_to_image.jpg
---

How should I start to develop a web portal. First I develop the portal and after that I will develop a app for android and ios. 

What is the best way to do that? Is react the best way to start?
Difference Between :placeholder-shown and ::placeholder in CSS
Tags: css, html, webdev
Published: 2021-05-09 13:21:09

## The :placeholder-shown Pseudo-class

> A CSS **pseudo-class** is a selector that selects elements that are in a specific state.

The `:placeholder-shown` pseudo-class selects any `<input>` or `<textarea>` element that is currently displaying a placeholder text.

### HTML

```html
<input type="text" placeholder="Search university">
```

### CSS

```css
input[type=text] {
  width: 100px;
}

:placeholder-shown {
   text-overflow: ellipsis;
}
```

### Result

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


## The ::placeholder Pseudo-element

> A CSS **pseudo-element** is a selector that lets you style a specific part of an element.

The `::placeholder` pseudo-element can be used to style the placeholder text in an `<input>` or `<textarea>` element.

### HTML

```html
<input type="email" placeholder="Enter your email">
```

### CSS

```css
::placeholder {
   color: red;
}
```

### Result

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2kvri8w4flyt57sbrc6l.png)

Thanks for giving it a read.

Happy coding!
Exception Handling
Published: 2021-05-09 13:17:53

Exception Handling
When an error occurs, or exception as we call it, Python will normally stop and generate an error message.
These exceptions can be handled using the try statement:
Example:
The try block will generate an exception because x is not defined:
try:
  print(x)
except:
  print("An exception occurred")

Since the try block raises an error, the except block will be executed.
Without the try block, the program will crash and raise an error:

Many Exceptions
You can define as many exception blocks as you want, e.g. if you want to execute a special block of code for a special kind of error:

Example
Print one message if the try block raises a NameError and another for other errors:

try:
  print(x)
except NameError:
  print("Variable x is not defined")
except:
  print("Something else went wrong")

Else
You can use the else keyword to define a block of code to be executed if no errors were raised:

Example
In this example, the try block does not generate any error:

try:
  print("Hello")
except:
  print("Something went wrong")
else:
  print("Nothing went wrong")


Finally
The final block, if specified, will be executed regardless if the try block raises an error or not.

Example
try:
  print(x)
except:
  print("Something went wrong")
finally:
  print("The 'try except' is finished")

Raise an exception
As a Python developer, you can choose to throw an exception if a condition occurs.

To throw (or raise) an exception, use the raise keyword.

Example
Raise an error and stop the program if x is lower than 0:

x = -1

if x < 0:
  raise Exception("Sorry, no numbers below zero")
The raise keyword is used to raise an exception.

You can define what kind of error to raise, and the text to print to the user.

Example
Raise a TypeError if x is not an integer:

x = "hello"

if not type(x) is int:
  raise TypeError("Only integers are allowed")