teleren/devto huggingface dataset:
How would you design an Instagram-like backend?
Tags: career, systems
Published: 2022-09-29 12:49:16

📸 Instagram has roughly 500m Daily Active Users

When designing a system to support that scale there are special considerations that need to be made.

How would you design an Instagram-like app to support 500m DAU?

Try out the newest problem we launched on LeetDesign Share a link to your submission in the comments and I'll give you feedback on how you did!


https://leetdesign.com/problems/instagram
new image
Published: 2022-09-29 12:47:54


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


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

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


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

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

![holder for cordialebeautylounge](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a17znqbo935op1np4avc.jpeg)

![reactjs blog](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/65y1etmaqqxry0jf8vbk.jpg)

![right align projects](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a9mi84xpp6i6q4yn28go.png)

![space x project](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0op3jew8hcxrk4on4suw.jpg)

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

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

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

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


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


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



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



![exposure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qgityz5do1f6ww3aewud.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pzr3dprepwhs53mo69xh.png)
![well being](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hyvwj6x8dsxnnyxlo3hs.jpg)


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

![exposed](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3u2cynx3cl5a2oy5t0b0.png)


![emotions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fvi9mdzqes4nt18ycfes.png)


![stocks](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g4vi81q9enc2rcjepqg0.png)


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


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

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8diid58d1so5v3magdp8.jpg)
Easy maintenance of openGauss - DETAIL level diagnostic report
Published: 2022-09-29 12:28:00

Diagnostic category

1. Time Model 
It is mainly used to evaluate the performance of the current system in the time dimension. Contains the time spent by the system at various stages: kernel time, CPU time, execution time, parsing time, compile time, query rewrite time, plan generation time, network time, IO time.

2. SQL Statistics 
Mainly used for the diagnosis of SQL statement performance problems. Contains normalized SQL performance metrics sorted on multiple dimensions: Elapsed Time, CPU Time, Rows Returned, Tuples Reads, Executions, Physical Reads, Logical Reads. The types of these metrics include: execution time, number of executions, row activity, Cache IO, etc.

3. Wait Events 
It is mainly used for detailed performance diagnosis of system critical resources and critical time. It includes the performance of all key events over a period of time, mainly the number of events and the time consumed.

4. Cache IO Stats 
Used to diagnose the performance of user tables and indexes. Contains all user tables, file reads and writes on indexes, and cache hits.

5. Utility status 
Diagnostics for diagnosing backend job performance. Contains the performance of backend operations such as page operations, replication, etc.

6. Object stats 
Used to diagnose the performance of database objects. Contains user tables, tables on indexes, index scan activities, insert, update, delete activities, number of valid rows, status of table maintenance operations, etc.

7. Configuration settings 

Used to judge whether the configuration is changed enough. A snapshot containing all current configuration parameters.
Easy maintenance of openGauss - Summary level diagnostic report
Published: 2022-09-29 12:26:06

Diagnostic category

1. Database Stat:

It is mainly used to evaluate the load and IO status on the current database. Load and IO are the most important characteristics to measure the TP system. Contains the session currently connected to the database, the number of transactions committed and rolled back, the number of disk blocks read, the number of disk blocks that have been found in the cache, returned, fetched, inserted, updated, deleted through database queries The number of lines, the number of conflicts and deadlocks, the usage of temporary files, IO read and write time, etc. 

2. Load Profile:

Evaluate the performance of the current system load from the dimensions of time, IO, transaction, and SQL. Including job running elapse time, CPU time, transaction log volume, logical and physical read volume, read and write IO times, size, login and logout times, SQL, transaction execution volume, SQL P85, P90 response time, etc.

3. Instance Efficiency Percentages: 

Used to evaluate the efficiency of the current system's cache. Mainly includes the database cache hit rate. 

4. Events: 

It is used to evaluate the performance of the current system kernel key resources and key events. It mainly includes the number of occurrences of key events in the database kernel and the waiting time of time. 

