teleren/devto huggingface dataset:
Monit to Slack notifications with Ansible
Tags: monit, ansible, slack, rbenv
Published: 2022-10-27 13:40:38

---
title: Monit to Slack notifications with Ansible
published: true
description: Monit to Slack notifications with Ansible
tags: monit, ansible, slack, rbenv
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2022-10-27 13:33 +0000
---
This post is a quick one where I share my Ansible playbook which installs Monit on the server, add space usage alerts with Slack notifications.

````
---
- hosts: all
  gather_facts: yes
  environment:
    PATH: /usr/local/rbenv/shims:{{ ansible_env.PATH }}
  roles:
  - role: zzet.rbenv
    tags: ['rbenv']
    rbenv_clean_up: false
    rbenv:
      env: system
      version: v1.2.0
      default_ruby: 3.0.4
      rubies:
        - version: 3.0.4
  - role: pgolm.monit
    tags: ['monit']
    vars:
      slack_webhook: "'https://hooks.slack.com/services/xxxx/xxxx/xxxx'"
      monit2slack_path: "/usr/local/rbenv/shims/monit2slack"
      monit_cycle: 120
      monit_webinterface_enabled: false
      monit_services:
      - name: disk_usage
        type: filesystem
        target: /
        rules:
          - 'if space usage > 90%
          then exec "{{monit2slack_path}} --webhook {{slack_webhook}} --status error"
          else if succeeded then exec "{{monit2slack_path}} --webhook {{slack_webhook}} --status ok"'
          - 'if inode usage > 90%
          then exec "{{monit2slack_path}} --webhook {{slack_webhook}} --status error"
          else if succeeded then exec "{{monit2slack_path}} --webhook {{slack_webhook}} --status ok"'
  tasks:
    - name: Update system gem
      command: gem update --system
      become: yes
      become_method: su
      become_user: root
      environment:
        PATH: "/usr/local/rbenv/bin:/usr/local/rbenv/shims:{{ ansible_env.PATH }}"

    - name: Install latest version of monit2slack
      gem:
        name: monit2slack
        state: latest
      environment:
        PATH: "/usr/local/rbenv/bin:/usr/local/rbenv/shims:{{ ansible_env.PATH }}"

    - name: Install monit2slack gem
      command: gem install monit2slack
      become: yes
      become_method: su
      become_user: root
      environment:
        PATH: "/usr/local/rbenv/bin:/usr/local/rbenv/shims:{{ ansible_env.PATH }}"

````
I made a Virtual Mouse!!
Tags: python, programming
Published: 2022-10-27 13:26:08

After watching tutorials and scrolling through forums I found a way to make a Virtual Mouse that is controlled by hand movements !!.
In Python...
It can move and right click on the screen. But till now it is not able to do left click and drag. I am trying to include that too by seeing many other tutorials and web forums. Till then please Share your feedback about the project in the discussion section.
Thankyou
Stay Tuned
showcert: human-friendly openssl
Tags: openssl, security, webdev, certificate
Published: 2022-10-27 13:23:17

