teleren/devto huggingface dataset:
☸ Install and Configure WildFly (JBoss) on Ubuntu 20.04 LTS
Tags: jboss, wildfly, web, ubuntu
Published: 2021-04-21 07:21:41

**Step 1:** Open the Terminal

**Step 2:** Update repository index

```bash
sudo apt-get update
```

**Step 3:** Install the OpenJDK package from APT

`sudo apt-get install default-jdk`

**Step 4:** Create a user and group for WildFly

`sudo groupadd -r wildfly`

`sudo useradd -r -g wildfly -d /opt/wildfly -s /sbin/nologin wildfly`

**Step 5:** Download the WildFly Installation file

Version_Number=22.0.1.Final

```bash
wget https://download.jboss.org/wildfly/$Version_Number/wildfly-$Version_Number.tar.gz -P /tmp
```

**Step 6:** Extract the WildFly tar.gz file to /opt folder

`sudo tar xf /tmp/wildfly-$Version_Number.tar.gz -C /opt/`

**Step 7:** Create a symbolic link to point to the WildFly installation directory

`sudo ln -s /opt/wildfly-$Version_Number /opt/wildfly`

**Step 8:** Give access to WildFly group and user

`sudo chown -RH wildfly: /opt/wildfly`

**Step 9:** Configure Wildfly to be run as a service

`sudo mkdir -p /etc/wildfly`

`sudo cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.conf /etc/wildfly/`

`sudo nano /etc/wildfly/wildfly.conf`

`**WILDFLY_BIND=0.0.0.0**`

`sudo cp /opt/wildfly/docs/contrib/scripts/systemd/launch.sh /opt/wildfly/bin/`

`sudo sh -c 'chmod +x /opt/wildfly/bin/*.sh'`

`sudo cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.service /etc/systemd/system/`

`sudo systemctl daemon-reload`

**Step 10:** Start the WildFly service

`sudo systemctl start wildfly`

`sudo systemctl status wildfly`

`sudo systemctl enable wildfly`

### Configure WildFly

**Step 1:** Allow traffic on port 8080

`sudo ufw allow 8080/tcp`

**Step 2:** Create a WildFly Administrator

`sudo /opt/wildfly/bin/add-user.sh`

**Step 3:** Access and verify the successful setup of WildFly

IP address: `**http://192.168.1.8:8080**`

**Managing the Administrative console remotely**

`sudo nano /etc/wildfly/wildfly.conf`

`WILDFLY_CONSOLE_BIND=0.0.0.0`

`sudo nano /opt/wildfly/bin/launch.sh`

```bash
$WILDFLY_HOME/bin/domain.sh -c $2 -b $3 -bmanagement $4

else

$WILDFLY_HOME/bin/standalone.sh -c $2 -b $3 -bmanagement $4
```

`sudo systemctl restart wildfly`

`sudo nano /etc/systemd/system/wildfly.service`

`ExecStart=/opt/wildfly/bin/launch.sh $WILDFLY_MODE $WILDFLY_CONFIG $WILDFLY_BIND $WILDFLY_CONSOLE_BIND`

`sudo systemctl daemon-reload`

`sudo systemctl restart wildfly`

**Open the Administrative Console CLI**

`cd /opt/wildfly/bin/`

```bash
./jboss-cli.sh --connect
```
C# Tips: Be specific when handling Exception
Tags: csharp
Published: 2021-04-21 07:20:20

Our program is great only when we handle exceptions appropriately.
We all know that we can **catch** different type of Exceptions in C# with try/catch, but we always forget to be a bit more specific.

There are several interesting example in official docs, so I pick up one to explain how this works.

