teleren/devto huggingface dataset:
Percona Monitoring with Postgres Docker on local environment
Tags: postgres, docker, percona, performance
Published: 2022-10-03 15:07:58

You have a Postgres running in Docker container, but don't know how to monitor its active connections. Percona Monitor can be considering for using in this case.



## Install PMM
https://docs.percona.com/percona-monitoring-and-management/setting-up/server/docker.html#run-docker-with-volume

## To access the web UI with port 80
If you don't want to use the port 443 in local (because it might be complicated to setup the key/cert/pem), can also use port 80.

```bash
docker run --detach --restart always \
--publish 8889:80 \
-v pmm-data:/srv \
--name pmm-server \
percona/pmm-server:2
```

It will map port 8889 of host computer to port 80 on the container

## Add new instance to PMM
After login into the tool, we can go to add the instance of DB that we want to do monitoring. 

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

Then, ensure the pmm-server joins the network of DB, so it can connect to the instance DB host with container name:
```
docker network ls
```

Given example that DB of your service is running on dev_default, here is how to add pmm-server into that network:
```
docker network connect dev_default pmm-server
```

After pmm-server joining the network, we can just simply setup the instance:

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

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

Then click on **Add service**.

## Enable the pg_stat_statements to have ability of looking at query analysis
This article is useful: https://gist.github.com/lfittl/1b0671ac07b33521ea35fcd22b0120f5

Query to test after enabling 
```psql
SELECT /* pmm-agent:pgstatstatements */ "pg_stat_statements"."userid", "pg_stat_statements"."dbid", "pg_stat_statements"."queryid", "pg_stat_statements"."query", "pg_stat_statements"."calls", "pg_stat_statements"."total_time", "pg_stat_statements"."rows", "pg_stat_statements"."shared_blks_hit", "pg_stat_statements"."shared_blks_read", "pg_stat_statements"."shared_blks_dirtied", "pg_stat_statements"."shared_blks_written", "pg_stat_statements"."local_blks_hit", "pg_stat_statements"."local_blks_read", "pg_stat_statements"."local_blks_dirtied", "pg_stat_statements"."local_blks_written", "pg_stat_statements"."temp_blks_read", "pg_stat_statements"."temp_blks_written", "pg_stat_statements"."blk_read_time", "pg_stat_statements"."blk_write_time" FROM "pg_stat_statements" WHERE queryid IS NOT NULL AND query IS NOT NULL;

```

Practice some DB activities on the service, then choose the menu to see the new monitoring data in this menu

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

The data looks cool now when checking dev-db host.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nw980sj12jbmarbbxmpi.png)

It's done to setup PMM with Postgres on the local env.
I'm really confused about myself on computer career. Pls help!
Tags: computerscience, career, discuss, help
Published: 2022-10-03 15:05:42

I'm really confused about my interest because I like neither making apps nor creating websites. But I really love Computer Science — computer architecture, data structures and algorithms, etc...

My main question is that — one can learn Computer Science without having interested in software development? 

Apart from software creation and website development, Is there anything else I can do in CS?
Am I missing anything? 
Any recommendation or suggestion for me, please. Thanks in advance.
How to avoid top 5 mistakes in SQL
Tags: sql, beginners
Published: 2022-10-03 15:04:32

Let’s discuss some tips and tricks to avoid major mistakes in SQL

## Never use Select *

- select *, gets the data from all the columns, which increases the latency and is expensive for huge data.
- Instead, get only the required fields, which limits the size of each record


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

## Use EXISTS() Instead of COUNT()
- If you want to know whether a record/result exists or not, it is better to use exists(), rather than count()
- count(), will browse the entire table to get you the number of records.
- Whereas, exists(), will get back to you, when it finds the first record for the query, saving you time and computing.



## Functions on indexed columns is useless

- Using functions on indexed columns, while querying, will make the indexes remain useless.
- In order to use indexes, we need to avoid adding functions on the indexed columns.


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


## LIMIT Statements

- Most common used pagination is LIMIT, OFFSET, which is not optimal.
- It is fast for smaller and immediate sets like “LIMIT 0, 10”
- But when OFFSET is changed to 1000000, it takes too long, since database doesn’t know where 1000000th record exists, it starts from scratch till it finds 1000000th row.
- Better approach would be to add another filter, mostly indexed column, like below


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


