teleren/devto huggingface dataset:
Enums’ inheritance
Tags: java, beginners
Published: 2021-08-03 08:27:06

Did you ever try to implement enums which are children of other ones ? In Java, you can’t do so. Enums can’t inherit, however you can use a simple tip to avoid this issue : composition.

First of all, create a list of all the elements you need. In our example, we will use a list of animals. Each of these animals are part of the same enumeration, so they share the same type and the same structure. For visibility, we will keep our example as simple as possible.

    enum Animal {
      DOG,
      CAT,
      COW,
      ANT,
      BUTTERFLY,
      LADYBUG
    }


Then we create a “parent“ enum regrouping animals by type.

    import static Animal;

    enum AnimalType {
      MAMMAL(DOG, CAT, COW),
      INSECT(ANT, BUTTERFLY, LADYBUG);
    
      private List<Animal> animals;
    
      public AnimalType(Animal... animals) {
        this.animals = Arrays.asList(animals);
      }
    
      public List<Animal> getAnimals(){
        return animals;
      }
    }

This parent enumeration can be more complex. I recommend setting the list of elements at the end of parameters to gain visibility.

    import static Animal;

    enum ComplexAnimalType {
      MAMMAL(1, 2, Arrays.asList(DOG, CAT, COW)),
      INSECT(3, 4, Arrays.asList(ANT, BUTTERFLY, LADYBUG));
    
      private int field1;
      private int field2;
      private List<Animal> animals;
    
      public ComplexAnimalType(int field1,
                               int field2, 
                               List<Animal> animals) {
        this.field1 = field1;
        this.field2 = field2;
        this.animals = animals;
      }
    
      //getters
    }

Moreover, you can add tests which flatmap all animals from AnimalType to compare with the list of whole animals. This way, you will avoid mistakes like duplication or missing elements.
Go: Identifiers vs. Unicode
Tags: go, unicode
Published: 2021-08-03 08:23:29

