teleren/devto huggingface dataset:
Reading Notes #518
Tags: devjournal
Published: 2022-08-15 20:17:51

---
title: Reading Notes #518
published: true
date: 2022-08-15 11:21:00 UTC
tags: devjournal
canonical_url: https://www.frankysnotes.com/2022/08/reading-notes-518.html
---
  
Good Monday, Already time to share new reading notes. Here is a list of all the articles, blog posts, and podcast episodes that catch my interest during the week.

If you think you may have interesting content, share it! 

![Trees](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n43ycgckjw96cokee0fl.jpg)

## Cloud

- **[MySQL and PostgreSQL… in Azure!](https://www.sadukie.com/2022/08/10/mysql-and-postgresql-in-azure/)** (Sarah Dutkiewicz) - This short post shares information about our different SQL options in Azure.

- **[Public preview: Update management center in Azure](https://azure.microsoft.com/en-us/updates/public-preview-update-management-center-in-azure/)** (null) - If you are using VMs you need to look at this management tool.

## Programming

- **[4 Ways to Optimize Your Workflows with Docker Extensions](https://thenewstack.io/4-ways-to-optimize-your-workflows-with-docker-extensions/)** (Felipe Cruz) - Nice! There are so many great extensions that can simplify our lives. I'm downloading two of those right now.

- **[GitHub Pages now uses Actions by default](https://github.blog/2022-08-10-github-pages-now-uses-actions-by-default/)** (Chris Patterson, Yoann Chaud) - That's excellent news! I have a few GitHub pages and Jekyll too. Look like fun little projects are coming up.

- **[Heap Sort in C#](https://code-maze.com/csharp-heap-sort/)** (Code Maze) - It was nice to refresh my memory about this sort of algorithm. Remembering the details and performance; nice post.

- **[Prompting Developers to Install Recommended Azure Tools](https://www.blueboxes.co.uk/prompting-developers-to-install-recommended-azure-tools)** (John Kilmister) - I started to do this to make it easier when working on that project from a different machine and to ease the onboarding experience. It is simple and it makes a difference.

## Podcast

- **[Measuring DevSecOps with Victoria Almazova](https://castbox.fm/episode/Measuring-DevSecOps-with-Victoria-Almazova-id2446-id513151934)** (.NET Rocks!) - DevSecOps, what's that? Security, yes, but to what limit, so many great questions are discussed in this nice episode.

- **[Photographing Home with Mylo Fowler](https://castbox.fm/episode/Photographing-Home-with-Mylo-Fowler-id430001-id506591736)** (Wild Ideas Worth Living) - This post is a great example that there are so many completely different journeys to reach your destination. Follow yours and enjoy it as much as you can.

  

~frank
A short introduction to MongoDB and Mongoose
Tags: mongodb, mysql, nosql, mongoose
Published: 2022-08-15 10:55:00



**1. Introduction to MongoDB**

MongoDB was first born by MongoDB Inc. in October 2007. It was part of the PaaS (Platform as a Service) product like Windows Azure and Google App Engine. It was later made open source in 2009.
MongoDB uses JSON like files schemas, meaning data are stored as documents or collections which can be strings, numbers, floats and even arrays and objects. 
MongoDB is also known as NoSQL database; it allows the insertion of data without interrupting the service and provides the real-time application changes.
Due to the vast complexity in web development and usage, the relational database cannot cope with the scale and agility
challenges of modern applications. When comparing relational database to NoSQL, the NoSQL database has better performance and is more scalable.

![SQL Terms vs MongoDB Terms.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/de19ns94lij14uz7mq3x.png)

**2. Pros and Cons of MongoDB**

The outstanding advantages of MongoDB convincing the choice of current users are:

- Since MongoDB uses data in the JSON form, each collection has different sizes and documents. Nevertheless, they are very flexible when it comes to archiving.

- MongoDB data is usually not bound to each other; it does not support join query like in RDBMS, so when users insert, delete or update, it will not spend too much time to check if it satisfies the constraints like in RDBMS or not.

- MongoDB is easy to scale. In MongoDB, the concept “cluster” refers to clusters of nodes containing data to communicate with each other. Adding a new node to the cluster helps users expand the system quickly.

- The unique identifier _id will always be indexed automatically, so the speed of querying information will consistently achieve the highest performance.

- The unique identifier _id will always be indexed automatically, so the speed of querying information will consistently achieve the highest performance.


**3. What Is Mongoose?**

Mongoose is a query language to communicate between the server and the database and performs reading, writing, updating and deleting operations of the data.
It is an Object Data Modeling (ODM) library for MongoDB and NodeJS which provides schemas to model application data which therefore cleans up the ambiguity of databases. 
It enforces a standard structure to all the documents in a collection using schema.
It also validates the stored data in the documents as well as allow only valid data to be saved in the database. 
Overall Mongoose provides all the features to the MongoDB including
query building functions and business logic in the data.
Problemas resolvidos para entrevistas de programador
Tags: braziliandevs, programador, python
Published: 2022-08-15 10:44:00

Trouxe aqui algumas resoluções de algoritmos requisitados em entrevistas. Foi programado da forma mais reduzida e eficiente possível usando python 3.

## Maior número ímpar de uma lista
Algoritmo que retorna o maior número ímpar de uma lista.

```python
# %% 
from functools import reduce

data0 = [1,2,3,4,5,6,7,8,19,10,11,21,24,12,14,15,22]

def biggestOdd(array):
    return reduce(lambda x, y: x if x > y else y, filter(lambda x: x & 1, array))

print("Problem 1 - " + str(biggestOdd(data0)))
```

## Inverte a frase
Algoritmo que inverte a frase de entrada, esse algoritmo retorna a frase invertida.
```python
def inversePhrase(phrase):
    return " ".join(phrase.split(" ")[::-1])

print("Problem 2 - " + str(inversePhrase("A frase inteira deve ser revertida")))
```

## Maior soma de sequência contínua
O algoritmo retorna a maior soma de uma sequência contínua.
```python
# %%
def continousSequenceBiggestSum(array):
    max_sum = 0
    for i in range(len(array)):
        for j in range(i, len(array)):
            if sum(array[i:j+1]) > max_sum:
                max_sum = sum(array[i:j+1])
    return max_sum


print("Problem 3 - " + str(continousSequenceBiggestSum(data)))

data2 = [6, -4, -2, 1, -3, 5, -1, 2, 1, 1, -5, 4]
print("Problem 3 - " + str(continousSequenceBiggestSum(data2)))
```

## Maior soma de sequência contínua otimizada
Esse algoritmo também retorna a maior soma de uma sequência contínua, porém é mais reduzido o código.
```python
# %%
def continousSequenceBiggestSum2(array):
  [sum(array[idx:i+1]) for idx, itm in enumerate(array) for i, j in enumerate(array)]


data = [-1, 5, 2, 1, 4, -7, 8, -3, -4, 2]
print(continousSequenceBiggestSum2(data))
```

Espero que isso te auxilie de alguma forma.  Eu pretendo criar conteúdos relevantes de algoritmos em português.

Se você sentiu falta de algo nesse tutorial, por favor comenta pra que eu possa aperfeiçoar meu trabalho.
python — How do I remove a trailing newline?
Tags: python
Published: 2022-08-15 10:37:18

Question:

How do I remove the last character of a string if it is a newline?

"abc\n"  -->  "abc"
Solution 1:

Try the method rstrip() (see doc Python 2 and Python 3)

>>> 'test string\n'.rstrip()
'test string'
Python’s rstrip() method strips all kinds of trailing whitespace by default, not just one newline as Perl does with chomp.

>>> 'test string \n \r\n\n\r \n\n'.rstrip()
'test string'
To strip only newlines:

>>> 'test string \n \r\n\n\r \n\n'.rstrip('\n')
'test string \n \r\n\n\r '
In addition to rstrip(), there are also the methods strip() and lstrip(). Here is an example with the three of them:

>>> s = "   \n\r\n  \n  abc   def \n\r\n  \n  "
>>> s.strip()
'abc   def'
>>> s.lstrip()
'abc   def \n\r\n  \n  '
>>> s.rstrip()
'   \n\r\n  \n  abc   def'
Solution 2:

And I would say the “pythonic” way to get lines without trailing newline characters is splitlines().

>>> text = "line 1\nline 2\r\nline 3\nline 4"
>>> text.splitlines()
['line 1', 'line 2', 'line 3', 'line 4']
Solution 3:

The canonical way to strip end-of-line (EOL) characters is to use the string rstrip() method removing any trailing \r or \n. Here are examples for Mac, Windows, and Unix EOL characters.

>>> 'Mac EOL\r'.rstrip('\r\n')
'Mac EOL'
>>> 'Windows EOL\r\n'.rstrip('\r\n')
'Windows EOL'
>>> 'Unix EOL\n'.rstrip('\r\n')
'Unix EOL'
Using ‘\r\n’ as the parameter to rstrip means that it will strip out any trailing combination of ‘\r’ or ‘\n’. That’s why it works in all three cases above.

This nuance matters in rare cases. For example, I once had to process a text file which contained an HL7 message. The HL7 standard requires a trailing ‘\r’ as its EOL character. The Windows machine on which I was using this message had appended its own ‘\r\n’ EOL character. Therefore, the end of each line looked like ‘\r\r\n’. Using rstrip(‘\r\n’) would have taken off the entire ‘\r\r\n’ which is not what I wanted. In that case, I simply sliced off the last two characters instead.

Note that unlike Perl’s chomp function, this will strip all specified characters at the end of the string, not just one:

>>> "Hello\n\n\n".rstrip("\n")
"Hello"
thanks to : [pythonhowto](https://pythonhowto.org/)
How to add logs to your running applications on-demand without redeploying, restarting, or stopping the execution
Tags: docker, node, python, java
Published: 2022-08-15 10:23:48


Logs have become a fundamental part of traditional software development as they help us understand what is going on with our systems while they are running.

![](https://miro.medium.com/max/1400/0*WTRtvC8QZ5MbXHWh.jpeg)

_Photo by Thierry Chabot on Unsplash_

Regardless of your runtime you can add logs anywhere you want and start collecting information but there is always a catch:

As your system becomes more complex and/or the number of logs you are generating increases it is getting easier to get lost in log piles. On the flip side, logs only help you if they are placed in the right place and any replacement etc. requires a new deployment which does not end to be the most chill scenario if you are trying to find a bug in production.

# These two points create a dilemma:

You either log everything for your comfort and get lost in gigabytes or maybe a larger of logs you have created or you end up with inadequate logs that you need to populate by adding more logs into your code and redeploying it.

# Solution: Dynamic logging

Our latest update brings logpoints along with many improvements.

Logpoints are points that you can add to your running application, just like Tracepoints, for adding logs dynamically.

Logpoints solve the dilemma by letting you add logs to your running applications without stopping and redeploying. Since you can add and remove your logs at any time, getting the log wherever and whenever you need it becomes a walk at the park!

Not only solving the issues of traditional logging, but Sidekick Logpoint feature also comes with extras. In addition to adding and removing logs on demand, with Sidekick you can:

- Define conditions for your logpoints

- Define time to live and maximum hit counts

- Change log levels dynamically

- Enrich your log content with variable information from the context

- Configure agent to print logs directly to **stdout**

- Send generated logs to any target you desire!

![](https://miro.medium.com/max/1400/0*S2rOj0biOmf2754y.png)

Our integrations with Slack and some of the well-known logging tools are at the corner and we also added custom webhook support for you to extend the possibilities. Don’t forget to join our [**Discord channel**](https://www.runsidekick.com/discord-invitation) for news and to share your integration requests.

# TL;DR

> [**Sidekick’s Logpoints feature**](https://app.runsidekick.com/signup), in the end, opens the way of dynamic logging to its users. It replaces traditional logging with dynamic logging. This means you easily have the potential to lower stage sizes, costs, and time for log searching. Additionally, logpoints feature brings the ability to add new logpoints without editing the source code, redeploying, or restarting the application.

![](https://miro.medium.com/max/1400/0*s6HiR06ne09o5aLh.png)
HTML tags: Most beginner does not Know( Part 1)
Tags: html, programming, css, webdev
Published: 2022-08-15 10:15:00

Lets explore some HTML tags to understand the HTML better and use it properly for the next time.

Using appropriate HTML tags at appropriate location is important.
lets learn few tags today!! (learn little but better)

## 1) HTML abbr Tag
abbr mean abbreviation and it actually use for the Acronym like the world NASA which mean National Aeronautics and Space Administration. OMG this long phrase is difficult to read. so we use abbr tag in HTML body to identify something and when user hover over the mouse, a small explanation or full abbreviation will appear.<br>
Syntax:
```
<abbr title= "Full form">Acronym</abbr>
```
Example:
```
<!DOCTYPE html>
<html lang="en">
<head>
    <title>abbr taf</title>
</head>
<body>
    <p> 
        This is 
        <abbr title="National Aeronautics and Space Administration">
            NASA
        </abbr>
     </p>
</body> 
</html>
```

## 2) HTML map and area Tag

map tag is use to make different areas of an image clickable and link those parts to some souces. <br>

But for map we need to understand area tag.

**map tag** make image clickable<br>
**area tag** define shape, coordinates and source of that clickable area.

e.g: Look at below image. What if I want to make each planet clickable. I can only do this by map tag.<br>
How?<br>
By defining the cordinates of pixals and a links inside area tags and wrap those area tag around map tag. lets have a look at the code:
```
<img src="solar.png" usemap="#planetmap">
    <!-- comment=> usemap connect image with map tag, ignor for now-->
    <map name="planetmap">
        <area 
            coords="0,0,82,126" 
            href="https://bit.ly/3pgWtiK"   
            alt="sun"  >
    </map>

```
solar.png:

![Image description](https://bit.ly/3QF3ghY)
## 3) HTML aside tag
Aside tag is use to display text as the column/side bar text.


![Image description](https://bit.ly/3zRODkG)
syntax:
```
<aside> Your Text here </aside>

```

Thanks for reading. <br>
>Learn Little but Better
React Link Social Accounts to the same user, is it possible?
Tags: react, webdev, firebase, help
Published: 2022-08-15 10:11:50

Hi, anyone knows if it's possible yo connect multiple social accounts ( YouTube,twitter, Facebook...) To the same user account when they have different emails?
Example: I have a user that signs up with email and password, after that he can connect his social accounts ( not for login, but to post stuff on them via my app ) but the catch is, the accounts may have different emails, and as i see not all auth providers support linking multiple accounts woth different emails, and the ones that do, do that for login only.
So my question is , how do i do it? Should i save the users accounts on a database after they login, so when he logins on the app the next time, i will fetch all his accounts from my account and display them?!
SK Learn Practice: NCAA Big East
Published: 2022-08-15 05:14:00

I wanted to practice using sklearn and create a short outline for preparing the data and running a few basic models (Linear Regression, Ridge Regression, Lasso Regression) and comparing the results for the following [dataset](https://www.kaggle.com/datasets/mattop/college-basketball-big-east-1979-2021).

**Step 1: EDA**
With the target column of 'wins' in mind, I opted to drop many of the columns that were not relevant ex. id, year, school and also some columns that had incomplete information due to the fact that the data has only started getting tracked relatively recently ex. offensive rating, net rating.

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

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

**Step 2: Train Test Split**
After this, it is time to perform a train test split. It is important to split the training and test data before making transformations that could have a potential impact on the overall distribution of the data or lead to data leakage.
[Train Test Doc](https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html)

**Step 3: Scale**
Fitting and Transforming the training data with StandardScaler and just Transforming the testing data will allow our predictive models to perform better as these types of models tend to not like data that is not normally distributed.
[StandardScaler Doc](https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.StandardScaler.html)

**Step 4: Set Up Models**
For this particular example, I chose to run a Linear Regression, Ridge Regression, and Lasso Regression as these are 3 of the most basic and most frequently used linear models and we are also looking at a larger number of features.

LinearRegression serves as our simple model

LassoRegression applies L1 Regularization on top of Linear Regression (absolute value of magnitude)

RidgeRegression applies L2 Regularization on top of Linear Regression (squared magnitude)

**Step 5: Evaluate and Select Final Model**

OLS: ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pcjed6lzujbh5p1gm7du.png)
Lasso: ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sdlcwive4hjk2lxwa2ky.png)
Ridge: ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xkwtx88kxtbje6337tza.png)


The Ridge Model minimized RMSE and maximized R2, so we would go with the Ridge Regression model as our final model.
 
[Notebook Link](https://github.com/benjaminybai/big_east_predict/blob/main/index.ipynb)
UI vs UX
Published: 2022-08-15 09:25:05

I have seen a lot of confusion between these two terms among the developers. The developers tend to mix these two and for a matter of fact, these are written as UI/UX which makes it more confusing to people.


### User Interface

It is the elements on screen that you see like button, spinner, progress bar, slider, etc. UI deals with how the look their color, their shape, etc. The UI is the first thing people see on your website and it is a foremost important thing as its the first impression. Richer the UI greater is the impression.

### User Experience

It is the flow of elements on your screen eg. a button leading to navigation is the flow of the app. UX people connect the parts of UI to make an experience for the user that is easy to use the system. The flow of information between screens and tasks are logical to understand.

### Wrap Up

User Interface is all about the look and feel of the app. How creatively information can be displayed it takes a lot of creativity to make a great UI.

User experience is determined by how easy or difficult it is to interact with the user interface elements that the UI designers have created.

UX designer decides how the user interface works while the UI designer decides how the user interface looks. This is a very collaborative process, and the two design teams tend to work closely together. As the UX team is working out the flow of the app, how all of the buttons navigate you through your tasks, and how the interface efficiently serves up the information user’s need, the UI team is working on how all of these interface elements will appear on screen.  
Correct meme from [Patrix Hansen](http://www.patrickhansen.com/2017/09/01/ui-vs-ux-design-meme-problem/).


![UI vs UX](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9jfsiwyo3f08b8utc5li.jpeg)
Methods of primitive
Tags: javascript, webdev, beginners, tutorial
Published: 2022-08-15 09:20:07

Let’s start with a piece of code:
```js
const name = "aniket";
name.toUpperCase(); // ANIKET
```
The `name` is a primitive but we are able to access a method on it as if it were some sort of object. But we know that primitive isn’t an object.   
What is the story here?🧐

Primitive are simple values stored in memory, those are lightweight and extremely fast. Whereas an object is a collection of the key, value pairs, it is heavy but it allows to access some utility properties associated with the object that is very useful. The javascript people faced the dilemma where they wanted to put primitive for being lightweight and fast but also wanted to allow access useful methods on primitives.

The solution the came up with was:

_As soon as the engine reaches line 2 it sees that you are trying to do property access on primitive, but as primitive itself doesn’t have methods on them. It momentarily wraps the primitive value into a corresponding type wrapper object that has these methods on them and that object exposes us the properties which we can use, as soon as the method is done executing it returns the result of the operation in a new memory space and deletes this wrapper object._

#### Constructors function

The constructor function `String, Number, Boolean` is for internal use only. Languages like Java allows us to explicitly creates a wrapper object that is also possible with JavaScript but those are not recommended and are for internal use only. A lot of things can go crazy if we use those.
```js
// Insane Use 🙅‍♂️ Not recommended
const age = new Number(22);
typeof age; // "object" 😱
// Sane Use 😍
const age = Number("22");
// explicit type conversion
```
#### Recap with a question

Explain the console output in `strict` and non-strict mode?

```js
const name = "Aniket";
name.last = "Jha";
console.log(name.last);
```

In `strict` mode on line 2, the engine sees that we are trying to create a property on internal momentarily created internal wrapper object so there occurs an error. For a non-strict mode the engine on line 2, allows you to create a property on momentarily created wrapper object but this object is thrown out of memory as soon as line 2 is done executing. On line 3 a new wrapper object is created momentarily but as this is different from previous it doesn't have the`last`property and thus `undefined` is the output.

#### Conclusions

The primitive is indeed a simple value but the engine treats primitive especially if it sees there is property access on it by wrapping it in wrapper object and exposing us with useful methods and properties.