5. Wait Classes: 

Used to evaluate the performance of the current system key event types. It mainly includes the release of the data core on the main types of wait events: STATUS, LWLOCK_EVENT, LOCK_EVENT, IO_EVENT. 

6. CPU: 

It mainly includes the time release of the CPU in user mode, kernel mode, Wait IO, and idle state. 

7. IO Profile: 

It mainly includes database Database IO times, Database IO data volume, Redo IO times, and Redo IO volume. 

8. Memory Statistics:

Contains the maximum process memory, the memory used by the process, the maximum shared memory, the size of the shared memory used, etc.
Como adicionar pre-commit no Git
Tags: git, swe, developer, tooling
Published: 2022-09-29 12:24:26

Tendo uma verificação de pre-commit evitamos enviar código com warnings de lint, erros de teste e outros para o PR:

Baixar o arquivo abaixo e colocar no diretório 'hooks' do seu repositório:
```
$ cd project-repo-directory
$ cp ~/Downloads/pre-commit .git/hooks/
$ git add .
$ git commit -m 'xxx'
```

Quando ele detecta um erro no teste ou lint ele para e não commita.

A linha 9 é um comando usado para verificar os lints localmente.
Na linha 12 para funcionar vc precisa instalar o gotestsum, que acho mais ágil para ler os erros, ou trocar a linha dessa ferramenta para 'make test' ou o comando que você utiliza pra seus testes unitários.

pre-commit

```
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments.  The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
make metalint
exit $?
​
gotestsum --format pkgname --  -race ./...
exit $?
​
​
if git rev-parse --verify HEAD >/dev/null 2>&1
then
	against=HEAD
else
	# Initial commit: diff against an empty tree object
	against=$(git hash-object -t tree /dev/null)
fi
​
# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --bool hooks.allownonascii)
​
# Redirect output to stderr.
exec 1>&2
​
# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
	# Note that the use of brackets around a tr range is ok here, (it's
	# even required, for portability to Solaris 10's /usr/bin/tr), since
​
	# the square bracket bytes happen to fall in the designated range.
	test $(git diff --cached --name-only --diff-filter=A -z $against |
	  LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
	cat <<\EOF
Error: Attempt to add a non-ASCII file name.
​
This can cause problems if you want to work with people on other platforms.
​
To be portable it is advisable to rename the file.
​
If you know what you are doing you can disable this check using:
​
  git config hooks.allownonascii true
EOF
	exit 1
fi
​
# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --
```
Create a "Table of Contents" for your dev.to posts with one click
Tags: showdev, writing, javascript, productivity
Published: 2022-09-29 12:22:23

---
title: Create a "Table of Contents" for your dev.to posts with one click
published: true
description: For my posts on dev.to I always want to have a Table of Contents. Until now I did that manually which was a lot of work. So I created a small JS snippet that you can use as bookmarklet
tags: showdev, writing, javascript, productivity
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bubwavdgi8h1j8z450y2.png
---

For my posts on dev.to I always want to have a Table of Contents. Until now I did that manually which was a lot of work. So I created a small JS snippet that you can use as bookmarklet.

A bookmarklet looks like a bookmark in your browser. But when you click it, a JS snippet runs on the current page.

![Using a bookmarklet to generate a Table of Contents](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qc42dkzrbz2xao7tj7aa.gif)

Here's the source code. It goes through all h2 and h3 of the article, creates internal links, and concatenates them as markdown. Ready to copy & paste to your dev.to post.

```js
(() => {
  let toc = "";
  let numH2 = 1;
  let numH3 = 1;
  document.querySelectorAll("article h2,article h3").forEach(element => {
    const a = element.firstElementChild;
    if (a?.nodeName === "A") {
      const text = (element.lastChild?.nodeValue || "").replaceAll("\n", "").trim();
      if (element.nodeName === "H2") {
        toc += `${numH2}. [${text}](${a.hash})\n`;
        numH2 += 1;
        numH3 = 1;
      } else if (element.nodeName === "H3") {
        toc += `    ${numH3}. [${text}](${a.hash})\n`;
        numH3 += 1;
      }
    }
  });
  console.log("## Table Of Contents\n\n" + toc);
})()
```

