teleren/devto huggingface dataset:
Dockerfile for Elasticsearch
Tags: elasticsearch, docker, linux, dockerfile
Published: 2022-05-28 08:57:00

Elasticsearch is a distributed, free and open search and analytics engine for all types of data, including textual, numerical, geospatial, structured, and unstructured.

Elasticsearch is the central component of the Elastic Stack, a set of free and open tools for data ingestion, enrichment, storage, analysis, and visualization.

It is considerably easier and faster to run elasticsearch in a container than to install it on a host server.

1)Create a docker file and add the below contents.

`# vim Dockerfile`

```
FROM centos:7
MAINTAINER vishakkv954@gmail.com
RUN useradd -ms /bin/bash elasticsearch
RUN yum -y install java-1.8.0-openjdk-devel
RUN yum -y install wget
RUN wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.0.rpm
RUN rpm -ivh elasticsearch-5.5.0.rpm
RUN mkdir /usr/share/elasticsearch/config
RUN cp -R /usr/share/elasticsearch/* /home/elasticsearch/
COPY elasticsearch.yml /home/elasticsearch/config/
COPY log4j2.properties /home/elasticsearch/config/
RUN chown -R elasticsearch:elasticsearch /home/elasticsearch/*
WORKDIR /home/elasticsearch
USER elasticsearch
EXPOSE 9200
EXPOSE 9300
CMD ["/home/elasticsearch/bin/elasticsearch"]
```
elasticsearch.yml and log4j2.properties are the updated files with the configurations needed for our elasticsearch.Place both files in the same directory where dockerfile exists.



2) Build docker image
   NB: be in the directory where dockerfile exists
   `docker build -t elasticsearh . `
   "elasticsearch is the image name"

3) Create docker container
    `# docker images` #to get the docker image id
    `# docker run -d -P 9200:9200 -P 9300:9300 --name elastic <image id>`

4) check container status
    `# docker ps`

Play with docker🥂
My first post
Published: 2022-05-28 08:23:24

Hi everyone,
I'm Stefano from Italy. Now I'm working in a garage as auto repair but my passion is to code. I started learning basic html about ten years ago. Now I have some experience with Html, Javascript, css, Php and React. In the future I hope to work as programmer from home and leave my actual job. For now I love to read many posts from this community and I want to learn as much as possibile from the others. 
Good coding to everyone!
Dark Mattr: A New VS Code Theme
Tags: javascript, vscode, theme, webdev
Published: 2022-05-28 08:16:19

There are a lot of themes on the Visual Studio marketplace and picking out the right one might sound not very important or relevant but it could actually be a very daunting task if VS Code is your daily weapon of war.

As developers, we all have our favorite plugins and extensions which are there to make our lives easier. But what about a theme? Why choosing the right one is imperative? We stare at our editor for almost 7–8 hours every day, sometimes even more. I have been using VS Code for almost 2 years now and I can assure you one thing, not every theme is friendly to the eyes.

Extremely bright colors can be really disturbing to the eyes and I have tried every popular theme there is. I would not say they are bad, some themes are really good and a few are my personal favorites but I have always felt I am still not getting the right color combination which would both be pleasing to my eyes and also make the theme look real classy.

Dark Mattr ( currently version 0.1.2) is a theme that I created using the right combination of colors and it took me 9 versions to come up with the best possible combination of colors :D .

So here is the theme:

