teleren/devto huggingface dataset:
What is python🐍modules 🤔
Tags: python, module, function
Published: 2022-10-01 12:41:02

A module is simply Python file with a .py a extension that can be imported inside another Python program.


In Python, there are two types of modules.
**1. Built-in Modules
2. User-defined Modules**


**Built-in Modules**
Built-in modules come with default Python installation.
Some commonly used Python built-in modules are datetime, os, math, sys, random, etc.

**User Defined Modules**
The modules which the user defines or create are called a user-defined module.
We can create our own module, which contains classes, functions, variables, etc., as per our requirements.


How to import Modules?

The import statement is used to import the whole module.

`import math`

You can import multiple modules by seperating a comma between them.

`# Import more than 1 modules
import math, random
`

**Create Modules in Python
**
To create a module, write Python code in the file, and save that file with the.py extension.
Now you can use functions defined in your file in another file by just importing module and not writing whole code again.


**See all functions of any module at once**.

_dir()_ is a built-in function. This function is used to list all members of the current module.


`import math
print(dir(math))
['__doc__', '__loader___', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma' 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'loglp', 'log2', 'modf', 'nan', 'pi', 'pow', 'radians', 'remainder', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'tau', 'trung 1`
Hacktoberfest is here — and this is the lowdown
Tags: hacktoberfest, meta, opensource, beginners
Published: 2022-10-01 15:15:55

Hacktoberfest has become a staple in open source. It's an annual tradition loved by many (and it's not for everyone, that's fine).

But here is the deal:

- Everyone is welcome
- Quantity is fun, but quality is key
- Short-term action, Long-term impact

These are values we can get behind at DEV.

In terms of the challenge itself, follow the rules, and make enough _valid_ pull requests this month, and claim some really fun and unique prizes from DigitalOcean.

## [Here are the full participation rules](https://hacktoberfest.com/participation/)

***

This year, as DEV members participate, here is what to know:

## Post under the [#hacktoberfest](/t/hacktoberfest) tag on DEV.

Whether you are elevating a project, or walking through your successes, you are welcome to post here on DEV.

## Post under the [#hacktoberfest](/t/hacktoberfest) tag on [CodeNewbie](https://community.codenewbie.org/).

Yes, there is another Forem community that might even be better than DEV to post to — one just for newbies. Join if you haven't yet!

## Get your DEV badge if you complete the Hacktoberfest challenge!

Yes, we have dedicated profile badges on DEV for completing the Hacktoberfest challenge.

Here is my 2019 Hacktoberfest badge on my profile:

![Hacktoberfest](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0knqpiuh7naggq58nj2h.png)

If you complete the challenge, you'll get a code you can redeem with us to claim your badge. This is totally optional, and up to you.

## Have fun!

Happy contributing! 🕊
Increase Memory and Maximum Upload Limit in WordPress
Tags: programming, tutorial, wordpress, plugin
Published: 2022-10-01 15:08:54

Learn how to increase the maximum upload file size for your WordPress site. In this video, I have shared how to increase maximum upload file size in localhost and increase PHP memory limit in WordPress.

Dealing with [Fatal Errors](https://user-meta.com/blog/increase-php-memory-maximum-upload-limit/) in WordPress happens to everyone eventually. A fatal error occurs when something in the code is preventing a site from loading properly. The problem is not going to solve itself. You have to identify what is causing it and get it resolved before your site will not come back. There are some solutions given for the Fatal Error. Try to follow the steps and hope that you can solve your problem.

https://www.youtube.com/watch?v=YgBeH8WVIDA
need help in sql script
Published: 2022-10-01 15:07:06

Hi all,

My requirement is as below:
I do have three tables and from each table i am taking one column to get the logic. Below are the two logics as per the requirement. 

In t3 there is a column called XYZ, by applying the below two logics, the t3.XYZ column should display the result:

Table names:
t1 has columns ABC and MNC
t2 has columns ABC and MNC
t3 has XYZ 
 
1) The t1 and t2 tables have one column called ABC column. when t1.abc and t2.abc contains the value as "Y,", then i need to Display t3.XYZ column as 'INVALID'
                      or
