teleren/devto huggingface dataset:
Run a Bash command after file changes [Linux/macOS]
Tags: bash
Published: 2022-02-12 09:43:38

---
title: Run a Bash command after file changes [Linux/macOS]
published: true
description: Execute a Bash command every time a file changes on a UNIX sytem
tags: bash
---

This blog post shows how to run a [Bash](https://www.gnu.org/software/bash/) command every time a file changes on a UNIX system. To achieve this goal, we can use the [entr project](https://eradman.com/entrproject). The snippets in this post have been tested on Ubuntu and macOS.


## Setup

### Ubuntu

On Ubuntu, `entr` can be installed with [APT](https://wiki.debian.org/Apt):

```bash
sudo apt-get update
sudo apt-get install entr
```

See https://howtoinstall.co/en/entr for further details.

### macOS

On macOS, `entr` can be installed with [Homebrew](https://brew.sh):

```bash
brew install entr
```

See https://formulae.brew.sh/formula/entr for further details.

## Usage

To execute a Bash command every time a file changes, we first need to create a file, e.g. with the help of the [`touch`](https://tldr.ostera.io/touch) program:

```bash
touch /tmp/example.txt
```

Now we can [pipe](https://www.geeksforgeeks.org/piping-in-unix-or-linux/) the name of the file into the `entr` program and declare a Bash command which should be executed every time the file changes:

```bash
echo "/tmp/example.txt" | entr bash -c "echo 'File changed.'"
```

If you now open the file `/tmp/example.txt` in a text editor, you will see "File changed." printed to the terminal, every time you save the file.

For further information, refer to the homepage or the source code of the `entr` project:

- https://eradman.com/entrproject
- https://github.com/eradman/entr
Data-Toggle Doesn't work! Help please.
Published: 2022-02-12 09:34:39

Hey guys, i just make a button with my udemy teacher. I did the same think as he did. But in my page it doesn't work. What am i missing?
I just created a button but when i click on it the text doesn't opening.

Thank you so much for your reply !


```
**<body class="w-75 mx-auto my-4">

    <p>
        <a href="#content" class="btn btn-dark bg-warning" data-toggle="collapse">Read More</a>
    </p>

    <div id="content" class="collapse">
        <h2>Lorem ipsum dolor sit.</h2>
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Deleniti sint nobis vero quaerat ad ex. Et,
            pariatur. Nemo, impedit. Eligendi exercitationem ea provident eos eum nesciunt deleniti quos debitis
            numquam?</p>
    </div>
**



    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
        integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
        crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.10.2/dist/umd/popper.min.js"
        integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB"
        crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.min.js"
        integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13"
        crossorigin="anonymous"></script>
</body>

</html>

```
I just started.
Published: 2022-02-12 09:17:16

This is my 1st post on Dev.to. I recently started learning Web development and found out this platform is good for developers to become a better developer so I have to be here so here I am.

Please Note: if you are reading this, you won't get any benefit reading this I am writing this because while going through the settings this window pop up and says your title here and text here so I am writing this.

if you read it through..
thank you..
Happy coding...
Valid Parenthesis
Tags: interview, python, dsa
Published: 2022-02-12 08:53:51

##Instructions
Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

An input string is valid if:

Open brackets must be closed by the same type of brackets.
Open brackets must be closed in the correct order.

### examples

```python
Input: s = "()[]{}"
Output: true

Input: s = "(]"
Output: false
```


## Approach

In this problem, we are mainly concerned about the most recent parenthesis we encounter such that if it is a closing parenthesis, we match it to an open parenthesis previously encountered. If there is no open parenthesis occurring before the closing, then the string is not a valid parenthesis.

Since we are interested in the most recent character, we can use the **stack** data structure, which implements _**Last In First Out (LIFO)**_ behavior. 
Therefore, the last item to go into the stack is the first to be removed. 

So we push the open parenthesis, and when we encounter its matching closing parenthesis, we pop it (the opening parenthesis) from the stack.

For a valid parenthesis string s, the end result will be an empty stack; if the stack is not empty, then s is not a valid parenthesis.


##Python Implementation

- ####Breakdown 

- Initialize stack to add and pop from
- Initialize a dictionary of the brackets where closing is the key and opening is the value.

- Loop through given string; if element in string is in the dictionary keys, check if the stack is empty 
and if element at stack[-1] ie most recent element is equal to element at dict[i] and remove this bracket from the stack.
Note: if the stack is empty we return False because a valid string cannot begin with a closing parenthesis.

- if the above conditions are not met we immediately return false 
else we append to the stack because that means the element in the string is an opening parenthesis.

###Code

```python
def isValid(self, s):        
    parentheses = {'}': '{', ']': '[', ')': '('}
    stack = []
     for i in s:
         if i in parentheses:
            if stack and stack[-1] == parentheses[i]:
               stack.pop()
             else:
                 return False
         else:
             stack.append(i)
     return not stack
```


##Time Complexity
O(n)
The algorithm scales linearly as the input increases.

##Space Complexity

The space complexity is O(n) because, in the worst-case scenario where all elements are opening brackets, we will have to store n elements in the stack.
O porquê você deve fazer Live Coding
Tags: coding, programming, live, productivity
Published: 2022-02-12 08:51:57

## O que é o Live Coding
Como primeiro post no dev.to, nada mais justo de falar sobre uma das ações que podem ter colaborado muito na minha carreira como desenvolvedor, o Live Coding. Como o nome já diz, o Live Coding consiste em simplesmente você codar, seja qualquer projeto, e fazer live ao mesmo tempo ~~pareceu muito óbvio escrevendo mas pra quem não entendeu, tá aí!~~.


Hoje a prática de Live Coding é uma categoria que está crescendo bastante na Twitch, segue abaixo o quão a categoria Science & Technology cresceu nos últimos anos:

![Dados do [SullyGnome](https://sullygnome.com/game/Science_and_Technology)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1j41mv3wyt5nns9chm7e.png)

A partir disso, separei alguns tópicos para te dar os motivos do **porquê você deve fazer Live Coding**.

---

## Foco
Esse foi um dos motivos de eu começar a fazer lives, e ainda é. A procrastinação está muito presente, e o fato de abrir live, te passa um sentimento de obrigação de programar.

E a parte do foco pode-se aplicar não só para a parte de Coding, mas também para muitas outras áreas, faculdade, matérias de escola, tudo! O que você tem que fazer é somente abrir a live e estudar, ou melhor, explicar o que você está fazendo como estivesse alguém te assistindo, e pode ter até alguém te assistindo mesmo interessado no mesmo tópico, e a consequência disso leva pra outro tópico…

## Networking
Imagina só, você está lá fazendo live estudando HTML e CSS e chega uma pessoa no seu chat explicando o porquê de uma div não está sendo posicionada no meio, e a partir daí você consegue suprir um conhecimento a partir do ensinamento do viewer da sua live, OLHA QUE COISA FANTÁSTICA. 

E além disso, fazer live permite você conhecer pessoas fantásticas com uma bagagem enorme que podem te ensinar várias coisas e até mesmo aprender com o que você está estudando, eu mesmo consegui meu primeiro emprego a partir de uma pessoa que eu conheci pelas lives. 

## Coworking
Uma das coisas curiosas que acontecem quando alguém está codando ou outra coisa do tipo, é que você consegue motivar as pessoas que estão te assistindo a estudar, ou até mesmo encontrar uma solução pra um bug que você está preso há horas, eu não sei muito bem como explicar isso, mas acontece bastante.

---


Espero que a partir desses pontos que citei aqui, você possa se sentir motivado a fazer live coding, ou até assistir alguma. Você pode clicar [aqui ](https://www.twitch.tv/moovhe4rt/)e visitar minha live, se eu estiver offline, sempre avisarei no meu [twitter ](https://twitter.com/moovhe4rt)quando estiver online!
Até a próxima! ;)
How To return CREATED HTTP Status Code in Jax-Rs
Tags: java, jaxrs, rest, codever
Published: 2022-02-12 08:51:25

Use `created(URI location)`  of the `javax.ws.rs.core.Response` class. Usually when you return the 201 HTTP Status Code, you should return a `location` header with the location where the new REST resource is available.

```java
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.ws.rs.*;
import javax.ws.rs.core.*;

@Path("messages")
@Stateless
@Tag(name = "Message")
public class MessageRestResource {

  @Inject private MessageService messageService;

  @POST
  @Consumes(MediaType.TEXT_PLAIN)
  @Operation(summary = "Create message")
  @ApiResponses({
    @ApiResponse(
        responseCode = "201",
        description = "Message successfully created."),
    @ApiResponse(responseCode = "403", description = "Forbidden")
  })
  public Response createMessage(
      @Parameter(description = "Message") String message, @Context UriInfo uriInfo)
      throws JAXBException {
    Message created = messageService.createMessage(message);
    UriBuilder builder = uriInfo.getAbsolutePathBuilder();
    builder.path(created.getUuid().toString());
    return Response.created(builder.build()).build();
  }
```

In the snippet the `UriBuilder` method  `builder.path(created.getUuid().toString())` appends the identifier of the newly created message (`uuid`) to the absolute path of the request, which was obtained from the `uriInfo`

<hr/>

> Shared with :heart: from [Codever](https://www.codever.dev/snippets/62069c03e102f148ceb9f5c3/details). Use :point_right: [**copy to mine**](https://www.codever.dev/snippets/62069c03e102f148ceb9f5c3/details) functionality to add it to your personal snippets collection.
Make your own Custom Hooks in React!
Tags: react, webdev, javascript, beginners
Published: 2022-02-12 08:27:03

**React** provides many in-built hooks that you can use in your app

But you can also create **custom** hooks, which helps reduce the amount of code

Custom hooks are similar to functions but usually start with *use* and may call other in-build hooks as well


##Need for Custom Hooks

The main reason why you should be using Custom hooks is to maintain the concept of **DRY**(Don't Repeat Yourself)

To understand more about **DRY** and **WET** refer to the tweet below.

[Dry or Wet Code](https://twitter.com/grover_sumrit/status/1486712333711724547)


## When and How to use it

If you want to share the logic between different components, we can extract that to a **separate function**. 

Because custom hooks are JS functions the rules of hooks apply to it as well.



## Rules of Hooks are-

1. Never call Hooks from inside a **loop or condition** 

2. Hooks should sit at the **top-level** of your component

3. Only call Hooks from React functional components

4. Never call a Hook from a regular function

5. Hooks can call other Hooks



## Building your Custom Hook

Making your own hook is similar to making a JavaScript function, but its name starts with *use*.

Inside them, you can use any other hook, take anything as parameters, return anything you want it to return.




## Put it to the test

Let us create a custom hook that uses *useEffect* hook that updates the title of the document 

This is how you traditionally write the code

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

 



## Creating the custom hook

What we would do is take out the *incrementCount* function and put it in a separate file and pass the count state in it.

Like this

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


## Call the Custom hook 

Call the hook in your file as you would normally call a JS function

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

## Conclusion

This is how easy it is to make your own custom hooks and integrate them into your application

If you want to try and experiment with this code, here is the link to the same 

[Code Base](https://gist.github.com/smgrv123/ca8ac47c8cefed07239d772082852464)
Calling All Africa Flutter Developers & Figma Designers!
Tags: flutter, africa, design, figma
Published: 2022-02-12 08:06:57

In partnership with our Parabeac Africa Chapter led by Will Odia, we are throwing our first challenge where you can win up to $300 USD by building an app prototype or component package using Figma, Flutter & Parabeac! You can use [parabeac_core](https://github.com/Parabeac/parabeac_core) which is our open-source tool that converts Figma files into Flutter code or Parabeac Nest which is a web app that enables you to take the design file, generate code, and merge it into a Github repo.

To participate in the challenge, create an app prototype or a component package using Parabeac and submit your video(s) here: [https://airtable.com/shrq1fHwJtTs1mu9v](https://airtable.com/shrq1fHwJtTs1mu9v)
There are two challenges available:

Video Submission: Judged by Parabeac team members; We will select 1st ($300), 2nd, ($200) & 3rd ($100) place winners based on the video submitted and a review of the codebase. (3 min max)

TikTok Submission ($100): The video with the most views highlighting the prototype/package built with Parabeac will be the winner. (Be sure to use the #parabeac hashtag)

Be sure to watch this video to help give you ideas on submissions!
[https://www.youtube.com/watch?v=FmopfwIzVIU&t=2](https://www.youtube.com/watch?v=FmopfwIzVIU&t=2
)

Good luck!
Today's Daily Dose of Programming Humor
Tags: jokes, dailydeveloperjokes
Published: 2022-02-12 08:00:19

---
title: "Today's Daily Dose of Programming Humor"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e12588c48015.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit._

<!--
Joke text:
```
[Please Enter New Password]

fortnight

[Error: Password is Two Week]
```
 -->
Modify RDS Instance Type using Lambda during peak hours with Cloudwatch Events
Tags: aws, serverless, rds
Published: 2022-02-12 07:58:58

Hi Folks, hope you are doing good.
Use-case: To modify RDS Instance Type to facilitate load during peak hours using Lambda and Cloudwatch Events

Create a Lambda Function:
- Author from scratch
- Function Name - your desired name
- Runtime - Python 3.9
- Architecture - x86_64
- Permissions - Create a new role with basic Lambda Function

Code - (https://raw.githubusercontent.com/RajitPaul11/AWS-Lambda/main/RDS-DB-Modify/lambda_function.py)

Additional IAM Policy for RDS Modify Access:
Policy Json - (https://raw.githubusercontent.com/RajitPaul11/AWS-Lambda/main/RDS-DB-Modify/rds-modifyaccess-iam.json)
- Add this as an inline policy to the Lambda Default Role

Amazon EventBridge (Cloudwatch Events):
Create a new rule
Rule Name - Desired Rule Name
Pattern - Schedule - Cron Expression (Cronex - 55 7 ? 2 7 * (Every Saturday at 7:55 GMT) - Choose your cron expression according to your requirement
Cron Expression Help - (https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html#CronExpressions)
Select Targets - Target - Lambda Function - Select your function.
Create Cloudwatch Event

We have automated the RDS Instance Type modification, the Cloudwatch Event shall trigger the Lambda Function at the desired time and modify the RDS Instance to an upgraded Instance type, you can also use this for downgrade db instance.
New Release: Notion RSS Reader🎁
Tags: opensource, typescript, node, notion
Published: 2022-02-12 07:45:06

## TL;DR;
You can save articles from your favorite sites in the Notion Database.

## How to use

👇 Please access & fork this repository! 
[https://github.com/watsuyo/notion-rss-reader/](https://bit.ly/3GFCIYq)

The Setting method is described in the [README](https://bit.ly/3LFHDwz) in GitHub. 

## Why I made "Notion RSS Reader"
The reason is that I wanted to consolidate information in Notion, which I use on a daily basis.

Ideally, I'd like to consolidate the information scattered in blogs, YouTube, Twitter, Feedly, Pocket, etc. into the Notion Database.

Also, even if you're not an engineer, you should be able to view and operate it using the user interface of a browser or an application.

## Features
- At each interval you set, it will get articles from your favorite sites and save them to Notion.

This tool is a minimum valuable product for an early adapter.
Other features will be added in the near future.

You can subscribe to updates by starring the repository⭐️
[https://github.com/watsuyo/notion-rss-reader/](https://bit.ly/361C6zX)

### Roadmap
- [Feedly integration](https://github.com/watsuyo/notion-rss-reader/issues/5)
- [Awesome Browser UI](https://github.com/watsuyo/notion-rss-reader/issues/4)

Please create some [issues](https://bit.ly/361C6zX) or submit Pull Requests on GitHub👍

## Contacts
watsuyo - [@watsuyo_2](https://twitter.com/watsuyo_2)
Project Link: [https://github.com/watsuyo/notion-rss-reader/](https://bit.ly/3GFCIYq)
En guide för att snabba upp en Wordpress hemsida (2022)
Tags: wordpress, performance
Published: 2022-02-12 07:11:35

Att ha höga poäng i Google Page Speed insights är ett gott tecken på att du har en webbplats som är lämplig för dess ändamål. Ett av våra favoritverktyg som vi använder för att testa webbplatsers prestanda är GTMetrix.

Du hittar all information [här](https://www.webbofsweden.se/snabba-upp-wordpress-hemsida-2022/)
Hello World
Tags: beginners, web3, metaverse, hacker
Published: 2022-02-12 07:11:25

I am here to participate in the decentralised, co-creation of the Metaverse. A world that is modular and composable. Interoperable and integrated.

I believe in designing systems inspired by biomimicry. Symbiotic solutions are sustainable. SolarPunk is sexy.

Am here to both inspire and be inspired. 

My background is as a Creative Director, working in both tech and community building. My chosen life path is as a game designer. I see it as being an architect of reality.

I am an apprentice, but am willing to walk a thousand miles and ten thousand hours to bring something of worth to humanity.

Sharing the learnings on the journey through the 'Games Without Borders' podcast.

I'm the director of Open World Theatre, I agree with Shakespeare - that all the world's a stage.

I design systems of play and tools to explore the chaos of the unknown.
Webb 3.0 vad kan vi förvänta oss?
Published: 2022-02-12 07:10:42

Web 3.0 är spännande teknik som kommer ta mer och mer plats i vårt internet. 
Det handlar om tid innan det helt skiftar om till 3.0. 

Du hittar såklart vidare information om hur du snabbar upp din hemsida [här] (https://www.webbofsweden.se/snabba-upp-wordpress-hemsida-2022/)
Desplegar Nextcloud en Docker usando Ansible
Tags: docker, ansible, nextcloud
Published: 2022-02-11 08:46:05

Nextcloud nos permite tener nuestro propio [servidor de archivos](https://nextcloud.com/files/) a lo Dropbox. Pero a mí lo que más me gusta es poder tener [mi calendario y mis contactos](https://nextcloud.com/groupware/) independiente del todopoderoso Google.

Vamos a ver como podemos desplegar Nextcloud en una Debian usando Docker y todo ello automatizado con Ansible.

El esquema que vamos a tener es una máquina Debian con tres contenedores dentro:

- haproxy
- nextcloud
- mariadb

![Nextcloud containerized](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ra2nzpd55nde9ixykdul.png)
 
## Requisitos

* Tener acceso root a la máquina Debian.
* Tener instalado Ansible.

A mí personalmente me gusta instalar Ansible en un virtualenv de python:

```bash
$ virtualenv3 venv/py3
$ source venv/py3/bin/activate
(py3)$ pip install ansible
```

Instalamos los roles necesarios:

```bash
(py3)$ ansible-galaxy install jilgue.ansible_role_docker_nextcloud
(py3)$ ansible-galaxy install jilgue.ansible_role_docker_haproxy
```

## Playbook

A continuación vamos a generar la configuración de Ansible.

Necesitamos generar el inventario:

```ini
nextcloud ansible_ssh_host=192.168.56.20
```

También la configuracion del haproxy:

```
global
    daemon
    maxconn 256

defaults
    mode http
    timeout connect 5000ms
    timeout client 50000ms
    timeout server 50000ms

frontend http-in
    bind *:80
    mode http
    default_backend servers

backend servers
    server server1 nextcloud:80 maxconn 32
```

Y por último el playbook:

```yaml
---
- hosts: all
  become: true
  become_method: sudo

  vars:
    nextcloud_trusted_domains: 192.168.56.20
    nextcloud_ports: []
    haproxy_cfg_template_path: "{{ playbook_dir }}/"
    haproxy_links:
      - nextcloud
    haproxy_ports:
      - 80:80

  roles:
    - { role: nextcloud, tags: [ 'nextcloud' ] }
    - { role: haproxy, tags: [ 'haproxy' ] }
```

Y con esto tendríamos todo, al aplicar el playbook y entrar en la url [http://192.168.56.20/](http://192.168.56.20) podremos ver nuestro nextcloud instalado.

El usuario y contraseña por defecto son [admin / admin](https://github.com/CallePuzzle/ansible-role-docker-nextcloud/blob/master/defaults/main.yml).

![Nextcloud welcome](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ig698ei6i7c833bsuvc1.png)

Podéis ver la configuración de mi propio servidor en [github](https://github.com/CallePuzzle/ansible-playbook-hetzner-cloud).