teleren/devto huggingface dataset:
How to find and do work that you love (Ikigai)
Published: 2021-05-30 18:09:10

This article is based on a lecture delivered by dr. Nayanapriya Gunawardhana, former general manager, supply chain excellence, Brandix, Sri Lanka. It was about work for a mission-powered by passion and was organized by Software Engineering Teaching Unit, University of Kelaniya.

####Ikigai - Reason for being

Ikigai is a Japanese concept of having a direction or purpose of you live for or your reason for being. The work consists of 'iki'('to live') and 'gai'('reason').

The opportunity to do what you love is a dream come true for many of us. But this doesn't have to be just a dream through the Ikigai exercise, we can be our own guideline to become dream true in our everyday life.

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

Those circles are overlapped at the middle. If you have something that belongs to every circle, that would be your reason for being.

* **What do you love?**
This section includes what we do or experience that brings us the most joy in life and makes us feel more alive and fulfilled. What is important is that we allow ourselves to think deeply about what we love, without any concern for whether we are good at it, whether the world needs it, or if we can get paid for doing it.
<br>

* **What are you good at?**
This section includes anything that we are particularly good at, such as skills we have learned, hobbies we have pursued, talents we have shown since an early age. This only concerns talents and capabilities, whether or not we are passionate about them, whether world needs them or if we can get paid for them.
<br>

* **What skills are in demand that you can get paid for?**
This dimension refers to the skills what someone else is willing to pay us for. Whether we can get paid for our passions or talents depends on factors such as the state of the economy, whether our passions or talents are in demand etc.
<br>

* **What does the world need right now?**
The 'world' here might be humanity as a whole, a small community you are in touch with, or anything in between. What the world needs might be based on your impressions or needs expressed by others.
<br>

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/10qloofow85pwm98ckpc.jpg)
Adapter Pattern in Java
Tags: adapter, java, pattern
Published: 2021-05-03 17:09:02

https://grokonez.com/design-pattern/adapter-pattern-java

Adapter Pattern in Java

Adapter Pattern is a <strong>Structural Pattern</strong> in which, an interface of a class is converted into another interface that Client expects to work. With Adapter Pattern, we can reuse existing code without changing it.

<!--more-->
<h2>I. OVERVIEW</h2>
Adapter Pattern defines an <strong>Adapter</strong> that can adapt a target class/interface (that we called <strong>Adaptee</strong>) to <strong>Client</strong>'s requirement.
<img src="https://grokonez.com/wp-content/uploads/2017/03/adapter-pattern-overview.png" alt="" width="552" height="281" class="alignnone size-full" />
The <strong>Adapter</strong> contains an instance of <strong>Adaptee</strong> (also hides it from <strong>Client</strong>). It helps that, <strong>Client</strong> calls <strong>Adapter</strong> methods without knowing anything about <strong>Adaptee</strong>, then <strong>Adapter</strong> uses <strong>Adaptee</strong> instance inside to call its appropriate methods.
<img src="https://grokonez.com/wp-content/uploads/2017/03/adapter-pattern-diagram.png" alt="" width="700" height="152" class="alignnone size-full" />
<h2>II. PRACTICE</h2>
<h3>1. Project Overview</h2>
We have <strong>Person</strong> <em>'fullname'</em> information, but Client want to use <em>'first name'</em> and <em>'last name'</em> as <strong>Customer</strong> information. So we create a <em><strong>Person-to-Customer-Adapter</strong></em> that Client will work with.
<img src="https://grokonez.com/wp-content/uploads/2017/03/adapter-pattern-demo.png" alt="" width="700" height="318" class="alignnone size-full" />
<h3>2. Step by Step</h2>
2.1- Create <code>Person</code> class:
<pre><code class="language-java">
package com.javasampleapproach.adapter.pattern;

public class Person {
	private String fullName;

	public Person(String fullName) {
		this.fullName = fullName;
	}

	public String getFullName() {
		return fullName;
	}

	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	@Override
	public String toString() {
		return "Person [fullName=" + fullName + "]";
	}
}	</code></pre>
2.2- Create <code>ICustomer</code> interface:
<pre><code class="language-java">
package com.javasampleapproach.adapter.pattern;

public interface ICustomer {

	public String getFirstName();
	public String getLastName();
}	
</code></pre>
2.3- Create <code>PersonToCustomerAdapter</code> class that implements <code>ICustomer</code> interface:

More at:

https://grokonez.com/design-pattern/adapter-pattern-java