[Dark Mattr](https://dark-mattr-theme.glitch.me/)


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

Does ergonomics really play an important part when it comes to choosing the right theme? Well, if you are not fond of colors, you can go for something really minimal but I figured since code editors are something that I spend most of my time with, why not make it a little colorful? But I made sure the colors blend in well and subconsciously give you a feeling of satisfaction and confidence while you are coding.


You are more than welcome to give this theme a try and if you happen to like it, drop some love in the form of feedback.

Happy coding fellas!
HSEG Devlog 4
Tags: unity3d, devjournal, csharp, programming
Published: 2022-05-28 08:03:48

Now, I know the approach I want to take for the better planet generation. But before I can do that, I need to be able to simulate gravity between multiple bodies. And before I can do _that,_ I need a proper understanding of C# and Unity.

At the time of me writing this, I am about halfway to my goal in terms of how much I understand, and still working on it.


![Chair generator.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bpfs2b8e308n50higvva.gif)

## This concludes devlog posts of things that have already happened.
Setting up your first ReactJS & Firebase Auth project
Tags: javascript, programming, beginners, react
Published: 2022-05-28 08:01:29

Nowadays, security is very important on websites and apps. Sometimes, developers make their own backend incorporating their own custom security methods. Other developers use various cloud platforms so that they don’t need to worry about security logic, and these platforms help developers with most secure ways of authenticating users.

We are going to see how you can use Firebase auth service to secure your react APP.

## Setting up Firebase

First you will need to set up our own Firebase project through the Firebase Console. To get started, navigate your browser to **Firebase Console**. Make sure you are logged into your Google account.

Now, click on **Add project** and follow the simple instructions provided. Once presented with a dashboard, click on **Authentication** on the sidebar and click on Get Started to enable the module. Now you will be presented with various authentication options. Click on **Email/Password**, enable it, and save it. We will come back later, let create our react app first.

## Setting up React project

Navigate to your terminal and use _npx create-react-app appname_ to create a new react app.
Next lets install firebase and react router dom: _npm install firebase react-router-dom react-firebase-hooks_ 

## Integrating Firebase into our React app

Now lets go back to the Firebase Console dashboard, click on **Project Settings**. Click on the third icon (</>) to configure our Firebase project for the web. Here you will see a config file. Copy the config. Create a new file in the src folder named firebase.js, import firebase modules, and paste the config file here.
Next we will initialize our app and services so that we can use Firebase throughout our app. This will use our config to recognize the project and initialize authentication and database modules.

With this on your react app you can now start to create login and signup forms and use the firebase authentication module.
A Nice Developer Joke For Today
Tags: jokes, dailydeveloperjokes
Published: 2022-05-28 08:00:08

---
title: "A Nice Developer 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/5e12594a73e61.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 did the document store go out of business?

___A:___ It had NoSQL.
 -->
HSEG Devlog 3
Tags: devjournal, unity3d, gamedev, design
Published: 2022-05-28 07:58:32

...and that problem was that no matter how large you made a planet, it would be pretty terrible quality up close.
![Bad quality up close.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8jtbxyxj5sysdiiafg7r.png)
That is no good. I need planets you can explore from the surface, not planets you only look at from afar.
All of that work, just to have to delete it all and take a different approach. Tis the life of development.
HSEG Devlog 1
Tags: devjournal, github, showdev, design
Published: 2022-05-28 07:32:17

## **These first few Devlog posts are things that were done before I joined this platform.**

I started this project off by making a GitHub project page for it. Listing off all of the ideas I had off the top of my head at the time. ![HSEG Project Planning Page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5en7llopz08fk3wnwgs3.png)
 
You can keep up to date with any changes I make to the planning here: https://github.com/users/Megallix/projects/2/views/2

Something I know for certain about this game, is that I want there to be a point where even _I, the developer_ am unsure what someone could find out there.
On top of that, I want to create some serious AI lifeforms that will create their own civilizations which players can meet and explore.
This is a **hardcore** game, so I need to make many hazards. Things such as black holes, fast moving space rocks, other players, hostile AI, planetary weather, space weather, whatever, there needs to be a multitude of ways a player can die.
It will be hardcore in the sense that, once you die you may start over from a new, blank file. Each player will be given a "true name" assigned to their file. Their actual usernames remain anonymous (though, there will be ways to identify your friends). Logging discoveries will be done through an "in game forum" of sorts. Once you die, your legacy, your discoveries, your impact on the universe and the database, all remain, but you can no longer change that impact in any way and begin anew with a new "true name".
Python Lists
Tags: programming, tutorial, python, beginners
Published: 2022-05-28 07:53:33

Lists are a collection of data or the same or different data types that can be stored in a systematic part of the memory.
A way of creating an empty list in Python is by equating an identifier to square brackets
I.e 
Numbers= []
To create a list 
Code
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/spugbiblflvurqoclypg.png)
Output

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c2lktkf2wi9sm0mqaarf.png)
Code
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/039kdgmagkej0r7zb476.png)
Output
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tf7d5ipkwlg1x09bk82q.png)

