teleren/devto huggingface dataset:
Compile-time exhaustiveness checking in Common Lisp with Serapeum
Tags: lisp
Published: 2023-03-19 13:03:14

[Serapeum](https://github.com/ruricolist/serapeum/blob/master/REFERENCE.md) is an excellent CL library, with lots of utilities. You should check it out. It provides a `case`-like macro, to use on enums, that warns you at compile-time if you handle all the states of that enum.

Example with `ecase-of` from its README. First we define the enum:

```lisp
(deftype switch-state ()
  '(member :on :off :stuck :broken))
```

We write a function that does something depending on the state of a switch object. We use `ecase-of` against this enum type to not miss any state.

Below we only check two states, so we'll get a warning (at compile-time, with a `C-c C-c` on Slime: the feedback is… instantaneous). Imagine that `(state switch)` is a function call that gets the current state of the "switch" variable passed to the function:

```lisp
(defun flick (switch)
  (ecase-of switch-state (state switch)
    (:on (switch-off switch))
    (:off (switch-on switch))))
```
=> the warning:

```
; caught WARNING:
;   Non-exhaustive match: (MEMBER :ON :OFF) is a proper subtype of SWITCH-STATE.
;   There are missing types: ((EQL :STUCK) (EQL :BROKEN))
; in: DEFUN FLICK
;     (CL-USER::STATE CL-USER::SWITCH)
```
And a nice message too.

The syntax is the following: 

```lisp
(ecase-of switch-state state 
  (:state (do-something))
  (:state (do-something)))
```
where `switch-state` is the enum-type defined above, `state` is the current value we are testing. 

Another example: you think you fixed the previous example with the following version, but it has a bug. Serapeum catches it:

```lisp
(defun flick (switch)
  (ecase-of switch-state (state switch)
    (:no (switch-off switch)) ;; <---- typo!
    (:off (switch-on switch))
    ((:stuck :broken) (error "Sorry, can't flick ~a" switch))))
```
=>
```
; caught WARNING:
;   (MEMBER :NO) is not a subtype of SWITCH-STATE
```
We see another possible syntax:

```lisp
(ecase-of … …
  ((:stuck :broken) (do-something)))
```
we can group and handle states together.

### Union-types

And we can do the same with union-types, using `etypecase-of`:

```lisp
(defun negative-integer? (n)
  (etypecase-of t n
    ((not integer) nil)
    ((integer * -1) t)
    ((integer 1 *) nil)))
```
=> Warning

```
; caught WARNING:
;   Can't check exhaustiveness: cannot determine if (OR (NOT INTEGER)
;                                                       (INTEGER * -1)
;                                                       (INTEGER 1 *)) is the same as T
```

and indeed, we are handling ]∞, -1] U [1, ∞[

```lisp
(defun negative-integer? (n)
  (etypecase-of t n
    ((not integer) nil)
    ((integer * -1) t)
    ((integer 1 *) nil)
    ((integer 0) nil)))
=> No warning: handle 0.
```

This all happens at compile time, when we define functions, and the feedback is immediate, thanks to the live Lisp image.

Go play with it!

    (ql:quickload "serapeum")
Quasar Minimalist Design
Tags: webdev, vue, quasarframework, quasar
Published: 2023-03-19 13:02:29

In the world of web design and development, a minimalist approach has gained a lot of popularity in recent years. Minimalist design focuses on creating an aesthetic that is clean, uncluttered, and simple. This design philosophy is all about making the most of the essentials and doing away with the superfluous. Quasar Minimalist Design, an admin template, is a perfect example of this philosophy.

Quasar Minimalist Design is a premium admin template that offers a range of features and functionalities. It is designed to cater to the needs of businesses and organisations that require a user-friendly and efficient dashboard. The template includes a range of components, including a dashboard, customers, library, settings, calendar, and login page.

Check out the website at https://quasar-minimalist-design.netlify.app


If you're interested in purchasing this template, please visit my sponsorship page([Sponsor Me](https://github.com/sponsors/pratik227)). To gain access to the code, you'll need to sponsor me for $49 per month (one-time payment).


## Dashboard

![Dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/28st5det6xjbb9dy5bag.png)

## Customers

![Customers](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zvwqfntsk8532i0f00xe.png)


![Customers Add](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h3ib5yc9k1bvz7xnpy5p.png)


## Library


![Library](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/55doyb6497dvm3f19p4t.png)

## Settings


![Settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8jj2lir9skbz7fww2kg2.png)

## Calendar


![Calendar](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s2shjhdccpy3gknxrpty.png)

## Login


![Login](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/npiasn2aq77mdh56acfp.png)

In conclusion, Quasar Minimalist Design is a premium admin template that is designed to cater to the needs of businesses and organisation's. It includes a range of components, including a dashboard, customers, library, settings, calendar, and login page. The template is designed with a minimalist philosophy in mind, which means that it is clean, uncluttered, and simple.

If you are looking for an admin template that is both user-friendly and efficient, Quasar Minimalist Design is definitely worth considering.

Thanks,
Pratik Patel
How to comment in Javascript?
Tags: javascript, react, beginners, programming
Published: 2023-03-19 12:54:01

Comments are lines of code that JavaScript will intentionally ignore. Comments are a great way to leave notes to yourself and to other people who will later need to figure out what that code does.
There are two ways to write comments in javascript:

Using `//` will tell JavaScript to ignore the remainder of the text on the current line. This is an in-line comment:

`// This is an inline comment in javascript`

You can make a multi-line comment beginning with /* and ending with */. This is a multi-line comment:

`/* This is an multi-line comment */`

**NOTE:**As you write code, you should regularly add comments to clarify the function of parts of your code. Good commenting can help communicate the intent of your code—both for others and for your future self.

__Tip:try commenting by writing each one of them today.__

By **Dennis Mbugua** Programmer and writer
Perl Weekly Challenge #208
Tags: perl, perlweeklychallenge, challenge
Published: 2023-03-19 12:28:59

I've been doing the Perl Weekly Challenge, so here are my solutions to the [PWC #208](https://theweeklychallenge.org/blog/perl-weekly-challenge-208). All solutions are about to be posted, but this could be a spoiler if you're trying to solve it too. I was very pleased this week that I got it down to about 15-25 minutes for each task, so I'm definitely getting more comfortable in Perl again.

First, task 1:

    use strict;
    use v5.10;
    
    my @list1 = ("Perl", "Raku", "Love");
    my @list2 = ("Raku", "Perl", "Hate");
    
    # my @list1 = ("A", "B", "C");
    # my @list2 = ("D", "E", "F");
    
    # my @list1 = ("A", "B", "C");
    # my @list2 = ("C", "A", "B");
    
    my $minindex;
    my @results;
    for (my $index1 = 0; $index1 < scalar @list1; $index1++) {
        for (my $index2 = 0; $index2 < scalar @list2; $index2++) {
            if ($list1[$index1] eq $list2[$index2] && defined($minindex)) {
                if ($index1 + $index2 < $minindex) {
                    @results = ($list1[$index1]);
                    $minindex = $index1 + $index2;
                } elsif ($index1 + $index2 == $minindex) {
                    push (@results, $list1[$index1]);
                }
            } elsif ($list1[$index1] eq $list2[$index2] && !defined($minindex)) {
                @results = ($list1[$index1]);
                $minindex = $index1 + $index2;
            }
        }
    }
    if (scalar @results == 0) {exit}
    foreach (@results) {
        say $_;
    }

Pretty simple. For every item in list 1, I iterate through list 2 and look for a match with a lower sum than the previous lowest sum. If I find one it replaces the previous results, if it's equal I add it to the results. Then I say the results.

Now task 2:

    use strict;
    use v5.10;
    
    my $index;
    my ($duplicate, $missing);
    foreach (@ARGV) {
        if (!defined($index)) {$index = 1 and next}
        if ($_ == $ARGV[$index - 1]) {$duplicate = $_}
        if ($_ != $ARGV[$index - 1] + 1) {$missing = $ARGV[$index - 1] + 1}
        $index++;
    }
    defined($duplicate) && defined($missing) ? say ("Duplicate is $duplicate", "\n", "Missing is $missing") : say -1;


For this one, I iterate through them and if it's the same thing as the previous one it's my duplicate and if it's not the previous item plus 1 then it's your missing number.

Anyways, hope you liked them this week. I always look at the other solutions blogged about and get ideas for use in my code. If you have any better ideas comment below.
How to create local wildcard domains in MacOS using dnsmasq?
Tags: dns, macos
Published: 2023-03-19 12:25:45

## Introduction
Recently I was looking around for tutorials to setup local wildcard domains in MacOS for development purpose. Most tutorials were similar and I just could not resolve the local domains. If you are having the same issue, your should take a look of your DNS server settings.

## Preparation

### Install dnsmasq
Dnsmasq is a DNS server which allows you to create DNS records locally. Besides, it also forwards domain queries to upstream servers, such that we can resolve public domains as well.

By default, dnsmasq looks for upstream servers in `/etc/resolv.conf`.

```
brew install dnsmasq
```

### Verify your homebrew prefix

Dnsmasq service is installed in a different location based on your Mac's chip (Intel / Apple Silicon). You can check it by running command `brew --prefix`. 

Since I am using M1 Macbook, the installation path is `/opt/homebrew`. If you are using intel Macbook, be careful of the path settings and make changes accordingly.

### Modify the dnsmasq.conf file
```
vi $(brew --prefix)/etc/dnsmasq.conf
```

Go to the end of the file, uncomment the line `conf-dir=/opt/homebrew/etc/dnsmasq.d/,*.conf`. 

Now dnsmasq will look for local DNS records in `/opt/homebrew/etc/dnsmasq.d/`.

### Create a DNS record
I will use **test** as my local domain name. And I want dnsmasq to resolve any `test` domain queries to IP `127.0.0.1`. Dnsmasq will also try to resolve subdomain records as well, such as `a.test`, `b.c.test`, which is very convenient.

```
bash -c "echo 'address=/test/127.0.0.1' > $(brew --prefix)/etc/dnsmasq.d/test.conf"
```

The name of the conf file does not matter, it is just good for management, having one file for each domain.

### Setup DNS servers
To let your Macbook knows sending query to dnsmasq. Left click your wifi icon in the menu bar -> "Wi-Fi settings" -> "Details" -> go to "DNS" section. 

Take a record of your existing DNS servers and remove all of them. Then add "127.0.0.1" as your topmost entry such that DNS query will be sent to dnsmasq first. 

It is very important because if your query is send to other DNS servers first, it may respond with record is not found which explains why you are unable to query local domains.

Lastly you can add back all your existing DNS servers.

![The "DNS Servers" setting](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/skkiaetgcxiwk2u768za.png)

Now if you take a look of the `/etc/resolv.conf` file, you can see that it is actually generated from the settings of the "DNS" section.

### (Re)start dnsmasq
To reflect your dnsmasq changes, you need to restart it.

```
# brew services start dnsmasq
brew services restart dnsmasq
```

## Conclusion

It is a short article. Thanks for reading!

![Dig result](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g5svc4x5o41w8zys6bz8.png)
useEffect()
Tags: react, beginners
Published: 2023-03-19 12:08:01

useEffect is a hook that manages side-effects in functional components.


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

****

A function will always produce the same output when given the same input; these functions are known as **Pure functions**. This function produces a predictable output.


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




**Side-effects** are the actions performed to communicate with the outside world. These actions are unpredictable.

**Example of Side-effects**

- Making an API request.

- interacting with DOM.

- using localStorage or setTimeout or setInterval functions.

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

****

**useEffect** hook will take two arguments a callback function which will be called after a component render and a dependency array.this array tells react when to call this function.



If no array is passed, useEffect will run at every render.

```
function MyComponent(){
 useEffect(()=>{
  console.log("Hello World");
 });
}

```

If an Empty array is passed, useEffect will run only at initial render.

```
function MyComponent(){
 useEffect(()=>{
  console.log("Hello World");
 },[]);
}
```

If array with a value inside is passed, useEffect will run whenever that value is changed between renders.

```
function MyComponent(){
 const [value,setValue]=useState(0);
 useEffect(()=>{
  console.log("Hello World");
 },[value]);
}
```

****

**Comparing Class-based components with Functional-based components.**

{% codepen https://codepen.io/tyeb_11/pen/poOZBXJ %}

we should avoid code duplication in componentDidMount and componentDidUpdate. So here we introduce useEffect hook in functional component.

{% codepen https://codepen.io/tyeb_11/pen/wvExZLb %}

****

**Cleanup function in useEffect**


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



lets say we are using a setInterval function that runs every second and this side-effect is not cleaned up. So whenever our component is unmounted or you moved to the next page this setInterval will still be running in background. This is bad and is known as memory leak.


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

****

**componentDidMount()**

```
useEffect(()=>{
 console.log("component mount");
 },[])
```
**componentDidUpdate()**

```
useEffect(()=>{
 console.log("component update");
 },[values])

```
**componentWillUnmount()**

```
useEffect(()=>{
 return ()=>console.log("component removed");
 },[])
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g41y27st9vle6418qtcs.jpeg)
Leads in the box
Tags: growthhacking
Published: 2023-03-19 11:38:39

---
title: Leads in the box
published: true
description: Transform Linkedin into a lead machine.
tags: GrowthHacking
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-03-19 11:29 +0000
---

Comment transformer Linkedin en machine à Leads en 2023 ? 


Les étapes sont simples : 

- Créez un profil parfait

Améliorez votre photo de profil pour en avoir une pro.
Modifiez votre photo de couverture pour qu'elle serve de vitrine à votre activité.
Ajoutez un "résumé" pour détailler vos activités et votre proposition.
Retravaillez votre profil pour que Linkedin vous fasse apparaître dans les résultats de recherche avec les bons mots clés.

- Faites une recherche avancée sur Sales Navigator

La recherche avancé Sales Navigator est parfaite pour créer une liste de prospect qualifié. Une bonne liste ne contient pas plus de 2000 résultats. Sinon, vous pouvez ajouter des filtres pertinents pour réduire le nombre de résultat.

- Utiliser un [outil de prospection automatique](https://leadsinthebox.com) pour gagner du temps et améliorer votre taux de réponse.

Un bon outil de prospection automatique comme Leads in the box est nécessaire pour travailler à grande échelle sur Linkedin. Ce type d'outil gère les visites de profil (pour déclencher la notification "X a vu votre profil"), les demandes de connexion mais aussi l'envoi de messages personnalisés. 

Vous pouvez ensuite lancer la campagne de prospection automatisée, et c'est parti ! Vous n'avez plus qu'à répondre aux prospects qui sont intéressés pour aller plus loin.
React doc, what's new ?
Published: 2023-03-19 11:30:29

Hello javascript fans mainly react  users.
I want to share with you what I think is new on React doc now, I mean for `React 18`.

what you can observe before was, like you have to learn two concepts of react everytime.

In fact React teams in the past promoted class based components, then the new way to build component now recomand fonctional approach. Classes was cool for old users of react, but for new users it was like you are learning thing twice, it was confusing.

Now when you start, you can jump directly into functional component and you'll learn with funny examples.

Another thing is the references to frameworks, today you can find popular frameworks described and included directly in react doc, we can list : 

> Next.js

> Remix

> Gatsby

Theres is also a reference to 

> React native

You can enjoy also with the new design.
Enjoy with react !!!
Revolutionizing APIs: The GraphQL Future
Tags: graphql, javascript, programming, webdev
Published: 2023-03-19 10:57:07

GraphQL is a query language and runtime for Facebook APIs (Application Programming Interfaces). It enables developers to specify the structure of the data 
they require from the API, and the server will return that data.

One of the primary benefits of GraphQL is that it allows customers to request only the data they require. This decreases data overfetching and underfetching, which can increase application performance while also lowering network traffic.

GraphQL specifies a schema that outlines the different sorts of data and the queries and changes that may be done on that data. The schema acts as a contract between the client and the server, guaranteeing that only legitimate data is requested by the client.

GraphQL is also adaptable and expandable, allowing developers to create new kinds, queries, and mutations. It is compatible with a broad number of computer languages and frameworks, and it is gaining popularity in the web development community.

**Advantages :**

**1)**GraphQL allows clients to request exactly the data they want, decreasing data overfetching and underfetching, which can enhance application speed and minimise network traffic.

**2)**GraphQL's schema and tightly typed architecture assist to prevent frequent API problems and enable auto-generated API documentation, resulting in increased developer productivity. This can increase developer productivity and decrease debugging time.

**3)**GraphQL is both versatile and extendable, enabling developers to build their own types, queries, and mutations. As a result, it is appropriate for a wide range of applications.

**4)**Improved client-server collaboration: The GraphQL schema establishes a clear contract between the client and the server, guaranteeing that the client may only request legitimate data. This has the potential to promote communication between client and server teams.

**5)**Cross-platform support: GraphQL can be used with a wide range of programming languages and frameworks, making it a versatile technology for building APIs.

**Future of GraphQL :**

GraphQL has a bright future because it is already being utilised by a lot of businesses and developers and is anticipated to continue growing in popularity. Further tools and resources will probably be created when it is embraced more widely in order to make it simpler to use. There may also be an effort to standardise best practises and norms more broadly.

In addition to APIs, GraphQL may also be applied to other kinds of data sources. When this potential is investigated, it may result in more data sources being integrated.

In especially when GraphQL is used to handle bigger quantities of data, performance optimization will be a key area of attention. Overall, GraphQL has a promising future since it is still a cutting-edge and adaptable technology for creating APIs and managing data.
Understanding Value Types and Reference Types in JavaScript
Tags: webdev, javascript, beginners, programming
Published: 2023-03-19 10:48:57

When working with JavaScript, understanding the difference between value types and reference types is essential for writing efficient and effective code. This blog post will provide an overview of these two data types and explain how they differ in terms of **memory allocation** and **variable assignment**. By the end of this post, you will have a clear understanding of the benefits and limitations of each data type and be able to make informed decisions about how to use them in your own code. Whether you're a beginner or an experienced JavaScript developer, this post will provide valuable insights into one of the most fundamental aspects of the language.

In JavaScript, data types can be classified into two categories: value types and reference types. Understanding the difference between these two types is crucial for writing efficient and effective code.

**_Value types_** are simple data types such as numbers, strings, and booleans. When a value type is assigned to a variable, the variable **stores a copy of the value itself**. This means that any changes made to the variable do not affect the original value. For example:

```
let num1 = 5;
let num2 = num1;
num2 = 10;
console.log(num1); // Output: 5
console.log(num2); // Output: 10
```

In this example, num1 is assigned the value 5. When num2 is assigned the value of num1, it creates a copy of the value stored in num1. Any changes made to num2 do not affect the value of num1.

**_Reference types_**, on the other hand, are objects such as arrays and functions. When a reference type is assigned to a variable, the variable stores a reference to the object in memory, rather than a copy of the object itself. This means that any changes made to the object through one variable will also affect the object as accessed through other variables. For example:

```
let obj1 = {
    name: 'John',
    age: 20,

}
let obj2 = obj1;
obj2["position"]="developer"
console.log(obj1); // { name: 'John', age: 20, position: 'developer' }
console.log(obj2); // { name: 'John', age: 20, position: 'developer' }
```
In this example, obj1 is an object with two elements. When obj2 is assigned the value of obj1, it creates a reference to the same  object in memory. When obj2 is modified by adding an element, it also modifies obj1 since both variables reference the same  object in memory.

In conclusion, understanding the difference between value types and reference types is crucial in writing efficient JavaScript code. By optimizing memory usage and avoiding common pitfalls, developers can write better code and build more effective applications.
We Coded event
Tags: wecoded
Published: 2023-03-19 10:47:58

<!-- ✨This template is only meant to get your ideas going, so please change/add/remove these prompts as you wish! ✨ -->

## I pledge to embrace equality in tech by providing equal knowledge sharing irrespective of gender.

## One of the biggest obstacles to gender equality in the tech industry is not having the required skills.

## I will commit to educating myself about Angular and various other Python Automation stuffs in this event.

<!-- Once your post is published, it will not appear on the /t/wecoded page until an admin approves it. This is an extra step to ensure there is no abuse on this important tag. -->