Adapter Pattern in Java
Running Machine Learning Model On top of Docker Container.
Published: 2021-05-30 17:56:08

**First build model in Jupyter or any other dev environment.
sample code:**

import pandas
db = pandas.read_csv('marks.csv')
y = db["marks"]
x = db['hrs']
x = x.values
x = x.reshape(4,1)
from sklearn.linear_model import LinearRegression
mind = LinearRegression()
mind.fit( x,  y)
mind.predict([[ 6 ]] )
mind.coef_

**import joblib
mind = joblib.load('marks.pk1')
y = int(input("enter no. of hours: "))
output = mind.predict([[y]])
print(output[0])**

save the model as savemodel.py file.

**open WinSCP, to transfer these files(marks.csv,savemodel.py) from windows to VirtualBox Linux.**

Now open your linux terminal.

**systemctl start docker**     # this will start docker service

**docker run -dit --name ML_model centos**      # this will pull and run docker with latest centos version and having a interactive terminal

**docker attach ML_model**    # this will attach docker container running

we have to install some packages now:
**yum install python3**
**pip install scikit-learn**

now go to Base linux os for copying Ml model saved .pk1 file to running docker container.

**docker cp savemodel.py ML_Model_check:/**  # this will copy model file from base os to container

now come to container, 

**python3 savemodel.py**    # this will run the model file and ask for input, give input and get the prediction.
How to set Horizontal ScrollView inside Horizontal RecyclerView?

Published: 2021-05-30 17:42:09

I have searched in similar questions and tried several answer without solving .. I have Horizontal Recycler View displaying city names and some data the problem is that I put canvas bar chart or RV chart as figure below inside Main RV adapter at every position and to scroll this chart I put the chart in Horizontal Scroll View to see data of chart in long Horizontal direction while scrolling this chart from right to left and vise versa but actually it doesn't scroll Horizontal only Main Recycler view scroll Horizontal to display city when touch it and for this chart inside RV didn't scroll when touch it to scroll (freeze) is recycler view only scroll in horizontal and prevent any other scroll inside its child??
Day 97
Tags: 100daysofcode, programming
Published: 2021-05-30 17:29:00

Day 97/200 of #200DaysOfCode #100DaysOfCode


- Solved four problems on Codewars.

1 - [Friday the 13ths](https://www.codewars.com/kata/540954232a3259755d000039) (6 kyu) || [MySolution](https://github.com/Rb-wahid/My-Coding-Experience/blob/master/src/Codewars/6%20kyu/FridayThe13ths.js)

2 - [Pretty date](https://www.codewars.com/kata/53988ee02c2414dbad000baa) (6 kyu)  || [MySolution](https://github.com/Rb-wahid/My-Coding-Experience/blob/master/src/Codewars/6%20kyu/ProofRead.js)

3 - [Elapsed Seconds](https://www.codewars.com/kata/517b25a48557c200b800000c) (7 kyu)  || [MySolution](https://github.com/Rb-wahid/My-Coding-Experience/blob/master/src/Codewars/7%20kyu/ElapsedSeconds.js)

4 - [Jubilee Year](https://www.codewars.com/kata/5b3f8ac282417eb3180000e6) (7 kyu)  || [MySolution](https://github.com/Rb-wahid/My-Coding-Experience/blob/master/src/Codewars/7%20kyu/JubileeYear.js)
Disable opening dev console in browser using javascript
Tags: javascript, webdev
Published: 2021-05-30 17:20:39

# How to disable opening dev console in browser
In order to disable dev console in browser, you need to disable two things.
1. Right click
2. **ctrl+shift+I**

## Disable right click
```js
document.addEventListener('contextmenu', event => event.preventDefault());
```
For more info [visit](https://stackoverflow.com/questions/737022/how-do-i-disable-right-click-on-my-web-page)

## Disable `ctrl+shift+I`
```js
document.body.addEventListener("keydown", (e) => {
            if(e.ctrlKey && e.shiftKey && e.key == "I")
                e.preventDefault();
        })
```
For more info [visit](https://stackoverflow.com/questions/7559409/how-to-disable-browser-developer-tools)

## Note:
There is still some ways to get around this technique and user can open dev console on your website, can you guess what it is?
You'll Never See Your Face
Tags: javascript
Published: 2021-05-30 17:06:28

Sure you can see a reflection, you can see a picture, a friend can describe it to you in detail for hours, but you can never perceive your face directly. 

Great. What does this have to do with Javascript?

Well, the other day I was practicing solving algorithms, and I stumbled across something that was a bit mystifying. I was trying to do this:
```
arr.find(el => el === [2,3])
```
It returned undefined even though I was looking at the input data and knew that there was a matching element. After triple checking everything else around this find() method I knew it must have something to do with the comparison operators and how Javascript treats arrays. I found a solution for this particular problem:
```
arr.find(el => el.length === 2)
```
But I made a note to come back to it later and here we are. My first step to clearing this up was to hop in the console and play around with array comparison a bit:
```
let test = [2,3]
undefined
test == [2,3]
false
typeof test === typeof [2,3]
true
test === [2,3]
false
[2,3] === [2,3]
false
```
Hmmm, seems like two arrays with the same values in the same order are not equal to each other. My reflection isn't my face!

Well, sort of. After a bit of digging, turns out that the comparison operators are only meant to work on primitive data types. When you use them on objects or arrays(which inherit from Object) Javascript returns true only if the compared values refer to the same instance. So:
```
let a = {name: "bob"}
let b = {name: "bob"}
a === b
false
a === a
true
b === b
true
//but you can always do
a.name === b.name
true
//because both name properties return strings
```
Which makes a lot of sense. Objects and Arrays are structured datatypes, and if you want to compare two instances for equality you should consider exactly what it means for two Arrays or Objects to be equal. The answer will be different depending on the situation. In certain situations, you may want to consider two arrays equal that have the same elements but in a different order. In other situations, you may want to consider two objects not equal because one has the k/v `name: null` and another has the k/v `name: undefined`.

So there you have it. If you want to compare objects or arrays, just remember you need to loop through their values in a way that will allow you to use the comparison operator on primitive datatypes.
Implementing Smooth Scroll
Tags: react, navbar, smoothscrolling, navigation
Published: 2021-05-30 16:34:58

When I initially built the site for [Adrian’s Dream](https://adriansdream.netlify.app/), I used `react-router-dom` to set my routes for each individual page. As I was designing and building though, I realized that what I really wanted was to have everything on a single page and, rather than having the navbar redirect us to a different page, I wanted it to scroll to the clicked component.   So in this post, I am going to tell you about [react-scroll](https://www.npmjs.com/package/react-scroll) and how to use it.

--------

To get started, run:
```
npm install react-scroll --save
```
to add `react-scroll` to your package.   

Now we jump to our navbar component and we change our `Link` import from:
```
import { Link } from 'react-router-dom';
```
to:
```
import { Link } from 'react-scroll';
```

*(Before we move on, we need to make sure that we have `id`s for each of the places on the page that we want to scroll to. So if you don't have those yet, go ahead and add those.)*

Now for the fun part! We're going to actually implement the functionality. Back in our navbar component, we are going to change what's in our `Link` tag so that each one looks as follows:

```
   <li className='nav-item'>
       <Link
       to='about'
       className='nav-links'
       onClick={closeMobileMenu}
       spy={true}
       smooth={true}
       offset={-70}
       duration={500}>
           ABOUT
       </Link>
  </li>
```

To quickly break that down:
* We are linking `to` our `id`
* We have our `className`
* We set our `onClick` to close the menu when it is in mobile view (no applicable for desktop view)
* We set `spy` to `true` (which makes Link selected when scroll is at its targets position)
* We set `smooth` to `true` (which sets the animation)
* The `offset` makes up for any additional pixels that need to be scrolled due to padding or something, and the `duration` is how long (in milliseconds) it is going to take.

**And honestly, that's it!** Set that for each `nav-item` and you've got yourself a smooth-scrolling page!

*Please check out [Adrian’s Dream](https://adriansdream.netlify.app/) for any of your crafting needs! It's a wonderful company with a meaningful story.*
Greatest Common Divisor - Javascript Problem

Tags: javascript
Published: 2021-05-30 16:31:12

I am stuck explaining a solution to myself and I need help.

Question: 

Write a function gcd that takes two natural numbers and calculates their gcd.
Example: gcd (6, 15) should return 3.


Answer:

function gcd (a,b) {

if ((typeof a !== 'number') || (typeof b !== 'number'))
return false; 

a = Math.abs(a); 
b = Math.abs(b); 

while (b) {
let c = b; 
b = a % b; 
a = c; 
}
return a;

};


Explanation:

> we declare a function 'gcd'
> it has 2 parameters: 'a' and 'b'
> we first open an if statement to check if our condition is true
> we want to know if typeof a or typeof b is not a number
> if our condition is true, meaning if typeof a & typeof b are not a number and a string, boolean or any other data type, then we return false and end the function 
> if our condition is false, which it is, as both (typeof a and typeof b) are numbers then we want to execute the following code
>>> we want to convert our two parameters 'a' & 'b' to absolute positive values
>>> we do that by using Math.abs(a) and Math.abs(b)
>>> we initialize the variable a & b by the output we get from using the Math.abs method on a & b
>>> we then open a while statement
>>> this while loop will loop through a block of code as long as a specified condition is true
>>> if the specified condition is false then the statement after the while loop will be executed
>>> our condition is to check if b is a truthy or falsy value
>>> if it is true then we want to run the block of code 
>>>> we create a temporary variable 'c'
>>>> we initialize it with the value of 'b'
>>>> we then use the modulo / remainder operator by dividing a by b
>>>> we store the result in b


Help: I need assistance understanding as I am blank from this point onwards.

Thank you in advance !!
SQLite, Perl, and a Boolean
Tags: programming, perl, sql
Published: 2021-05-30 16:27:02

I’ve [written](https://dev.to/fgasper/use-sys-binmode-4e6o) [several](https://dev.to/fgasper/perl-s-svpv-menace-5515) [articles](https://dev.to/fgasper/perl-unicode-and-bytes-5cg7) [now](https://www.perl.com/article/json-unicode-and-perl-oh-my-/) about the trials and tribulations of character encoding in Perl. Having gained the knowledge I have, I’ve also been finding bugs in libraries we use at $work and sending patches to their maintainers.

The latest one is [DBD::SQLite](https://metacpan.org/pod/DBD::SQLite), CPAN’s self-contained SQLite binding. It’s a great library that I’ve used for years, but I recently noted two problems in it:

1) In its default configuration it used the `SvPV` macro to translate Perl strings to C strings, which is bad for reasons I detailed in “[Perl’s SvPV Menace](https://dev.to/fgasper/perl-s-svpv-menace-5515)”.

2) In its (non-default) “unicode” configuration it used a “naïve” method of UTF-8 decoding that neglects validation. This mechanism can corrupt Perl’s internals by making it mistake invalid UTF-8 sequences for valid ones.

Neither of these is trivial to fix: applications may depend on the `SvPV` problem—what one coworker of mine calls a “load-bearing bug” 😀—while adding UTF-8 validation entails a performance hit.

In reality, DBD::SQLite needed at least 4 modes of translating between Perl and C strings:

1) The current (“load-bearing-buggy”) default.
2) Same as #1, but use `SvPVbyte` to avoid the `SvPV` bug.
3) Current “naïve unicode” behaviour.
4) A “non-naïve unicode” mode that validates incoming UTF-8.

(I eventually made two variants of this last one: one that just warns on invalid data, and the other that throws an exception.)

There was another problem, though: DBD::SQLite’s interface for controlling this was a boolean. That meant only two modes were even _possible_!

This exemplifies a principle a mentor of mine taught me years back: **avoid boolean parameters.** They restrict your ability to add additional configurations.

(And for pity’s sake, abhor _unnamed_ booleans in particular! What does the 0 in `open_file($path, 0)` mean??)

To fix this [my pull request](https://github.com/DBD-SQLite/DBD-SQLite/pull/80) had to deprecate the existing `sqlite_unicode` parameter. It’s an unfortunate step that’ll produce new warnings in existing applications, but the “omelet” here justifies the “broken egg”.
When do i use ruby on rails ?
Tags: ruby, rails, webdev
Published: 2021-05-30 16:19:57

I am trying to put together the best possible web development process for a team i am trying to build. I am completely self taught web developer and whats most confusing for me is choosing the development stack. I have built complex websites with just vue js and firebase only. I have also built websites with just webflow, vuex and firebase only.

But i have no idea if this is the efficient way. I heard ruby on rails makes web development easier with its MVC model. If i have to learn it i will, but is it necessary ?

What role does ruby on rails play in the whole web development process? and if i can build a website without it, why should i use it ? What exactly is the best development stack if you are building a website like etsy or instagram ?
The Art of Debugging - Intro
Tags: debugging
Published: 2021-05-30 16:05:30

I recently started a Ghost blog, writing about debugging. My basic thesis is that debugging, like programming, is a technical skill that anyone can learn. However debugging well, like programming well, is as much art as it is skill.

In my long career as a software developer and architect, I have had to debug a lot of things. And it continually amazes me, when working with others on a problem, how some people just get lost trying to get at the root of a problem. What seem like obvious next steps elude them.

So this blog is about helping people see the forest for the trees. It shares what I have learned over many years, and many problems, hopefully demonstrating the core concepts of effective debugging in whatever language or problem domain you happen to be in.

If this sounds like something you are interested in, I invite you to subscribe at https://debugmsg.io/. And if you are not interested, but think you know someone that may, please let them know about it.
How to Host a Python Web App
Tags: python, webdev
Published: 2021-05-30 15:22:53

You might have a great idea for a web application, but you’re not sure how to turn it into a reality. 

Your options for hosting your app are either building your own hosting environment from scratch or using a third party’s services.

I don't recommend opening up your local network to the internet. While technically possible, this comes with a lot of security risks. Instead I recommend using a third party.

## VPS

You could spinup a VPS on Vultr. While easy, this gives you the burden of maintaining the system and dealing with all the security problems that come along with it.

You need to choose which operating system to use, or which flavor of Linux. Which web server. Harden your server, block fake ssh logins etc. It also requires you to learn the [command line](https://bsdnerds.org/what-is-linux-shell/). 

If you're new to this, this sounds like a lot of work. Is there an easier way, if you just want to host a Python App and deploy your code to the web?

## Host Python

You can host a Python web application using PythonAnywhere. PythonAnywhere is a Python hosting service.

It’s very inexpensive, and it offers some neat features like a super-simple setup, easy-to-use terminal, great documentation, and the ability to expose your app through a root domain (without an extra charge).

[Python Anywhere](https://www.pythonanywhere.com/?affiliate_id=00535ced) lets you deploy an app with one click, not having to worry about maintaining any server.

Deploying a Python app to the web can be a challenge. There are many different frame works you can use. You could use [Flask](https://pythonbasics.org/flask-tutorial-hello-world/), [Django](https://pythonbasics.org/django-web-app/) or another web framework.

Then you probably need a database system. Do you use [MySQL](https://pythonspot.com/mysql-with-python), SQLite or something else?
Positioning text on image/div using css position and transform properties
Tags: css, webdev, javascript, html
Published: 2021-05-30 14:02:35

**Use Case :**

Sometimes we need to put some text on image/div on different positions. We can do this by using positions like below

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

**HTML**


```
<div class="container">
      <div class="top-left">Top Left</div>
      <div class="top-right">Top Right</div>
      <div class="center">Center</div>
      <div class="bottom-left">Bottom Left</div>
      <div class="bottom-right">Bottom Right</div>
 </div>
```


**CSS**

```
.container {
  font-size: 20px;
  color: red;
  font-weight: bold;	
  background-image: url("https://i.picsum.photos/id/1/200/300.jpg?hmac=jH5bDkLr6Tgy3oAg5khKCHeunZMHq0ehBZr6vGifPLY");
  background-size: cover;
  width: 500px;
  height: 500px;
  position: relative;
}

.top-left {
  position: absolute;
  top: 15px;
  left: 50px;
}

.top-right {
  position: absolute;
  top: 15px;
  right: 50px;
}

.bottom-left {
  position: absolute;
  bottom: 15px;
  left: 50px;
}

.bottom-right {
  position: absolute;
  bottom: 15px;
  right: 50px;
}

.center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
```


Thanks for reading this. You can follow me on YouTube

{% youtube w_xjs9WHg3E %}
What's your experience with VSCode for Java development?
Published: 2021-05-30 13:47:41

Anyone using VSCode for Java development?

I've been trying to set it up, it's partially working, looks like I would go back to good old IntelliJ.

Have you tried it? Did you stick on with it?

PS: VSCode is a great TextEditor + Git + Terminal + Docker + File Comparison Tool for me at work, where I mostly write Java in IntellIj.
Amazing Button Hover Using HTML & CSS
Tags: html, css, webdev, beginners
Published: 2021-05-30 13:46:44

Hello Guys,

Today I created a Amazing Button Hover Effect Using HTML & CSS. this hover effect is simple but it looks amazing. I hope you like this also comments about your thoughts.

For more content follow me on Instagram  [@developer_nikhil27](https://www.instagram.com/developer_nikhil27/).

Thank you!

{% codepen https://codepen.io/NikhilBobade/pen/MWpOvKy %}