teleren/devto huggingface dataset:
Early Return in Elixir
Tags: elixir
Published: 2021-10-20 12:29:51

The only thing I've missed while working in Elixir the last few years is an early return.

In Javascript, you can do this:

```javascript
let contrivedFunction = arg => {
  if(!arg) {
    return 'falsy';
  }

  if([] !== []) {
    return 'wtf';
  };

  // This will never be evaluated because JS is
  // a sad language where [] does not equal []
  return 'truthy';
};
```

At any point, you can stop the execution of the current function and return a value, and nothing after that point will run.

Usually, in Elixir, you can get by just fine without that ability. You can use the `with` statement, pattern matching, or control flow like `case` and `cond`.

But sometimes, I really miss having an early return. Usually when I'm working in a really messy domain with a lethal combo of tech debt, third-party APIs, and a long chain of processing where things can go wrong in a lot of places.

I recently ran into a situation like that, and decided to do some digging. I knew that a function stopped execution as soon as an error was `raise`d, so I thought I could maybe write a macro for that functionality. But then in the [Elixir guides](https://elixir-lang.org/getting-started/try-catch-and-rescue.html) for `try`, `catch`, and `rescue`, I realized that the solution was hiding in plain sight:

```elixir
def contrived_function(arg) do
  if !arg do
    throw("falsy")
  end

  if [] != [] do
    throw("wtf")
  end

  # Elixir is sane and [] does equal [], so this is possible
  "truthy"
catch
  value -> value
end
```

It turns out, when you `throw` within a function, execution stops and you can `catch` (and return) the value! No macros or extra abstractions needed.

I don't anticipate that I'll use this pattern very much - in most cases the standard methods of control flow are easier to reason about and follow.

But, I hope that like me you appreciate having an extra tool in hand for those situations when it feels like the best way to express a bit of logic.
Emmet not working in VS Code ?— Here’s how you can fix this problem!!
Tags: vscode, emmet, json, howtofix
Published: 2021-10-20 12:21:43

Emmet is a powerful extension in Visual Studio Code. If you are developing a website or working with any language such as HTML, Emmet helps you to write your code fast and efficiently without making silly mistakes.

But sometimes, while updating VS Code, the VS Code loses the file associations or Emmet stops working for some reason. I encountered the similar problem after I updated my VS Code. I was not able to use Emmet and it seemed annoying to me because I didn’t want to write whole html starter templates while working on website development. So I started finding out the solution and figured out how to fix that.

Step 1: Start your VS Code. Click on the Settings or press **Ctrl+,** to open the VS Code Settings.

Step 2: Click on the Extensions tab on the left side of the settings. Click on HTML.

Step 3: Click on the ***“Edit in settings:json”*** hyperlink to edit the settings in JSON format.

![vscode_emmet.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1634625044136/bpbXb8FjiZ.png)
 
Step 4: Inside the curly braces, enter the following code under the already written JSON code:

```
“emmet.triggerExpansionOnTab”: true,
“files.associations”: {“*html”: “html”},
"emmet.useInlineCompletions": true
``` 

Step 5: Save the file. Now if you try to apply Emmet in your code, it will work smoothly!!

That’s how I fixed this Emmet not working problem which I encountered when I updated VS Code. I hope this solution may be helpful for you as well and serves the purpose.
A Quick 10-Second Programming Joke For Today
Tags: jokes, dailydeveloperjokes
Published: 2021-10-20 12:00:19

---
title: "A Quick 10-Second Programming Joke For Today"
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/5e125997196ca.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:
___Q___: Why are keyboards always working so hard?

___A___: Cause they have two shifts!
 -->
What's the difference between computer science and software engineering?
Tags: discuss
Published: 2021-10-20 11:40:40

Last weekend I was reflecting on the difference between computer science and software engineering. 

I studied computer science at university and I now work as a full-time software engineer. However, I know of people that instead preferred to study software engineering instead of computer science.

I think that computer science is more about the communication between software and hardware, and there is a lot of emphasis on mathematics, algorithms, computational theory and in general the science behind computers. For example, one of the modules that I took during my first year was database systems. But it was explained using relational algebra. 

Software engineering revolves more around the software development lifecycle, and engineering principles.

Academic wise, the difference is subtle, both programs differ by a few modules. Probably software engineering students do more programming than computer scientist. Job-wise, I think they end up taking the same career paths.

What do you think?
Improved Error Tracking for Node.js in AppSignal
Tags: node
Published: 2021-10-20 11:31:45

Good news for Node.js developers using AppSignal: a new version of our Node.js library is available on npm with improved [error tracking](https://www.appsignal.com/tour/errors).

We've added two new helpers to make your life easier as a Node.js developer. One helper allows you to track errors whenever you need to, no matter how many nested spans you have in your current context. The other lets you send an isolated error with no spans or context involved (for more information about spans, check out [our docs](https://docs.appsignal.com/nodejs/tracing/span.html)). Please keep reading to see some usage examples!

## Using `tracer.setError(error)` to Set Errors on Traces in Node.js

If you are a user of AppSignal's Node.js library, you are probably familiar with the now deprecated helper `span.addError(error)`. This helper allowed you to link an error to any span object. The main issue with this was that if the span calling the function was not a `RootSpan`, it was ignored. This made error tracking in complex nested contexts a problematic task.

Using the new `tracer.setError(error)` function will make everything easier and safer. If you want to send an error related to the current trace, you don't have to search for the root span; the tracer object is always there to receive the error and set it on the current root span.

Example:

```js
const tracer = appsignal.tracer();

tracer.withSpan(tracer.currentSpan(),  (span) => {
  try {
    throw new Error("Oh no!");
  } catch (err) {
    tracer.setError(err);
  }
});
```

## Send Isolated Node.js Errors with `tracer.sendError(error, fn())`

This new helper is really useful for instrumentation that doesn't automatically create AppSignal traces to profile, which means anything outside of a web or database context.

The function receives an error object and an optional callback function to set custom metadata as arguments if needed.

Example with metadata:

```js
const tracer = appsignal.tracer();

try {
  throw new Error("Oh no!");
} catch (err) {
  tracer.sendError(err, span => {
    span.setName("daily.task"); // Set a recognizable action name
    span.set("user_id", user_id); // Set custom tags
  });
}
```

Example without metadata (note: this error is grouped in the same incident as errors of the same type without an action name):

```js
const tracer = appsignal.tracer();

try {
  throw new Error("Oh no!")
} catch (err) {
  tracer.sendError(err);
}
```

## Track Your Node.js Errors with a Stroopwaffle by Your Side 🍪

If you haven't yet tried AppSignal for monitoring your Node.js apps, [take five minutes and check it out (https://www.appsignal.com/nodejs).

Here's what you need to know:

- Error monitoring is included alongside all of our features.
- We have a free trial option that doesn’t require a credit card.
- AppSignal supports Node.js, Ruby, and Elixir projects.
- We’re free for open source & for good projects.
- We ship stroopwafels to our trial users on request.
SVG - Every Developer's best friend 🤗
Tags: webdev, beginners, frontend
Published: 2021-10-20 11:16:18

SVG stands for Scalable Vector Graphics. It is an Extensible Markup Language based image format for two-dimensional graphics with support for interactivity and animation.

There are two groups of image formats - bitmap and vector. Bitmap format defines what color each pixel of an image should be painted whereas in vector format it consists of shapes, curves, lines, and text which together make a graphic. In simpler words the vector format gives instructions on how the image should be rendered. JPEG, PNG file formats fall under bitmap category whereas the SVG file format falls under the vector category.

For images with high detailing such as photographs, bitmap formats are suitable whereas for images with high scalable requirements like icon, web graphics, SVG format is suitable.

In the web dev community, recent trends have shown that developers prefer vector format files, i.e. SVG over any other raster group files. Here are the reasons why :

</br>
**Scalability**

With users accessing web applications from a wide range of devices of different sizes, it is very important to make sure the graphic resolutions are intact. This is solved by utilizing SVG formats as they fit each and every resolution requirement without any trouble as they scale seamlessly.

</br>
**Smaller File Size**

Compared to other file formats, SVG's when properly optimized result in smaller file size which enables faster loading images resulting in better performance and improved user experience.

</br>
**Inline SVG's**

SVG's can also be embedded using the inline method. This eliminates the HTTP request that is needed to load in an image file. As there are no files that need to be downloaded, the loading time of the page goes down and makes the website to appear faster and thus in turn improving the user experience as well.

</br>
**Styling and Animating**

Since SVG's are XML format files, they can be styled and scripted just like HTML files. This is extremely beneficial when there is a requirement to customize icons or add character to it such as when active, not active, disabled etc and all this can be done with a single file.

</br>
Though SVG's are highly beneficial, creating complicated images is very challenging and involves a lot of mathematical computations to be done. However with the right use of illustration tools, the problem can be tackled. In conclusion, the advantages of using an SVG clearly gives it an upper hand compared to its counter file formats making every developer's life easier !

</br>
If you have made it till here, thank you for taking the time to read this and I hope you found it useful.

![bye bye birdy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sfjq5djio7bawj0qxdyz.gif)
 

Until next time 😄👋🏽
5 Best adblockers for download your computer
Published: 2021-10-20 08:47:50

#What are the Ad blockers?
>Ad blocking or ad filtering is a software capability for blocking or altering online advertising in a web browser, an application or a network. This may be done using browser extensions or other methods.


#1.Adlock
![Image description](https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTpoLWXe4vreLTQPp5x_uVvlHcWsaK6AiUBnA&usqp=CAU)

###What is adlock adblocker?
AdLock is a comprehensive ad blocking software that meets all of your expectations. It blocks pop-ups, flash banners, video ads, banners with malware code
www.adlock.com

#2.Trustnav Adblocker
![Image description](https://lh3.googleusercontent.com/1Hb2yEBXzKMqWKGGlsaPhlKHfyprb7NyzBgWWE7gROy3HQ9ucFzd8mQD_3V9_Z-eU8XJ_ykMSqixWYx6pFfUOqvc=w128-h128-e365-rj-sc0x00ffffff)

###What is Trustnav Adblocker?
Adblocker by Trustnav is the definitive adblock as it removes popups, annoying banners and video ads. AdBlocker is the fastest adblock extension available. Use AdBlocker to get rid of banner ads, popup windows, video ads and stop advertising companies from tracking your moves online
www.trustnav.com
#3.AdGuard
![Image description](https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQkfI3dp15WHkbn4PussSRXMq9Xo-LRNgg60CROdDaV7zqkZFDzSuDcJzgY2KJ8783piGo&usqp=CAU)

###what is AdGuard?
AdGuard Software Limited develops ad blocking and privacy protection software for blocking pop-ups, banners, and web tracking, obscene content, malware and phishing. Some of AdGuard products are open-source, some are free, and some are shareware. Some products support Microsoft Windows, Linux, macOS, Android and iOS
www.adguard.com
#4.Poper Blocker
![Image description](https://pbs.twimg.com/profile_images/846025411612041217/FN2ecxaG_400x400.jpg)

###What is Poper Blocker?
Poper Blocker intelligently blocks spam pop-ups on any site, including javascript popups and overlays. ... This gives us focus and puts us at an advantage both in terms of accuracy and lightness, beyond your standard popup and ad blocker for Firefox like Adblock Plus, AdGuard Adblocker, AdBlock for Firefox, etc
www.poperblocker.com
#5.Adblock Plus
![Image description](https://www.apkdownloadhunt.com/wp-content/uploads/2019/12/adblock-plus-1-1-1.png)

###What is Adblock Plus?
Adblock Plus is a free and open-source browser extension for content-filtering and ad blocking. It is developed by developer Wladimir Palant's Eyeo GmbH, a German software company

www.adblockplus.org

###Thanks for read this article. follow me for get more information's like this🙂😀😀😀
###please write a comment which adblocker you like 

Visit my other website:- https://golink.netlify.app/

Visit my game page:- https://nethgame.itch.io
How to setup golang backend and react frontend in a monorepo
Tags: go, react, typescript, monorepo
Published: 2021-10-20 10:23:49


[Previously](https://dev.to/ynwd/how-to-setup-react-tailwind-webpack-and-typescript-in-a-monorepo-3ogm), we have set up a frontend module using react and typescript in a monorepo.

Next, we will use the golang server to serve the built webapp.

```
.
├── go.mod
├── go.sum
├── main.go
├── package.json
└── web
    ├── components
    └── modules
        └── root
            ├── build
            │   ├── asset-manifest.json
            │   ├── favicon.ico
            │   ├── index.html
            │   ├── logo192.png
            │   ├── logo512.png
            │   ├── manifest.json
            │   ├── robots.txt
            │   └── static
            │       ├── css
            │       │   ├── main.33a5a96b.chunk.css
            │       │   └── main.33a5a96b.chunk.css.map
            │       └── js
            │           ├── 2.59f16c8b.chunk.js
            │           ├── 2.59f16c8b.chunk.js.LICENSE.txt
            │           ├── 2.59f16c8b.chunk.js.map
            │           ├── 3.93db3793.chunk.js
            │           ├── 3.93db3793.chunk.js.map
            │           ├── main.f7ff0158.chunk.js
            │           ├── main.f7ff0158.chunk.js.LICENSE.txt
            │           ├── main.f7ff0158.chunk.js.map
            │           ├── runtime-main.08d49f3a.js
            │           └── runtime-main.08d49f3a.js.map
            └── package.json


```

clone repo: https://github.com/ynwd/monorepo/tree/typescript

create services folder
```
mkdir -p internal/services
```

init golang app
```
go mod init github.com/ynwd/monorepo
```

downlod fastrex package
```
go get github.com/fastrodev/fastrex
```

this will generate go.mod file
```
module github.com/ynwd/monorepo

go 1.17

require github.com/fastrodev/fastrex v0.0.0-20211008073151-687f0b90ec18 // indirect

```

create golang app entry point
```go
/* main.go */
package main

import (
	"github.com/fastrodev/fastrex"
)

func main() {
	app := fastrex.New()
	app.Template("web/modules/root/build/index.html")
	app.Static("web/modules/root/build")
	app.Get("/", func(req fastrex.Request, res fastrex.Response) {
		err := res.Render()
		if err != nil {
			panic(err)
		}
	})
	err := app.Listen(8080)
	if err != nil {
		panic(err)
	}
}

```

build react root module
```
npm run build -w @fstr/root
```

run golang server
```
go run main.go
```

You can see the final source code here: https://github.com/ynwd/monorepo/tree/fastrex
Programmer les popups de Popup Builder
Tags: php, wordpress, wordpresspopupbuilder, french
Published: 2021-10-20 10:18:03


---
title: Programmer les popups de Popup Builder
published: true
description: La version gratuite du plugin WordPress Popup Builder ne permet pas programmer l&rsquo;affichage des popups. Cependant elle créé le filtre sgpbOtherConditions qui permet de les désactiver.
tags: php, wordpress, WordPressPopupBuilder, french
canonical_url: https://blog.samdha.net/2021/07/28/programmer-les-popups-de-popup-builder/
cover_image: 
---

La version gratuite du plugin [WordPress Popup Builder](https://wordpress.org/plugins/popup-builder/) ne permet pas programmer l’affichage des popups. Cependant elle créé le [filtre](https://developer.wordpress.org/plugins/hooks/filters/) sgpbOtherConditions qui permet de les désactiver.

Ce filtre est appelé pour chaque popup qui peut s’afficher sur la page et si l’argument ‘status’ à `false` est ajouté à ceux existants, la popup ne s’affiche pas.

```php
	/**
	 * Check Popup conditions
	 *
	 * @since 1.0.0
	 *
	 * @return array
	 *
	 */
	private function isSatisfyForOtherConditions()
	{
		$popup = $this->getPopup();
		$popupOptions = $popup->getOptions();
		$popupId = $popup->getId();

		$dontAlowOpenPopup = apply_filters('sgpbOtherConditions', array('id' => $popupId, 'popupOptions' => $popupOptions, 'popupObj' => $popup));

		return $dontAlowOpenPopup['status'];
	}
```
Pour désactiver automatiquement vos popups, vous pouvez ajouter ce code à [functions.php](https://developer.wordpress.org/themes/basics/theme-functions/)

```php
add_filter('sgpbOtherConditions', 'my_sgpbOtherConditions', 10, 1);

// update popin status
function my_sgpbOtherConditions($args = array()) {
    // if popup is already unactive, do nothing
    if (isset($args['status']) && $args['status'] === false) {
        return $args;
    }

    switch ($args['id']) {
        case 17938: // summer holiday active between 2021-07-30 and 2021-08-01
            $now = time() + 2 * 60 * 60; // for time zone, can be improved
            $from = strtotime('2021-07-30 00:00:00');
            $to = strtotime('2021-08-02 00:00:00');

            // if we are not between 2021-07-30 and 2021-08-01 desactivate the popup
            if (($now < $from) || ($now > $to)) {
                $args['status'] = false;
            }			
            break;
        case 16412:  // covid reassurance unactive between 2021-07-30 and 2021-08-01
            $now = time() + 2 * 60 * 60; // for time zone, can be improved
            $from = strtotime('2021-07-30 00:00:00');
            $to = strtotime('2021-08-02 00:00:00');

            // if we are between 2021-07-30 and 2021-08-01 desactivate the popup
            if (($now >= $from) && ($now <= $to)) {
                $args['status'] = false;
            }
            break;
    }
    return $args;	
}
```
Ainsi la popup 17938 ne sera active qu’entre le 30 juillet et le 1 août 2021 alors que la 16412 ne le sera que le reste du temps.
Sauvegarde automatique sur FTP
Tags: backup, bash, sysadmin, french
Published: 2021-10-20 09:31:49


---
title: Sauvegarde automatique sur FTP
published: true
description: A force je pense avoir un script de sauvegarde FTP efficace. Il sauvegarde les bases de données ainsi qu&rsquo;un dossier du serveur et les envoi sur un serveur FTP. Si le serveur FTP est plein, il supprime les sauvegardes les plus anciennes jusqu&rsquo;à avoir assez de place pour mettre la nouvelle.
tags: backup, bash, sysadmin, french
canonical_url: https://blog.samdha.net/2021/10/20/sauvegarde-automatique-sur-ftp/
cover_image: 
---

A force je pense avoir un script de sauvegarde FTP efficace.

Il sauvegarde les bases de données ainsi qu’un dossier du serveur et les envoi sur un serveur FTP. Si le serveur FTP est plein, il supprime les sauvegardes les plus anciennes jusqu’à avoir assez de place pour mettre la nouvelle.

Si une erreur arrive, il envoi un mail d’alerte.

Le script nécessite [curlftpfs](https://doc.ubuntu-fr.org/curlftpfs).

Utilisation :
-------------

- Modifiez le script dans la partie configuration
- Enregistrez le sur le serveur, par exemple dans /opt/scripts/backup.sh
- Donnez les droits d’execution au fichier : `chmod +x /opt/scripts/backup.sh`
- Ajoutez une tâche cron : `02 00 * * * /bin/bash /opt/scripts/backup.sh > /var/log/backup.log 2>&1`

{% gist https://gist.github.com/Shagshag/acd208c48253b3b43ca941ceb4f3ad9a %}

Also on: [GitHub](https://gist.github.com/Shagshag/acd208c48253b3b43ca941ceb4f3ad9a)
How and why to use infer in typescript
Tags: typescript, javascript, beginners, tutorial
Published: 2021-10-20 09:28:54

Hi everyone, how are you today? Hope you all are doing well!


Today I'm going to explain how hell works and why it's important in conditional structures in typescript. Initially the concept is relatively simple, but the implementation makes us question its real reason for use.

First, it is important to note that the use of hell is directly related to ternary conditions in the typescript. But why?

![Infer Theory](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ui20ndop35pztuakxg6i.png)

If we can infer T, G will be the result, if not, F will be the result
 
The purpose of inference is to test whether an inference is possible, see the example:

![Example 01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kjur5xfwzt3f50ugjm92.png)

It turns out that when we use our custom type we will have never as an answer when trying to infer an object with no return.

![Example 02](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g1qaestwqlurempbclyt.png)

Take one more example, if S cannot infer in the sentence pattern it will return never.

There is great power when using inference in conjunction with generics and conditional structures in typescript. They are very useful when in recursive conditional structures in typescript.

I tried to show you real use cases from hell and maybe you don't get the theory at first, but if you have any questions just send me a message and I'll be happy to answer.

![Naruto](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/068j7du3ioxra0e5os4v.gif)

<center>Time is very important, thanks for sharing a little bit of yours with me 😊.</center>

<a style="float: left;" href="https://github.com/devneto">![image](https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white)</a>

<a style="float: left;" href="https://twitter.com/_devneto">![image](https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white)</a>