teleren/devto huggingface dataset:
Set User Agent on pandas read_csv
Tags: python
Published: 2022-03-28 03:59:07

---
canonical_url: https://waylonwalker.com/til/pandas-read-csv-user-agent/
series: til
published: true
tags:
- python
title: Set User Agent on pandas read_csv
---

I keep a small [cars.csv](https://waylonwalker.com/cars.csv) on my website for quickly trying out different pandas operations.  It's very handy to keep around to help what a method you are unfamiliar with does, or give a teammate an example they can replicate.

## Hosts switched

I recently switched hosting from netlify over to cloudflare.  Well cloudflare does some work to block certain requests that it does not think is a real user. One of these checks is to ensure there is a real user agent on the request.

## Not my go to dataset 😭

This breaks my go to example dataset.

```python
pd.read_csv("https://waylonwalker.com/cars.csv")

# HTTPError: HTTP Error 403: Forbidden
```

## But requests works???

What's weird is, requests still works just fine!  Not sure why using urllib the way pandas does breaks the request, but it does.

```python
requests.get("https://waylonwalker.com/cars.csv")

<Response [200]>
```

## Setting the User Agent in pandas.read_csv

_this fixed the issue for me!_

After a bit of googling I realize that this is a common thing, and that setting the user-agent fixes it.  This is the point I remember seeing in the cloudflare dashbard that they protect against a lot of different attacks, aparantly it treats `pd.read_csv` as an attack on my cloudflare pages site.

```python
pd.read_csv("https://waylonwalker.com/cars.csv", storage_options = {'User-Agent': 'Mozilla/5.0'})

# success
```

## Now my data is back

Now this works again, but it feels like just a bit more effort than I want to do by hand.  I might need to look into my cloudflare settings to see if I can allow this dataset to be accessed by `pd.read_csv`.
Laravel 8 Eloquent whereNull() and whereNotNull() Query Example
Tags: laravel, laraveleloquent, php
Published: 2022-03-28 03:50:44

Originally posted @ https://codeanddeploy.com visit and download the sample code: https://codeanddeploy.com/blog/laravel/laravel-8-eloquent-wherenull-and-wherenotnull-query-example

In this post, I'm sharing a **Laravel 8 eloquent where null and where not null query** with a simple example. Usually, when querying your database you need to get data with null values. Or sometimes we need to get or check if the data value is not null. So Laravel already provided a shortcut for this to shorten our code.



## Laravel Where Null Eloquent

Using **Laravel where null** or whereNull() eloquent query. This will help us to get null data values from your database. In my example let's get the users not using two-factor authentication. So let say I have a **two_factor_secret** field in my user's table.

```php
<?php
  
namespace App\Http\Controllers;

use App\User;
use Illuminate\Http\Request;
  
class UserController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $users = User::whereNull('two_factor_secret')->get();
  
        dd($users);
    }
}
```

## Laravel Where Not Null Eloquent


**Laravel where not null** or whereNotNull() eloquent query will help us to get not null data values from your database. So in my previous code, we get the users without two-factor authentication. Now let's get the users with two-factor authentication.

```php
<?php
  
namespace App\Http\Controllers;

use App\User;
use Illuminate\Http\Request;
  
class UserController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $users = User::whereNotNull('two_factor_secret')->get();
  
        dd($users);
    }
}
```
Now you have a basic knowledge already about Laravel where null and where not null eloquent query.

I hope this tutorial can help you. Kindly visit here https://codeanddeploy.com/blog/laravel/laravel-8-eloquent-wherenull-and-wherenotnull-query-example if you want to download this code.

Happy coding :)
Types of Machine Learning.
Tags: programming, machinelearning, kubernetes, datascience
Published: 2022-03-28 03:44:04

## 1. Supervised Machine Learning :

Supervised learning algorithms are used when the output is classified or labeled.

This algorithms learn from the past data that is inputted, called training data, runs its analysis and uses this analysis to predict future events of any new data within the known classifications.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cww5b22ktelnzr75cflg.jpg)

## 2. Unsupervised Machine Learning :

Unsupervised learning is a machine learning technique in which the users do not need to supervise the model. Instead, it allows the model to work on its own to discover patterns and information that was preciously undetected.

It mainly deals with the unlabelled data.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pa5tqpqe1bejayrpob03.jpg)

