teleren/devto huggingface dataset:
Things only bad developers do
Tags: beginners, programming, productivity, codenewbie
Published: 2021-04-10 15:26:44

As a developer, our job is not only limited to wring the code. There are a few more things that we must do apart from writing code.

Today, we will tell you a few points that you **should not** do as a developer.

## 1. Writing Over Optimized Code 
It's always good to write optimized code, but it's also important to make sure that we don't over-optimize it. Let's say, you are working in a team and you are assigned to write a function that does something. Suppose, you come up with a solution that does that job in 2 or 3 lines, but it's over-optimized and not very easily readable.

If other team members are trying to understand this function, they will hardly understand what your code is doing and how is it working, because it's hardly readable due to being over-optimized. 

Always write optimized code, **but not at the cost of readability and ease of understanding.**

## 2. Pushing untested code into production
No matter how much sure you are about your code and its working, pushing it directly to production without testing it, is a BAD decision.

You might feel like doing this when you have made a really small change and not feel like testing it.

But, there could be chances that that change might not be implemented as you wanted.

## 3. Pushing commented code in production
This is very dangerous. You might think what harm it might do? But, when code comes under maintenance or updations and some other dev starts working with the code, there are always chances that he might uncomment it and screw up the entire application. Also, it might create unnecessary confusion.

## 4. Not considering the bad scenarios
Your code will not always run in an ideal scenario or your users will not always use the app as you want them to use. So, ignoring all the basic bad scenarios is the worst thing to do. If you do that, your code will horribly fail.

As a developer, always consider, manage all the bad scenarios. Make sure your code is ready to face the worst of conditions.

Thanks for reading.
Let us know your thoughts in the comments below
How To Solve Laravel 8 API Response that is returning welcome page instead of JSON
Tags: laravel, php, api
Published: 2021-04-10 15:06:58

I created a dribble clone using Laravel 8 and Nuxt.js. Since I won't be using the web route so I decided to create a global JsonRequestMiddleware that accepts headers as application/json.  This write-up aims to show you how I implemented that step by step. Happy reading
Step 1: create a new middleware

```
php artisan make:middleware JsonRequestMiddleware

```
Step 2: Copy this code and place it inside the JsonRequestMiddleware at the handle method before 'return $next($request);'

```
$request->headers->set("Accept", "application/json");

```
Your end result should look like this:

```
public function handle(Request $request, Closure $next)
{
    $request->headers->set("Accept", "application/json");
    return $next($request);
}

```
Step 3: Go to App\Http\Kernel.php file and add the code below at global HTTP middleware stack.

```
protected $middleware = [
    \App\Http\Middleware\JsonRequestMiddleware::class,
    // Other Middleware::class comes after...
];

```
Step 4: clear the application config cache and dump-autoload

```
php artisan config:cache or composer dump-autoload

```
you can share with me if you have got a better way of achieving this. I hope this is helpful. Thanks.
How to start Spring Data Cassandra with SpringBoot
Tags: springboot, cassandra, springdata
Published: 2021-04-10 15:03:44

https://grokonez.com/spring-framework/spring-data/start-spring-data-cassandra-springboot

How to start Spring Data Cassandra with SpringBoot

How to start Spring Data Cassandra with SpringBoot

<strong>Apache Cassandra</strong> database is a <strong>NoSql</strong> solution for scalability & high availability. In the tutorial, <strong>JavaSampleApproach</strong> will show you how to start Spring Data Cassandra by sample code.

Related article:
- <a href="https://grokonez.com/spring-framework/spring-boot/start-springboot-elasticsearch-using-spring-data">How to start SpringBoot ElasticSearch using Spring Data</a>
- <a href="https://grokonez.com/spring-framework/spring-data/couchbase-create-spring-jpa-couchbase-application-springboot">Couchbase – How to create a Spring Jpa Couchbase application with SpringBoot</a>
- <a href="https://grokonez.com/spring-framework/spring-boot/springdata-reactive-cassandra-repositories-springboot">SpringData Reactive Cassandra Repositories | SpringBoot</a>
- <a href="https://grokonez.com/spring-framework/spring-boot/angular-4-spring-boot-cassandra-crud-example">Angular 4 + Spring Boot + Cassandra CRUD example</a>
- <a href="https://grokonez.com/spring-framework/spring-boot/angular-spring-webflux-spring-data-reactive-cassandra-example-full-reactive-angular-http-client-spring-boot-restapi-server">Angular + Spring WebFlux + Spring Data Reactive Cassandra example | Full-Reactive Angular Http Client – Spring Boot RestApi Server</a>

