teleren/devto huggingface dataset:
7 Python Project Structure Best Practices.
Tags: programming, beginners, python, codenewbie
Published: 2021-10-04 15:19:24

Is there a perfect project structure for Python? It turns out there is.

I don't mean the folder structure. But an initial setup that multiplies your odds of creating a groundbreaking project.

In this post, I've discussed 7 techniques you should always use in every Python project.

If they sound too overwhelming, don't worry. I've also created __a blueprint__ you can easily copy and use right away.

[7 Ways to Make Your Python Project Structure More Elegant](https://www.the-analytics.club/python-project-structure-best-practices)
How to use Unit tests in Laragine
Tags: laravel, programming, php, api
Published: 2021-10-04 19:04:20

In the previous tutorial, I taught you how to create a `fully CRUD API`, let's continue the journey and learn how to use **Laragine** to test the `API` that we created in the previous tutorial.

## Steps:
We need to do 3 things in `phpunit.xml` in the root directory:

1. Change the value of the `bootstrap` attribute to `vendor/yepwoo/laragine/src/autoload.php` in `PHPUnit` tag (it's the same as `vendor/autoload.php` but with needed stuff to run the tests correctly in the generated modules and units).

2. Add the following to the `Unit` test suite:

`<directory suffix=".php">./core/*/Tests/Feature</directory>`
`<directory suffix=".php">./plugins/*/Tests/Feature</directory>`

3. add the following to `Feature` test suite:

`<directory suffix=".php">./core/*/Tests/Feature</directory>`

`<directory suffix=".php">./plugins/*/Tests/Feature</directory>`

**Here's the full code snippet: **
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0s0987u0gmiezp883auf.png)


* Let's go to `PostTest.php` in `core/Blog/Tests/Feature`
* There're **five** main *functions* in the file: 
1. `testItShouldGetListingOfTheResource()` 
for testing get the lists of the the resource.
2. `testItShouldStoreNewlyCreatedResource()` 
for testing create a new resource in the storage. 
3. `testItShouldGetSpecifiedResource()` 
for testing get a specefied the resource.
4. `testItShouldUpdateSpecifiedResource()`
for testing update a resource in the storage 
5. `testItShouldRemoveSpecifiedResource()`
for testing remove a resource from the storage

## Note
you can edit the unit tests function as you want, we just write the main methods for each CRUD.

Now open your `terminal` or `git bash` in your project and let's run the test, you can run one of the following commands: 
1. `php artisan test`
2. `./vendor/bin/phpunit`

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/396wngvgv6lskazdg3z1.png)

## Conclusion
I hope you found this article helpful. If you need any help please let me know in the comment section.

Let's connect on [LinkedIn](https://www.linkedin.com/in/abdlrahmansaber/)
The ‘Engineering Production-Grade Shiny Apps’ book is available in print!
Tags: rstats
Published: 2022-04-01 09:20:19

---
title: The ‘Engineering Production-Grade Shiny Apps’ book is available in print!
published: true
date: 2021-10-04 00:00:00 UTC
tags: rstats
canonical_url: https://colinfay.me/engineering-shiny-print/
---

I’m so, so excited to announce that the _‘Engineering Production-Grade Shiny Apps’_ book is now available in print! This book is the result of two years of work, and I couldn’t be more happy to see it available in print.

As its title suggests, _‘Engineering Production-Grade Shiny Apps’_ is a book about building `{shiny}` apps that will be sent to production. It goes deep into `{golem}`, of course, but it’s not a book about `{golem}` only — it tries to cover a large panel of topics, and I’m pretty sure that if you are a `{shiny}` developer, there is something for you in this book: project management, code organization, team work, best practices for front end development, CI and CD, deployment, code optimization…