See [this document](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/exceptions/exception-handling#catch-blocks) for more detail.

# Sample code

Let's create sample code as console app.

```csharp
using System;

namespace ExceptionFilter
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] array = { 1, 2, 3 };
            int index = -1;

            try
            {
                int result = array[index];
            }
            catch (IndexOutOfRangeException e) 
            {
                Console.WriteLine("IndexOutOfRangeException", e);
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("something went wrong!");
            }
        }
    }
}
```

When I run the program, I see **IndexOutOfRangeException** as expected.

However, what if I want distinguish when user put negative value and when user put larger size than the array length? Then I can use **when** exception filter like below.


```csharp
using System;

namespace ExceptionFilter
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] array = { 1, 2, 3 };
            int index = -1;

            try
            {
                int result = array[index];
            }
            catch (IndexOutOfRangeException e) when (index < 0)
            {
                Console.WriteLine("Parameter index cannot be negative.", e);
            }
            catch (IndexOutOfRangeException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Parameter index cannot be greater than the array size.");
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("something went wrong!");
            }
        }
    }
}
```

That's it! It may sound stupid, but in real case life, we had to do if/else statement inside catch several years ago :D
How to start with Ruby on Rails when you use Django
Tags: 5blog
Published: 2021-04-21 07:18:35

@andrzejkrzywda challenged me once to try Rails web framework instead of Django. I was a bit skeptical about this, but I have given a try. I have spent two weeks to try to figure it out how it works. Of course my way of thinking about Rails was Django-way, so it gives me hard, meaningless time. 
So, how to start?
Don't try to find a place where you can describe Class Based View or Function Based View.
View in Django are controller in Rails. 
It is a specific way to create a controller in Rails.
Mostly it will have a name of a template.
If you have some uncommon needs which needs additional code don't create a separate file. Just add a method to your controller class and use it as a class method in a template. 
On the beginning it's looks really wired and uncommon, but now I think it is more logic than views conception in Django
JavaScript creating a new element
Tags: javascript
Published: 2021-04-21 06:43:55

I've realized I've done quite a few articles already where I used the technique to create elements from scratch in Vanilla JavaScript.

But I've never actually gone through the basics of creating elements in JavaScript.

TLDR; You can use `document.createElement()` to create new elements.

## Creating new elements in JavaScript

When using the `createElement()` function you can pass the element you can to create, but you don't need to pass in the brackets `<>`.

Some examples:

```js
document.createElement('div');
document.createElement('aside');
document.createElement('custom');
```

Run this in JavaScript and it will create these three elements for you.

As you can see it allows known HTML element or even custom elements.

These however will not get added to the dom directly.
We can console log them to see what's happening.

![Created element in JavaScript](https://cdn.hashnode.com/res/hashnode/image/upload/v1618766006690/OSEesd6Jf.png)

Let's create a full element and add it to the dom now.

```js
let div = document.createElement('div');
div.textContent = `I'm created`;
div.style.backgroundColor = 'red';
div.id = 'custom_id';

document.body.appendChild(div);
```

And this will actually append a red div to our dom.
The red div will have a custom ID even.

![Styled element to dom in JavaScript](https://cdn.hashnode.com/res/hashnode/image/upload/v1618766226537/02HQDExYl.png)

Pretty cool right?
You can try this out yourself in the following Codepen.

{% codepen https://codepen.io/rebelchris/pen/RwKYPBP %}

### Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on [Facebook](https://www.facebook.com/DailyDevTipsBlog) or [Twitter](https://twitter.com/DailyDevTips1)
Image Sorting Visualizer
Tags: javascript, vue, algorithms
Published: 2021-04-21 06:42:58

# Hello World! :wave: 

It's been a year since I created this small project for fun. I was having fun learning algorithms and data structures, and solving various problems. With the free time I had at the moment I decided to make small app demonstrating how various Sorting algorithms work, by using them to get the original image from shuffled one.
Sorting algorithms are probably the on of easier topics when it comes to algorithms but still pretty fun to visualize. Also coming from a Backend background I decided to do this using Javascript and a bit of Vue, just because learning something new is always fun and I want to start getting into Frontend languages as well, so don't judge my code too hard if you decide to open it :D . Nevertheless here is the end-result.

You can test the app at: https://image-sorting-visualizer.herokuapp.com/
Git repo is: https://github.com/fvukojevic/Image-Sorting-Visualizer if some of you want to :star: the project, highly appreciated

This is my old post about the app, you can watch the demo video there and see how it works: https://www.linkedin.com/posts/ferdo-vukojevic-2a9370181_javascript-frontend-vue-activity-6624224236007415808-to_k
49 Days of Ruby: Day 25 - Mutable and Immutable Objects
Tags: ruby
Published: 2021-04-21 06:37:48

---
title: 49 Days of Ruby: Day 25 - Mutable and Immutable Objects
published: true
description: Join us on a 49 day learning journey through Ruby!
series: 49 Days of Ruby
tags: #ruby
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/9m73qaetuse3nm3y3it8.png
---

**Welcome to day 25 of the 49 Days of Ruby! 🎉**

Today is all about freezing things! No, we're not going to freeze you, personally, but we are going to talk about *mutability* and *immutability*.

What are these terms and what do they mean for my coding journey in Ruby?

When something is *mutable* it means that it can be changed. When something is *immutable* it means that it cannot be changed.

For example, let's take a look at the following code:

```ruby
first_coffee = "espresso"
second_coffee = first_coffee

> puts second_coffee
# => "espresso"

second_coffee[0] = "E"
# => "Espresso"

> puts first_coffee
# => "Espresso"
```

Did you notice how when we modified the first letter of `second_coffee` it also modified the first letter of `first_coffee`?

We probably do not want that behavior! We want to treat `first_coffee` as unchangeable by cloning the first copy as the value of the second variable instead:

```ruby
second_coffee = first_coffee.clone
```

Now, we can modify `second_coffee` and not touch the `first_coffee`.

How can we turn a `mutable` thing into an `immutable` thing? Welcome to the `#freeze` method!

```ruby
first_coffee = ["americano"].freeze

first_coffee[0] = "Espresso"

# => FrozenError (can't modify frozen Array: ["americano"])
```

The `#freeze` method does not work on strings themselves but on objects. Hence, we created an array and put the string inside of it, and called `#freeze` on that.

The result when we tried to modify that is an exception: `FrozenError`.

What do you think some of the benefits of mutability and immutability are?

Share your ideas with the community using the hashtag [#49daysofruby](https://twitter.com/hashtag/49daysofruby)!

**Come back tomorrow for the next installment of 49 Days of Ruby! You can join the conversation on Twitter with the hashtag [#49daysofruby](https://twitter.com/hashtag/49daysofruby).**
Day 38 of 100 Days of Swift UI
Tags: 100daysofcode, 100da
Published: 2021-04-21 06:36:36

I just completed day 38 of 100 Days of Hacking with SwiftUI. Today I worked on the IExpense challenge.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4nb1qlj371dgva2q50ix.png)

Here's a link to the [github repo](https://github.com/sanmiAde/IExpenses)
REACT - setState Object
Tags: reactnative, react
Published: 2021-04-21 06:32:06

Sometimes, we need to use the React Hook to store the object rather than the single field. Here is example:

![setState object](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0jl1pu9vt6vjw2o7m38s.png)

: PS/
Hope to help you with something.
Thanks

#devnote
#react
Gravitee.io Cockpit now available
Tags: api, apimanagement, apiplatform
Published: 2021-04-21 06:26:36

🆕 We are pleased to announce that Cockpit is now available.

🚀Gravitee.io Cockpit is a centralized, multi-environment tool for managing all your Gravitee API Management and Access Management installations in one handy, interactive dashboard: https://cockpit.gravitee.io
Laravel Validation Number Less Than Example
Tags: laravel, php, tutorial, example
Published: 2021-04-21 06:26:16

Today, I will learn you to create validation lt in laravel.we will show example of laravel validation lt.The given field The field under validation must be less than the given field. The two fields must be of the same type. Strings, numerics, arrays, and files are evaluated using the same conventions as the size rule
more..
https://itwebtuts.blogspot.com/2021/04/laravel-validation-number-less-than.html
The simplest way to validate file input type
Tags: webdev, javascript
Published: 2021-04-21 06:14:18

I've been working on a form lately and one day I got a task to add type validation to field input. My first thought was to simply check the file type after the file is being uploaded and, based on that, store this file in the list in my app or drop it. The idea was to have extensions whitelist and allow user to add only files that are on that whitelist to make sure that there is nothing insecure being introduced to our system.

I wanted to make sure that I covered all needed extensions so I ended up checking what were possible types supported by input field. And then I found it - `accept` attribute in file input itself. Thanks to that user experience is just great - files not listed in the `accept` attribute are simply greyed out so user can't select them. It allows to avoid confusion, dedicated error message and clearly shows the user what he or she can and cannot add to the form.

I recommend you to check the details in the [docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept), I just want to emphasise that this attribute can accept both file extensions and unique file type specifier. See examples below (taken from [here](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept)) 

- `accept="image/png"` or `accept=".png"` — Accepts PNG files.
- `accept="image/png, image/jpeg"` or `accept=".png, .jpg, .jpeg"` — Accept PNG or JPEG files.
- `accept="image/*"` — Accept any file with an `image/*` MIME type. (Many mobile devices also let the user take a picture with the camera when this is used.)
- `accept=".doc,.docx,.xml,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document"` — accept anything that smells like an MS Word document.

Using `accept` attribute instead of checking every file manually and then adding it to the list speeded my work. I didn't have to throw an error every time wrong file is added and explain to the user what he or she should do now. However, I wanted to be 1000% sure that there is no way to attach wrong file in the form. That's true that `accept` attribute doesn't allow user to select file with type I didn't specify but you know... the form can be always compromised with external script. This is why I decided to add one more step before adding files to the list and wrote the function checking if selected file type is included in the extensions whitelist I have in the app.  If it is not there - nothing happens (no error for the user is needed as this is edge case only if someone compromises the form). And the app is safe.
How To Speed Up The Python Code?
Tags: python, programming
Published: 2021-04-21 06:01:29

We all know that Python is one of the most popular programming all over the world. These days, it is being used in competitive programming because of its simple syntax and rich libraries. You can almost do anything with Python from data science, machine learning, signal processing to  data visualization. But many people claim that python is a bit slow while solving grave problems. Time to execute a program depends on the code that you write. Knowing some tips to optimize the code will help you to speed up the python code. Let’s see the top 10 tips to speed up python code.

#Top 10 Tips To Speed Up Python Code –
**1. Use Proper Data Structure-**
Use of proper data structures has significant effect on runtime. Python includes tuple, list, set and directory as built-in data structures. Most of the people use the list in all cases, but it is not a good choice. Basically use of proper data structures depends on your task. You can use tuple instead of list, because iterating over tuple is easier than iterating over a list.

**2. Use Built In Functions And Libraries-**
Python includes lots of library functions and modules written by expert developers and have been tested thoroughly. Hence, these functions are efficient and able to speed up the code-no need to write the code if the function is already available in the library. Let us see a simple example-

Know more at- [https://solaceinfotech.com/blog/how-to-speed-up-the-python-code/]
Weekly web development resources #70
Tags: webdev, weekly
Published: 2021-04-21 05:57:46



______

##[Design Resources](https://github.com/MohamedYoussouf/Design-Resources)
[![Design Resources](https://wwebdev-images.s3.eu-central-1.amazonaws.com/content/weekly/70/design-resources.jpg)](https://github.com/MohamedYoussouf/Design-Resources)
A curated list of design resources from design templates, stock photos, icons, colors, and more.

______

##[Creating a Smart Navbar With Vanilla JavaScript](https://css-tricks.com/creating-a-smart-navbar-with-vanilla-javascript/)
[![Creating a Smart Navbar With Vanilla JavaScript](https://wwebdev-images.s3.eu-central-1.amazonaws.com/content/weekly/70/smart-nav.jpg)](https://css-tricks.com/creating-a-smart-navbar-with-vanilla-javascript/)
Create a navbar that gets visible when the user scrolls up.

______

##[Understanding browser cookies](https://chenhuijing.com/blog/understanding-browser-cookies)
[![Understanding browser cookies](https://wwebdev-images.s3.eu-central-1.amazonaws.com/content/weekly/70/cookie.jpg)](https://chenhuijing.com/blog/understanding-browser-cookies)
A nice article that explains the basics of browser cookies.

______

##[GitHub Theme](https://marketplace.visualstudio.com/items?itemName=GitHub.github-vscode-theme)
[![GitHub Theme](https://wwebdev-images.s3.eu-central-1.amazonaws.com/content/weekly/70/github-theme.jpg)](https://marketplace.visualstudio.com/items?itemName=GitHub.github-vscode-theme)
A theme for Visual Studio Code, that is made and used by GitHub.

______

##[DirectShare](https://directshare.io/)
[![DirectShare](https://wwebdev-images.s3.eu-central-1.amazonaws.com/content/weekly/70/directShare.jpg)](https://directshare.io/)
A free and secured file transfer solution with no size constraint.

______

##[Beautiful PDFs from HTML](https://pdf.math.dev/)
[![Beautiful PDFs from HTML](https://wwebdev-images.s3.eu-central-1.amazonaws.com/content/weekly/70/pdf-html.jpg)](https://pdf.math.dev/)
A guide, that provides a basic tutorial to using paged.js.

______

##[natto](https://natto.dev)
[![natto](https://wwebdev-images.s3.eu-central-1.amazonaws.com/content/weekly/70/natto.jpg)](https://natto.dev)
A tool for fidgeting with JavaScript. Write and manipulate JavaScript expressions on a spatial canvas.

______

##[Frontend Toolkit](https://www.fetoolkit.io/)
[![Frontend Toolkit](https://wwebdev-images.s3.eu-central-1.amazonaws.com/content/weekly/70/fe-toolkit.jpg)](https://www.fetoolkit.io/)
A customizable dashboard for your recurring Frontend tasks

______

##[Wave](https://loading.io/background/m-wave/)
[![Wave](https://wwebdev-images.s3.eu-central-1.amazonaws.com/content/weekly/70/wave.jpg)](https://loading.io/background/m-wave/)
A generator for smooth gradient waves in multiple layers, that flowing slowly.

______

##[WinBox](https://github.com/nextapps-de/winbox)
[![WinBox](https://wwebdev-images.s3.eu-central-1.amazonaws.com/content/weekly/70/winbox.jpg)](https://github.com/nextapps-de/winbox)
A modern window manager for the web

______

To see all the weeklies check: [wweb.dev/weekly](https://wweb.dev/weekly)
Local Party - A website where you can create rooms and chat while watching local video files synchronized with your friends.
Tags: javascript, html, css
Published: 2021-04-21 05:52:30

# Local Party
A website where you can create rooms and chat while watching local video files synchronized with your friends.

<img src="https://imgur.com/bcdrBr4.png"/><br>

## Features

- Create watch party rooms.
- Watch videos in sync with your friends.
- Chat with your friends while watching videos.

## <img src="https://imgur.com/z5Qsm06.png"/>

## Getting Started

1) Go to [https://localparty.tk/](https://localparty.tk/)

2) To create a room, click on the create room button and enter the name you want to chat with, the room's name and select the video file. 

3) You would be redirected to the room page once you have created it. You can now share the room code with your friends and they can join with the same video file and room code.

4) To join a room, click on the join room button and enter the name you want to chat with, the room's code and select the same video file with which the host has created the party with.

5) You can view how many people are in the party by hovering over the user icon in the top right of the room page.

6) You can leave the party by clicking on the leave icon in the top left of the room page.

## Video

[![Local Party Demo](https://img.youtube.com/vi/Tw1BuJPapg4/hqdefault.jpg)](https://youtu.be/Tw1BuJPapg4)

## Media
An album of screenshots of the website can be found [here](https://imgur.com/a/wzKc2g7).

## Contributing

1) Fork
2) Clone and setup

    ``` 
    git clone https://github.com/sheldor1510/local-party.git
    cd local-party
    ```
3) Open a live server

Check out the backend API [here](https://github.com/sheldor1510/local-party-api).