teleren/devto huggingface dataset:
Custom Gitlab Hooks
Tags: git, programming, eventdriven, webhook
Published: 2023-01-16 12:45:47

Welcome dear reader, My name is Silent-Mobius, also known as Alex M. Schapelle.
Today we'll cover controversial topic of custom hooks on the git SCM server, mainly on GitLab-CI, and howto create them.
Before we dwell onto subject, Let us address the existing wisdom:
- Today, special type of events can be a triggered with built-in tools called web-hooks.
- For custom conditioning of web-hooks, via web UI, currently is not possible.
- If one insists, it can be automated, to use web-hook to trigger, custom service that will activate your custom hooks, yet it is somewhat trouble some.

### What are these custom hooks, you speak of ?
Simple put, a script or a piece of software that perform tasks of check, order or conditioning of your remote requests.

Git natively supports hooks that are executed on different actions. Examples of server-side git hooks include pre-receive, post-receive, and update. See Git SCM Server-Side Hooks for more information about each hook type.

When it comes to GitLab, as of gitlab-shell version 2.2.0 (which requires GitLab 7.5+), GitLab administrators can add custom git hooks to any GitLab project.
**>Note: Custom git hooks must be configured on the filesystem of the GitLab server**. Only GitLab server administrators will be able to complete these tasks

### What would be the cases, one might need custom hooks ?
The cases, where using web-hooks only triggers the pipelines in development environment, but there is no possibility to **condition** or run specific commands from gitlab notification, thus usage of server side custom hooks are in demand.

### Let us dive into setup

git hooks are placed in the repository or project's hooks directory. GitLab creates a symlink from each project's hooks directory to the gitlab-shell hooks directory for ease of maintenance between gitlab-shell upgrades. As such, custom hooks are implemented a little differently. Behavior is exactly the same once the hook is created, though. Follow these steps to set up a custom hook.

- Pick a project that needs a custom git hook.
- On the GitLab server, navigate to the project's repository directory. For an installation from source the path is usually `/home/git/repositories/<group>/<project>.git`. For Omnibus installs the path is usually `/var/opt/gitlab/git-data/repositories/<group>/<project>.git`.
- Create a new directory in this location called `custom_hooks`.
- Inside the new custom_hooks directory, create a file with a name matching the hook type. For a pre-receive hook the file name should be pre-receive with no extension.
- Make the hook file executable and make sure it's owned by git.
- Write the code to make the git hook function as expected. Hooks can be in any language. Ensure the 'shebang' `#!` at the top properly reflects the language type. For example, if the script is in Bash the shebang will probably be `#!/usr/bin/env bash`.

That's it! Assuming the hook code is properly implemented the hook will fire as appropriate.
Amazon Security: WAF and Shield
Tags: beginners, aws, security, amazon
Published: 2023-01-16 12:42:51

## Web application Firewall

Web Application Firewall is a security service provided by AWS that helps protect your Web Application from common web exploits that could affect application availability, compromising security, or consume excessive resources.
It is used to monitor the HTTP and HTTPS requests that are forwarded to an Amazon API, Gateway API, Amazon CloudFront, or an Application Load Balancer.
It also gives control over which traffic to allow or block to your web applications by defining customizable web security rules.
Any public web applications are exposed to certain common exploits, using a web application firewall; you can watch for vulnerabilities and block them upfront without affecting your applications running on these AWS services.
When we enable the Web Application Firewall, it watches for the following character streaks in a web request.


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

**Cross Site Scripting (XSS):**
These are scripts that are likely to be malicious. Attackers embed these scripts that can exploit vulnerabilities in your web applications.

**IP addresses range that requests originate from:**
WAF can look for countries or geographical locations where requests originate from.
Length of a specific part of the request such as the query string.

**It can find the SQL Injection:**
SQL Injections are SQL code that is likely to be malicious. So that attackers can try to extract data from your database by embedding malicious SQL code in a web request.
It can also look for strings that appear in the request, for example, values that appear in the query string.