This book will remain available online for free at [https://engineering-shiny.org/](https://engineering-shiny.org/) (and I want to thank Chapman and Hall/CRC for this), but if you want to grab a copy, you can go on [routledge.com](https://www.routledge.com/Engineering-Production-Grade-Shiny-Apps/Fay-Rochette-Guyader-Girard/p/book/9780367466022) and order one. I know it can feel counter-intuitive to buy a print copy of a book which is available online, but if you want this to continue to happen, please continue to support the publisher by buying a copy of this book, or of any other from Chapman and Hall/CRC — they have been doing a massive work when it comes to organizing, editing and reviewing.

I want to personally thank everybody that has been contributing to this book, with some special thanks to [Eric Nantz](https://twitter.com/theRcast) which has been a `{golem}` early adapter and an all time supporter of everything from the `golemverse`, to [David Granjon](https://twitter.com/divadnojnarg) for all his feedback on the book, and to [Christophe Dervieux](https://twitter.com/chrisderv) for his precious help during my battles with Markdown. Thanks also to [David Grubbs](https://twitter.com/crcgrubbsd) from Chapman and Hall/CRC for making this happen.

That being said, I still can’t believe I’ve added my name to the list of authors in “The R Series” books 😱

I hope you’ll enjoy it!
Divtober Day 2: Watch
Tags: codepen, divtober, css, art
Published: 2021-10-05 00:36:39

---
title: Divtober Day 2: Watch
description: A neighborhood watch sign done with a single element in CSS
published: true
tags: codepen,divtober,css,art
series: divtober
---

I forgot to post the one I did for day 2 😅.

Here's a Neighborhood **Watch** sign coded with a single CSS element.

{% codepen https://codepen.io/alvaromontoro/pen/mdwggPb %}
Does blogging make you a better dev?
Tags: javascript, webdev, beginners, watercooler
Published: 2021-10-05 04:16:26

Why should you start a blog as a developer? Does it actually have any benefits, or is it just one of those things people tell you to do to feel productive?

Although at ground level it seems scary and not worth the effort, there are actually quite a lot of benefits from doing so. There's a quote that floats around the internet and it goes.

> **If you can't explain it simply, you don't understand it well enough.**

This means the opposite is also true, if you can explain it simply, then you do understand it. Having to sit down and write about a topic really highlights what you do understand about it and what you don't. This is great for finding what you excel at and what you need to buckle down and study.


There is a technique out there called the Feynman Technique, which is to write out the thing you're trying to learn as simply as possible. Then read back over it and find any flaws within the explanation, or any over technical jargon, and simplify it even further.

This process really highlights what your knowledge about a certain concept, as well as if you understand the concept behind it or just the basic-level jargon. The funny thing about this technique is that it is incredibly similar to writing a blog. A simpler explanation about overly technical topics, condensed into an easy to read format.

Another reason to start a blog is to increase your writing communication skills. There's no such thing as being too good at communication. As you slowly develop your skills and start making the transition into a professional job, being able to sell yourself in written format will become crucial.

As well as being able to articulate your ideas and get them down on paper. Into a presentable form for that board meeting or startup pitch, you've been meaning to do. Communication is one of the most important skills someone can have, and having somewhere to practise it, such as a blog, is important. 

### Thank **YOU** ✨💝
I just hit 1k followers on my Dev.to account. I never thought about reaching this milestone. I really hope I have been able to share knowledge and benefit others from my posts. Thank you for showing me so much of love.

Let's connect on [Twitter](https://twitter.com/rainboestrykr)
Python abs()
Tags: python, programming, codenewbie, tutorial
Published: 2021-10-07 07:04:29

---
title: Python abs()
published: true
date: 2021-10-05 08:30:00 UTC
tags: #python #programming #codenewbie #tutorial
canonical_url: https://itsmycode.com/python-abs/
---

ItsMyCode |

The **`abs()`** function in Python returns the absolute value of a given number, which means the **`abs()`** method removes the negative sign of a number. 

If the given number is complex, then the **`abs()`** function will return its magnitude.

## **abs() Syntax **

The syntax of **`abs()`** method is 

**abs(number)** 

## abs() Parameters

The **`abs()`** function takes a single argument, a number whose absolute value is to be returned. The number can be 

- integer
- floating-point number
- complex number

## abs() Return Value

**`abs()`** method returns an absolute value of a given number.

- **For integers**  – absolute integer value is returned
- **For floating numbers**  – absolute floating-point value is returned
- **For complex numbers**  – the magnitude of the number is returned

## What does the abs() function do in Python?

The **`abs()`** function will turn any negative number into positive, the absolute value of a negative number is multiplied by (-1) and returns the positive number, and the absolute value of a positive number is the number itself. 

## Example 1: Get absolute value of a number in Python

In this example, we will pass an integer, float into the **`abs()`** function, and returns the absolute value.

```python 
# Python code to illustrate abs() built-in function

# integer number
integer = -10
print('Absolute value of -10 is:', abs(integer))

# positive integer number
positive_integer =20
print('Absolute value of 20 is:', abs(positive_integer))

# floating point number
floating = -33.33
print('Absolute value of -33.33 is:', abs(floating))

```

**Output**

```python 
Absolute value of -10 is: 10
Absolute value of 20 is: 20
Absolute value of -33.33 is: 33.33
Absolute value of 3-4j is: 5.0
```

## Example 2: Get the magnitude of a complex number

In this example, we will pass a complex number into the **`abs()`** function and returns the absolute value.

```python 
# Python code to illustrate abs() built-in function

# complex number
complex=(3-4j)
print('Absolute value of 3-4j is:', abs(complex))
```

**Output**

```python 
Absolute value of 3-4j is: 5.0
```

The post [Python abs()](https://itsmycode.com/python-abs/) appeared first on [ItsMyCode](https://itsmycode.com).
Working with Optimizely Projects
Tags: optimizely, projects, csharp, microsoft
Published: 2021-11-05 11:38:32

Optimizely has a featured called ['Projects'](https://world.optimizely.com/documentation/developer-guides/CMS/projects/), which allows editors to collaborate on content before scheduling to publish.

### Problem

While work on a project that imports hundreds, of pieces of content. These pieces of content are added to a project for the team to review and mark the items as ready to publish.

You can see the problem here in that with hundreds of pieces of content to review, marking each content piece as ready to publish could take some time.

### Solution

To over come the problem we decided to create a scheduled job that would loop over all items in a project and mark them as ready to publish.

To retrieve the projects and their project items we can get an instance of the 'ProjectRepository' into our scheduled job.

Once we have the project and its items we can then loop over the project items and use the 'IContentChangeManager' interface to update the status of the content items.

```csharp
var projects = _projectRepository.List();

foreach (var project in projects)
{
	var projectItemIds = _projectRepository.ListItems(project.ID).Select(x => x.ID);

	foreach (int projectItemId in projectItemIds)
	{
		ProjectItem projectItem = GetProjectItem(projectItemId);
		if (projectItem != null)
		{
		CommitResult commitResult = _contentChangeManager.Commit(projectItem.ContentLink, SaveAction.CheckIn);
		}
	}
}

public ProjectItem GetProjectItem(int projectItemId) => _projectRepository.GetItem(projectItemId);

```

I just wanted to share this piece of code with anyone who was trying to achieve something similiar.
REST API CRUD NodeJS, typescript, mongo, express with 2 commands.
Tags: javascript, tutorial, beginners, programming
Published: 2021-10-05 13:32:47

[SuperApiBoost](https://www.npmjs.com/package/superapiboost) is a client who seeks to improve development times.

In this post I will show you how to make a complete api under NodeJs with Typescript, Mongo and Express with just two commands an a file.

First thing they need to do is install the client with npm.

```bash
npm i -g superapiboost
```

To generate the project you must execute the "new" command with the -n flag to assign the name

```bash
sabo new -n=Awesome
```

This will create a root folder with the name of the project and install the dependencies.

```bash
📦Awesome
 ┣ 📂node_modules
 ┣ 📂src
 ┃ ┣ 📂api
 ┃ ┃ ┣ 📂routes
 ┃ ┃ ┗ 📜index.ts
 ┃ ┣ 📂controllers
 ┃ ┃ ┗ 📜mongoBasic.ts #CRUD Methods
 ┃ ┣ 📂interfaces
 ┃ ┣ 📂tools #utils functions
 ┃ ┃ ┗ 📜validateType.ts
 ┃ ┣ 📜app.ts
 ┃ ┣ 📜config.ts
 ┃ ┗ 📜mongo.ts
```
As an example we will create a crud for the following json.

```bash
{
  "name":"Andy",
  "cellphone":303030303,
  "isValid":false
}
```

We will create a json file and use the following format for the generation of the routes and the controller.

```bash
{
  "name":{
    "type":"string",
    "required":true,
    "default":"'Andy'"
  },
  "cellphone":{
    "type":"number",
    "required":false
  },
  "isValid":{
    "type":"boolean",
    "required":true,
    "default":"true"
  }
}
```

as a key we will assign the name of the property to create.

type: string, number, date, [].
required: false, true.
default(optional): 'true','"Name"'.

We will copy the complete path and execute the generate command.

```bash
sabo generate -n=user -p=c:/models/user.json
```
This will create the interface, controller and routes.

Go to the config.ts file and assign the connection string of our mongo database.

Execute npm start and we will be able to consume the api with our preferred client.


### Create
![Create](https://imgur.com/v6PeTDW.png)
### Update
![Update](https://imgur.com/UNwr1B2.png)
### Delete
![Delete](https://imgur.com/fLaQuIZ.png)
### GetAll
![GetAll](https://imgur.com/m4R3fGs.png)
### GetById
![GetById](https://imgur.com/tn3oDRx.png)
Infrastructure and Ops book bundle by O'Reilly
Tags: devops, kubernetes, linux, aws
Published: 2021-10-05 13:43:51

![Infrastructure and Ops book bundle by O'Reilly](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3fg399c8bxqety5xvu5q.jpg)

**[Infrastructure and Ops book bundle by O'Reilly](https://www.humblebundle.com/books/infrastructure-and-ops-oreilly-books?partner=indiekings)**

Modern technology has changed the way we live and work. Developing systems, applications, and more is complex, but O’Reilly are showing us how to get stuff done in the newest Humble bundle, Infrastructure and Ops by O’Reilly!

Dive into eBooks like Kubernetes Operators, Learning Helm, Kubernetes Best Practices, and Distributed Systems with Node.js, and learn how to shape our digital world to suit you, both in and out of work!

Plus, your purchase helps support Code for America!

Code for America is a non-partisan, non-political 501 organization founded in 2009 to address the widening gap between the public and private sectors in their effective use of technology and design.
Find Phone Number Location Using Python | Project
Tags: python, programming, security, beginners
Published: 2021-10-05 13:58:08

## Python Project For Tracking A Phone Number In A Map Using Python

Hi everyone 👋

Today we will do a **simple python project**. If you are a beginner, then no need to worry. It will be a **simple python project for beginners**. We will write a **simple python script** to **find out someone's phone number location using python**.

{% youtube Dz3rSZHnKkM %}

### Here you will get the answers of -
How To Track Phone Number Location With Python. track phone number location using python. Track phone number location using python github. how to track a phone number github. How to track location using python. python code for live location. Phone numbers Python.

Phone numbers python documentation. python phone number validation. get current location google maps python. How do I create a location tracker in Python?. How do I get coordinates in Python?. How do I track my phone using python?.


## Properties Used - 

YouTube: https://youtu.be/Dz3rSZHnKkM

Phonenumbers Python Library: https://pypi.org/project/phonenumbers/

OpenCage Geocoding Module Python: https://pypi.org/project/opencage/

OpenCage Geocoding API: https://opencagedata.com/

Folium: https://pypi.org/project/folium/

PyCharm (Code Editor): https://www.jetbrains.com/pycharm/
.
.
**Feel free to visit my YouTube channel: [@Tech2etc](https://www.youtube.com/c/Tech2etc/)**

**Follow me on Instagram where I'm sharing lot's of useful resources! [@fahimkabir.hamim](https://www.instagram.com/fahimkabir.hamim/) 😉**
.
.
## Checkout My Other Articles Also - 

{% embed https://dev.to/fahimkabir/15-python-projects-for-beginners-4j4f %}
{% embed https://dev.to/fahimkabir/python-project-how-to-make-snake-game-using-python-step-by-step-306c %}
{% embed https://dev.to/fahimkabir/7-javascript-projects-for-beginners-d3m %}

**Feel free to visit my YouTube channel:**
[@Tech2etc](https://www.youtube.com/c/Tech2etc/videos)

**Follow me on Instagram where I'm sharing lots of useful resources!
[@fahimulkabir.chowdhury](https://www.instagram.com/fahimulkabir.chowdhury/) 😉**
Learning TensorFlow? These resources can help!
Published: 2021-12-11 16:56:02

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p7xfyr7a2lnxkyaby164.png)
#### [**1\. TensorFlow Tutorial**](https://www.tensorflow.org/tutorials)

This is the Official TensorFlow documentation and tutorial. Everything from the basics to the advanced parts is covered. Excellent tutorial for tests and interviews as well since TensorFlow concepts are also covered.

*[Created by TensorFlow]*

[More info](https://www.tensorflow.org/tutorials)

#### [**2\. TensorFlow Tutorial For beginners**](https://www.youtube.com/watch?v=t_DdvgY71NE)

In this TensorFlow tutorial for beginners video, you will learn TensorFlow concepts like tensors, the program elements in TensorFlow, and constants & placeholders in TensorFlow python how variable works in placeholder and a demo on MNIST. There's a short quiz as well at the end to test your knowledge.

*[Created by Intellipaat]*

[More info](https://www.youtube.com/watch?v=t_DdvgY71NE)

#### [**3\. Introduction to TensorFlow**](https://www.coursera.org/learn/introduction-tensorflow)

Introduction to TensorFlow is a Coursera tutorial that teaches the basics about TensorFlow through Videos, Assignments, and Notes.

*[Created by Laurence Moroney]*

[M‍ore info](https://www.coursera.org/learn/introduction-tensorflow)

#### ‍[**4\. Intro to TensorFlow for Deep Learning**](https://www.udacity.com/course/intro-to-tensorflow-for-deep-learning--ud187?irclickid=VDsxb5SEsxyLWL10HbRLDTgpUkBReW38NyVD2Q0&irgwc=1&utm_source=affiliate&utm_medium=&aff=2890636&utm_term=&utm_campaign=__&utm_content=&adid=786224)

Learn how to build deep learning applications with TensorFlow. The TensorFlow team and Udacity developed this course as a practical approach to deep learning for software developers. You'll :

1.  get hands-on experience building your state-of-the-art image classifiers and other deep learning models.
2.  Use your TensorFlow models in the real world on mobile devices, in the cloud, and in browsers.
3.  Use advanced techniques and algorithms to work with large datasets.

By the end of this course, you'll have all the skills necessary to start creating your own AI applications.

*[Created by Udemy]*

[M‍ore info](https://www.udacity.com/course/intro-to-tensorflow-for-deep-learning--ud187?irclickid=VDsxb5SEsxyLWL10HbRLDTgpUkBReW38NyVD2Q0&irgwc=1&utm_source=affiliate&utm_medium=&aff=2890636&utm_term=&utm_campaign=__&utm_content=&adid=786224)

#### [**5\. Hello, TensorFlow**](https://www.oreilly.com/content/hello-tensorflow/)

A tutorial cum online project that walks you through the entire process of learning TensorFlow and makes you build your first TensorFlow graph from the ground up.

*[Created by Aaron Schumacher]*

[M‍ore info](https://www.oreilly.com/content/hello-tensorflow/)

*Originally posted at* [*raftlabs.co*](https://raftlabs.co/development/top-5-free-resources-to-learn-tensorflow?utm_source=devto&utm_campaign=crosspost)
A Compositional Approach to Optimizing the Performance of Ruby Apps
Tags: ruby, performance
Published: 2021-10-05 20:17:54

---
title: A Compositional Approach to Optimizing the Performance of Ruby Apps
published: true
description: 
tags: ruby, performance
//cover_image: https://direct_url_to_image.jpg
---
Ruby makes developers happy, but at times I wish it was faster. In a [new article](https://noteflakes.com/articles/2021-10-05-a-compositional-approach-to-ruby-performance) I explore a novel approach to improving the performance of Ruby apps.
備份與還原 AWS EC2 的 EBS
Tags: aws
Published: 2021-10-06 03:17:36

先前情提要簡單介紹一下 AWS，在 AWS 的世界，與傳統虛擬主機最大的不同，即 AWS 幾乎把主機的每個部份都拆成一個服務，有運算服務、聯網服務、儲存服務、安全服務、監控服務、容器服務、VPN 服務等等等等等，我們可以自由的把各種服務混合搭配使用，並依照各種服務的用量付費標準付錢錢給 AWS。

AWS 其中的 EC2 是一種可以被量化的雲端計算服務，這也是 EC2 的全名「Elastic Compute Cloud」的含意，而與 EC2 搭配的儲存服務是 EBS (Elastic Block Store)，我們可以把 EC2 與 EBS 簡單的對比為「電腦」與「硬碟」，與傳統電腦不同的是在 AWS 的電腦與硬碟都可以隨時被更換，更換的方法可能是人工到 AWS 網站更換或是由我們自己的程式透過 AWS SDK 去更換，這樣的特性就是 elastic 這個字眼想表達的意義：彈性。

## 備份 EC2 的 EBS

除了排程內的定期備份外，在對機臺做某些重大變更時我習慣會對 EBS 另外做人工備份，這些重大變更包括 OS 大升級、自己的程式大改版之類的時候。

EBS 的備份為我們熟知的快照式備份，而 [EBS 的快照是依容量收費](https://aws.amazon.com/tw/ebs/pricing/)的，但是是依實際容量而非額定容量計價，所以就算開 1 TB 的硬碟，但實際只用了 1 GB，那就只會拿 1 GB 來計價。

實際進行快照備份則相當簡單，一般都是從先到 EC2 主控台確定要備份的那台機器，在機器明細頁那裡找到兩個項目「Root device」與「Block devices」，Root device 指的是掛在 /dev/sda1 的開機碟，Block devices 指的是全部的硬碟，在典型的情況下應該 EC2 就只會有一顆硬碟，並且也一定是開機碟，所以 Root device 與 Block devices 應該都只會是 /dev/sda1，這顆被掛在 /dev/sda1 的硬碟有相對應的 EBS ID，透過這組 EBS ID 可以直接連結到 EBS 的主控台頁面下的這顆（卷）EBS。

進入 EBS 主控台的這卷 EBS 後，按下畫面上的 **操作** **創建快照** 就開始快照，並且會再幫我們跳轉到快照的主控台及這筆新快照的明細頁，依照容量的不同會花一點時間建立快照，等到快照的狀態變為綠燈 completed 後，即表示已經完成。

EBS 快照是支援熱快照的，也就是建立快照時 EC2 是不用關機的，但習慣上能關機的我還是會關機，不能關機的則盡量降低磁碟的存取量。

在等待快照建立完成的期間，可以在快照的 Name 欄位填一個容易往後識別的名字，不要太相信自己的記憶力。

## 從快照還原

情境是在 EC2 的某台機器被玩壞了，必須用之前的快照還原。

首先把那台 EC2 上面掛載的壞掉的那卷 EBS 卸下，先把那台被玩壞的 EC2 停機，接著在那台 EC2 的明細找到 Root device 找到壞的 EBS，進入那台 EBS 的明細頁，按 **操作** **斷開卷**，此時這個 EBS 卷會與 EC2 脫離，但因為還是有佔用到 AWS 的空間，所以還是會持續計費，因此在成功還原之後記得把確定無用的、壞的 EBS 刪除掉避免漏財。

然後到 EBS 快照的主控台，確定要還原的快照，按 **操作** **創建卷**，會建立一個新的 EBS 卷，對那個新的 EBS 卷按 **操作** **連接卷**，並填入要掛上的 EC2 機器，以及填入掛載點，**[如果是要做為 Root device 開機碟的話，務必填入 /dev/sda1 作為掛載點才可正常開機](https://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/device_naming.html)**。最後記得把確定無用的 EBS 卷或快照刪除。