[showcert](https://github.com/yaroslaff/showcert) is easy to use CLI tool with to show/verify local (.pem) and remote SSL certificates.

showcert does only (1%) most often-used (99%) functions of openssl, but simple and easy to use.

Install: `pip3 install showcert`

Usage:
```shell
$ showcert github.com
IP: 140.82.121.3
Names: github.com www.github.com
notBefore: 2022-03-15 00:00:00 (182 days old)
notAfter: 2023-03-15 23:59:59 (183 days left)
Issuer: C=US O=DigiCert Inc CN=DigiCert TLS Hybrid ECC SHA384 2020 CA1
```

Also:
```shell
# show certificate from local file, or from stdin if path is -
showcert /etc/ssl/certs/ssl-cert-snakeoil.pem

# check all *.pem files in current directory, and warn if any expires soon. Add `-q` for quiet mode
showcert *.pem -w

# show certificate for gmail POP3 over SSL
showcert pop.gmail.com:995 

# show cert for yandex POP3. Yes, it will do STARTTLS automatically)
showcert pop.yandex.ru:110 

# connect to localhost, but ask to show cert for google.com (SNI)
# -i = insecure, ignore verification error
showcert -i -n google.com localhost 

# 'steal' remote server fullchain.pem (without privkey, obviously)
showcert google.com --chain -o pem > fullchain.pem

#
# LetsEncrypt specific features:
#

# Warn if expire in less then 10 days. Non-zero exit if at least one certificate is expiring.
# same as `showcert -w 10 /etc/letsencrypt/live/*/fullchain.pem

showcert -w 10 :le

# list all names from certificate (as -o names), but each name prepended with -d. 
# e.g. `-d example.com -d www.example.com`
showcert -o dnames example.com

# Useful to use with certbot to generate new certificate from existing cert or site. E.g.:
certbot certonly --webroot /var/www/PATH `showcert -o dnames example.com`
```

Seem more on GitHub repo: https://github.com/yaroslaff/showcert
What Is Open-Source? A Simple Introduction
Tags: opensource, explainlikeimfive, security, tooling
Published: 2022-10-27 13:00:00

*Quick plug before we get started: this post was original published in [my new blog site](https://the-net-blog.netlify.app/post/what-is-open-source/), check it out if you want to read more like this! I'll be posting a new blog every Monday!*

Open-source is a very important topic that every software engineer should know about. By the end of reading this post, you'll know what the popular term open-source means, potentially start using open-source software and understand the importance of open-source.

## Table Of Contents
1. [The Basics](#the-basics)
2. [Why Open Source](#why-open-source)
3. [What Is Wrong With Closed Software?](#what-is-wrong-with-closed-software-propietary-software)
4. [Popular Open Source Software](#popular-open-source-software)
5. [Read More](#like-this-post-watch-more)


## The basics
Let's start with what the actual defenition is of open-source, basically when something is open-source it means that *anyone* can see the code that makes that product, and anyone can contribute to it as well. Anyone can see the code, modify, and inspect the code. 


**Actual Picture of an Open Source User:**

![Picture Of Open Source User](https://media.giphy.com/media/Vp3ftHKvKpASA/giphy.gif)

## Why Open Source?
* Open source ensures that the software that you use is secure and private (or easy to know if it's not),
* Open source allows any bug to be easily detected and fixed a lot faster.
* Everyone has different points of view of things, open source allows millions of developers from all around the world to contribute to their favourite software's code.

*BTW: this website is open-source so feel free to contribute to it! You don't need to know how to code, even a simple typo fix can help!*

## What is wrong with closed software (proprietary software)
First of all, you have *no idea* how much data they are stealing from you, and how much they know about you. Since the code is not available to the public security bugs (and other bugs as well) might go un-noticed for a long time which can lead to very security hazardous bugs being abused.

## Popular Open Source Software:
So you want to start using open source software? Well here are a few software that can help you get started!
* [Mozilla Firefox - Web Browser](https://www.mozilla.org/en-US/firefox/new/)
* [Ubuntu - Linux Operating System](https://ubuntu.com/)
* [Gimp - Powerful Photo Editing Tool](https://www.gimp.org/)


## Like this post? Watch more!
I appreciate you spending your time reading this post, if you'd like to read more here you go:

[Why I chose Hugo (and why you should too)](https://the-net-blog.netlify.app/post/why-i-chose-hugo/)

[Home Page](https://the-net-blog.netlify.app)
What are your must have requirements from a UI library?
Tags: discuss, webdev, opensource, javascript
Published: 2022-10-27 12:59:12

Currently I am developing a new UI library targeting multiple frontend frameworks and this made me wonder: 
`What makes a UI library great? Why whould anyone pick mine?`

These questions made me realise that my priorities are not necessarily everyone's priority, 
So here am I asking for your input. 

What are your `must have` requirements when you pick a UI library for your framework of choice? 

Some feedback that I received so far:

- Familiarity (be it with other UI library for a different framework or for the same one) 
- Extensive SEO and accessibility support
- Easily customisable
- A great number of components
Code Smell 173 - Broken Windows
Tags: webdev, beginners, programming, tutorial
Published: 2022-10-27 12:38:19

*Always leave the campground cleaner than you found it.” If you find a mess on the ground, you clean it up regardless of who might have made it.*

> TL;DR: Follow Uncle Bob's boy scout rule.

# Problems

- Readability

- Maintainability

# Solutions

1. Leave the code better

2. Change it

# Context

We read code many more times than we write.

We must take ownership of code with errors and leave it better.

# Sample Code

## Wrong

[Gist Url]: # (https://gist.github.com/mcsee/5577d55a7a059073137b7d892b218e80)
```c
    int mult(int a,int  other) 
    { int prod
      prod= 0; 
      for(int i=0;i<other  ;i++) 
        prod+= a ; 
         return prod; 
    } 

// Formatting, naming, assignment and standards inconsistent
```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/952f2de180ccdbe8bb73f7dfac162fe5)
```c
int multiply(int firstMultiplier, int secondMultiplier) {
  int product = 0; 
  for(int currentIndex=0; currentIndex<secondMultiplier; currentIndex++) {
    product += firstMultiplier; 
  }
  return product; 
} 

// or just multiply them :)
```

# Detection

[X] Semi-Automatic 

We can use other code smell detectors and leave the code in a better shape.

# Tags

- Standards

# Conclusion

We must follow the Boy Scout rule and leave the code better.

# Relations

{% post https://dev.to/mcsee/code-smell-164-mixed-indentations-3gfc %}

{% post https://dev.to/mcsee/code-smell-159-mixedcase-nc %}

# Disclaimer

Code Smells are just my [opinion](https://dev.to/mcsee/i-wrote-more-than-90-articles-on-2021-here-is-what-i-learned-1n3a).

# Credits

Photo by [Pawel Czerwinski](https://unsplash.com/@pawel_czerwinski) on [Unsplash](https://unsplash.com/s/photos/windows-broken)  

* * *

> One broken window, left unrepaired, instills in the inhabitants of the building a sense of abandonment. People start littering. Graffiti appears. Serious structural damage begins. In a relatively short span of time, the building becomes damaged

_Andy Hunt_
 
{% post https://dev.to/mcsee/software-engineering-great-quotes-26ci %}

* * *

This article is part of the CodeSmell Series.

{% post https://dev.to/mcsee/how-to-find-the-stinky-parts-of-your-code-1dbc %}
Resizing & cropping images using Python Pillow
Tags: programming, python, beginners, image
Published: 2022-10-27 12:21:43

We're going to use `Image` and `ImageOps` components of `Pillow` module to resize/crop image.

## How to resize an image keeping aspect ratio

```python
from PIL import Image, ImageOps

im = Image.open('/var/www/examples/heroine.png')
width = 100
height = width * im.size[1]/im.size[0]

im = im.resize((width, height))
```

- `100` - resized image width,
- `width * im.size[1]/im.size[0]` - calculates height so that aspect ratio is maintained.

[Open original](https://onelinerhub.com/python-pillow/how-to-resize-and-image-and-maintain-aspect-ratio) or [edit on Github](https://github.com/Onelinerhub/onelinerhub/tree/main/python-pillow/how-to-resize-and-image-and-maintain-aspect-ratio.md).


## How to crop an image from center

```python
im = Image.open('/var/www/examples/heroine.png')
crop = (400, 400)
left = round((im.size[0] - crop[0])/2)
top = round((im.size[1] - crop[1])/2)
im = im.crop((left, top, crop[0]+left, crop[1] + top))
```

- `(400, 400)` - cropping area width and height,
- `(im.size[0]` - crop[0])/2` - left coordinate of a crop area to position in the horizontal center,
- `(im.size[1]` - crop[1])/2` - top coordinate of a crop area to position in the vertical center.

[Open original](https://onelinerhub.com/python-pillow/how-to-crop-an-image-in-the-center) or [edit on Github](https://github.com/Onelinerhub/onelinerhub/tree/main/python-pillow/how-to-crop-an-image-in-the-center.md).


## How to resize/crop an image cropped to fit certain area (cover thumbnail)

```python
im = Image.open('/var/www/examples/heroine.png')
im = ImageOps.fit(im, (100,100), Image.ANTIALIAS)
```

- `100,100` - thumbnail area width and height,
- `ImageOps.fit(` - fits an image into given area.

[Open original](https://onelinerhub.com/python-pillow/how-to-create-square-thumbnail-cropped-to-fit) or [edit on Github](https://github.com/Onelinerhub/onelinerhub/tree/main/python-pillow/how-to-create-square-thumbnail-cropped-to-fit.md).
How to Make a Vehicle Charging Website Using Html CSS JS
Tags: css, javascript, beginners, tutorial
Published: 2022-10-27 12:14:50

{% youtube EBS4Cl0IK2Q %}

How to Make a Vehicle Charging Website Using Html Css JS

This video will show you how to build a vehicle charging website using html css javascript

[Github Repo](https://github.com/codewithsadee/pixology)

---

HI 👋
I'm Sadee (webdev)
In this channel I make videos about Complete Responsive website.
You can checkout my channel 👇

📺 My Channel : [codewithsadee](https://www.youtube.com/channel/UC1PZHWV6VvICTL1LgFUZq6g)
🔔 Subscribe : [subscribe now](https://www.youtube.com/channel/UC1PZHWV6VvICTL1LgFUZq6g?sub_confirmation=1)

---

🔗 Essential links
-----------------------------
[Download the starter file to practice](https://drive.google.com/file/d/10ssXyyO4zFiGLs6AM_DtoHzYNnS4caGm/view?usp=sharing)

---

⏱️ Timestamps
-----------------------------
0:00 - Demo
4:02 - File structure
4:46 - Project initial
11:40 - Preloader
16:45 - Header
28:46 - Hero section
39:46 - About section
50:01 - Stats section
57:21 - Service section
1:07:58 - CTA section
1:12:17 - Blog section
1:22:34 - Contact section
1:25:59 - Footer
1:41:23 - Media queries
1:46:18 - Scroll reveal
1:50:34 - Responsive

---

[![Become a patreon](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fnjl14kdm5qf08hu5lop.png)](https://www.patreon.com/bePatron?u=62535867)
Best sites to learn programming
Tags: javascript, webdev, programming
Published: 2022-10-27 12:03:05

Hello cousins and cousins!

If you're a beginner or someone who's really good at programming, I think you should check out these sites. All of them are free and I believe they will help you to improve your skills.

**[Code academy](https://www.codecademy.com/)**

Code Academy is one of the best sites to learn programming. In it you will find many options of programming languages with many projects.

**[Datacamp](https://www.datacamp.com/?irclickid=zH0RBrxA3xyNTICV6dxUAzlaUkDUuew9XTkox80&irgwc=1&utm_medium=affiliate&utm_source=impact&utm_campaign=000000_1-2784918_2-mix_3-all_4-na_5-na_6-8-na_7-mp1-1_6-na_7-mp1-1)**

If you want to build your career in Data Science, Datacamp is a great option for you to start learning.

**[HackerRank](https://www.hackerrank.com/products/main/)**

HackerRank is suitable for anyone who wants to improve their coding skills. Through practical problems and challenges.

**[GeeksforGeeks](https://www.geeksforgeeks.org/)**

It has a wide range of solutions and explanations for all topics in the IT field.

**[W3Schools](https://www.w3schools.com/)**

W3Schools is a website that provides tutorials and reference materials for web developers.

If there's a site you like that isn't here, let us know in the comments.
How can I get started as the Blockchain developer?
Tags: beginners, tutorial, salesforce
Published: 2022-10-27 11:53:00

Let's be sincere in this instance. The study shows that only 0.71 % of the world population utilizes blockchain technology. Experts are all the odds in its favor of being the next major technological advance.
Blockchain has all the ingredients to change the way the market operates and how it operates. From payments in to the vote, all over there's an uproar about blockchain that is attracting people looking for "how to become an Blockchain developer".Also are you interested to learn about the specifics about Salesforce Administrator Exam (ADM 2001) or Salesforce Administrator Exam (ADM 201) and the Platform App Builder (CRT 403) certification exam. Are you interested in finding out about more details about [Salesforce Training](https://www.edureka.co/salesforce-administrator-and-developer-training).

If you're to the same class of people, read this an extensive blog on blockchain uses, benefits, and usages and ways to become an blockchain developer.

What exactly is blockchain?

Blockchain is a public immutable, permanent ledger that tracks the transactions as well as tracks assets of a distributed network. These assets could be tangible or intangible. It gives the ability to keep track of and trade virtually all things.

Blockchain Blockchain an approach to processing information in a fast and shared method. Businesses require the data to manage their businesses and run their business, don't you think? This is where ultra-modern technology is essential in providing instant accessible, transparent, and shared information. The data is stored inside an irreversible ledger which can only be accessed by a network participant. If you're looking for more details about Salesforce interview questions and FAQs, click here. deep dive into [Salesforce interview questions and answers](https://www.edureka.co/blog/interview-questions/salesforce-interview-questions/).

Every participant on the network is able to share an identical view of the truth, which allows everyone to view all transaction details to ensure security and efficiency.
Fetch several branches locally in GitHub actions
Tags: github, workflow
Published: 2022-10-27 11:39:51

_Edited_

Working on [Open Terms Archive](https://www.opentermsarchive.org), I recently needed to fetch both the `main` branch and my current branch **locally** in order to make a programmatic `git diff` on a file.

Unfortunately, GitHub Actions only allows the local fetch of one branch at a time, and even though such a syntax:

```yaml
- uses: actions/checkout@v2
  with:
    fetch-depth: 0 # fetch all history for all branches and tags
  fetchLocal: ["main"]
```
would have been great, it does not exist.

_NOTE: `fetch-depth: 0` will fetch all the branches and will make them available on `remotes/origin/<branch>` but my script used the local branch `main` so I had to map it locally_

So here is how fetching 2 branches locally can be done:

## Solution

_Thanks to [Matti](https://mattischneider.fr/)_

```yaml
- uses: actions/checkout@v2
  with:
    fetch-depth: 0 # fetch all history for all branches and tags
- run: git branch main remotes/origin/main
```

## Other workaround

I keep it here as it shows how to retrieve the current branch name on both `push` and `pull_request` events (which I did not see anywhere).
But you should definitely use the above solution
 
```yaml
- name: Get branch name
  run: |
    if [ -z $GITHUB_HEAD_REF ]; then BRANCH=$GITHUB_REF_NAME; else BRANCH=$GITHUB_HEAD_REF; fi
    echo "BRANCH=$BRANCH" >> $GITHUB_ENV
- uses: actions/checkout@v2
  with:
    ref: main
    fetch-depth: 0 # fetch all history for all branches and tags
- run: git checkout --force -B $BRANCH refs/remotes/origin/$BRANCH
```

## Conclusion

This way, both branches are available locally for the diff.


## Who am I?
My name is Martin Ratinaud and I’m a senior software engineer and remote enthusiast, contagiously happy and curious.
I create websites like this one for [staking crypto](https://www.stakingcrypto.io/) and [many more...](https://www.indiehackers.com/martinratinaud)

Check my [LinkedIn](https://fr.linkedin.com/in/martinratinaud) and get in touch!
Find work in web3 - in web3 way
Tags: web3, blockchain, crypto
Published: 2022-10-27 11:10:17

We at Kleoverse are developing the portfolio for web3 builders. We have built a protocol – Proof-of-Talent – to verify and record achievements on-chain. You can create skill scores based on your achievements and gather this information into an intuitive, highly actionable portfolio. Dozens of organizations are already looking for new talent based on close to 25,000 created portfolios.

This is what you can expect:

📝 Web3 portfolio, designed and built to serve web3 builders
⛓ Blockchain-verified working history with actionable skill scores
⚡️ NFT-based badges for open-source contributions and other achievements
🤝 +700 listed jobs from leading web3 organizations
📈 Rapidly growing community of 25,000 signed-up users
🛠 Tooling for organizations hiring builders
📯 Lots more!

Proof-of-Talent verifies skills objectively and transparently. Our goal is to enable fair and highly accurate matches between projects and builders based on proven skills, not networks or status signals. Starting from web3, we want to uncover hidden talent across industries everywhere in the world.

Enter Kleoverse: https://kleoverse.com/badges

Join the community: https://discord.gg/fGxPadHDph
Why Cloud Computing is so cool? (Short notes about clouds #1)
Tags: beginners, cloud, aws, devjournal
Published: 2022-10-27 11:08:24

Welcome to my first part about Cloud Computing. In the next articles I am gonna share with you guys in short notes about what I am currently learning and what is inspiring me. 

**Why the cloud computing is so cool?**

1. global reach
    This allows you to execute application around the world just in minutes for minimal delays for your customers.
    
2. flexibility 
    You can adjust processing power to your present situation. For example you do not have to buy more hardware for preparing for  a bad time. Increasing, decreasing your storage or needed processing power is easy, costs you just a few clicks on the mouse.
    
3. agility 
    Of the many functionalities available through the provider, you can perfectly choose the ones you need.  You can customize everything for yourself.
    
4. cost optimization
    If you use cloud computing in responsible way, it will save you a lot of money thanks to for example flexibility or agility, mention above.



Have a nice day!
Path to Cypher Query tuning
Tags: neo4j, cypher
Published: 2022-10-27 11:08:04



What are the things to learn to be able to tune cypher queries

1. Preparing for Query Tuning
2. How queries work in Neo4j [here](https://neo4j.com/graphacademy/training-cqt-40/01-cqt-40-how-queries-work-in-neo4j/)
3. Controlling Row Cardinality
4. Neo4j Behind the Scenes
5. Optimizing Property Access
6. Node Degree Shortcuts
7. Monitoring Running Queries


you should be able to:
- Define the terms row and DB hit in the context of Cypher querying [cypher-cardinality](https://neo4j.com/developer/kb/understanding-cypher-cardinality/)
- Use EXPLAIN and PROFILE to identify weaknesses in a query plan
- Use Cypher tools to minimize the number of rows processed in a query
- Use best practices for minimizing property access
- Use monitoring tools to identify the underlying causes of a long-running query [1](https://neo4j.com/labs/halin/)  [2](https://github.com/moxious/halin)


Resource to get learn above topics

- [Lesser Known Features in Cypher
](https://www.youtube.com/watch?v=BN5T8IimB78)
- [Tuning Cypher
](https://www.youtube.com/watch?v=QnozzFP_fPo)
- [Best practices for queries that can take hours to complete
](https://community.neo4j.com/t5/neo4j-graph-platform/best-practices-for-queries-that-can-take-hours-to-complete/m-p/27305)
- [5 Secrets to More Effective Neo4j 2.2 Query Tuning
](https://neo4j.com/blog/neo4j-2-2-query-tuning/)