teleren/devto huggingface dataset:
Otimizando seu banco !
Tags: mysql, tipsandtricks, zabbixbr, zabbix
Published: 2023-05-13 18:06:39

---
title: Otimizando seu banco !
published: true
date: 2020-12-22 18:49:26 UTC
tags: mysql,tipsandtricks,zabbixbr,zabbix
canonical_url: 
---

### Otimizando seu banco !

![](https://cdn-images-1.medium.com/max/771/1*FjOAb6snhj-83MgR76yMkQ.png)

Essa semana dei atenção a um problema que estava postergando a bastante tempo aqui onde trabalho, o MySQL.

Desde o inicio atestei que o ambiente estava crescendo de forma desordenada, e o banco estava uma bagunça, porem não tinha conhecimentos tão aprofundados em MySQL para manipular suas tabelas com segurança, ou efetuar qualquer tipo de procedimento sem medo de corromper tudo e perder o emprego (rs);

Fiz algumas pesquisas, e vi que como o Zabbix efetua muitas consultas de DELETE, o principal problema de crescimento, pode ser corrigido com alguns comandos simples.

Importante, aconselho utilizar os comandos abaixo apenas com seu Zabbix parado.

### Check Table

Primeiramente o mais importante creio que seja verificar a saúde do seu banco ao todo. Com o “check table” você pode verificar erros e inconsistências nas tabelas;

![](https://cdn-images-1.medium.com/max/387/1*qJ5emAEZIJvx-dQNpCw90A.png)

### Repair Table

Se o comando anterior detectar erros, é necessário utilizar o repair table;

![](https://cdn-images-1.medium.com/max/447/1*EgEJDWcrS4CoPeSWsCdQpQ.png)

### Optimize Table

Normalmente o Zabbix efetua muitas operações de exclusão, deixando assim os registros desordenados. Com o optimize table, ele vai desfragmentar e liberar algum espaço da sua tabela.

![](https://cdn-images-1.medium.com/max/875/1*gAEiJnu0XNzXKLe-euOSxw.png)

Mas e como saber disso pode me ajudar?  
Bem, o Zabbix é um monstro em leitura/escrita dentro do MySQL, sendo assim, sempre tem tabelas que podem ter espaço sendo desperdiçado, aguardando um optimize… a pergunta é, como saber quais tabelas posso fazer isso?

Ao logar no MySQL, selecione o banco utilizado pelo zabbix, e rode o comando abaixo:

> SELECT TABLE\_NAME, ROUND((DATA\_LENGTH + INDEX\_LENGTH)/1024/1024) AS USED\_SPACE\_MB, ROUND(DATA\_FREE/1024/1024) AS UNUSED\_SPACE\_MB FROM INFORMATION\_SCHEMA.TABLES WHERE ROUND(DATA\_FREE/1024/1024) > 100 ORDER BY UNUSED\_SPACE\_MB DESC;

Ele vai mostrar todas as tabelas com mais de 100MB sem uso, prontas para seu deleite (rs). Depois é só dar um “optimize table \_\_\_ ;” e ver seu disco sendo liberado.
Explain JMeter! 1.0
Tags: dohackathon, performance, testing
Published: 2020-12-22 18:49:10

## Explain JMeter

A simple utility for JMeter commands.  
[![Deploy to DO](https://mp-assets1.sfo2.digitaloceanspaces.com/deploy-to-do/do-btn-blue-ghost.svg)](https://cloud.digitalocean.com/apps/new?repo=https://github.com/QAInsights/Explain-JMeter/tree/master&refcode=612aff60e215)

### Category Submission: 
Random Roulette

### App Link
https://explain-jmeter-krxsh.ondigitalocean.app/

### Screenshots
![Explain JMeter Home Page](https://dev-to-uploads.s3.amazonaws.com/i/3wa3w4w1osaihjm1qr6f.jpg)
![Explain JMeter Sample Command](https://dev-to-uploads.s3.amazonaws.com/i/giqs0f6m3bhbev4ca94k.jpg)

### Description
Apache JMeter is an open source performance testing tool which is widely used among developers, performance testers, and in DevOps. 

CLI mode is the recommended mode for load testing in JMeter. It is not possible to remember all the commands. 

Explain JMeter! helps to educate the commands for a successful load testing.

### Link to Source Code

{% github qainsights/explain-jmeter %}

### Permissive License
[Apache](https://www.apache.org/licenses/)

## Background

Being a performance engineer, I do not have development experience. It is apt to develop a utility for performance engineers. I am learning Python and Flask. DO Hackathon motivate me to develop a small tool.

### How I built it 

This utility written in Python, Flask, and HTML. DO App platform helped me to gain knowledge how the app is deployed into production. I never worked in production environment, I executed performance tests in production. But I never got a chance to work as DevOps or Developer in my career.

To show all the commands and its description, I created a JSON file. Using Python and Flask, it fetches the relevant command and its description using the HTTP method.

I learned about Waitress server, build and run commands, Flask, CSS, and Jinja during this development.


### Additional Resources/Info
[![Deploy to DO](https://mp-assets1.sfo2.digitaloceanspaces.com/deploy-to-do/do-btn-blue-ghost.svg)](https://cloud.digitalocean.com/apps/new?repo=https://github.com/QAInsights/Explain-JMeter/tree/master&refcode=612aff60e215)
useReducer Vs useState (The War)
Tags: hooks, react, webdev, reducer
Published: 2020-12-22 18:46:57

In this post, we are going to see the difference between *useReducer* and *useState* hooks and when to use them.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/k0z9r0fyhojaytokogf2.JPG)

*Hope it might help you guys*

*Happy Coding!*

*Thank You*

*-Jayant Khandelwal*
Get pinned GitHub repositories as JSON
Tags: github, json, pinned, repositories
Published: 2020-12-22 18:36:06

---
title: Get pinned GitHub repositories as JSON
published: true
date: 2020-12-22 18:33:28 UTC
tags: github,json,pinned,repositories
canonical_url: 
---

![JSON](https://dev-to-uploads.s3.amazonaws.com/i/fnpbaap4b74mgp93lm7i.png)
I saw a lot of people asking about how they can get pinned GitHub repositories as a JSON response. This can be done with GraphQL, but some of them are asking for a rest API solution. Fortunately, I found a solution for them.

Visit this site:

- [https://gh-pinned-repos-5l2i19um3.vercel.app/](https://gh-pinned-repos-5l2i19um3.vercel.app/)
- Type your GitHub username
- Click the ‘go’ button

There you have your JSON response. Or else, you can just replace your Username in the following URL.

```
https://gh-pinned-repos-5l2i19um3.vercel.app/?username=Username
```

This program was originally developed by [@egoist](https://github.com/egoist).

For contributors: [Source code](https://github.com/egoist/gh-pinned-repos)
Shared Hosting vs. VPS Hosting vs. Cloud Hosting vs. Dedicated Hosting
Tags: hosting, codenewbie, webdev
Published: 2020-12-22 18:26:21

As web developers we usually don’t have to care much about hosting or hosting plans. Quite paradox when you think about it. Your product is hosted somewhere but you don’t know how it works or what alternatives you have. Therefore I think it’s important for web developers to also know about hosting.

There are different ways of hosting a website. In this article I’ll only concentrate on the most common ones and explain them to you in simple terms.

https://link.medium.com/Caz0aToYocb
How to run commands using SSH
Tags: todayilearned, shell, unix, ssh
Published: 2020-12-22 18:24:23

---
title: How to run commands using SSH
published: true
description: 
tags: todayilearned, shell, unix, ssh
//cover_image: https://direct_url_to_image.jpg
---
On your UNIX or Linux terminal you may use the `ssh` command to connect to a distant server/machine and start a new session there. While connected to this session, you may run all the commands you have permission to run in that server/machine but what if you wanted to run these commands but still staying in your starting session?

If to connect to a machine with `$IP_ADDR` as ip address and with `$USERNAME` as user you run `ssh $USERNAME@$IP_ADDR` to run a command in that machine as the aforementioned user you can run __`ssh $USERNAME@$IP_ADDR 'cmd'`__ which can be any command like `ls`, `pwd`, `whoami` and so on. Quotation marks `''` are not mandatory but in my opinion they help to clearly identify what command you intend to run.

A practical (even if a bit cheaty) example:

```bash
$ ssh mcaci@localhost 'whoami' # "ssh mcaci@localhost whoami" would give the same result
...
mcaci@localhost's password: 
mcaci
```

[Reference](https://www.cyberciti.biz/faq/unix-linux-execute-command-using-ssh/).
Docker - Comandos do docker congelando como resolver?
Tags: docker, containers, node, kurybr
Published: 2020-12-22 18:23:33

---
title: Docker - Comandos do docker congelando como resolver?
published: true
description: Uma forma "rádical" para solucionar o problema de congelamento do docker.
tags: docker, containers, node, kurybr
---


Recentemente eu venho passando por alguns problemas de Congelamento do `docker`, o que signfica, que ele simplesmente trava.

A melhor solução que encontrei para resolve esse problema foi apagar todas as imagens e containers do computador. 

No meu caso como uso o Linux, resolvi o problema com os seguintes comandos.

```
sudo rm -rf /var/lib/containerd
sudo rm -rf /var/lib/docker
```

**É uma solução rádical**, porém foi a unica que funcionou no meu caso; pois nenhum comando do docker estava respondendo. Inclusive tentei executar o stop do serviço do docker no computador, e também não obtive 
uma solução. 


Eu espero que de alguma forma possa ajudar vocês. 

Até uma próxima !
Find if any page is hosted in the cloud.
Tags: cloud, serverless
Published: 2020-12-22 18:17:07

## Nov 25 AWS outage
Shortly after the AWS outage, I was looking around if I can easily see what pages are running on what cloud providers.

I could not find any suitable tool. The closest was simple iplookup/whois. 

I though there must be a better way.

It looks like every decent cloud provider (Looking at you, Microsoft) provides public lists of IP ranges. But there was no tool to check it against given website.



## ISITIN.cloud
So I decided to create easy way to lookup this information.
[isitin.cloud](https://isitin.cloud)


In the first version, I scanned the whole website, grabbed all the links resolved the DNS, compared it to the list.

It took some time, and it was probably not worth it, I did not really care that much about the subsequent requests. But if you wanted it, the functionality is there waiting to be turned on again.
![out (1)](https://dev-to-uploads.s3.amazonaws.com/i/oh0629o3bqueh8w99tmu.png)
 

In current version, I only check the requested domain.

I hope you will find it useful.
The 7 Most Popular DEV Posts from the Past Week
Tags: top7
Published: 2020-12-22 18:12:57

---
title: The 7 Most Popular DEV Posts from the Past Week
published: true
description: A round-up of the most-read and most-loved contributions from the community this past week.
tags: icymi
cover_image: https://thepracticaldev.s3.amazonaws.com/i/sfwcvweirpf2qka2lg2b.png
---
Every Tuesday, we round up the previous week's top posts based on traffic, engagement, and a hint of editorial curation. The typical week starts on Monday and ends on Sunday, but don't worry, we take into account posts that are published later in the week. ❤️

### The power of pure HTTP stream

@nwtgck explains how pure HTTP stream allows us to do screen sharing, video chatting, real-time text messaging, SSH, VNC, and so on. 

{% link https://dev.to/nwtgck/the-power-of-pure-http-screen-share-real-time-messaging-ssh-and-vnc-5ghc %} 


### We accept Visa, MasterCard, and the CSS frosted, blurry glass effect


@dailydevtips1 decided to recreate a [dribbble shot from Dede Dwiyansyah](https://dribbble.com/shots/14647209-Glass-Credit-Card) of a frosted, blurry credit card -- with their own twist! The end result is super cool.

{% link https://dev.to/dailydevtips1/css-frosted-glass-credit-card-3lak %} 

### Let's make our websites accessible for everyone!

@ezgihendrickx details the essential steps to follow when creating an accessible website. Important subject!

{% link https://dev.to/ezgihendrickx/11-golden-rules-for-a11y-146c %}

### A really valid use-case for micro frontends

“Monoliths are not always necessarily bad,” writes @anfibiacreativa “but sometimes they're hard to manage.”

Here’s when it makes sense to go the micro frontend route -- and when it doesn’t.

{% link https://dev.to/this-is-learning/micro-frontends-my-lessons-learned-1pcp %}

### A study plan worth considering

I love the way @eddyvinck is planning to tackle their web development studying in 2021: with organization and high bar-setting, while demonstrating grace with themself.

Note: everyone’s study plan will look different so avoid comparing yourself too heavily ❤️

{% link https://dev.to/eddyvinck/my-web-development-study-plan-for-2021-5b57 %}

### When “failing” is a win

This post from @farhanaxmustafa is chock full of incredibly valuable insights from many different technical interviews that didn’t lead to a job. Turns out, the experience and lessons learned are worth their weight in gold. 

{% link https://dev.to/farhanaxmustafa/what-i-learned-from-failing-my-technical-interviews-276a %}

### Software soundwaves

I love this short list of podcasts for developers from @mindninjax 😊 

{% link https://dev.to/mindninjax/top-5-podcasts-every-dev-should-start-listening-1cmd %}

_That's it for our weekly wrap up! Keep an eye on dev.to this week for daily content and discussions...and if you miss anything, we'll be sure to recap it next Tuesday!_
My JavaScriptmas Journey
Tags: javascriptmas, scrimba
Published: 2020-12-22 18:00:49

A spotify ad told me that "You will find love in 2020".So, I have found love with coding in JavaScript. I somehow managed to solve almost all [24 days of #JavaScriptmas](https://scrimba.com/learn/adventcalendar?utm_source=newsletter&utm_medium=email&utm_campaign=javascriptmas_welcome_email) challenges on my own and special thanks to [Scrimba](https://scrimba.com/) for making these challenge questions.

Here are my solutions: 

1st Dec 2020 [Day 1](https://scrimba.com/scrim/coa214b20b9fa048ccdbf7a3a): Candies

2nd Dec 2020 [Day 2](https://scrimba.com/scrim/co23f435781339c101312ca0f): Deposit Profit

3rd Dec 2020 [Day 3](https://scrimba.com/scrim/co651474389a91f3ff5859ccd) :Chunky Monkey

4th Dec 2020 [Day 4](https://scrimba.com/scrim/coc2a4beb97d9636e20c13fe6) : Century of the Year

5th Dec 2020 [Day 5](https://scrimba.com/scrim/co7924a66b04c636bfc2a80d5) : Reverse a String

6th Dec 2020 [Day 6](https://scrimba.com/scrim/codfb4910814aceb14c4dbabd) : Sort by Length

7th Dec 2020 [Day 7](https://scrimba.com/scrim/co7c544278747b396af25a62d) : Count Vowel Consonant

8th Dec 2020 [Day 8](https://scrimba.com/scrim/co52c4247b2bc17e3f391367d) : The Rolling Dice

9th Dec 2020 [Day 9](https://scrimba.com/scrim/co2dd4111bd18669f29bae100) : Sum Odd Fibonacci numbers

10th Dec 2020 [Day 10](https://scrimba.com/scrim/co34d4b658086bcf1a1ea27d6) : Adjacent Elements Product

11th Dec 2020 [Day 11](https://scrimba.com/scrim/co03247709e3ea716cde02c7a) : Avoid Obstacles

12th Dec 2020 [Day 12](https://scrimba.com/scrim/coacd45fa9556484fe27001a5) : Valid Time

13th Dec 2020 [Day 13](https://scrimba.com/scrim/co34d493d9060c9f7f16d2a26) : Each Extract Kth

14th Dec 2020 [Day 14](https://scrimba.com/scrim/co4874b46a9a761c041844889) : Maximal Adjacent Difference

15th Dec 2020 [Day 15](https://scrimba.com/scrim/co3134f7fac65ab07641c78cb) : Carousel

16th Dec 2020 [Day 16](https://scrimba.com/scrim/co4414f34bfacc0bd7075de91) : Insert Dashes

17th Dec 2020 [Day 17](https://scrimba.com/scrim/cocc64e5caf56f6388e772b02) : Different Symbols Naive

18th Dec 2020 [Day 18](https://scrimba.com/scrim/co93a40e789a609fb1a32bd91) : Array Previous Less

19th Dec 2020 [Day 19](https://scrimba.com/scrim/cod084686b369a4ddd8794d51) : Alphabet Subsequence

20th Dec 2020 [Day 20](https://scrimba.com/scrim/co1734e71bb3632fcabc6e746) : Domain Type

21st Dec 2020 [Day 21](https://scrimba.com/scrim/co11a41dba36414a72dc8a8b5) : Sum of Two

22nd Dec 2020 [Day 22](https://scrimba.com/scrim/co7dd4470861d1d6807c0649d) : Extract Matrix Column

23rd Dec 2020 [Day 23] (https://scrimba.com/scrim/co65844b19d27d9666a628182) : Tweet Input Component

24th Dec 2020 [Day 24] (https://scrimba.com/scrim/co00a47638946a36c86f51d13) : Test your agility!
3 Best Ways to Run webpack in AWS
Tags: webpack, aws, cloud, javascript
Published: 2020-12-22 17:58:50

With webpack v5 out, there's no better time than to learn how to run webpack in the cloud. There are many different ways you can run webpack on AWS, but I break down the 3 best ways. I've used each one of these in production applications at real companies, so they are tried and true. Watch this video for more details!

Sample code: https://www.github.com/ryanmurakami/webpack-on-aws

Table of Contents:
0:00 Introduction
0:25 1) AWS CodeBuild
2:37 webpack on AWS CodeBuild demo
7:25 2) AWS Amplify
8:20 webpack on AWS Amplify demo
11:12 3) AWS Lambda
12:34 webpack on AWS Lambda demo
18:30 Bonus: Amazon EC2
19:54 Final thoughts

---

🙏 Thanks for taking a look at my content!

📨 Join my newsletter for more: https://ryanlewis.dev

🎥 Subscribe to my [YouTube channel](https://www.youtube.com/c/ryanhlewis)!

---

[YouTube](https://www.youtube.com/c/ryanhlewis) | [Twitter](https://twitter.com/ryanmurakami) | [GitHub](https://github.com/ryanmurakami) | [Site](https://ryanlewis.dev)
#Day 13: Sorting Algorithms
Tags: 100daysofcode
Published: 2020-12-22 17:52:33

Hello there!

I was just so busy trying to balance my end semester examinations along with coding that I could not find time to write down my coding journey. Hence, I would sum up some of them here.

I studied the various sorting algorithms from 'mycodeschool' YouTube channel. This channel is the best thing that I can recommend anyone. Please watch the Sorting playlist from this channel, you will learn a lot. I studied about Selection, Bubble, Insertion, Merge and Quick Sort from here. Today I studied about Heap Sort. This has blown my mind. I watched a lot of videos. It is a bit clear now but I need to code and run it myself in order gain confidence.
useReducer (The Intermediate):
Tags: react, webdev, hooks, context
Published: 2020-12-22 17:51:52

**Welcome back** devs!

We have talked about useReducer hook, its usage, and its implementation in the previous post of this series.

Now in this post, we will make use of useReducer in a slightly complex manner.

First of all let us have a *recap*,

**Roles**

**action**: Action is a plain JavaScript string or object that contains information. Actions tell the reducer what kind of action to perform and all other fields contain information or data.

**initialState**: defines the initial state of the component.

**currentState**: defines the current state of the component

**reducer**: reducer() function accepts the currentState and action and then returns a new state based on that action

*useReducer* hook returns the currentState and the dispatch method.

**dispatch**: dispatch method is capable of accepting an action to execute the code specified in the render function i.e. it accepts the action and transfers it to the reducer function.

Note: initialization of initialState and reducer() is always made outside the functional component.

First of all, let's initialize our initialState and implement our reducer function as follows:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/24yeybe07buykxnhyry2.JPG)

You can see that this time we have two states to maintain that is *firstCounter* and *secondCounter*. So, in order to maintain two states, we have used an object to initialize the state. 

We have used **spread operator** because useReducer **does not** automatically merge and update the object i.e. useReducer does not merge the state automatically.

Now let's take a look at the functional component,
![Functional Component](https://dev-to-uploads.s3.amazonaws.com/i/d296hmws4907x2bldxeb.JPG)

Here we have passed *action* as an object. We generally pass action as an object when we have more than one property to be accepted by the reducer function.
 
As here we are maintaining two states, therefore we are sending two different type property (eg: *increment* and *increment2*) for 
firstCounter and secondCounter respectively.

Let's have a complete look at the code,
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ia257a83t5v8k6f3g7v0.JPG)
 
Output:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/lc14213fx7edjkks4obr.JPG)

*We will see one more way to use the **useReducer** hook in the upcoming posts of this series.*

*Stay Tuned!*

*Happy Coding!*

*Thank you!*

*-Jayant Khandelwal*
Session Storage vs Local Storage vs Cookies
Tags: webdev, browserstorage, cookies, sessionstorage
Published: 2020-12-22 17:47:48

Wondering which browser storages best fit your use case? Here's a brief comparison to help you with making decision:

|   | Session Storage| Local Storage| Cookies |
| - |:--------------:|:------------:| -------:|
|Storage Size| 5MB on browser | 10MB on browser | 4kb on browser or server|
|HTML support| HTML 5 | HTML 5 | HTML 4&5 |
|Accessibility| Own tab only | Across tab & windows | Across tab & windows |
|Expiry| Expires on tab close | No expiration | *Configurable |
|Updatable via| *Web Browser API | *Web Browser API | Server Side Request or *Web Browser API |

*Configurable Expiry: When a server responds to a browser request, it can send down a Set-Cookie header with one or many cookies, ex:
`Set-Cookie: user_id=5; Expires=Fri, 5 Oct 2018 14:28:00 GMT; Secure; HttpOnly, remember_me=true`

*Web Browser API: see https://developer.mozilla.org/en-US/docs/Web/API for list of APIs
How often do you run into “VANILLA” of html, css, JS? 
Tags: css, javascript, devops, help
Published: 2020-12-22 17:46:40

With JavaScript, tutorials have been aweful to get a true “context” to learn what is taught, in a real example, instead of “console log” the answer or what it does.... it’s not truly used.

I’ve been trying vanilla JS in a external sheet, and I mess up because it’s just not truly used right in tutorials. 
I like when it’s in React, and things are setup better.
But by itself, there’s a longer way to go around.... that’s just not truly taught right.
setState in Reactjs is not a function
Tags: react, javascript
Published: 2020-12-22 17:32:22

I'm new to react and I am trying to hit an API using `fetch` and then `setState` to a state variable but it is throwing the error as

    Unhandled Rejection (TypeError): Object(...) is not a function

[CodeSandboxLink][1]
Below is the code

    import React from "react";
    import { useState, useEffect, setState } from "react";
    import "./styles.css";
    
    export default function App() {
      const [person, setPerson] = useState([]);
      fetch("https://jsonplaceholder.typicode.com/users")
        .then((response) => {
          return response.json();
        })
        .then((data) => {
          setState(data);
        });
      console.log("dasdasd", person);
      return <div className="App">{JSON.stringify(person)}</div>;
    }

  [1]: https://codesandbox.io/s/frosty-breeze-ori5f?file=/src/App.js

Please suggest where I am doing wrong.