On other instances or occasions, you can create a list with multiple datatypes.
Code 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tetektczapsf3ttphyv5.png)
Output
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kswbci9fswjefhy5i1m1.png)

Items in the list can be accessed 
This is done my specifying the nth item on the list, list numeration starts from zero 
So you use print(list[0]) to print the first item on the list then print(list[1]) for the second item.

Code
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rv1bdbv4bc6l02p2fwvt.png)
Output
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pu2jlwyyj5v7n3q7scd5.png)
Along with that, you can also reassign different values in place.

Code
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r1be8iqmf1txu021veaf.png)
Output
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kom0h5gz91l6kl8vxr70.png)
Now that we know how to create a list we can also alter the list by using some special keywords 

List.append(5)-the word append is to add more values to a list.
List.remove(2)- deletes the number 2 in the list.
Max(list)-in a list of integers finds the maximum number.
Min(list)-in a list of integers find the minimum number.
List.reverse()-reverses the list 
List.sort-sorts the list.
Code
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pc62mo0bzgsklu7e2jj1.png)
Output
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xxpvqp6mmvm743s4mlyi.png)
Lists are very useful in programming as we will see in later lessons.
Thanks for reading, like, share, comment.
Must have for a portfolio ?
Tags: portfolio, webdev, discuss
Published: 2022-05-28 07:10:57

Hey!

I'm building my portfolio, since I need, as a freelance, to find a new mission after many years. I needed to build something to have a background of my last missions.

I'm starting to make a figma before any code.

I need to speak about my last clients with their missions and my personal projects.

What am I missing?
Did you know you can view chrome devtool for a mobile site?
Tags: webdev, programming, todayilearned
Published: 2022-05-28 07:03:38

Chrome devtools is a great resource for web developers. With devtool, developers can view console logs, errors messages, local storage, session storage and view the source code of a website.

You can access these tools by pressing F12 or right clicking on a web page and clicking 'inspect'. But how can you view them for mobile? 

## How can I access devtools on mobile?
You can't view devtools directly on mobile but you can connect the device to a PC via USB and see dev tools for each browser tab open. 

So how do you do that? 
### Enable developer mode
First let's enable developer mode on your *android* device. This is done by opening up your phone settings and search "Build number". Once you find it, tap the build number several times. 
Developer mode has been enabled. Now search for "usb debugging" in your settings and enable. You have now set up your developer mode.

### Connect to your PC
With developer mode enabled, connect your phone to your PC with a USB. 

### Open up Chrome dev tools
Open up chrome on your PC and navigate to `chrome://inspect/#devices`. You will see the connected devices here and all the chrome tabs open on your mobile device.

If you right click on the tab and click `inspect tab` you now have access to all the developer tools  as if you are viewing the site on mobile.

Isn't that awesome!! 

To say thank you, you could buy me a coffee?