<!--more-->
<iframe width="853" height="480" src="https://www.youtube.com/embed/zifV0Gn3kfw?rel=0" frameborder="0" allowfullscreen></iframe>
<div id="tuttoc" class="jsa-toc"></div>

<div id="tutcontents">
<h2>I. Technologies</h2>
– Java 1.8
– Maven 3.3.9
– Spring Tool Suite – Version 3.8.1.RELEASE
– Spring Boot: 1.5.1.RELEASE
- DataStax Community Edition for Apache Cassandra: v3.9.0

<h2>II. Practice</h2>

More at:

https://grokonez.com/spring-framework/spring-data/start-spring-data-cassandra-springboot
Regex for email validation in rails
Tags: rails, ruby, regex
Published: 2021-04-10 14:54:34

A simple regex for email validation 
```ruby
VALID_EMAIL_REGEX= /^(|(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6})$/i

	validates :email , presence: true,uniqueness:{case_sensetive:false},
	format:{with:VALID_EMAIL_REGEX,multiline:true}
```
view it on `rubular`
https://rubular.com/r/DofEroQvHSXNIw
API, FUNCTIONS, BUTTON NOT FIRING IN REACT
Tags: react, api, function, button
Published: 2021-04-10 14:53:36


 I am currently building a MERN application.

It is working fine on localhost - desktop, then I thought of exploring it on mobile, so I created a local network. See below for how to create and connect to local network.

Alas, some of my buttons were not responding.

What could have happened?

Upon troubleshooting, I realized that only 'SUBMIT' buttons were not working.

... after hours of googling ...

I threw _alert('i clicked')_ inside the onclick function, I got the alert whenever I clicked.

It was then I realized that I was calling a wrong API url. 

How?

The API URL i was calling is http://localhost:4000. Port 4000 was where my backend is connected to. This would work fine on my local machine. However, it wont work over the network, because localhost === 127.0.0.1, which is different from Local Area Network Address - 192.168.43.263 .

**SOLUTION:**

I change http://localhost:4000 to http://192.168.43.263:4000 for all instances.



**HOW TO CREATE A LOCAL NETWORK?**

Simple and straight forward:

A. Get your local ip:

1. open command prompt or any command line interface:
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mupzw01wx2atcpvazq6u.png)
2. Type in ipconfig:
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tentpqkksi71jbdfn04i.png)
3. Click enter:
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uqoupy3sctbr5x90vw5d.png)

4. The marked is your IP.

B. Connect your laptop (where your localhost is domiciled) to the same network with the other device (may be your phone) you want to use. This could be achieved by connecting them to the same wifi hubspot. 

My mobile device is connected to ColdVi wifi, same with my laptop, hence they are on the same network.
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lk42n9evmxxool1nh3a6.png)
![WhatsApp Image 2021-04-10 at 3.26.42 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xi02ezc78wfpgb01ehuc.jpeg)


 

C. On the other device, enter this combination in your browser:

http://yourIP:port
![WhatsApp Image 2021-04-10 at 3.46.29 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kwvpbcvj201i75zct1l7.jpeg)



_do not miss out the colon in between_

Your site should load.
Web crawling with python and selenium
Tags: python
Published: 2021-04-10 14:53:26