## 3. Reinforcement Machine Learning :

This type of machine learning algorithm uses the trial and error method to churn out output based on the highest efficiency of the function.

The output is compared to find out errors and feedback, which are fed back to the system to improve or maximize the performance.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/suivdw050z04apd7offa.jpg)
Laravel 8 Logout Other Devices after Login
Tags: laravel, php, laraveltips, javascript
Published: 2022-03-28 03:39:56

Originally posted @ https://codeanddeploy.com visit and download the sample code: https://codeanddeploy.com/blog/laravel/laravel-8-logout-other-devices-after-login

[![Advanced Laravel SAAS Starter Kit with CRUD Generator](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wyjyev8tz3r8vi2w3on1.png)](https://1.envato.market/5g5QAn)

[Advanced Laravel SAAS Starter Kit with CRUD Generator - GET YOUR COPY NOW!](https://1.envato.market/5g5QAn)

In this post, I will share an effective method provided by **Laravel 8 on how to log out other devices after login.** If your developing a Laravel project that has a subscription limit to the users and is only allowed to login into one device at a time then we must implement this method.

 

If your using the default login method by Laravel then follow the steps below:

First, in your LoginController we have a method named `login()`. See the example code below:

```php
/**
* Handle account login request
* 
* @param LoginRequest $request
* 
* @return \Illuminate\Http\Response
*/
public function login(LoginRequest $request)
{
    $credentials = $request->getCredentials();

    if(!Auth::validate($credentials)):
        return redirect()->to('login')
             ->withErrors(trans('auth.failed'));
    endif;

    $user = Auth::getProvider()->retrieveByCredentials($credentials);

    Auth::login($user, $request->get('remember'));

    if($request->get('remember')):
        $this->setRememberMeExpiration($user);
    endif;

    return $this->authenticated($request, $user);
}
```

As you can see in my example we returned the `authenticated()` method after no errors above codes.


Then we should have an `authenticated()` method in our LoginController, See the example below:

```php
/**
* Handle response after user authenticated
* 
* @param Request $request
* @param Auth $user
* 
* @return \Illuminate\Http\Response
*/
protected function authenticated(Request $request, $user) 
{   
    Auth::logoutOtherDevices($request('password'));

    return redirect()->intended();
}
```

As you can see I added **Auth::logoutOtherDevices(**) with the parameter of password. So that we can enable to log out of the other active devices.

[![Advanced Laravel SAAS Starter Kit with CRUD Generator](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wyjyev8tz3r8vi2w3on1.png)](https://1.envato.market/5g5QAn)

[Advanced Laravel SAAS Starter Kit with CRUD Generator - GET YOUR COPY NOW!](https://1.envato.market/5g5QAn)

I hope this tutorial can help you. Kindly visit here https://codeanddeploy.com/blog/laravel/laravel-8-logout-other-devices-after-login if you want to download this code.

Happy coding :)
arduino – Does it make sense to plot the angle in an signal spectrum analyzer?
Tags: electricalelectronic, analyzer, angle, arduino
Published: 2022-03-29 03:39:30

---
title: arduino – Does it make sense to plot the angle in an signal spectrum analyzer?
published: true
date: 2022-03-28 03:37:49 UTC
tags: ElectricalElectronic,analyzer,angle,arduino
canonical_url: https://stackallflow.com/electrical-electronics/arduino-does-it-make-sense-to-plot-the-angle-in-an-signal-spectrum-analyzer/
---

I’ve built a toy oscilloscope with an Arduino, acquiring the samples with the ADC and plotting the spectrum on my computer. The spectrum is the output of the FFT algorithm. You can [see a video here](https://stackallflow.com/reference/38986) of the program in action.

The yellow line is the actual value of each sample as the output from the Arduino’s ADC. The red line is the magnitude of each complex number as the output from the FFT function, and the green plot is the angle of each of those complex numbers. The first spike is noise from the AC main power line, which is 50 Hz.

The red plot shows the “energy” of each frequency. What information does the angle shows? Is there an intuitive explanation?

## Accepted Answer:

In this case, the absolute angle you are plotting is relative to the phase at which you are taking samples with your ADC. By the way, it looks like your sample rate isn’t very stable, judging from how much the speed of the waveform moving across the display varies.

It would probably be more useful if you were to provide a triggering function for your oscilloscope, so that you get a stable waveform display to begin with, and then display _relative_ phase, perhaps taking the phase of the largest magnitude peak as your “zero” reference angle.

Keep in mind that the phase information in FFT bins that have low magnitude values is mostly the result of low-level noise, and won’t be very relevant to the overall signal analysis.

#Electronic #arduino #sense #plot #angle #signal #spectrum #analyzer

The post [arduino – Does it make sense to plot the angle in an signal spectrum analyzer?](https://stackallflow.com/electrical-electronics/arduino-does-it-make-sense-to-plot-the-angle-in-an-signal-spectrum-analyzer/) appeared first on [Stack All Flow](https://stackallflow.com).
How to display SMD footprints in Eagle CAD as separate layer instead TOP or BOTTOM?
Tags: electricalelectronic, bottom, cad, display
Published: 2022-03-29 03:39:06

---
title: How to display SMD footprints in Eagle CAD as separate layer instead TOP or BOTTOM?
published: true
date: 2022-03-28 03:27:39 UTC
tags: ElectricalElectronic,bottom,CAD,display
canonical_url: https://stackallflow.com/electrical-electronics/how-to-display-smd-footprints-in-eagle-cad-as-separate-layer-instead-top-or-bottom/
---

I would like to print Pads, Vias, SMD footprints altogether so that I can apply UV solder mask on board. The problem is that the SMD footprints is part of TOP layer.

What to do?

Looks like correct layer would be tStop, but it appears stripped instead of filled. Looks like I should use some image editing software to fill those pads manually.. .

## Accepted Answer:

As the others have pointed out, the correct layer to use for solder mask are `tStop` and `bStop`.

In many cases these layers are visualised in Eagle as hatched lines which is not what you want for printing. However it is very easy to remove this and print them out as solid. Simply check the `Solid` option in the print dialog:

[![Printing Solid](https://i.stack.imgur.com/sqcv4.png)](https://stackallflow.com/reference/38985)

#Electronic #display #SMD #footprints #Eagle #CAD #separate #layer #TOP #BOTTOM

The post [How to display SMD footprints in Eagle CAD as separate layer instead TOP or BOTTOM?](https://stackallflow.com/electrical-electronics/how-to-display-smd-footprints-in-eagle-cad-as-separate-layer-instead-top-or-bottom/) appeared first on [Stack All Flow](https://stackallflow.com).
Is anyone else too lazy to create blog post header images for each blogging platform?
Tags: discuss, blogging
Published: 2022-03-28 03:27:15

I am currently posting my blog posts to 3 websites:

1. my own website
2. dev.to
3. hashnode

I'd like to post in even more platforms like Hackernoon and Medium.

I find it troublesome to create header images though. For each platform, I have to figure out the appropriate dimensions, then create an image on photoshop that works best for each.

Is anyone else having this problem, or is it just me?

I'm asking because I'm thinking about building a solution for it, so that we only spend 5-10 minutes making these images.

Thoughts? How do you create your images? Would you use a blog post header image generator or prefer to do it yourself using existing tools?
RAD And V Models of SDLC
Published: 2022-03-28 03:14:15

_SDLC - Software Development Life Cycle_

**What is SDLC ?**
SDLC is a structured process that aims at developing _high quality software_, at the _lowest cost_ with _shortest production time_. International standard for software lifecycle process is defined in [ISO/IEC 12207](https://en.wikipedia.org/wiki/ISO/IEC_12207).

**SDLC Stages:**
1. Plan
2. Design
3. Implement (Develop)
4. Test
5. Deploy
6. Maintain

**SDLC Models:**
1. Waterfall Model (1970s to 90s)
2. Prototyping Model
3. Iterative Model
4. Spiral Model
5. V-shaped Model
6. Agile
7. Scrum
8. Kanban


**V-shaped Model**
This model is also known as _Verification and Validation model_, and is an extension of Waterfall model with testing phase integrated in each SDLC stage. Thus, in this model, Testing and Development goes in Parallel. 

Requirements <----------> Acceptance Testing
Specification <--------> System Testing
Architectural Design <------> Integration Testing
Detailed Design <-------> Unit Testing
< Coding >

The coding phase connects validation phase and verification phase.

**Pros:**
- Highly disciplined model, easy to understand and manage
- Effective for projects where requirements are fixed and well understood 

**Cons:**
- Less adaptive to change
- Not appropriate for large and complicated projects 
- Working software is produced towards the end only


**RAD Model**
RAD (Rapid Application Development) is a combination of Prototyping and Iterative models. In this model a working model of the product is rapidly developed and iterated to fit the requirement of the customer. This also means the writing of the software phase itself involves collecting requirement for the development phase.
In RAD model there is minimal planning as the product changes rapidly with each iteration. Unlike V-shaped model where the working product is only obtained towards the end, in RAD model workable product (prototype) is delivered on every iteration.

- Phases of RAD
1. Business modeling
2. Data Modeling
3. Process Modeling
4. Application Generation
5. Testing and Turnover

These phases are iterated over and over until the required product is reached.

**Pros:**
- Highly adaptive to change
- Reduced development time
- Least planning required
- Feedback oriented

**Cons:**
- System **must** be modular to be iterative
- High cost for smaller projects due to multiple iterations
- Demands user's involvement
- Highly skilled developers needed


_DevOps Internship Assignment | Week 1__
Developer tools matter!
Tags: programming, devops, discuss
Published: 2022-03-28 02:46:59

May you think developer tools are only relevant to the personal behaviors of developers. From my prior experiences, developer tools may impact the teams collaboration, reliability of applications and even business outcome. 
In this article, I will talk about why developer tools matters.

## Mind pattern of a team
A shared mind pattern of a team is the lubricant of smooth communication.  If a team can form an agreement on a code boilerplate generator, developers of the team can foster a shared mind set of how their code will be structured. Standardization of engineering practices is your friend if you want to scale your development team quickly when your business expands. When I started my project, my team and I only focuses on the features delivery to meet business requirements, and we only had 6 team members, and each of us has an our own set of tools and development habits. In the name of polyglot of Microservices, some of services are constructed in varied ways. As our business grows, the code maintenance workload becomes overwhelming and new features delivery were dragged behind because developers have to spend hours to understand services that are developed by his/her peers. Besides the learning cost, when we try to build the CI/CD pipelines, because of varied code structure, multiple pipelines are needed.

## Service reliability
Service reliability are often ignored at the beginning. You must often hear saying of "Let's focus on the features first and fix the reliability issue when business is impacted". By saying this, reliability of services are often ignored until something really bad happens. Reliability must be considered at the beginning. Developer tools often have the reliability features included, that means we can use the tool to have the service built in the correct way so that the reliability features are included inherently. 

## Service security 
Security and reliability are often interconnected. A shared framework and development toolset can enable the authentication, authorization, encryption, key management, and etc inherently. By doing this, the security review are much more efficient. Developers can focus on what really matters to the business logic.
Starting a React App
Published: 2022-03-28 02:41:11

How to start a React app:

The first thing to do is make sure to have [Node.js](https://nodejs.org/en/) and Node Packet Manager (NPM) installed on your system. 

Then, run:

`npx create-react-app example-app`


Now, we can cd into the app directory. 

`cd example-app`

Start the server by running `npm start`
Some good UI Library for React. 🌐
Tags: react, webdev, programming, ux
Published: 2022-03-28 02:33:50

In this article we will see some nice UI Library.

### Bootstrap [🔗](https://getbootstrap.com/)
- Bootstrap always remains in top of my list. because of large community support for any errors, popularity, easy to use.
- Large variety of components, also templates, complex components of bootstrap can be found easily.
- We can use Sass for advance customization.

### MUI [🔗](https://mui.com)
- Material UI is based on Google's [material design] (https://material.io), so it gives more mobile-friendly user experience to your website.
- Material UI is also gives some complex components like Skeleton, which supports lazy loading of components.
- Informative Data-grid system.

### Fluent UI [🔗](https://developer.microsoft.com/en-us/fluentui#)
- Fluent UI by Microsoft gives similar experience to user like Microsoft Word, PowerPoint or any other of there app.
- It can easily be integrated to any platform - Web, IOS, Android, or any multi-platform language like Flutter or react native.
- If you are new to Web Development then, I highly recommend going with Fluent UI.
Chantheng Phun Founder Of Sikak Media ?
Published: 2022-03-28 02:04:29

Chantheng Phun, Born on (01 December, 2002,) in Battambang province, Cambodia, is an entrepreneur and founder and CEO of Sikak Media,

He is the co-founder and CEO of Sikak Media, of one of Cambodia’s first and most successful forays into e-commerce.

Chantheng Phun is an, entrepreneur, digital marketer, and businessman acency, Marketing online,and his outstanding Business mindset says much about the prosperous future of Sikak Media.
Paradigma Declarativo
Published: 2022-03-28 01:59:56

Continuando os artigos sobre os **paradigmas de programação**, vamos falar sobre o **Paradigma Declarativo**.

### Contextualizando...

Diferente do [Paradigma Imperativo](https://dev.to/dnovais/paradigma-imperativo-55eb), o **Paradigma Declarativo** tem como o foco principal **o que fazer** e não o como fazer.

Imagine que agora você vai pedir um sanduba com aquele combo caprichado, e para isso basta, você pegar o celular, abrir um desses aplicativos de delivery e de forma **declarativa** fazer o pedido e aguardar chegar, correto? E provavelmente você não se importa como o sanduíche foi feito e chegou, o importante é o resultado, ou seja, o pedido ter chegado de acordo com o que foi escolhido.

Se fossemos escrever um algoritmo, as instruções seriam passadas tudo de forma declarativa, ou seja, iriamos passar uma sequência de funções a serem executadas sem nos preocupar em como essas funções foram implementadas. De forma que o resultado esperado será sempre o mesmo, o pedido ter chegado de acordo com o que foi escolhido.

Ao nível computacional, estaríamos escrevendo um algoritmo de forma **declarativa**, onde passaríamos um passo a passo **do que fazer** para que o computador possa executar, porém, com um nível maior de abstração.

Dessa forma, o programador deve preocupar com o resultado esperado e não necessariamente em como o resultado deve ser computado.

### Linguagens de programação
Algumas linguagens baseiam-se no modelo declarativo, dentre elas: Elixir, Erlang, Haskell, Lisp, SQL.

Outras linguagens possibilitam um **mix** entre os paradigmas **imperativo** e **declarativo**, conhecidas como **linguagens multi-paradigmas** ([veja este artigo que escrevi sobre linguagens multi-paradigmas](https://dev.to/dnovais/o-que-significa-ser-multi-paradigma-8ad)).

Exemplos de linguagens de **programação multi-paradigma** são: C++, Groovy, Scala, Swift, Ruby, Lua e Python.
Laravel - Configurando dados Default para relacionamentos do tipo BelongsTo
Tags: laravel, eloquent, laraveltips
Published: 2022-03-28 00:55:57

---
title: Laravel - Configurando dados Default para relacionamentos do tipo BelongsTo
published: true
description: Aprenda a setar dados default quando um model em um relacionamento do tipo BelongsTo não for encontrado no laravel.

tags: laravel, eloquent, laraveltips
//cover_image: https://direct_url_to_image.jpg
---

{%embed https://youtu.be/W54JhxykBVk %}
Scaling up express js performance
Tags: node, typescript, javascript, performance
Published: 2022-03-28 00:54:26

Nodejs runtime was built on top of the v8 chrome engine which runs on the event loop model. Nodejs has a single thread runtime which makes it relatively fast in executing and dealing with I/O operations.

Even thought the single thread nature has much advantage it has some other disadvantages. 
Nodejs applications can be blocking when CPU intensive tasks are running.

Imagine an express application which has a route that checks whether a number is a prime number. When a user sends a request passing a larger number, the application will prevent a user who sends a smaller number from getting a faster response.

Nodejs exposes a lot of APIs that allows developer to manage process and make full use of the host machine's capabilities.

Imagine spinning up multiple instances of your node applications on a single host that is well load balanced. 

There is an easy implementation of this using a package I found on npm. The code snipped below shows a simple way of using this package to run multiple instances of your node applications on your host machine.
```
import express from "express";
import AppRunner from "express-worker-manager";

const app = express();

app.get("/hello", (_, res) =>
  res.send(`Hello response from app running in process ${process.pid}`)
);

const runner = new AppRunner(app, { env: "production",port:4000});
runner.listen(() => {
  console.log("App running");
});
```

The code below shows a simple usage of the express-worker-manager to spin up multiple instances of your express application based on the number of CPUs available on host machine. Each instance runs in a core of the CPU. 

Link to package https://www.npmjs.com/package/express-worker-manager