[![Buy Me A Coffee](https://cdn.buymeacoffee.com/buttons/default-black.png)](https://www.buymeacoffee.com/lukeecart)
Know the difference between `rails new` with flags
Tags: rails
Published: 2022-05-28 06:16:23

---
title: Know the difference between `rails new` with flags
description: I just created a repository to check the differences in the generated code depending on the flags specified in rails new.
published: true
tags: rails
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kf3ds7e4sqzahx6k0v6y.jpg
---

Whenever I do `rails new`, I always have to check the effect of `--skip-xxx`, so I created a repository.

## What I made

- https://github.com/snaka/rails_new_flags

In this repository, the code output from running `rails new` with the `Rails version` and `flag` combination can be referenced by git tags.

The name of the tag is in the form `{Rails version}-{flag}`.

For example, Rails 7.0.1 code output with `--minimal` can be referenced by the tag `7.0.1-minimal`.

Currently, the supported Rails versions are as follows

- 6.0.x
- 6.1.x
- 7.0.x

## Usage

It may be obvious when you see it, but just in case, here is how to use it.

For example, in Rails 7.0.1, there is a flag called `--api` and you want to find out how specifying it changes the generated code.

[Table in README.markdown](https://github.com/snaka/rails_new_flags#summary)(Following is an excerpt) to the `--api` flag line, click on the :mag: at the `7.0.1` position to see the diff on GitHub.

| flag | 6.0.4.4 | 6.1.4.4 | 7.0.1 |
| --- | --- | --- | --- |
| --api | [🔍](https://github.com/snaka/rails_new_flags/compare/6.0.4.4..6.0.4.4-api) | [🔍](https://github.com/snaka/rails_new_flags/compare/6.1.4.4..6.1.4.4-api) | [🔍](https://github.com/snaka/rails_new_flags/compare/7.0.1..7.0.1-api) |

(Diff. display as of 2022-01-08)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/8219/cf8ebd7b-c969-2b2c-ba67-f2185d890fe8.png)

From the above, we can see that specifying `--api` makes the following difference in the output results.

- Gemfile に `sprockets-rails`, `importmap-rails`, `turbo-rails`, `stimulus-rails`, `jbuilder`, ... (Omitted) ... is removed
- Parent class of `ApplicationController` changes from `ActionController::Base` to `ActionController::API`.
- Middleware configuration changes to the minimum required by adding `config.api_only = true` setting.
- And so on...

You can also compare arbitrary Tags by writing your own URLs. For more information on how to compare tags on GitHub, please refer to the following document.

- [Comparing commits - GitHub Docs](https://docs.github.com/en/pull-requests/committing-changes-to-your-project/viewing-and-comparing-commits/comparing-commits)
Python Scheduler
Tags: python, schedule, tutorial, beginners
Published: 2022-05-28 06:13:34

## A scheduler
 is used to run the function periodically using different types of patterns and syntaxes.  Normally, if a task has to be performed every time after a specific time difference, a scheduler can be used. 

Suppose you have a report which needs to be generated at 10 AM daily, this process can be triggered using a scheduled program. 

Python has a “schedule” library that can help you perform this scheduling using very friendly syntaxes.

Official documentation of this library is available at https://schedule.readthedocs.io/en/stable/

To use this library you will need to install it using 

```
pip install schedule
```

Now you are ready to schedule the jobs.

Let's try a simple example

```
import schedule
import time

# This method is the actual processing that we want to accomplish
# with every scheduled execution
def job():
    print("Job ran")

# This defines the frequency to run the program
schedule.every().hour.do(job)

# while loop to keep the program running in the memory
while True:
		# it will check if any execution is pending, 
		# if yes it will start execution
    schedule.run_pending()

		# program will sleep for 1 second and then will again start while loop
    time.sleep(1)
```
The above program will run every hour and print the line “Job ran”.

Let's look at some more examples to schedule job syntaxes

Scheudled job with frequency

```
# Run job every 15 seconds
schedule.every(15).seconds.do(job)

# Run job every 15 minutes
schedule.every(32).minutes.do(job)

# Run job every 12 hours
schedule.every(12).hours.do(job)

# Run job every 5 days
schedule.every(5).days.do(job)

# Run job every 2 weeks
schedule.every(2).weeks.do(job)
```

Scheduled job for specific time

```
# Run job every minute at the 45th second
schedule.every().minute.at(":45").do(job)

# Run job every hour at the 10th minute
schedule.every().hour.at(":10").do(job)

# Run job every day at specific time

# Everyday at 11 Hour 11 Minutes
schedule.every().day.at("11:11").do(job)

# Everyday at 11 Hour 11 Minutes 11 Second
schedule.every().day.at("11:11:11").do(job)

```

Checkout the working demo at
https://replit.com/@AshutoshSharm35/Python-Scheduler-Demo?v=1


![Working Demo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tuyviz0d56g93d1hpyk0.gif)
5 things you need to know about <Input> tag
Tags: webdev, css, html, javascript
Published: 2022-05-28 06:03:43


Hi folks, how are you holding up? I hope you’re doing good. In this blog, I’m gonna share some properties about the `<input>` tag that I wish I’d known sooner.

### 1. Focus: 
	
The `:focus` selector comes into action when we click the input element and we can type content in the input field. 

Suppose we don’t have a border in our `<input>` tag, we can implement this using:

```css
input {
    border: none;
} 
```
But, when we begin to type content in our input label, we get those borders back again. So, a simple solution to this problem will be:

```css
input:focus{
  outline: none;
}
```
### 2. Autocomplete: 

Autocomplete helps us to complete input fields, but sometimes it becomes irritating and suggests wrong details. A method to turn off autocomplete would be:

**React:**
```html
<input type=”text” autoComplete="new-off">
```
**HTML:**
```html
<input type=”text” Autocomplete="off">
```
### 3. File input:

Sometimes, text content is not what we want to send, it might be images, gifs, videos, etc. We can send this type of data using the `type="file"` attribute. 

```html
<input type="file">
```
Usually, we use `e.target.value` to access the input value, but here we can access the file data using ` e.target.files[0]`. It contains the details of the file like its name, path, etc in form of an object.


![input file](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nbulcb9aoiw7pqhrx7kg.png)

The "no file chosen" text is black by default, you can change this to any color using  `input[type='file'] `.

```css 
input[type='file'] {
  color: rgb(255, 255, 255)
}
```
### 4. Autofocus 

The input autofocus attribute specifies that an input field should automatically get focus when the page loads. Example: While editing/making blogs, when we land on the edit blog page, we would want the input to be in focus.

```html
<input type="text" autofocus>
```
### 5. Input list attribute

Want the user to choose from a specific list of options? We can use  the list attribute. Let’s look at an example.

```html
<form onSubmit={function}>
  <input list="anime" name="anime">
  <datalist id="anime">
    <option value="Naruto">
    <option value="My Hero Academia">
    <option value="Death Note">
    <option value="Dragon Ball Z">
    <option value="Attack on Titan">
  </datalist>
  <input type="submit" >
</form>
``` 

That’s it, folks, I hope you enjoyed these tips and would incorporate these small techniques in your next projects :)

If you know of other tips/tricks, let me know in the comments. Thanks for reading :)

Connect with me on -
- [Twitter](https://twitter.com/fidalmathew10)
- [Github](https://github.com/FidalMathew)
- [Linkedin](https://www.linkedin.com/in/fidalmathew/)
Remove duplicates in unordered array with Java using streams
Tags: java
Published: 2022-05-29 00:35:20

---
title: Remove duplicates in unordered array with Java using streams
published: true
date: 2022-05-28 06:00:00 UTC
tags: java,java
canonical_url: https://jsedano.dev/java/2022/05/28/remove-duplicates-in-unordered-array.html
---

Heres how to remove duplicates from an unordered primitive int array on Java using streams.

You can find the complete code for this here: [remove\_dupes\_unordered\_the\_smart\_way.jsh](https://github.com/jsedano/examples/blob/main/java-snippets/remove_dupes_unordered_the_smart_way.jsh).

Consider the following straight forward problem, you receive a primitive int array and you need to return a new array only containing the unique elements.

Because we are using `streams` since 2014 and we know that a `Set` does not accept duplicates, we only need to collect the array into a set and back into an array.

```
int[] removeDupes(int arr[]) {
    return Arrays.stream(arr)
        .boxed()
        .collect(Collectors.toSet()).stream()
        .mapToInt(Integer::intValue).toArray();
}
```

The `boxed` method just returns an Integer stream instead of a primitive one.

Download the complete code from this post here: [remove\_dupes\_unordered\_the\_smart\_way.jsh](https://github.com/jsedano/examples/blob/main/java-snippets/remove_dupes_unordered_the_smart_way.jsh).