#Intro
For a recent job interview I was tasked with scraping a web table and converting the data into a csv file. To get started I first searched the around for the proper tools for the job. I knew I would need to install selenium with **pip install -U selenium** then from reading the [docs](https://pypi.org/project/selenium/5) it states 'Selenium requires a driver to interface with the chosen browser.'. For this I choose the [chrome webdriver](https://sites.google.com/a/chromium.org/chromedriver/downloads) once downloaded **Make sure it’s in your PATH, e. g., place it in /usr/bin or /usr/local/bin.** if you do not do this chrome will fail to open.

#Learing to crawl
  To get started you must import selenium from webdriver, set a variable equal to webdriver.Chrome() and then call the variable.get('url here')

```python
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

browser = webdriver.Firefox()

browser.get('http://www.yahoo.com')
assert 'Yahoo' in browser.title

elem = browser.find_element_by_name('p')  # Find the search box
elem.send_keys('seleniumhq' + Keys.RETURN)

browser.quit()
```
Congrats you just learned to crawl. In my next blog I will go over using pandas to turn a web table into a dataframe then csv.

Make sure to check out the selenium docs for more information!
API Connect Conference free com mais de 60 palestrantes
Tags: graphql, devops, microservices
Published: 2021-04-10 14:17:59

Olha a 🍕 pizzaaaa. 
Pessoal, estamos com uma campanha de incentivo para divulgar o APICON. Os 5 que mais indicarem ganham iFood Card de R$50,00
Eu vou participar da abertura e vai ser 100% on-line e gratuito de 13 a 15 de abril.
http://bit.ly/apiconpizza
Veja o conteúdo das atividades aqui https://prensa.li/apicon/api-connect-conference-2021/
How to setup Node/Express development environment
Tags: node, express, setup, development
Published: 2021-04-10 14:17:45

https://grokonez.com/node-js/how-to-setup-node-express-development-environment

How to setup Node/Express development environment

In the tutorial, we will show you how to setup Node/Express development environment that includes installation of Nodejs, NPM package, and 'Express Application Generator' optionally.

<!--more-->
<h2>Installing Node</h2>
- Go to: <a href="https://nodejs.org/en/">https://nodejs.org/en/</a>
- Download the LTS build that is "Recommended for most users"

<img src="https://grokonez.com/wp-content/uploads/2018/04/download-nodejs-LTS-version.png" alt="download nodejs - LTS version" width="580" height="230" class="alignnone size-full wp-image-11495" />

Double-clicking on the downloaded file and following the installation prompts:

<img src="https://grokonez.com/wp-content/uploads/2018/04/install-nodejs.png" alt="install nodejs" width="491" height="386" class="alignnone size-full wp-image-11520" />

Testing your Nodejs and NPM installation:

<pre><code class="language-javascript">
>node -v
v8.11.1

>npm -v
5.6.0
</code></pre>

Create a 'helloworld.js', use 'http' module to create a Nodejs server <code>createServer()</code>.

<pre><code class="language-javascript">
//Load HTTP module
var http = require("http");

//Create HTTP server and listen on port 8000 for requests
http.createServer(function (request, response) {

   // Set the response HTTP header with HTTP status and Content type
   response.writeHead(200, {'Content-Type': 'text/plain'});
   
   // Send the response body "Hello World"
   response.end('Hello World\n');
}).listen(8000);

// Print URL for accessing server
console.log('Server running at http://127.0.0.1:8000/')</code></pre>

Start the server:

More at:

https://grokonez.com/node-js/how-to-setup-node-express-development-environment
Vue Router: Cara dan Contoh Penggunaan
Tags: vue, javascript, webdev
Published: 2021-04-10 13:54:07

## **Perkenalan**
> Vue sangat berguna untuk membuat Aplikasi Satu Halaman, halaman webnya juga sangat interaktif yang memungkinkan kita untuk tidak me-refresh halaman ketika kita mengubah dari halaman satu ke halaman yang lain. **Note: This article is intended for Indonesians**

<br />

> **Jika website kamu memiliki banyak halaman dan kamu menggunakan Vue**, itulah mengapa kamu membutuhkan Vue Router. **Note: Pastikan kalian paham tentang Vue dan Javascript dasar**

<br />

## **Basic Dari Vue Router**
#### 🚀 Mempersiapkan Vue Router dari awal

1.Pertama Kita Install Vue Router di Command Line
```bash
$ npm i vue-router@next
```
2.Konfigurasi pada Direktori **_/src/router/index.js_**
```javascript
import { createWebHistory, createRouter } from "vue-router";
// Import Component2 Kalian

import Home from "@/views/Home.vue"; 
import About from "@/views/About.vue";

const routes = [ 
  {
    path: "/", 
    name: "Home",
    component: Home,
  },
  {
    path: "/about",
    name: "About",
    component: About,
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

export default router;
```
**Note:** Di direktori **_/src/router/index.js_** kita membuat routes di dalam sebuah array yang akan mengspesifikasikan beberapa hal:
* Path - URL / Tempat dimana component akan di load
* Component - Komponen yang akan diload saat path dipanggil
* Name - (Opsional)

> Dibawah array routes **terdapat `createRouter` yang pastinya diperlukan untuk membuat router itu sendiri** 

<br />

> Dan juga terdapat **`createWebHistory` yang digunakan untuk beralih dari mode hash ke mode history di dalam browser, menggunakan API history HTML5, Ini yang akan membuat history pada browser kita setiap kita meload router**

3.Konfigurasi pada direktori **_/src/main.js_**
Pada direktori **_/src/main.js_** kita juga perlu menambahkan sesuatu
```javascript
import { createApp } from 'vue'
import App from './App.vue'
import router from './router' // <---

createApp(App)
  .use(router) // <---
  .mount('#app')
```
Ya, tentunya kita perlu mengimpornya ke file utama kita

<br />

#### 🚀 Menggunakan Router
Ada 2 component yang diberikan oleh Vue Router yaitu `<router-view />` dan `<router-link to="/" />`. 

> `<router-view />` digunakan untuk membungkus component2 yang akan dirender , dan `<router-link to="/" />` ini mirip seperti tag anchor pada html, pada tag anchor biasanya kita menggunakan href tetapi pada router link kita menggunakan 'to'

<br />

> **Note:** Biasanya `<router-view />` dideklarasikan di file App.vue karena file tersebut adalah halaman utama yang isinya akan kita ubah2

Contoh: 
```java
// (/src/App.vue)
<template>
  <div id="navbar">
      <router-link to="/">Home</router-link> |
      <router-link to="/about">About</router-link>
  </div>
  <router-view />
</template>
```
```java
// (Home.vue)
<template>
  <h1>Home Page</h1>
</template>

// (About.vue)
<template>
  <h1>About Page</h1>
</template>
```
🚀 Selesai.. ya mungkin seperti itu konsep dasar vue router, mohon maaf bila bahasa yang digunakan membingungkan
React: running something only after state hook has updated
Tags: react
Published: 2021-04-10 13:42:16

Hooks in React are great. It's such much easier than the old class method of sending state down to the children - you can just write it all in the component. Except that it doesn't update instantly. It looks like it's instant, but computers work quicker than humans and you can get some weird things going on if you assume the state has updated when it actually hasn't. Isn't programming fun?

Fortunately, there's a solution, using the useEffect hook.
```
useEffect(()=>{
  doSomething();
},[state])
 
```

useEffect will run whenever something updates - we tell it that something is our state. So every time the state updates, useEffect runs and it runs doSomething.

Which is great, except that it runs when the state is set. Including when we set it all up:
```
const [state setState] = useState();
```
Which might be what you want, but chances are, it's not.

Fortunately, another function comes to our rescue: useRef:
```
const firstRender = React.useRef(false);
useEffect(()=>{
  if(firstRender.current) {
    doSomething();
  } else {
    firstRender.current = true;
  }
},[state])
```

What happens here is that the first time useEffect runs - when the state is first set up - it only sets firstRender to be true. After that, it'll always run doSomething.
Top 5 Tips for Your First Golang Project
Tags: go
Published: 2021-04-10 13:40:07

[Golang](https://golang.com) aims to be "Fast, Concise, and Effective". The language promises a turn-key environment for those just getting started with the language, yet still provides support for those who want to write their own tools or delve deeper into the architecture. 

Much like other popular languages such as C/C++ and Java, Golang supports memory management (GC) and offers suitable support for [concurrency](https://golangr.com/goroutines/) and multi-core systems.

* **Pick your editor wisely**

Golang is a compiled language, unlike PHP, Ruby, or Javascript, where the source code is converted to machine code on the fly every time the server runs. Because of this, an editor that has support for Golang syntax makes a big difference. 

* **Use gofmt**

If you are new to Golang, you want to use the [gofmt tool](https://blog.golang.org/gofmt) while writing your code. This ensures that your code is formatted consistently and makes it easier for other developers to read it and contribute to your project.

* **Create a project readme**

You might want to create a quick document (README) which describes how to build and install your project. In addition to this, you can add any extra information which will be helpful for developers using the project.

* **Dependencies**

Always define your dependencies not only in the package management file (i.e. Godeps file) but also in the source code itself. This allows you to find all usages of external packages very easily.

* **Command line flags**

If you have command line flags which users might want to customize, then create separate functions for each of them.
5 Python Libraries You Need to Know
Tags: python
Published: 2021-04-10 13:32:01

On the internet, you can find thousands of tutorials and blog posts about the Python programming language. With so much information out there, it’s hard to know which libraries are worth learning.

## Discovering The Best Python Libraries

We’ve handpicked 5 of the best and most useful Python libraries:

* **PyQt**

A cross-platform application and [GUI framework](https://pythonpyqt.com/). It provides classes to create classic multi-window applications with a native look and feel. It can be used in Python or C++. It comes with a [GUI designer](https://pythonbasics.org/qt-designer-python/)

* **Requests**

The [Requests package](https://2.python-requests.org/en/master/) provides a simple interface for making HTTP requests. It wraps the powerful module urllib2 with a much simpler interface while providing useful information such as HTTP headers and cookies.
The requests library makes it easy to perform complex interactions that would otherwise require lots of code and multiple calls to external APIs.

* **Scrapy**

[Scrapy](https://scrapy.org/) is a fast high-level screen scraping and web crawling framework, used to crawl websites and extract structured data from their pages. It can be used for a wide range of purposes, from data mining to monitoring and automated testing.

* **BeautifulSoup**

Since 2004, [BeautifulSoup](https://beautiful-soup-4.readthedocs.io/en/latest/) has been one of the most important libraries for parsing HTML. It is flexible and allows users to create solutions that work with any web page structure.
Libraries like BeautifulSoup allow programmers to do anything from [extracting simple links](https://pythonspot.com/extract-links-from-webpage-beautifulsoup/), [tables](https://pythonprogramminglanguage.com/web-scraping-with-pandas-and-beautifulsoup/) to more complex analysis and data manipulation.

* **numpy and pandas**

[NumPy](https://numpy.org/) is the fundamental package for scientific computing in Python and provides a solid foundation on top of which to build your numerical algorithms. [Pandas](https://pandas.pydata.org/) provides powerful data structures and tools to make working with large datasets easier. It can [load data](https://python-commandments.org/pandas-apply/) in many formats including csv, json, html and others.
Importance of Schools in Humanity 
Tags: education, gurgaon
Published: 2021-04-10 13:30:15

In today's age of development and technology, people have often debated and discussed the importance of institutionalized education. With the increase in the number of <a href="https://www.karmelinternational.org/"><strong>Best school in Gurgaon</strong></a>, its importance is starting to be criticized as other options like homeschooling and acquiring knowledge via the internet emerges. Schools play an important role in human life, some of which are mentioned. 
●	Socialization- After family, school is the first place where a human being is socialized. School is the replica of the greater society and a child learns how to act in the society through school. They learn how to make friends- humans are social animals and they learn to become social in school. 
●	Development- School plays an important role in the development of a kid. All kinds of information that a child needs to become a functioning member of society are learned through school. Societal norms and conventions are learned by children from school. A child understands the concept of authority, peers, friends, and enemies only through school. Discipline, cooperation, empathy, and kindness are learned at school. Nearly all aspects of a person's mental and physical development are done at school. The best school in Gurgaon makes sure that your child is developed for society.
●	Basic Education- It is not enough for a child to learn one specific subject or field throughout their lives. Basic knowledge of all subjects like Math, History, Science, Environmental Studies is required to function properly in the world. This overall knowledge of all important subjects is given by the school.
●      Future- A child is prepared for the future through school. It is through school that they understand their strengths, weaknesses and which areas they are passionate about. <a href="https://karmelschool.wordpress.com/2021/04/10/10-tips-and-tricks-for-you-to-achieve-the-most-out-of-online-education/"><strong>Top school in Gurgaon</strong></a> will make your child completely ready for their future so that they go on to live very successful lives.
Schools are clearly a very important institution in a person's life. All our best memories are from our school days. The relationships and bonds we make in school persist for the rest of our lives just like the values learned there.