2) If the t3.xyz matches t1.mnc or t2.mnc then display t3.xyz else INVALID.

I have written the logic as below but it is not working
case
    when t1.abc = 'Y' then 'INVALID'
    when t2.abc = 'Y' then 'INVALID'
    when t3.xyz = t1.mnc or t3.xyz = t2.mnc then t3.xyz
else 'INVALID'
end

But it is taking else part. In this case i need to get the result as t3.xyz. Please help in this case.
Is Unique?
Tags: javascript, algorithms, react
Published: 2022-10-01 14:56:01

**We'll discuss three ways to determine if all characters in a string are unique. Each has benefits and drawbacks regarding time and space complexity.**

**Input: String**
**Output: Boolean**

## Examples
`isUnique('abcdef'); // -> true
isUnique('89%df#$^a&x'); // -> true
isUnique('abcAdef'); // -> true
isUnique('abcaef'); // -> false
`
**Solution 1
**
`
function isUnique(str) {
    for(let i = 0; i < str.length; i++) {
        if(str.lastIndexOf(str[i]) !== i) {
            return false;
        }
    }
  
    return true;
}

`
Fail to send ICMP packets by ping command on Synology NAS
Published: 2022-10-01 14:13:18

When you cannot send ICMP packets by ping command on Synology NAS, you have to set 'sudo' as the command prefix.

https://community.synology.com/enu/forum/2/post/129235

e.g. `sudo ping 1.1.1.1`
Nginx Ingress returns only a few metrics on Kuberntes.
Tags: nginx, kubernetes, prometheus
Published: 2022-10-01 14:11:13

# Situation

To visualize  http requests on grafana, I installed Nginx Ingress and Prometheus in Kubernetes Cluster (RKE2). The installation steps are based on official guide as follows.

https://kubernetes.github.io/ingress-nginx/

The similar problem is reported on GitHub.

https://github.com/kubernetes/ingress-nginx/issues/5755

The figure shows this situation.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ncrge9rjeqs32hz6s9o.png)

# Cause

This problem is caused by not specifying the 'host' parameter in yaml for ingress controller.

The metrics server in nginx ingress only return a few metric about the default host * (generally virtual host). Thus, few metrics display on grafana.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4wrssv0sb5dxcdz1mnkz.png)

# Solution

When you create ingress resource, you set 'host' parameter in yaml. Then, you can check the metrics (such as nginx_ingress_controller_requests) in grafana.

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hnh9e3wheb5peqxswert.png)
HorizontalPodAutoscaler does not return TARGETS metrics and returns '<unknown>' on kubectl.
Published: 2022-10-01 14:07:07

I had faced the error: HorizontalPodAutoscaler does not return TARGETS metrics and returns `'<unknown>'` on kubectl.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/918jlmgit3htc0s05y70.png)

# Environment

Kubrenetes engine: RKE2 (v1.22.6+rke2r1) x 3 nodes

Manifest: https://github.com/cdsl-research/text-checker/blob/c351a2ebe042560842913ca9501949fc90198252/kubernetes/scaleOut.yml

# Solution

First, I tried to run the following command.

```
kubectl get --raw /apis/metrics.k8s.io/v1beta1"
```

The command returns an error.

Second, I installed metrics-server to the cluster.

https://github.com/kubernetes-sigs/metrics-server

I retry to run `kubectl get --raw /apis/metrics.k8s.io/v1beta1`. The command runs successfully.

Third, I fixed kubernetes manifests as summarised below.

* Set 'requests' parameter per container in deployment
* Fix resource specs for HPA

https://github.com/cdsl-research/text-checker/commit/e13c178eaa4e1ab140462bf658a4e477f87babb1

https://github.com/cdsl-research/text-checker/commit/1bcc0dc21fc5f3fd8a7b42064e582e23cff303ab

Finally, the command 'kubectl get hpa'  returns values 'TARGETS' successfully.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ng5p02j1dn3d1wlmt9hp.png)
I made an admin dashboard for React using Typescript! Use it for free!
Tags: typescript, webdev, showdev, react
Published: 2022-10-01 13:59:02

Hey guys,
I made an admin template for React using Typescript! Use it for free!