When we are setting up WAF for different AWS services first we define the conditions for example if a request is originating from a particular country.
After defining the conditions we combine them into rules. A rule contains multiple conditions. The rules are then combined into Web ACL. This is where we define an action for each rule. We can also define a default action that gets executed when none of the rules are met.


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

## AWS Shield:

AWS Shield protects against DDoS attacks. The DDoS attack is a distributed denial of service (DDoS) attack. It is an attack in which multiple compromised systems attempt to flood a target, such as a network or a web application, with traffic. A DDoS attack can prevent legitimate users from accessing a service and can cause the system to crash due to the overwhelming traffic volume.

AWS provides two types of Shields:

**AWS Shield Standard:** 
Shield network and transport layer DDoS attacks that target your website or applications. All AWS customers are benefited from the automatic protections of AWS Shield Standard at no additional charges.

**AWS Shield Advanced:**
It provides expanded DDoS attack protection for web applications running on Amazon EC2, Elastic Load Balancing (ELB), CloudFront, and Route 53 resources. It comes with an additional charge.
Amazon Cognito
Tags: beginners, aws, security, cognito
Published: 2023-01-16 12:20:24

**Understanding Amazon Cognito:**
Cognito provides authentication, authorization, and user management for web and mobile apps. Users can sign in directly with their user name and passwords and can also use a third party such as Facebook, Amazon, Google, or apple to authenticate. There are a few main components of Cognito given:

- User Pools:These are user directories that enable signup and sign-in options for app users.
- Identity pools: It is used to grant users access to other AWS services. 

We can use identity and user pools separately or together. We can also synchronize data across devices(Cognito Sync)

**User Pools:** 
It is a user directory in Cognito.
Users can sign in to the web or mobile app through Cognito or federate through a third-party identity provider(IdP)
All members of the user profile have a directory profile accessible through SDK.

User pool capabilities:
- Sign up and sign in services
- Built-in web interface to sign in users 
- Sign in with Facebook, Google, Amazon, and Apple, and through SAML/OIDC identity protocol-based providers from user pools.
- Manage user directories and user profiles.
- Use lambda triggers to customize workflows and user migration.
- Multi-factor authentication, checks for compromised credentials, account takeover protection, and phone and email verification.


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

**Cognito Identity Pools:**
- Identity pools are used to obtain temporary credentials to access AWS services.
- Supports anonymous guest and identity providers that can be used to authenticate users for identity pools.
Cognito user pools
- Sign in with Facebook, Google, Amazon, and Apple, and through SAML/OIDC identity protocol-based providers from the user pool.
Developer authenticated identities.
- To save user profile information, an identity pool needs to be integrated with a user pool.

**Cognito Sync:**
It is a service and client library that provides cross-device syncing of application usage data.
We can synchronize user profile data across mobile devices and web apps without a custom backend.
client libraries cache data locally allowing the app to read and write data even with device connectivity variability.
With the device online, synchronize data, if push sync is enabled, notify other devices immediately that an update is available.
Vim: Powerful text editor
Tags: vim, beginners, programming, productivity
Published: 2023-01-16 11:59:00

## Introduction:

Vim is a powerful and versatile text editor widely used by programmers, developers, and system administrators. It has a steep learning curve but once mastered, it can greatly increase productivity and efficiency. One of the unique features of Vim is its modal design, which allows users to navigate, edit and manipulate text in different modes. In this post, we will explore the basics of Vim, from setting it up to mastering advanced commands and tips.

## Getting Started with Vim:

The first step in using Vim is setting it up on your computer. Once you have it installed, you can start learning the basic commands for navigation and editing. Vim has several modes, each with its own set of commands. For example, in normal mode, you can navigate and manipulate text, while in insert mode, you can insert new text. It's important to understand the different modes and their functions to effectively use Vim.

## Advance Vim:

As you become more comfortable with Vim, you can start exploring its more advanced features. Visual mode, for example, allows you to select text with the cursor, while multiple windows and tabs can help you work on multiple files at the same time. Macros can automate repetitive tasks, and folding can help you organize your code. Vim also has a variety of registers, which can be used to store and recall text, and plugins, which can add new functionality to Vim.

## Tips and Tricks:

There are many ways to customize Vim and make it work for you. You can create your own commands and mappings, and use plugins to add new functionality. There are also many productivity hacks you can use to make your work more efficient. It's also important to know how to troubleshoot problems that may arise while using Vim.

## Conclusion:

Vim is a powerful text editor that can greatly increase productivity and efficiency once mastered. This post has covered the basics of Vim, from setting it up to mastering advanced commands and tips. There are many resources available to help you continue learning and improving your skills. And if you want to take it to next level you can use our comprehensive and free Vim cheat sheet, which covers all the essential commands and make it easy for you to quickly find the command you need, when you need it.

### [Download now and master this powerful text editor in no time!](https://store.ahmedsuliman.com/l/VimCheatSheet)
Iniciante em Programaçao
Published: 2023-01-16 11:47:14

bom dia pessoal, eu sou novo nessa comunidade e ate mesmo nessa área, me  chamo Wesley e tenho 25 anos. comecei a estudar python por acaso faz umas 3 semanas, e eu estou pegando gosto, venho vendo vídeo e tutoriais e aprendendo sozinho e de graça então eu gostaria de participar de algum grupo de iniciantes ou ate mesmo iniciar alguma amizade
Application of Robots
Tags: robots, robotics, mechatronics
Published: 2023-01-16 11:42:04


Day by the day , uses of AI and robotics are increasing. Rarely we will find any industry which is not using robots in their assembly unit or manufacturing unit. Robots can do your hard task  very easily. That is why , application of robotics can  be found everywhere.
Application of robotics is not limited. It has a wide range of application. But let start with the definition of robotics.
 