A recent [Reddit post about Unicode characters in Go identifiers](https://www.reddit.com/r/golang/comments/owe6hn/i_cant_understand_which_characters_are_allowed/) sparked my interest to dive into the [Go spec](https://golang.org/ref/spec#Identifiers) and look things up properly:
 
According to the spec, the syntax for valid identifiers is

```
identifier = letter { letter | unicode_digit }
```

with

```
letter = unicode_letter | "_"
unicode_letter = /* a Unicode code point classified as "Letter" */ .
unicode_digit  = /* a Unicode code point classified as "Number, decimal digit" */ .
```

The "Letter" category consists of the Unicode categories `Lu` (uppercase letters), `Ll` (lowercase letters), `Lt` (titlecase letters), `Lm` (modifier letters), and `Lo` (other letters), where "Number, decimal digit" refers to the Unicode category `Nd`.

So an identifier has to start with either a "letter" or an underscore ("_"), and must contain only "letters", "decimal digits" and "underscores" - according to what's defined as letters and digits in Unicode.
The set of letters is not only the usual `A`-`Z`, `a`-`z`, but also letters from other scripts, like greek letters (e.g. [`Σ`](https://unicode-explorer.com/c/03A3), or CJK characters (e.g. [`㭪`](https://unicode-explorer.com/c/3B6A)). The same holds for digits - not only `0`-`9`, but also digits from other scripts are allowed: e.g. [`୩`](https://unicode-explorer.com/c/0B69), [`٣`](https://unicode-explorer.com/c/0663), etc.

Valid identifiers:

- `abc_123`
- `_myidentifier`
- `Σ` ([U+03A3 GREEK CAPITAL LETTER SIGMA](https://unicode-explorer.com/c/03A3))
- `㭪` ([some `CJK` character](https://unicode-explorer.com/c/3B6A) from the `Lo` category)
- `x٣३߃૩୩3` (`x` + decimal digits `3` from various scripts)

Invalid identifiers:

- `42` (does not start with a letter)
- `😀` (not a letter, but `So / Symbol, other`)
- `⽔` (not a letter, but `So / Symbol, other`)
- `x🌞` (starts with a letter, but contains non-letter/digit characters)

Although Go considers identifiers valid that contain other characters than `A`-`Z`, `a`-`z`, `0`-`9`, and `_`, it's generally not advisable to use those - because of readability, accessibility, or even to avoid rendering issues.
Coursera Discounts for Data Science Courses- August 2021
Tags: datascience, machinelearning, analytics, analyst
Published: 2021-08-03 08:16:39

Guy's,

Are you planning to enroll in **IBM Data Science, IBM Data Analyst, or IBM Applied AI?**

If yes, then I have something for you.

I have received **Exclusive Coursera Discounts** for my audience.

And today, I am going to share this with you.

You will get **25% OFF on these courses till 31st August 2021**.

You can get these discount links here- **[Coursera Discounts for Data Science Courses](https://www.mltut.com/coursera-discounts-for-data-science-courses/)**

Happy Learning!
Best 10 JavaScript libraries to know.
Tags: javascript, libraries
Published: 2021-08-03 08:14:47

1 <a herf="https://alvarotrigo.com/fullPage/">fullpage.js </a>
<img src="https://www.freecodecamp.org/news/content/images/2020/07/ezgif.com-video-to-gif-1--1.gif">

fullPage is an open-source library that allow you to Create fullscreen pages fast and full-screen scrolling websites that makes your website more responsive
<br>

It's easy to use and has many options to customize, so it's no surprise it is used by thousands of developers and has over 30k stars on GitHub.

2 <a href="https://www.animejs.com">Anime.js</a>
<img src="https://www.freecodecamp.org/news/content/images/2020/07/anime.gif">


Anime.js is one of the best. It’s easy to use, has a small and simple API,and offers everything you could want from a modern animation engine. The library has a small file size and supports all modern browsers, including IE/Edge 11+.
<br>
It works with CSS properties, SVG, DOM attributes and JavaScript Objects.

<a href="D3js.com">D3.js
</a>
<img src="https://kinsta.com/wp-content/uploads/2021/03/d3js-1.jpg">

D3.js is a JavaScript library for manipulating documents based on data. D3 helps you bring data to life using HTML, SVG, and CSS. D3’s emphasis on web standards gives you the full capabilities of modern browsers without tying yourself to a proprietary framework, combining powerful visualization components and a data-driven approach to DOM manipulation.


 <a href="bideojs.com"> Bideo.js</a>

<img src="https://kinsta.com/wp-content/uploads/2021/03/bideojs-1.jpg">

Bideo.js allow you to add full-screen videos into your site’s background page.
Easy to implement using CSS/HTML/JavaScript
<a href="https://kinsta.com/blog/javascript-libraries/#algolia-places">Algolia Places<a>

<img src="https://kinsta.com/wp-content/uploads/2021/03/algolia-1.jpg">

Algolia Places is a JavaScript library that provides an easy and distributed way of using address auto-completion on your site. It’s a blazingly fast and wonderfully accurate tool that can help increase your site user experience. Algolia Places leverages the impressive open-source database of OpenStreetMap to cover worldwide places.

For example, you can use it to boost your product page conversions.


<a href="https://kinsta.com/blog/javascript-libraries/#algolia-places">Leaflet<a>

<img src="https://kinsta.com/wp-content/uploads/2021/03/leaflet-1.jpg">

Leaflet is one of the best JavaScript libraries that you can use to include interactive maps into your site. It is open-source and mobile-friendly, weighing around 39kb. The MapPress Maps for WordPress plugin uses Leaflet to power its interactive maps.


<a src="https://momentjs.com/">Moment.js</a>

Moment.js helps you manage time and date effectively when working with different time zones, API calls, local languages, etc.

You can streamline dates and times by validating, parsing, formatting, or manipulating them.
Weekly Challenge 124
Tags: perl, theweeklychallenge
Published: 2021-08-03 08:00:53

[Challenge](https://theweeklychallenge.org/blog/perl-weekly-challenge-124/), [My solutions](https://github.com/manwar/perlweeklychallenge-club/tree/master/challenge-124/sgreen)

### TASK #1 › Happy Women Day

Write a script to print the [Venus Symbol](https://en.wikipedia.org/wiki/Planet_symbols#Venus), international gender symbol for women. Please feel free to use any character.

### My solution

I decided not to submit a solution. Short of doing a print with a huge [heredoc](https://perlmaven.com/here-documents) there doesn't actually appear to be a task. Maybe `say '♀'` cuts the mustard too.

## TASK #2 › Tug of War

### Task

You are given a set of `$n` integers (n1, n2, n3, ….).

Write a script to divide the set in two subsets of `n÷2` sizes each so that the difference of the sum of two subsets is the least. If `$n` is even then each subset must be of size `$n÷2` each. In case `$n` is odd then one subset must be `($n-1)÷2` and other must be `($n+1)÷2`.

### My solution

Looking at solutions to last week's Ugly Numbers task, it's clear that I don't always write the most efficient solution. I did however note that in my blog post last week too :-) This task may also fall into that category.

This task is about doing things in half. The target (most optimal solution) means that each set has exactly half the sum of all the inputs.

I have rolled my own `_get_next_combination` sub routine that works through all possible combinations of the first set. I do this because as a rule of thumb I don't use no-core Perl modules for these challenges.

For each combination, I get the sums of the values in the set and see how close it is to the target. If it is an exact match, we can exit the loop early. If the difference is less than any previous combination, I record this fact.

Finally, I get the half of positions not in the first set and display the result.

### Examples

Compared to the examples, the first example has the sets switched. The second example is completely different, but both solutions produce sets of 30.

```
$ ./ch-2.pl 10 20 30 40 50 60 70 80 90 100
Subset 1 = (10, 20, 50, 90, 100)
Subset 2 = (30, 40, 60, 70, 80)

$ ./ch-2.pl 10 -15 20 30 -25 0 5 40 -5
Subset 1 = (10, -15, 30, 5)
Subset 2 = (20, -25, 0, 40, -5)
```
New Luos feature: add some research API in the routing table.
Tags: embedded, opensource, luos, api
Published: 2021-08-03 07:44:03

### 🆕 Feature: Add some research API in the routing table

When it comes to developing the behavior of your machine, you will have to access some **drivers**.

With Luos, all the resources of your system are resumed into a [routing_table structure](https://docs.luos.io/pages/embedded/containers/routing-table.html). This structure allows you to find the resources you need to make your application work. We are constantly updating and optimizing the functions allowing you to easily find the resources you need.

In this [revision 1.3.0 of Luos](https://github.com/Luos-io/Luos/releases/tag/1.3.0), we added index research, giving you the most optimized way of getting resource information.

More details about this are on the [routing_table](https://docs.luos.io/pages/embedded/containers/routing-table.html) section of our [documentation](https://docs.luos.io).

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0izknnpvko5vq2cudbry.png)
Writing to file with PHP
Tags: php, programming, tutorial
Published: 2021-08-03 07:14:13

We will use the `w` mode and the `fwrite()` function to write files. The content of the file that we access only when using the `w` mode is completely deleted and replaced with the value we will write.

If you want to write without losing pre-existing content then you will need to use the `a` mode.

This function works with two parameters. In the first parameter we write the variable that we access the file with `fopen()`, and in the second parameter we write the content to be written.

```php
<?php
$file = fopen('hello.txt', 'w');
fwrite($file, 'Hello World');
fclose($file);
```

When we run the example above, we have written `Hello World` in the content of our file named `hello.txt`.

Follow my blog for more [baransel.dev](https://baransel.dev/).
Deleting a file in PHP
Tags: php, programming, tutorial
Published: 2021-08-03 07:13:21

You can destroy the file you want with the `unlink()` function, which we will see as the opposite of the file creation function.

Its use is as simple as the build function and has one parameter.

```php
unlink('hello.txt');
```

It deletes the `hello.txt` file that we are working on.

Follow my blog for more [baransel.dev](https://baransel.dev/).
The 3 most interesting C++ posts of July 2021
Tags: bestofdev, cpp
Published: 2021-08-03 07:06:49

Let me share with you 3 interesting [#cpp](https://dev.to/t/cpp) posts from July.

I don't take the most popular articles anymore, because I find that while some articles do meet the criteria to add #cpp as a tag, but they are not mostly about C++. So there is a bit of subjectivity to this list. Yet, I try not to include multiple articles from the same author and I don't include the wrap-up of the previous month either ;)

Feel free to share your favourite one in the comments.

***
[Vinit](https://dev.to/vinitjogani) wrote clearly the most popular post last month. While people love to complain, about the weather, about the system, about programming languages, he expressed why he thinks C++ is awesome. Thank you!

{% link https://dev.to/vinitjogani/c-is-awesome-here-s-why-1be0 %}

***

[Elvis](https://dev.to/elvisoric) shared a couple of book recommendations that always comes in handy.

{% link https://dev.to/elvisoric/c-learning-materials-books-fpd %}

***

Last but not least, [Animesh](https://dev.to/animeshmaru), didn't write about new features of C++, but old ones that got removed from the language. Remember, it's not only important to keep introducing new features, but we need to keep our language as clean as possible and remove the weed.

{% link https://dev.to/animeshmaru/c-removed-features-f86 %}

Happy coding!

## Connect deeper

If you liked this article, please 
- hit on the like button,  
- [subscribe to my newsletter](http://eepurl.com/gvcv1j) 
- and let's connect on [Twitter](https://twitter.com/SandorDargo)!
Stimulus Read More - Correct approach
Tags: stimulus, ruby, rails
Published: 2021-08-03 06:37:16

---
title: Stimulus Read More - Correct approach
published: true
tags: stimulusjs, ruby, rails
canonical_url: https://blog.corsego.com/stimulus-read-more
---

I did not find an easy Stimulus solution to this, so here is mine. Works. Easy. quite Light. Example:

![stimulus read more](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x44sno50yskxgc2np2k6.gif)

HOWTO:

read_more_controller.js

```
import { Controller } from "stimulus"

export default class extends Controller {
  static targets = ["shortText", "longText", "moreButton", "lessButton"]

  connect() {
    this.showLess()
  }

  showMore() {
    this.shortTextTarget.hidden = true
    this.moreButtonTarget.hidden = true
    this.longTextTarget.hidden = false
    this.lessButtonTarget.hidden = false
    console.log('show more')
  }

  showLess() {
    this.shortTextTarget.hidden = false
    this.moreButtonTarget.hidden = false
    this.longTextTarget.hidden = true
    this.lessButtonTarget.hidden = true
    console.log('show less')
  }
}

```

any view (html):

```
<div data-controller="read-more">
  <div data-read-more-target="shortText">
    ABC
  </div>
  <div data-read-more-target="longText">
    ABCDEFG
  </div>
  <button data-read-more-target="moreButton" data-action="read-more#showMore">
    Show more
  </button>
  <button data-read-more-target="lessButton" data-action="read-more#showLess">
    Show less
  </button>
</div>

```

or any view (sexy haml):

```
%div{ data: { controller: 'read-more'} }
  %div{ data: { target: 'read-more.shortText' } }
    ABC
  %div{ data: { target: 'read-more.longText' } }
    ABCDEFG
  %a{ data: { action: 'read-more#showMore', target: 'read-more.moreButton' } }
    Show more...
  %a{ data: { action: 'read-more#showLess', target: 'read-more.lessButton' } }
    Show less...

```
How does the promotion of posts work on DEV?
Tags: meta, discuss
Published: 2021-08-03 06:29:49

I have just been having a conversation on a post about how DEV decides what content to promote, so I thought I would ask the question instead of speculating!

- What dictates what is promoted on social media?
- What dictates top comments in the newsletter / weekly post?
- What dictates a top 7 post in the newsletter / weekly post?

**For clarity:** I am talking about things that the DEV team actively promotes, not what is popular in the feeds or how the feeds work.

I know they say in the top 7s that it is based on traffic or engagement but that doesn't appear to be the case (although I can't see traffic figures to be fair).

They do seem very much human driven (which is fine but then I am asking how are they chosen)?

Just wondered how it all worked and what is actually looked at as the criteria? 

Is there a bit of luck involved as to which posts the DEV team happen to read, as I understand you can't possibly read them all?

I am intrigued so I can learn how to ~~game the system~~ **write better content that gets promoted** 😉🤣

## Personal motivation
This question was sparked as I released a monster article (one that I believe is truly great quality...for once I didn’t shit post 😜!) that got great engagement but low views. (currently: 224 reactions to 2500 views)

As an experiment I deliberately wrote a "low effort" post that I released at one of the worst possible times that was designed to be a click magnet / get noticed and....the "low effort" one got promoted! (currently: 55 reactions to 4400 views)

Not complaining about getting a shout out (thanks DEV) it just seems a bit broken that I can predict what is likely to get shared based on the tags and title rather than the quality of the post!

I know that increasing visibility of quality content is something the DEV team is working on, so perhaps a final question is how you find that quality content in the first place (suggestions are: "reactions to views" ratio seems like a decent starting place, maybe "number of comments to views" too?)? 

Anyway just asking the question, and from a purely selfish standpoint (until people get sick of me promoting it!) here is the article I believe was "promotion worthy" and the one deliberately designed to get promoted!

### the "high effort" post
{% post https://dev.to/inhuofficial/101-digital-accessibility-tips-and-tricks-4728 %}

### the "low effort" post
{% post https://dev.to/inhuofficial/3-general-productivity-tools-you-should-be-using-that-you-possibly-haven-t-heard-of-1h9j %}

___

Thanks in advance for any clarity on this!


## Update
A great reply from @graciegregory covers all of the points in detail and beautifully, thanks Gracie! 

I have included it here in case it gets lost in the comments, it should, in my opinion, get added to the FAQs section as it is that comprehensive and I am sure I am not the only one who wanted to know this!

{% comment 1gp3h %}
pur avendo un tocco romantico moderno www.gillne.it
Published: 2021-08-03 04:51:06



Mobili vintage, accenti blu alla moda e decorazioni rustiche si uniscono per formare il dolce matrimonio di Noah e Kaitlin al Whispering Tree Ranch di Laveen, in Arizona. Adoriamo il modo in cui le impostazioni del posto ei tavoli non corrispondenti hanno aggiunto carattere a questo splendido matrimonio all'aperto. Sebbene il matrimonio avesse una combinazione di colori dai toni freddi, non sono mancati i momenti commoventi. J&G Photography ha catturato bellissime foto della coppia nel loro grande giorno.

http://www.gillne.it
Ispirazione:

Volevamo puntare a un tema vintage rustico, pur avendo un tocco romantico moderno. Molte decorazioni sono state fornite dal luogo ed era esattamente quello che volevamo. La maggior parte dell'arredamento era rustico e romantico, ma cose come la porcellana e i centrotavola erano classici e vintage. I temi si sono combinati perfettamente. Volevamo essere noi stessi e sentirci a nostro agio nel giorno del nostro matrimonio Abiti da sera viola, quindi abbiamo mantenuto la moda piuttosto moderna e semplice con i ragazzi in jeans color cachi e una camicia elegante, e le ragazze con un vestito da sole che avrebbero potuto indossare di nuovo in futuro. Il mio vestito aveva un aspetto un po 'vintage, ma era moderno nella parte anteriore. Tutto si è combinato perfettamente e si è abbinato alle nostre personalità.
HTML tags | fieldset
Tags: html, tags, fieldset
Published: 2021-08-03 06:13:44

It is used to **group related elements within a form**. It usually generates a border around it, modifiable with CSS.

Besides `name`, it has two main attributes:
* `disabled` to disable all form elements contained within the `<fieldset>` and not receiving navigation events (_click_, _focus_)
* `form` to, taking as value the `id` of a `<form>`, associate the `<fieldset>` to said form even if it is not contained within it. The latter **is confusing and is not recommended**, if you want to establish that link it is better to associate the form elements it contains one by one.

A title can be set for each `<fieldset>` using `<legend>` as the first child.

- Type: *block*
- Self-closing: *No*
- Semantic value: *No*

[Definition and example](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/fieldset) | [Support](https://caniuse.com/mdn-html_elements_fieldset)
A Moment of Testing
Tags: tdd
Published: 2022-02-05 13:28:39

---
title: A Moment of Testing
published: true
date: 2021-06-20 12:27:20 UTC
tags: tdd
canonical_url: https://mahmutcanga.com/2021/06/20/a-moment-of-testing/
---

![](https://sufidev.files.wordpress.com/2021/06/image.png?w=842)

Sometimes you may question _ **“Why should I write tests? Why TDD is important?”** _

I think this little moment of success can explain a lot of things…  
  
My tests here are run under 3seconds. This means, I’ll get an immediate feedback from my tests if I break anything….

**What is the result of not writing tests?**

1. Instead of only spending **3 seconds of my dev time** , I’m going to waste a lot of other people’s time in my team by expecting them finding out the issues by manual testing. Immediate feedback as in 3 seconds is extremely valuable during development. 
2. Plus, I’ll loose trust of my customers too by unintentionally asking them wasting their time using my software and only finding out the bugs…

Of course, there are moments we have to ask our team to test manually but it should be as minimum as possible….
Gatsby build cron issue..!!
Tags: gatsby, node, react
Published: 2021-08-03 06:04:46

Hi, I am trying to Build static pages for gatsby from a bash script. Bash script is working fine but whenever i try to run it via crontab it throw error for node and npm.

Node version i am using is v10.13.0 and npm version is v6.4.1. 

But somehow cron log gives me error which shows my node version v8.10.0 and npm version v3.5.2. Screenshot attached for the same.

Even i do not have node v8 installed on my server. Both on root and ubuntu user. 

Why it is taking node version 8 for cronjob?
4 tools I use daily to improve my productivity
Published: 2021-08-03 05:59:22

1) threadstartio



Helps me schedule tweets & thread



threadstart.io



2) NotionHQ

 

Helps me track my habits, todo and much more



notion.so



3) Discord



To stay connected with my friends, peers and colleagues



discord. com



4) VS Code



To write and edit code and work on my projects



What are the tools that you are using in your daily life to help you with your productivity?