## Use GROUP BY Instead of DISTINCT

- The distinct is an expensive operation, and doesn’t use indexes if available.
- Faster and easier way to do the same is to use group by.


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

---


## In Conclusion…


I haven’t covered many major SQL pitfalls. But these are some of the top mistakes, even made by experienced developers. Now you get to avoid them 😁

---

That’s it! Please let me know about your views and comment below for any clarifications.


If you found value in reading this, please consider sharing it with your friends and also on social media 🙏


Also, to be notified about my upcoming articles, subscribe to my newsletter below (I’ll not spam you 😂)


{% embed https://blogofcodes.substack.com %}


You can find me on [Twitter](https://twitter.com/sairahul1) and [LinkedIn](https://www.linkedin.com/in/sairahul1/) ✌️
Create Multi Arch Pipelines with Github Actions.
Tags: docker, github, tutorial
Published: 2022-10-03 14:58:52

Hello, I would like to share with you a sample Github workflow which builds Multiple Architecture Docker Images and finally push them to DockerHub. 

```
# https://github.com/docker/metadata-action
name: Multi-Arch-Build
on: 
   workflow_dispatch:

jobs:
  buildx:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v2
      - name: Set up Docker Buildx
        id: buildx
        uses: docker/setup-buildx-action@v2
      - name: Inspect builder # Debug only
        run: |
          echo "Name:      ${{ steps.buildx.outputs.name }}"
          echo "Endpoint:  ${{ steps.buildx.outputs.endpoint }}"
          echo "Status:    ${{ steps.buildx.outputs.status }}"
          echo "Flags:     ${{ steps.buildx.outputs.flags }}"
          echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
      - name: Login to Docker Hub
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.DOCKER_USER }}
          password: ${{ secrets.DOCKER_PASS }}
      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v4
        with:
          images: <docherhub-repo>/<actual-name># <specify the image name>
          tags: <sample>-${{ github.run_number }} # Tag
      - name: Build and push
        uses: docker/build-push-action@v3
        with:
          context: ./test/
          platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/arm/v6
          push: ${{ github.event_name != 'pull_request' }}
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
  ```

#### Result 

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


I hope you like the tutorial, if you do give a thumps up! and follow me in [Twitter](https://twitter.com/TVelmachos), also you can subscribe to my [Newsletter](https://dashboard.mailerlite.com/forms/167581/67759331736553243/share) in order to avoid missing any of the upcoming tutorials.

#### Media Attribution
I would like to thank [Clark Tibbs](https://unsplash.com/@clarktibbs) for designing the awesome [photo ](https://unsplash.com/photos/oqStl2L5oxI)I am using in my posts.


Thank you, Cheers!!!
React Stripe.js and the Payment Element
Tags: stripe, tutorial, payments, webdev
Published: 2022-10-03 14:49:51

{% youtube e-whXipfRvg %}

## What you’ll learn

With [React Stripe.js](https://stripe.com/docs/stripe-js/react) and the [Payment Element](https://stripe.com/docs/payments/payment-element) you can create a custom payment integration on your site that can offer more than 18 global payment methods with a single integration depending on your location and their availability. In this demo you’ll learn how to integrate the Payment Element with your React app, and how to turn on new payment methods via the dashboard without having to change, test or re-deploy your code.

## Prerequisites

If you’d like to follow along, you’ll need a Stripe account which you can [sign up for here](https://dashboard.stripe.com/register) and you can clone the getting started branch of the [repo here](https://github.com/matthewling-stripe/react-stripe-payment-element).

### Table of contents

* 00:00 [Introduction](https://www.youtube.com/watch?v=e-whXipfRvg)
* 01:07 [Cloning the repo and getting started](https://www.youtube.com/watch?v=e-whXipfRvg&t=67s)
* 02:12 [npm installs and starting the app](https://www.youtube.com/watch?v=e-whXipfRvg&t=132s)
* 03:50 [Building out payment.js](https://www.youtube.com/watch?v=e-whXipfRvg&t=230s)
* 05:18 [Creating a payment intent on the back end](https://www.youtube.com/watch?v=e-whXipfRvg&t=318s)
* 06:27 [Fetching and saving the client secret](https://www.youtube.com/watch?v=e-whXipfRvg&t=387s)
* 07:28 [Using the elements provider](https://www.youtube.com/watch?v=e-whXipfRvg&t=448s)
* 08:36 [Creating the checkout form](https://www.youtube.com/watch?v=e-whXipfRvg&t=516s)

## What to watch next

You can watch more videos on automatic payment methods [here](https://www.youtube.com/c/StripeDevelopers/search?query=automatic%20payment%20methods)

### About the author

![Matthew Ling](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c8rpgkqr91ivs8sxr73g.png) 

Matthew Ling ([@mattling_dev](@mattling_dev)) is a Developer Advocate at Stripe. Matt loves to tinker with new technology, adores Ruby and coffee and also moonlighted as a pro music photographer. His photo site is at [matthewling.com](https://matthewling.com) and developer site is at [mattling.dev](https://mattling.dev).


### Stay connected

In addition, you can stay up to date with Stripe in a few ways:

📣 Follow us on [Twitter](https://twitter.com/StripeDev)
💬 Join the official [Discord server](https://stripe.com/go/developer-chat)
📺 Subscribe to our [Youtube channel](https://www.youtube.com/StripeDevelopers)
📧 Sign up for the [Dev Digest](https://go.stripe.global/dev-digest)
Performance benchmarks - redis mget vs pipeline
Published: 2022-10-03 14:45:56

> This post was originally published at [distributedstack](https://www.distributedstack.dev/redis-mget-vs-pipeline/).

Redis provides a benchmarking tool called redis-benchmark for testing the performance of common redis commands. The benchmarks in this blog are run on below configuration.

```
Model - MacBook Air 2019
Processor - 1.6 GHz Dual-Core Intel Core i5
Memory - 8 GB 2133 MHz LPDDR3
Client - redis-benchmark
Server - localhost:6379
```
Both client and server are running on the same machine
redis-benchmark runs the tests over 100000 commands by default. You can tweak the numbers as required.

If you haven’t already, do checkout [this](https://www.distributedstack.dev/redis-hmget-pipeline-vs-mget/) article for more details on redis-benchmark tool.

Below benchmark runs 1000 commands in each pipeline over all the available tests.

```
$redis-benchmark -q -P 1000

PING_INLINE: 200803.22 requests per second
PING_BULK: 401606.44 requests per second
SET: 236406.61 requests per second
GET: 277008.31 requests per second
INCR: 229885.06 requests per second
LPUSH: 184501.84 requests per second
RPUSH: 220750.55 requests per second
LPOP: 183150.19 requests per second
RPOP: 223713.64 requests per second
SADD: 224719.11 requests per second
HSET: 172117.05 requests per second
SPOP: 335570.47 requests per second
LPUSH (needed to benchmark LRANGE): 186219.73 requests per second
LRANGE_100 (first 100 elements): 18278.19 requests per second
LRANGE_300 (first 300 elements): 6242.20 requests per second
LRANGE_500 (first 450 elements): 4006.73 requests per second
LRANGE_600 (first 600 elements): 2906.55 requests per second
MSET (10 keys): 29299.74 requests per second
```
So, we could do ~277k reqs/sec with redis get command in pipeline.

Let’s set some keys to benchmark redis mget

```
set hash1_key1 "The golden rule of a useful benchmark is not to compare apples to oranges"
set hash2_key2 "The golden rule of a useful benchmark is not to compare apples to oranges"
set hash3_key3 "The golden rule of a useful benchmark is not to compare apples to oranges"
$redis-benchmark mget hash1_key1 hash2_key2 hash3_key3 ... (1000 keys)

  100000 requests completed in 113.54 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

0.00% <= 1 milliseconds
0.06% <= 2 milliseconds
15.38% <= 44 milliseconds
20.01% <= 45 milliseconds
25.82% <= 46 milliseconds
32.60% <= 47 milliseconds
40.24% <= 48 milliseconds
48.40% <= 49 milliseconds
56.21% <= 50 milliseconds
63.03% <= 51 milliseconds
68.34% <= 52 milliseconds
72.26% <= 53 milliseconds
75.10% <= 54 milliseconds
90.14% <= 78 milliseconds
95.77% <= 83 milliseconds
99.99% <= 234 milliseconds
100.00% <= 235 milliseconds
100.00% <= 236 milliseconds
100.00% <= 237 milliseconds
100.00% <= 241 milliseconds
880.72 requests per second
```
So, we were able to fetch 880*1000 = 880k keys/sec via mget compared to 277k keys/sec with get in pipeline.
How To Use an API from your Ruby Server
Published: 2022-10-03 13:05:49

**Step 1**
**USE RESTCLIENT TO FETCH FROM API**
The first thing we want to do is fetch from the API.

```
def from_api
 resp = RestClient.get("https://exampleapi.com/?api_key=1241241515151")
 render json: resp.body, status: :ok
end
```

**Step 2**
**HIDE YOUR API KEY**
If you need to hide your key you can do so by using a gem called Figaro. 

```
gem "figaro"
```

Add figaro to to your gemfile, bundle install figaro and install figaro.

```
$ bundle exec figaro install
```
This creates a config/application.yml file and adds it to your .gitignore. You can use this to create Environment variables such as your key.

```
api_key: 1241241515151 (example)
```
And you can call it like this.

```
ENV['api_key'] 

> 1241241515151
```
Now use that key in your fetch request.
```
def from_api
    resp = RestClient.get("https://exampleapi.com/
?api_key=#{ENV['api_key']}")
    render json: resp.body, status: :ok
end
```
I need support
Published: 2022-10-03 14:44:06

I seriously need all your help
I am new to web designing and Zero knowledge about programming languages or other editing stuff. 
But, I successfully designed a website after watching Youtube videos. I used Bitnami Wordpress to  design the site on Localhost. I never had a paid host.
2 days back I deleted few images from a page I had by mistake. I couldn't undo the changes so I restored using the latest backed up file.
Restoring went up to 63% and held up over there and nothing happened so I escaped and refreshed the site.
After that entire Localhost site is inaccessible and showing I have a critical error. Nothing happens just the error message

Please anyone of you who has a good knowledge guide me through how to recover my localhost site😞....
Network Programming in Python + 2 Projects
Tags: python, community, programming, tutorial
Published: 2022-10-03 14:39:04

Hello!

Hope you enjoy studying network programming in Python exploring the next subjects :

1- Introduction to Socket Programming 
2- Server-Client Connection 
3- Project - TCP Chat Room (Server and Multiple Clients) 
4- Find Available Wi-Fi Networks Using CLI and PYTHON 
5- Port Scanner Using NMAP 
6- Port Scanner with Socket 
7- Project - Build SQL Injection Scanner with Python 

Thank you and I hope this video would be useful to you.

{% youtube SimNmTciQTs %}

Best,
Bek
Nifty crypto project finds of the week
Tags: blockchain, ethereum, web3
Published: 2022-10-03 14:32:07

There is so much excellent development going on in the crypoto, blockchain, Web3 space.  Here are a few of my favorite project finds over the last week:

Trading options can be a great low risk strategy for traders.  Here is a project bringing options to Ethereum mainnet.  [Hook™ – An option for options.](https://www.hook.xyz/)

Own a fraction of an NFT by buying with others in a party on Etherium mainnet:  [PartyBid](https://www.partybid.app/)
This is fascinating, with Hook and PartyBid someone created a listing to own part on an option to buy a Punk:  [Punk Option Part is buying Option Id2 | PartyBid](https://www.partybid.app/buy/0x5a9b11a110e9ec4f6ce8a89d69976e22a14a5776)

[The Labz](https://www.thelabz.com/) Farah Allen spoke at The Atlanta Blockchain Center on Sept. 29th.  Check out their take on creating engaging meta verse like experiences:  https://labzlive.com/unseenvirtualgallery/lobby

A firewall service to protect yourself against fraudulent transactions:  [Introducing Blowfish, the Security Service Your Web3 Wallet Needs](https://blog.blowfish.xyz/blowfish-raises-11-8m-round-led-by-paradigm/?utm_source=tldrnewsletter)

A Chrome plugin to make wallet transactions human readable:  [Fire Wallet Extension](https://www.joinfire.xyz/)
Fiverr Private API (Unofficial)
Tags: programming, webdev, android, career
Published: 2022-10-03 14:27:59

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

Hello everyone,

My name is Aimad, I'm a developer and reverse engineer.

Last week I had fun reverse-engineering Fiverr android mobile app and built my own **Fiverr API** solution, I had also chance to post it in [RapidAPI](https://rapidapi.com/contact-cmWXEDTql/api/fiverr4) marketplace.

## Fiverr Private API 🌟 

What can you scrape with my custom **Fiverr Private API**:

- Get all categories
- Category gigs
- Search keyword suggestion
- Search gigs
- Search users
- Get single gig
- Recommended gigs
- Get user
- User gigs
- User sheet
- User reviews

It's built with Python and using rotating proxies to bypass IP limits.

Now you can start scraping Fiverr and build apps/tools using API.

Happy coding!

[RapidAPI Link](https://rapidapi.com/contact-cmWXEDTql/api/fiverr4)
React 18 startTransition Adoption
Tags: react, discuss
Published: 2022-10-03 14:23:24

Hey, I have a simple question for the React community. 

**What is your (or your team's) strategy on adopting the startTransion API?**

The new concurrent rendering features are a breaking change, and opt-in. They bring new rendering benefits, but could cause rewrites/refactors in existing apps. It's always interesting to hear how others plan adopting of new APIs (especially those with breaking changes).

So I'd like to hear from people, whether they are immediately adopting, waiting a little or postponing indefinitely the adoption of the new startTransition API.

Any insight into your plans would be great to hear! Thanks
VSCode and WxWidgets
Tags: vscode, cpp, wxwidgets
Published: 2022-10-03 14:03:40

I can't seem to get VS Code to like WxWidgets on Linux or MacOS. It seems like it's trying to default to MSW?

_The specific question is making VSCode play nice (autocomplete, don't give false errors) with WxWidgets. In command prompt, compiling any Wx project works perfect._

Steps:

1. VS Code is installed
2. Create folder for project. Let's call it /src/hello
3. Create a hello.cpp file with code from: https://docs.wxwidgets.org/3.0/overview_helloworld.html
4. Download WxWidgets into /src/hello/deps
5. Going through steps to compile and install Wx https://docs.wxwidgets.org/trunk/plat_osx_install.html
6. Check my Intellisense includes to include ${workspaceFolder}/**

Now, in the command prompt, if I run: 
`g++ hello.cpp 'wx-config --cxxflags --libs' -o hello`
./hello runs perfect!

But in VSCode is unusable because it's giving me this error:
`cannot open source file "../../../lib/vc_lib/msw/wx/setup.h" (dependency of "wx/wxprec.h")`

I'm pretty sure msw is for windows? 

I feel like I've tried everything:

1. Downloaded and Git version of Wx (Yeah, I know it's the same. But people on the wx forums recommended trying...)
2. Use the Homebrew WxWidgets install.
3. Using the sample projects included with Wx.
4. Using the Hello World
5. Same issues in Linux and MacOS.
6. Updating Intellisense's includes every way you can think of.
7. Using the output of wxconfig and putting the cxxflags and lib include output into Intellisense.


Anyone able to test this all on their MacOS or Linux system and see if they are able to get VS Code to play nice?

THANK YOU!!
Dropdown Accessible Components just Released! 🎉
Tags: react, tailwindcss, uiweekly, news
Published: 2022-10-03 14:03:07

Hey all! 
Took some time to refactor some huge junks, but we are now back on our weekly releases!
New accessible Dropdown component, with mouse and keyboard navigation! As always for free!

[https://wind-ui.com/components/dropdowns/](https://wind-ui.com/components/dropdowns/)

We'd 💚 your feedback!
How to add flutterwave payment to flutter [2022]
Tags: flutter, flutterwave, programming, beginners
Published: 2022-10-03 13:53:24

> Hey guys have you been looking for a quick way to add flutterwave payment gateway to flutter 3.0+? 
> Flutter Package: https://pub.dev/packages/ade_flutterwave_working_version
> This video is for you. Watch till end.
> Have any questions? Comment below.

{% embed https://www.youtube.com/watch?v=uOvP3rwnVwQ %}