How to create a bookmarklet? Create a new bookmark in your browser. In place of the URL you type `javascript:` followed by your code.

Here the minified JS snippet from above for your bookmark.

```js
javascript:(()=>{let toc="";let numH2=1;let numH3=1;document.querySelectorAll("article h2,article h3").forEach(element=>{const a=element.firstElementChild;if(a?.nodeName==="A"){const text=(element.lastChild?.nodeValue||"").replaceAll("\n","").trim();if(element.nodeName==="H2"){toc+=`${numH2}. [${text}](${a.hash})\n`;numH2+=1;numH3=1}else if(element.nodeName==="H3"){toc+=`    ${numH3}. [${text}](${a.hash})\n`;numH3+=1}}});console.log("##%20Table%20Of%20Contents\n\n"+toc)})()
```
Optimize React Application Performance
Tags: javascript, react, performance, build
Published: 2022-09-29 12:18:26

- Use the Production Build
- Profiling Components with the DevTools Profiler
- Virtualize Long Lists (hundreds or thousands of rows) - react-window / react-virtualized
- Avoid Reconciliation / Re-randor - shouldComponentUpdate
- Not Mutating Data
- Code Splitting - Multiple Chunk Files
- Lazy Loading - Dynamic import
- Lazy loading images in React
- Use Route-Based Code Splitting
- Avoid dangerouslySetInnerHTML
- Dependency optimization - Moment.js / loadash / UI lib 
- Use React Fragments to Avoid Extra Tag
- Avoid Async Initialization in componentWillMount() use componentDidMount()
- Memoize React Components - React.PureComponent / React.memo 
- useMemo
- useCallback
- Throttling and Debouncing Events
- Create Error Boundaries for the Components
- Avoid using Index as Key for map - Using a Unique Key for Iteration
- CSS Animation Instead of JavaScript Animation
- Analyzing and Optimizing Your Webpack Bundle Bloat
- Consider Server-side Rendering
- Enable Gzip Compression on Web Server
- Using a CDN - React / ReactDOM
Submit button with rotation effect - CSS only - Step-by-step
Tags: css, webdev, tutorial, html
Published: 2022-09-29 12:07:30


![Submit button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rzhgjrfueq5g919qvucl.png)

## <u>HTML</u>
For HTML, we need a button with text and "check" svg element inside.

We'll display the text and hide the svg.

And on button focus, we'll display the svg and hide the text element.

```html
<button class="submit_button">
    <span>Submit</span>
    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
        <path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5" />
    </svg>
</button>
```
      
## <u>CSS</u>
For CSS, first, we'll style the button.

We'll set height to 30 px and align elements in center, using flexbox.

Now we'll set cursor to pointer and add a little transition.
Lastly, let's change text and border colors, and add a little radius.

```css
.submit_button {
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: .5s;
    color: rgb(196, 113, 62);
    border-color: rgb(196, 113, 62);
    border-radius: 2px;
}
```
      
On focus, we'll set radius to 15 pixels. With 30 pixels height, this will form a circle.

We'll set cursor to default, so that button doesn't look clickable.

And we'll change border and text color to green.

Let's rotate by 720 degrees (two whole circles - 360 * 2) and by adding transition, this change will happen smoothly.

```css
.submit_button:focus {
    border-radius: 15px;
    cursor: default;
    border-color: rgb(99, 184, 33);
    color: rgb(99, 184, 33);
    transform: rotate(720deg);
    transition: .5s;
}
```
      
Now we'll style "check" svg.

This element will be displayed only when button is focused.