Presentation: https://horizon-ui.com/
Live demo: https://horizon-ui.com/horizon-ui-chakra-ts/
Download on Github: https://github.com/horizon-ui/horizon-ui-chakra-ts
First Beginner Update.
Tags: beginners, github, devops, linux
Published: 2022-10-01 13:57:05


I’d really like to thank everyone who reached out to me on my previous post (https://dev.to/prettygirlscode/am-i-in-the-right-place-2c7i) 
I had no expectations but I was glad I published that first post.

**My Journey So Far**


A big part of any notable achievement involves the mindset. The first thing I had to work on was my mindset. Why was this step so important?
Usually, achieving notable success is difficult, it requires moving forward despite unavoidable roadblocks and hardships. The natural response to difficult situations is to give up and stay where you’re comfortable. I’ve had to continually tell myself;

“ It’s going to get harder with              time, keep going anyways”

**Linux or Windows**

What’s the best operating system to use when learning software engineering? 
There is Windows, Mac and Linux. I’ve not used the Mac operating system before so I had to choose either Windows or Linux. 
After much contemplation, I came to the following conclusions;

- Windows is proprietary and does not let you look deeper but Linux operating systems does not only encourage you to look deeper, it actually expects you to. 
Currently, I’m using the Linux operating system because it gives me deeper insight into every action I take, consequently increasing my understanding. 


- This decision boils down to what you actually want to do and the tool best suited for the task. I believe there are tasks best suited to Windows and tasks best suited Linux. After making the decision to use Linux primarily, I had to learn the Linux commands, shell navigation etc.

**Flowcharts, Pseudocodes and Algorithms**


I cannot emphasize enough how getting knowledge and understanding of these concepts is helping me get better at problem solving. It might not seem important at the beginning, but with time and as you start working on bigger projects you’ll begin to see their importance. A flowchart is simply a graphical representation of steps involved in a task, project or program. Algorithms are step by step procedures carried out to solve problems. Pseudocodes are false codes, codes written in plain English and they’re not language specific. Why did I find these concepts important? 
Because they improves problem solving, break down complex problems, they give a clearer picture of the solution and they help non programmers understand your program or solution.


**Git and GitHub**

I’m also getting familiar with Git and GitHub. If you’re a beginner, please sign up with GitHub and learn how to use it. It is super important and there are many resources for learning. 


What are your thoughts on this post? 
Please comment any advice, addition, subtraction and constructive criticism. If you found this post useful, kindly share.
Monthly Amazon Location Service Updates - 2022.09
Tags: amazonlocationservice, amplifygeo, amplify, amazonlocationserviceupdates
Published: 2022-10-01 13:43:54

![img](https://day-journal.com/memo/images/logo/aws/location-service.png)

### Monthly Amazon Location Service Updates - 2022.09

<br>

This is a summary of the September updates for Amazon Location Service.

<br>

## 2022.09 Updates

[Announcing unique place IDs for Amazon Location Service](https://aws.amazon.com/about-aws/whats-new/2022/09/unique-place-ids-amazon-location-service/)
Unique PlaceIDs are now available with the geocoding feature.

[Amazon Location Service Samples - OpenLayers Amplify](https://github.com/aws-samples/amazon-location-samples/tree/main/openlayers-amplify)
OpenLayers samples have been added.

<br>

## Other Info

[Amazon Location Service Developer Guide](https://docs.aws.amazon.com/location/latest/developerguide)
Official Amazon Location Service Documentation.

[Amplify Geo Docs](https://docs.amplify.aws/lib/geo/getting-started/q/platform/js)
Official Amplify Geo Docs.

[Amazon Location Service Samples](https://github.com/aws-samples/amazon-location-samples)
Official Amazon Location Service samples.

[amazon-location-service-starter](https://github.com/dayjournal/amazon-location-service-starter)
Build environment to get started with Amazon Location Service.

[A Summary of How to Build Amplify Geo and Amazon Location Service](https://dev.to/aws-builders/a-summary-of-how-to-build-amplify-geo-and-amazon-location-service-5hal)
Summary of Amazon Location Service and Amplify Geo. (as of December 2021)  

[dev.to](https://dev.to/dayjournal)
Articles on Amazon Location Service.

[tags - Amazon Location Service](https://day-journal.com/memo/tags/Amazon-Location-Service)
[tags - Try](https://day-journal.com/memo/tags/Try)
Notes on Amazon Location Service. (Japanese)

<br>

## Related Articles

{% link https://dev.to/aws-heroes/monthly-amazon-location-service-updates-202208-47jf %}
⚡ Serverlessland ⚡
Tags: awscloud, serverless, awscommunitybuilders, awscommunity
Published: 2022-10-01 13:38:29

**Want to Build and run applications without thinking about servers?**

Serverless technologies feature automatic scaling, built-in high availability, and a pay-for-use billing model to increase agility and optimize costs.

Learn to use and build apps that scale automatically on low-cost, fully-managed serverless architecture on AWS at Serverlessland. - https://serverlessland.com/

Serverlessland brings together all the latest blogs, videos, and training for AWS Serverless.

Read more about full list of Serverless services on AWS  - https://aws.amazon.com/serverless/

What are the aws serverless services you use? Comment bellow.
Testes em PHP com o framework PEST
Tags: testing, php, bdd, tdd
Published: 2022-10-01 13:11:47

## Introdução

Olá, me chamo Allisson Rafael e este artigo faz parte do meu trabalho de Ferramentas de Testes. 

Nele irei falar de forma geral sobre o framework PEST que é uma opção ao PHPUnit para a realização de testes em PHP.


Abaixo explico como instalar a mesma para que você possa escrever e executar seus testes de forma simples e intuitiva, que é o que a suíte propõe quando diz se um framework simples e elegante para a escrita de testes.

## Instalando a Suíte
Para instalar, devemos ter o composer instalado, então entendo que você já tem o mesmo instalado.

```
composer require pestphp/pest --dev --with-all-dependencie

```

Após instalada a suíte vamos entender como podemos escrever nossos testes.

## Executando o primeiro test

Vamos criar/rodar o nosso primeiro teste de acordo com o tutorial básico do framework. 

Dentro do diretório do nosso projeto usaremos o comando:

```
./vendor/bin/pest --init
```
Ao rodar o mesmo criará toda a estrutura necessária para rodar os testes escritos e o teste de exemplo que é criado após a inicialização da suíte.

E para rodar o teste de exemplo, usamos o seguinte comando:

```
./vendor/bin/pest
```

E a saída deverá ser a seguinte:

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

## Ficou curioso e quer saber como você pode escrever seus próprios testes utilizando a suíte? Eu vou deixar um vídeo tutorial onde mostro de forma rápida alguns testes que escrevi e como funciona cada um deles.
[Assista ao vídeo clicando aqui!](https://youtu.be/sVmwCTNk-tY)

Todos os códigos utilizados no vídeo podem ser baixados aqui:
[Baixar códigos](https://github.com/allissonaraujo/PEST-Framework-testing-tools)
What's new in Ansible Semaphore 2.8.66
Tags: ansible, devops, awx
Published: 2022-10-01 13:08:38

---
title: What's new in Ansible Semaphore 2.8.66
published: true
description: | After half a year of waiting, the release of the Semaphore has finally come out. What's new in the much-anticipated release?
tags:
- Ansible
- DevOps
- AWX

# cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tlhmcft4m8qf9wr3tqeq.jpg
---

After half a year of waiting, the release of the Semaphore has finally come out. What's new in the much-anticipated release?

### Dark mode

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

### Color highlighting for Ansible output

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

### Local playbooks

Previously Semaphore could only work with playbooks located in Git repositories. Support for local playbooks has been added in this version.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t1a9040ctxpyo9d2nf6b.png)
React useEffect And What Is It?
Tags: react, tutorial, interviewquestions, javascript
Published: 2022-10-01 12:56:52

## React Side Effect What is it with examples?

You may want to run some code after rendering without running that code in the render() method itself. The useEffect function runs after the JSX component return.

**Examples:**
All sort of codes will effect your app from outside: API, websockets, local storage and multiple states need to be in sync

---

## When does React run useEffect? and when does NOT?

Runs the first time with the first render and for each other re-render of the component it must check first on the dependency array.

---


## What is the dependency array?  

This is an important part of the useEffect function, it's an array containing the dependencies, these  dependencies will be the conditions that the useEffect function will only run when they change.

---
useEffect Example:

```
// import useEffect 
import { useEffect } from 'react';

 function MyComponent() { 
// We create the count state to include it in the useEffect 
   dependency array
   const [count, setCount] = React.useState(0); 

// Arguments: function and array 
// Count is one of dependencies 
   useEffect(() => {}, [count]); 
// will run useEffect when count has different value than 0

// JSX component return
 return ... }
```
Parallel Matrix Multiplication in Rust
Tags: rust, machinelearning
Published: 2022-10-01 12:56:52

Much of linear algebra revolves around matrix multiplications. Since this is an O(n^3) operation, other techniques are needed to improve its performance. Today, I will show how I parallelized matrix multiplication, improving speed by 4x on my 12-thread machine.

In my examples, I am using the `nalgebra` crate to handle matrix storage (which stores dynamically sized matrices as a Vec in column-major order). This isn't too important, the only thing that really matters is the ability to index the matrix by row and column index.

## Single-Threaded Implementation

In order to multiply matrices, we need to iterate over the columns of the rhs, then for each column, iterate over the rows of the lhs. We then zip the lhs row with the rhs column, taking the dot product of these two arrays.

```rust
let l_shape = lhs.shape();
let r_shape = rhs.shape();

// check for shape compatibility here...

// the multiplication
let result: Vec<f64> = (0..r_shape.1).flat_map(move |rj| {
    (0..l_shape.0).flat_map(move |li| {
        (0..r_shape.0)
            .zip(0..l_shape.1)
            .map(move |(ri, lj)| {
                lhs.index((li, lj)) * rhs.index((ri, rj))
            })
            .sum::<f64>()
    })
})
.collect();

// result is a vec in column-major order
```

## Parallelizing

I will now use `rayon` to parallelize this operation. It's way simpler than you may think!

```rust
let result: Vec<f64> = (0..r_shape.1).into_par_iter().flat_map(move |rj| {
    (0..l_shape.0).into_par_iter().flat_map(move |li| {
        (0..r_shape.0)
            .zip(0..l_shape.1)
            .map(move |(ri, lj)| {
                lhs.index((li, lj)) * rhs.index((ri, rj))
            })
            .sum::<f64>()
    })
})
.collect();

```

That's it! Just adding `into_par_iter` after the ranges is all that is needed. I benchmarked this on an Intel i5-10600K (12) @ 4.800GHz, multiplying a 1000x1000 matrix with a 1000x1 vector, and the average execution time went from 8 ms down to 2 ms. That is a 75% improvement in speed.
Multer Error
Tags: react, javascript, programming, node
Published: 2022-10-01 12:53:57

Getting this error while using multer with react.js and node.js
``Unexpected end of form
    at Multipart._final (E:\nearme\backend\node_modules\busboy\lib\types\multipart.js:588:17)
    at callFinal (internal/streams/writable.js:610:10)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  storageErrors: []
}``

react.js file 
`const fd = new FormData();
    fd.append("profile", data.profile);
    fd.append("name", data.name);
    fd.append("email", data.email);
    fd.append("password", data.password);

    const res = await axios.post("http://localhost:8000/signup/data", fd, {
      headers: { "Content-Type": "multipart/form-data" },
    });`

node js file:
`const multer = require("multer");
const storage = multer.diskStorage({
  destination: function (req, file, cb) {
    cb(null, "../public");
  },
  filename: function (req, file, cb) {
    const uniqueSuffix = Date.now() + "-" + Math.round(Math.random() * 1e9);
    cb(null, file.fieldname + "-" + uniqueSuffix);
  },
});`

`const upd = multer({ storage: storage }).single("profile");
router.post("/data", (req, res) => {
  upd(req, res, function (err) {
    if (err instanceof multer.MulterError) {
      console.log("A Multer error occurred when uploading");
    } else if (err) {
      console.log("An unknown error occurred when uploading", err);
    }
  });
});`