## **What is Robot :**
The **Robotics Industries Association (RIA)** of USA defines the robot as:
“A reprogrammable, multifunctional manipulator designed to move material through variable programmed motions for the performance of a variety of tasks.”
By the time , many different definitions has come. There are many more definitions , this is one of them. If you want to know more , please check it out [Evolution of Robots](https://mechatroneex.com/evolution-of-robots/).


## **Application of Robotics :**

**Medical :** 
Medical robots are mainly made for surgery. The goal of medical robots are not to replace surgeons but to provide them new set of versatile tool that can help them in their work. The design of the surgical robot must be suitable for the operation theatre and must be placed at a correct position.
 
**Mining :**
As we all know , mining is a very risky job , when workers are under the ground. There are toxic gases , dust , water, etc.; in simple terms, the environment is not healthy. Many accidental cases happen every day. By using mining robots, we can decrease the number of casualties.
 
**Space Exploration :** 
This is not new to us. Robots have been used to explore space for over a decade. Space robots can perform a variety of tasks such as soil testing, air testing, and environmental testing. Some of the examples are : Pathfinder (made by NASA) , Curiosity (made by NASA) etc.


[Read More ......](https://mechatroneex.com/application-of-robotics/)
Sending e-mails with Mailtrap
Tags: node, nodemailer, mailtrap
Published: 2023-01-16 11:26:27

---
title: Sending e-mails with Mailtrap
published: true
tags: ['node', 'nodemailer', 'mailtrap']
canonical_url: https://sevic.dev/notes/emails-locally/
---

For local testing or testing in general, there is no need to send e-mails to real e-mail addresses. [Mailtrap](https://mailtrap.io/) service can preview the e-mails for sending.

The inbox page can show credentials (username and password). A list of inboxes is available at [Projects page](https://mailtrap.io/inboxes).

```js
import nodemailer from 'nodemailer';

(async () => {
  const emailConfiguration = {
    auth: {
      user: process.env.EMAIL_USERNAME,
      pass: process.env.EMAIL_PASSWORD
    },
    host: process.env.EMAIL_HOST, // 'smtp.mailtrap.io'
    port: process.env.EMAIL_PORT, // 2525
    secure: process.env.EMAIL_SECURE,
  };

  const transport = nodemailer.createTransport(emailConfiguration);

  const info = await transport.sendMail({
    from: '"Sender" <sender@example.com>',
    to: 'recipient1@example.com, recipient2@example.com',
    subject: 'Subject',
    text: 'Text',
    html: '<b>Text</b>'
  });

  console.log('Message sent: %s', info.messageId);
})();
```

### Demo

The demo with the mentioned example is available [here](https://sevic.dev/demos).

### Related reading

- [Sending e-mails with Sendgrid](https://sevic.dev/notes/emails-sendgrid)
Tip : Write better error messages with ChatGPT
Tags: a11y, ux, productivity, webdev
Published: 2023-01-16 11:21:26

A friend of mine showed me a great use of ChatGPT to write human-friendly error messages. I thought it's brilliant and everyone needs to know this.

![Use ChatGPT to write better error messages](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r33vhnoykfpdkla7xivf.png)

Original Tweet: https://twitter.com/douglascayers/status/1613714294910160897
Episode 23/02: Angular 15.1, State of JavaScript 2022
Tags: webdev, javascript, angular, programming
Published: 2023-01-16 11:07:48


Angular 15.1 landed with some helpful new features.

In addition, the State of JavaScript Survey revealed a decrease in usage but an increase in interest.

Tomas Trajan wrote an insightful article on Jest and ES Modules.

{% embed https://youtu.be/Jn4LV0Np2KY %}

## Angular 15.1
Angular 15.1 is out. These are the main features:

- We got support for self-closing tags for components, directives, and custom elements.
- The language service, which Visual Code also uses for its Angular support, provides automatic imports even if multiple candidates are available.
- You should replace your `CanLoad` guards with `CanMatch` as the first one is deprecated.

Self-closing tags might not look like a huge change, but it kind of is. It is first time that Angular deliberately breaks its compliance with the HTML specification.
The main argument is that a template's HTML is never exposed to the browser. Instead, it is parsed and then re-generated during the runtime via simple document.createElement commands.

For more information on the 15.1 release, checkout the official [ChangeLog](https://github.com/angular/angular/releases/tag/15.1.0).

## State of JavaScript 2022

The results of the State of JavaScript survey are available.

As it was already the case last year, Angular didn't find itself on top of things ;).
In terms of usage, it dropped from 54% to 49% and ended in second place.
Number 1 is React, which increased from 80% to 82%.

Looking at the interest rate, though, we saw an increase for the first time. It went up from 16% to 20%.

Looks like the new features start to attract developers again.

[State of JavaScript 2022](https://2022.stateofjs.com/en-US/libraries/front-end-frameworks/ )

## Tomas Trajan: Jest und ES Modules

Tomas Trajan wrote a detailed article about Jest and its performance issues with ES modules. They are the default format since Angular 12.

Tomas comes up with a list of common use cases that require a customised Jest configuration. After applying all the strategies, his tests improved by 290%.

[Link to Article](https://angularexperts.io/blog/total-guide-to-jest-esm-and-angular)
Testing is easy...Monday smile
Tags: webdev, testing, ux, ui
Published: 2023-01-16 11:05:29

I heard quite often people refer to testing as being easy and that anyone can test.

I mean...they are correct...anyone can test...the same as anyone can write code. It does not mean that they will do a good job but they can still do it.

When you hear that testing is easy in the future or that no testing is needed show the below video to them.

It made my smile.

https://www.youtube.com/shorts/C_5sLkN0Sr8

P.S. This post was meant to be just fun and to bring a Smile
Perl is so nice...!!
Tags: programming, perl, beginners
Published: 2023-01-16 10:52:51

Hello! I'm Ryu from Japan, learning Perl little bit now. 

I've read Perl book "One-Liners: 130 Programs That Get Things Done" recently and I was impressed.

Wanna learn more about Perl. What book or material is good for begineers?


Produced by <a href="https://perlclub.net/">Perl Club</a>
A short blog on top 5 django customizations
Tags: webdev, django, python, beginners
Published: 2023-01-16 10:49:28

Django is a powerful web framework that provides a lot of flexibility and customization options. While the built-in functionality is more than enough for most projects, some more advanced use cases may require additional customization. In this blog post, we'll be discussing the top 5 advanced customizations that you can make to your Django project.

##Creating Custom Database Backends: 
[Django supports multiple databases](https://docs.djangoproject.com/en/4.1/topics/db/multi-db/) and the built-in database backends provide a lot of functionality, but sometimes you need to connect to a database that Django doesn't support out of the box. Creating a custom database backend allows you to connect to any database and use it with Django's ORM.

##Custom Middleware:
[Middleware](https://docs.djangoproject.com/en/4.1/topics/http/middleware/) is a powerful feature that allows you to modify the request and response objects at various stages of the request/response cycle. Creating custom middleware allows you to add your own logic and functionality to the request/response cycle.

##Custom Form Fields and Widgets:
Django provides a lot of[ built-in form fields](https://docs.djangoproject.com/en/4.1/ref/forms/fields/) and widgets, but sometimes you need to create your own. Custom form fields and widgets allow you to create forms that are tailored to your specific needs.

##Custom Template Tags and Filters:
[Django's built-in template engine](https://docs.djangoproject.com/en/4.1/topics/templates/) is powerful, but sometimes you need to create your own template tags and filters to add custom functionality to your templates.

##Custom Management Commands:
[Django's management commands](https://theubuntulinux.com/faq/how-to-create-django-custom-management-commands-with-example/) are a powerful feature that allows you to perform tasks from the command line. Creating custom management commands allows you to automate tasks that are specific to your project.

## Conclusion
These are just a few examples of the many advanced customizations that you can make to your Django project. By taking advantage of these customizations, you can create a more powerful, flexible, and tailored application that meets your specific needs.
How to force reinstall packges in Ubuntu
Tags: ubuntu, linux, tutorial, programming
Published: 2023-01-16 10:36:28

Reinstalling packages in [Ubuntu](ubuntu.com) can be a useful troubleshooting step when dealing with software issues. Sometimes, a package may become corrupted or may not be functioning correctly, and reinstalling it can fix the problem. In this blog post, we will go over the steps to force reinstall packages in Ubuntu.

The first step is to update the package list on your system by running the following command:

sudo apt-get update

Next, we will use the apt-get command with the --reinstall option to force reinstall the package. The general syntax for this command is as follows:

sudo apt-get --reinstall install [package-name]

For example, if you want to force reinstall the package nano, you would run the following command:

sudo apt-get --reinstall install nano

It's worth noting that this command will also automatically reinstall any dependencies that the package may have.

Another way of reinstalling the package is by using dpkg command, by running the following command:

sudo dpkg -i --force-all /path/to/package.deb

It's important to note that the --force-all option is necessary to override any file conflicts that may arise during the reinstallation process.

In addition to reinstalling a single package, you can also force reinstall all the packages on your system by running the following command:

sudo apt-get --reinstall install $(dpkg --get-selections | awk '{print $1}')

This command will reinstall all of the packages that are currently installed on your system.

## Conclusion

In conclusion, [reinstalling packages in Ubuntu](https://theubuntulinux.com/faq/how-to-reinstall-a-package-using-apt-get-debian-ubuntu/) can be a [useful troubleshooting step](https://ubuntu.com/core/docs/reference/troubleshooting) when dealing with software issues. The apt-get command with the --reinstall option can be used to force reinstall a package, and the dpkg -i --force-all command can be used to force reinstall a package in the form of a [.deb file](https://manpages.ubuntu.com/manpages/trusty/man5/deb.5.html). Remember to use these commands with caution as they will override any changes made to the package.