We'll set width to 0, and on button focus, to 15 pixels.

By adding a little transition, this element will shrink and expand nice and smooth.

```css
.submit_button svg {
    transition: .5s;
    width: 0;
}
.submit_button:focus svg {
    transition: .5s;
    width: 15px;
}
```
      
Now we'll style the text element.

This element will be displayed only when button isn't in focus.

To achieve that, we'll set width to 50px, and then on button focus, to 0 pixels.

Let's also set font size to 0 on focus, so that the text looks like it's growing.

By setting the transition, this will happen smoothly.

```css
.submit_button span {
    transition: .5s;
    width: 50px;
}
.submit_button:focus span {
    transition: .5s;
    width: 0;
    font-size: 0;
}
```
      
And that's it.

You can find video tutorial and full code [here](https://designyff.com/code/submit_button).

Thank you for reading. ❤️
Day-15 of Machine Learning
Tags: beginners, machinelearning, coursera, supervisedmachinelearning
Published: 2022-09-29 12:00:21

Day-15 of Machine Learning:
- Implemented **Sigmoid function, cost function, Gradient descent for logistic regression** for Logistic Regression and a prediction function with 0.5 threshold to build a logistic regression model to predict whether a student gets admitted into a university.
- Also implemented regularized logistic regression to predict whether microchips from a fabrication plant passes quality assurance (QA) where I implemented cost function and gradient descent for **Regularised Logistic Regression**.

With this I completed **Course-1: Supervised Machine Learning: Regression and Classification**
Axios interceptor token on first call
Tags: axios, intercept, javascript
Published: 2022-09-29 11:50:13

Just add the capture of the token in the local storage in the configuration inside the interceptors request.

In my case I use lib '@react-native-async-storage/async-storage', you should configure capture according to your storage method.

```ts
import AsyncStorage from '@react-native-async-storage/async-storage';

apiApp.interceptors.request.use(
  async config => {
    const userData = await AsyncStorage.getItem(STORAGE_USER_AUTH_DATA).then(
      response => JSON.parse(response || '{}'),
    );

    config.headers = {
      Authorization: `Bearer ${userData?.accessData?.token}`,
      ...config.headers,
    };
    return config;
  },
  error => Promise.reject(error),
);
```
TCS MasterCraft™ DataPlus Course Summary
Tags: tcs
Published: 2022-09-29 11:24:32

## Data Management and its Challenges
In the first chapter of the course we learn about what exactly is data management.
Here is Data management Lifecycle:-

![Data Management Lifecycle](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l5jrkjyo988v8l6hitn8.png)

### Important Takeaways:
- Data Management includes is related to Gathering of Data, organization, processing, measurement, control and protection of data.
- Key Challlenges with data are -  Data can be Unstructured, Semi Structured, Structured; Location from data is coming from may not be fixed, it can be complex to handle and sometimes the volume of data can be too high or low.
-  Software-driven approach for data management is Needed and preferable by enterprises.

## Introducing TCS MasterCraft™ DataPlus
Data privacy and Data Quality are one of the major concerns for enterprises, if the data quality(accurate and consistant) then company can benefit more from it.
So here comes TCS Mastercraft DataPlus into play 
### TCS MasterCraftTM DataPlus Features:

1. Metadata Management.
2. User and Role entitlements managements.
3. metrics and trending Analytics.
4. Activity Auditioning and alerts.
5. Data Dictionary .
6. Reports and Visualization.

#### This software is available in different editions:
1. **Privacy Edition** which emphasizes on privacy-safe data provisioning and access.
2. **Provisioning Edition** provides test data management capabilities.
3. **Data Enablement Edition** is a leaning version of Provisioning Edition.
4. **Quality Management Edition** focuses on quality management that helps discover and fix issues in the data.
5. **Ultimate Edition**  serves as a combination of all the other 
editions.

and that's it.
after this i cleared the basic quiz and got the certificate for the course.

![TCS MasterCraft DataPlus course certificate](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0xrotwr4f7o0x943kirz.png)
Question about error
Tags: cpp, beginners
Published: 2022-09-29 11:47:32

Hi I'm just beginner of c++ and also i just started community if i'm not following the rule of community just let me know.


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

this is my error. I know this seems easy one to solve and I tried to find about error but it doesnt't work. Is there anyone who knows why?
Release Notes 22.09.29 - SDN bulk enabling/disabling
Tags: webdev, sdn, devops, network
Published: 2022-09-29 11:44:38

We’re excited to present you with the latest release of Syntropy Stack. We’re introducing bulk actions for SDN in `Connections` table. Now the developers are able to enable or disable SDN for more than one connection. Our team has been tailoring the product to better align with upcoming features, and we hope these aesthetic and functional updates will also improve your Syntropy Stack experience today.

![Example of bulk actions for the Connections](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eu9f037l88fdane251ui.png)
### Features
- global/local SDN enabling/disabling in bulk at Connections

### Improvements
- Bi-directional visualisation of the `Connections`
- `Agent` statuses improvements
- added SDN agents logs to `Admin Panel`

### Fixes
- UI Platform related bugfixes

## Getting Started
Get started with Syntropy Stack with our three-minute [quick start video](https://vimeo.com/499558754), or follow the [documentation](https://docs.syntropystack.com) for more details. Use Syntropy Stack to streamline your container and multi-cloud deployments and automate network orchestration.

## Getting Involved
Our community helps us identify the right problems to solve for our users. Whether you’re an active user of one of our products or just getting started, [join our community on Discord](https://discord.com/invite/HxW6DbUeMn)! We love to foster communication among developers. Also, don’t hesitate to send us a message if you have feedback or need assistance. We're happy to help!
How to install Stable Diffusion in an Ubuntu 22.04 GNU/Linux Oracle VirtualBox VM
Tags: stablediffusion, ubuntu, vm, tutorial
Published: 2022-09-29 11:43:55

Here's how I managed to install Stable Diffusion AI image generator with Linux-Auto-Customizer to be able to run it within an Ubuntu 22.04 GNU/Linux VirtualBox VM. Minimum 16GB of memory recommended.

- Install Python3, cmake and Linux-Auto-Customizer:
`sudo apt install -y python3 cmake git
git clone https://github.com/AleixMT/Linux-Auto-Customizer
cd Linux-Auto-Customizer
git checkout stablediffusion_feature
sudo bash src/core/install.sh -v -o customizer`

- Download .cpkt model weights manually (huggingface account will be needed):
The model file needed by Stable Diffusion is hosted on Hugging Face. 
You will need to register with any email address. 
Once registered, head to the latest model repository, which at the time of writing is stable-diffusion-v-1-4-original. 
Under the ‘files and versions’ tab, download the checkpoint file, sd-v1-4.ckpt.
[Link to download weights](https://huggingface.co/CompVis/stable-diffusion-v-1-4-original)

- Load the weights of the Stable Diffusion model in ~/.customizer/cache directory named as stableDiffusion_bundle_file:
`mv ~/Downloads/sd-v1-4.ckpt ~/.customizer/cache/model.ckpt`

- Reload bash environment:
`bash`

- Set up Stable Diffusion:
`customizer-install -v -o stableDiffusion`


- Reload bash environment:
`bash`

- Run function stablediffusion:
`stablediffusion "A cat riding a rocket from outer earth"`


Now we have Stable Diffusion installed running on our CPU in the Ubuntu 22.04 GNU/Linux Oracle VirtualBox VM, it is considerably running slower than running it in the GPU in bare metal.

Happy VM AI art generating!


![A cat riding a rocket from outer earth](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2209eudtn8feuv4iip99.png)
A cat riding a rocket from outer earth!! 
FUN!

Did this article helped you? Share it, comment or give a like if it did! 😄