teleren/devto huggingface dataset:
Handling Bootstrap Dropdowns in Selenium
Tags: selenium, java, automation, testing
Published: 2020-05-09 11:49:52

Handling dropdowns usually involves 4+ lines of code and there are chances of code duplication. Below is the code which makes it easier for us to handle all kinds of dropdowns (single select, multi select, starting with //select tag, starting with //div or other tags etc.) in 2 lines.

Below is the code:
```java
package com.qa.TestCase;

import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;

import io.github.bonigarcia.wdm.WebDriverManager;

public class HandleBootStrapDropDownUsingStreams 
{
	public static WebDriver driver;
	
	@Test
	public void bootStrap() throws InterruptedException
	{
		WebDriverManager.chromedriver().setup();
		driver = new ChromeDriver();
		driver.manage().window().maximize();
		driver.manage().deleteAllCookies();
			
		driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
		driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
			
		driver.get("https://www.jquery-az.com/boots/demo.php?ex=63.0_2");
			
		driver.findElement(By.xpath("//button[@class='multiselect dropdown-toggle btn btn-default']")).click();
		
		By bootStrapDropDown = By.xpath("//ul[contains(@class,'multiselect-container')]//li//a//label");
		
		HandleBootStrapDropDownUsingStreams.printBootStrapDropDownValues(bootStrapDropDown);
		
		HandleBootStrapDropDownUsingStreams.selectValueFromBootStrapDropDown(bootStrapDropDown, "HTML");
		HandleBootStrapDropDownUsingStreams.selectValueFromBootStrapDropDown(bootStrapDropDown, "CSS");
		HandleBootStrapDropDownUsingStreams.selectValueFromBootStrapDropDown(bootStrapDropDown, "Angular");
		
	}
	
	//Function to Select a Value from BootStrap Drop Down using Streams.
	public static void selectValueFromBootStrapDropDown(By locator, String value)
	{
		List<WebElement> dropDownValues = driver.findElements(locator);
		dropDownValues.stream().filter(values -> values.getText().matches(value)).forEach(values -> values.click());
	}
	
	//Function to Print BootStrap Drop Down Values using Streams.
	public static void printBootStrapDropDownValues(By locator)
	{
		List<WebElement> dropDownValues = driver.findElements(locator);
		dropDownValues.stream().map(values -> values.getText()).collect(Collectors.toList()).forEach(values -> System.out.println(values));
	}
}
```
How to install Letsencrypt Certificates with Certbot in Ubuntu
Tags: ubuntu, security, letsencypt
Published: 2020-06-15 14:56:44

---
title: How to install Letsencrypt Certificates with Certbot in Ubuntu
published: true
date: 2020-05-09 11:37:42 UTC
tags: ubuntu, security, LetsEncypt
canonical_url: https://www.ma-no.org/en/how-to-install-letsencrypt-certificates-with-certbot-in-ubuntu-16-04
---

In this article we will explain how to install, manage and configure the SSL Security certificate, Let's Encypt in NGINX server used as proxy. This certificate is free but does not offer any guarantee and has to be renewed every 3 months.We recommend that users with shell access use the ACME client called Certbot. This can automate the issuance and installation of certificates with zero downtime. It also has expert modes for people who do not want to self-configure. It's easy to use, works on many operating systems, and has great documentation.Certbot Installation and NGINX configurationInstall Certbot's Nginx package with… 



Read on [📖!](https://www.ma-no.org/en/how-to-install-letsencrypt-certificates-with-certbot-in-ubuntu-16-04)
Bash | Find out the usage of a certain PORT
Tags: bash
Published: 2020-05-09 11:31:00

When I was trying to run acme.sh to generate SSL certification, I got an error:

```bash
[Sat May  9 18:54:10 HKT 2020] tcp port 80 is already used by 
[Sat May  9 18:54:10 HKT 2020] Please stop it first
[Sat May  9 18:54:10 HKT 2020] _on_before_issue.
```

I believe it is expected to show the service which is using port 80 in the first line, but nothing at all. I have to find out my self.

```bash
sudo netstat -tulpn | grep :80
```

I got the output:

```bash
tcp6       0      0 :::80                   :::*                    LISTEN      10541/apache2
```

Oh, yes, Apache2. I wanna shut it down temporally:

```bash
sudo systemctl stop apache2
```

Now, generate cert again:

```bash
~/.acme.sh/acme.sh --issue -d mydomain.me --standalone --keylength ec-256
```
How to face failures and critics? A Motivational Story of Kung Fu Panda
Tags: podcast, productivity, motivation, codenewbie
Published: 2020-05-09 11:15:32

{% spotify spotify:episode:75STzHeNzoD3cWgzQ5Iy7E %}

## Intro
When you start doing something there will be a hundred critics, demotivators, competitors on the way. The ones who learn from all these incidents and improve are the only ones who succeed. Success isn't easy.

In this episode dp_says talks about his important Badminton match and what he learned from it for a couple of minutes and then I narrate a motivational story about a painter Panda who is the cousin of Kung Fu Panda. This story was narrated to me by a YouTuber Hitesh Choudhary.

## What do we take away from this Podcast?
_Learn and improve on the critics, but don't ponder on them._

Hope you enjoy this episode.

- Tharun Shiv from Developer Tharun

You can find my podcasts at https://anchor.fm/developerTharun
And my YouTube Channel at https://youtube.com/c/developerTharun
Promisifying Phaser
Tags: phaser, gamedev, devdiary, showdev
Published: 2020-05-09 10:58:41

Working on web development, [promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) are a basic tool I use every day, and I feel that the old days when everybody used callbacks are long gone. Except when I'm working with Phaser!

For example, at the start of the game, I want to move the camera around so the player gets a sense of their surroundings, and then start playing the game. Phaser cameras have a `pan` method to do that, and this method receives a callback which is called on every update. In order to wait and call another method once the effect has finished, you need to check if the `progress` has reached `1`:

```js
create() {
  this.cameras.main.pan(
    this.survivor.x,
    this.survivor.y,
    4000,
    'Linear',
    false,
    (_, progress) => {
      if (progress === 1) {
        this.cameras.main.startFollow(this.survivor)
        this.play()
      }
    }
  )
}
```

This approach might be useful if I want to do something while the pan is running, but most of the time I want to wait until it's done, and it's a bit tedious to keep writing the callback, not to mention if you want to chain multiple effects: you easily run into [callback hell](http://callbackhell.com/).

So, I decided to turn this kind of Phaser methods into promises:

```js
cameraPan(x: number, y: number, time = 1000) {
  return new Promise((resolve) => {
    this.cameras.main.pan(x, y, time, 'Linear', false, (_, progress) => {
      if (progress === 1) {
        resolve()
      }
    })
  })
}
``` 

This way, thanks to async/await, the previous code looks much simpler and easier to understand:

```js
async create() {
  await this.cameraPan(this.survivor.x, this.survivor.y, 4000)
  this.cameras.main.startFollow(this.survivor)
  this.start()
}
```

The improvement is even more obvious when you are using several camera effects, tweens, and other methods that would require callbacks. Imagine how this code would look without `await`:

```js
async endScene() {
  this.cameras.main.stopFollow()
  await this.cameraFade('fadeIn')
  await this.cameraPan(0, 0, 4000)
  await this.createDialog("How strange to see northern lights so far down south.")
  await this.cameraPan(this.survivor.x, this.survivor.y, 4000)
  await this.cameraFade('fadeOut', 2000)
}
```

You can still use the original Phaser method at certain points when you need more control over the progress, but I've found this is a quick and easy way to make your Phaser games a bit more readable. Hope it helped!
Past is gone. Look forward to future.
Tags: motivation, javascript, webdev, codenewbie
Published: 2020-05-09 10:46:24

This is not a technical blog or something like that. This is to motivate all those people who have had a bad past, or those who can't get over their past. 

Today I wrote a simple Javascript code to render some radio buttons. Then  I realised may be I can create something good out of it. 

#### So I created this [Days in 2020](https://vyasriday.github.io/pages/life_in_years.html)

Hope this motivates you to make the best use of time you have. 

Happy Coding!

Thanks for reading. 😊
Built and deployed Python Telegram Bot "Yoda Speaks" on Heroku
Tags: python, telegrambot, heroku, beginners
Published: 2020-05-09 10:44:06

I made a Telegram Bot in Python which converts from English to Yoda speak and deployed it on Heroku using the Heroku CLI. For those of you who don't know <a href="https://en.wikipedia.org/wiki/Yoda">Yoda</a> is a fictional character from the Movie star wars.
<a href="https://github.com/issourav/YodaSpeaks-Telegram-Bot">Link</a> to github repo.
Wizar devlog 15 - Adding cluster on Wizar
Tags: gamedev
Published: 2020-05-09 10:31:10

As Wizar is geolocalised game I needed a map. As I use Cordova I decided to develop [a Mapbox plugin](https://github.com/dagatsoin/cordova-plugin-mapbox) years ago. It is only available for Android and it is not documented but a [demo is available](https://github.com/dagatsoin/cordova-plugin-mapbox-demo)
It implements :
- offline support
- map HTML overlay (you can put HTML on the native view)
- and now clustering
react js issue while npm start
Published: 2020-05-09 10:27:16


events.js:287
      throw er; // Unhandled 'error' event
      ^

Error: spawn cmd ENOENT
←[90m    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)←[39m
←[90m    at onErrorNT (internal/child_process.js:469:16)←[39m
←[90m    at processTicksAndRejections (internal/process/task_queues.js:84:21)←[39m
Emitted 'error' event on ChildProcess instance at:
←[90m    at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)←[39m
←[90m    at onErrorNT (internal/child_process.js:469:16)←[39m
←[90m    at processTicksAndRejections (internal/process/task_queues.js:84:21)←[39m {
  errno: ←[32m'ENOENT'←[39m,
  code: ←[32m'ENOENT'←[39m,
  syscall: ←[32m'spawn cmd'←[39m,
  path: ←[32m'cmd'←[39m,
  spawnargs: [ ←[32m'/s'←[39m, ←[32m'/c'←[39m, ←[32m'start'←[39m, ←[32m'""'←[39m, ←[32m'/b'←[39m, ←[32m'"http://localhost:3000"'←[39m ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hello-world@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hello-world@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\win7\AppData\Roaming\npm-cache\_logs\2020-05-09T10_07_04_308Z-debug.log

help me
World of WoqlCraft - Ep.7 My Frist Graph Visualization with TerminusDB
Tags: database, beginners, visualization, tutorial
Published: 2020-05-09 09:56:21

---
title: World of WoqlCraft - Ep.7 My Frist Graph Visualization with TerminusDB
published: true
description: This episode is a beginner version of World of Woql Craft (we want more people to get started). It is for people who have not used TerminusDB and WOQL before. We start form how to download TerminuDB, creating a schema, loading csv data, querying to customizing the graph view on TerminusDB console.
tags: database, beginner, visualization, tutorial
---
This episode is a beginner version of World of Woql Craft (we want more people to get started). It is for people who have not used TerminusDB and WOQL before. We start form how to download TerminuDB, creating a schema, loading csv data, querying to customizing the graph view on TerminusDB console.

[Visit our blog](https://terminusdb.com/blog/2020/01/14/my-first-terminusdb-graph-visualisation-bike-share-data/) for a text version of this tutorial.

Find the source code from our [tutorial repo](https://github.com/terminusdb/terminus-tutorials).

Join the TerminusDB community at [Discord](https://discord.gg/Gvdqw97)
Rhythmbox ile DLNA/UPnP sunucu üzerindeki müzikleri dinlemek
Tags: rhythmbox, dlna, upnp
Published: 2020-05-09 09:50:50

Evinizde çeşitli şekilde kurabileceğiniz DLNA/UPnP sunucunuz varsa ve üzerinden müzik dinliyorsanız varsayılan olarak Rhythmbox bu paylaşıma erişimi sağlayamamaktadır. Bu erişimi sağlayabilmek için ise önceliklie Grilo isimli bir eklentiyi kullanmanız gerekmekte. Bu eklentiyi kullanabilmek için aşağıdaki komut ile genel rhythmbox eklentilerini yükleyebiliyorsunuz.

```bash
sudo apt install rhythmbox-plugins
```

İlgili paketi indirdikten sonra rhythmbox üzerindeki eklenti yapılandırma sayfasından eklentiyi aktif hale getirmeniz gerekiyor.

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

Fakat eklentiyi aktif yapmanız yeterli olmuyor. Bunun için kullandığınız debian tabanlı sistem sürümüne göre rhythmbox haricinde grilo plugins'i de kurmanız gerekiyor. Örneğin Debian 10 ve Pardus 19'da aşağıdaki sürümü kurmanız yeterli olmaktadır. 

```bash
sudo apt install grilo-plugins-0.3
```

Bu adımdan sonra rhythmboxı yeniden başlattığınızda paylaşılan müzikler sol kısımda listelenebilecektir.
Use a scoped registry with Yarn
Tags: registry, yarn, github, verdaccio
Published: 2020-05-09 09:13:00

---
title: Use a scoped registry with Yarn
description: Learn how you can configure Yarn to use a different registry for scoped packages
canonical_url: https://sergiodxa.com/articles/use-scoped-registry/
published: true
tags: registry, yarn, github, verdaccio
---

When working with private packages we have a few options to use as our registry

- npm registry
- GitHub registry
- Custom registry (e.g. [Verdaccio](https://verdaccio.org))

If we decide to use the npm registry, and pay for it, we can continue using Yarn and npm without changes. And what if we use another one? And if we want to keep using the npm registry for non-scoped packages?

Enter `.yarnrc`, create this file inside the project root and write this:

```
"@company:registry" "https://npm.pkg.github.com"
```

Now every time you install a package with the `@company` scope (e.g. `@company/design-system`) Yarn will use the GitHub registry to download it instead of the public npm registry.

You can use any scope and any URL as a registry, if you setup your own Verdaccio registry under `registry.company.com` you can add:

```
"@company:registry" "https://registry.company.com"
```

And the best thing is that you can have more than one:

```
"@frontend:registry" "https://npm.pkg.github.com"
"@backend:registry" "https://registry.company.com"
```
Setup a redirect inside a project deployed to Vercel
Tags: vercel, redirect
Published: 2020-05-09 09:12:36

---
title: Setup a redirect inside a project deployed to Vercel
description: Learn how you can create a redirect in any project deployed to the Vercel platform.
published: true
tags: vercel, redirect
canonical_url: https://sergiodxa.com/articles/vercel/setup-redirect/
---

If you have had a website for a certain time most probably your links have been shared in different websites, and most of those are website you can go and update in case you decide to move a page to another URL.

[Vercel](https://vercel.com) makes solving this problem easy, first create a `now.json` file, if you don't already have one, and put this content inside:

```json
{
  "redirects": [{ "source": "/essays(.*)", "destination": "/articles$1" }]
}
```

The `redirects` key is an array with all of our redirects, inside we write an object per redirect we want to setup, and define the keys `source` and `destination`.

The `source` is a string with the pathname the user will access before its redirected, in this case I have that sergiodxa.com/essays redirects me to the `destination`, and the `destination` is another string with the target URL the user will be redirected, in my case that ise sergiodxa.com/articles, if you go, right now, to https://sergiodxa.com/essays/vercel/setup-redirect it will take you to this same page you are reading right now.

The `(.*)` let us tell to Vercel we want to catch whatever comes after `/essays`, that let use detect URLs like `/essays/vercel/setup-redirect` and not only `/essays`, this is a RegEx and whatever matches inside the parenthesis will be available for use to use in the `destination`.

And going there, the `$1` means the first element detected and caught between parenthesis by the `source`, this is what let use append whatever the user write after `/essay` and `/article` so we can correctly redirect the user.
Purge unused CSS with TailwindCSS
Tags: tailwindcss, purge, css
Published: 2020-05-09 09:12:13

---
title: Purge unused CSS with TailwindCSS
description: Learn how to use the built-in purge support of Tailwind to remove unused classes in production.
published: true
tags: tailwind, purge, css
canonical_url: https://sergiodxa.com/articles/tailwind/purge-unused-css/
---

[TailwindCSS](https://tailwindcss.com) now comes with built-in support to purge the unused CSS, to use this creeate, if you don't already have, a `tailwind.config.js` file in your project root, inside it export an object, using CommonJS syntax, and there define a property `purge` with an array of the globs to use to find which files are using Tailwind.

```js
module.exports = {
  purge: [
    "./src/**/*.{ts,tsx}"
  ],
};
```

In our example we are searching for any `.ts` or `.tsx` file inside any level of folders inside the `src` folder in the root.

We could also disable it by passing `false` instead of an array.

```js
module.exports = {
  purge: false
};
```

This is helpful if we are purging them using another tool.
Spring Boot 2.2.x with JUnit 5.x
Tags: springboot, junit
Published: 2020-05-09 09:01:45

---
title: Spring Boot 2.2.x with JUnit 5.x
published: true
description: Spring boot 2.2.x with junit 5.x and how to use it
tags: #spring-boot, #junit
---


https://medium.com/@soyphea2222/spring-boot-2-2-x-with-junit-5-x-f84547c109a7
The shebang line
Tags: perl
Published: 2020-05-09 09:00:15

 > NOTE: originally posted on 05 Sept 2014 [more](https://dev.to/ksankar/migrating-to-dev-to-ea2)

What's up with shebang.

The shebang line is added at the top of a script to specify the path to the interpreter that should be used to run the script. The syntax of the shebang line would be like this:
`#!/path/to/interpreter`

For example, let's take a perl file test.pl
```
    #!/usr/bin/perl

    use strict;
    use warnings;

    my $str = "Hello";
    my $btr = "world";

    print "\n$str $btr\n";
```

If we run this file(assuming the perl path is same is in your machine) directly ./test.pl, the perl interpreter inside /usr/bin/ would be called with the argument /path/to/test.pl

Let's play around with it a bit, try moving the shebang line to the second line of your code and run test.pl. You will get an error, which means shebang line should always be the first line of the script. You must be wondering why, it's because the Kernel will only look at the first 2 bytes at the start of the executable file, and if these are #! then the rest of the line is considered as the interpreter which will run our script. If all else fails then the kernel will try to execute the file as a shell script.

Next add some spaces between #! and the /path/to/interpreter, the program will run fine, spaces are allowed between #! and interpreter.
On one source I read a bit about space being mandatory after #! on some older versions on UNIX, but the post also says that it's 'virtually impossible to find a Unix which actually required this' :/ . I'll leave the links at the end if you want to know more about it.

Now give a wrong path and see what happens #!/usr/bah/humbub/, you will get an error 'bad interpreter'.

Is shebang line mandatory? nope. You can simply execute the file like this perl testfile.pl.
In fact there are some posts which say that it's better not to rely on it. Why? Portability. Say you wrote the perl script on your machine which has bath /alpha/beta/ then you copied it to another machine which has path /gamma/delta/ , the script breaks.
If you have the shebang line and you are calling the script with perl, then the line will simply be ignored, so it doesn't hurt to have it there.

A few tips to end the whole shebang,
Find the locations of perl in your system with this command: `whereis perl`
To know which perl is getting execute when you run perl test.pl use any of these commands
`which perl` or `perl -le 'print $^X'`

There's a lot more to read about #!, take a look through these links if you have time time.

Sources:
[faqs.org](http://www.faqs.org/faqs/unix-faq/faq/part3/section-16.html), [#!magic](http://www.in-ulm.de/~mascheck/various/shebang/), [perltricks.com](http://perltricks.com/article/5/2013/3/25/You-don-t-need-a-shebang-line)
why does react context need the provider?
Tags: react, help
Published: 2020-05-09 08:40:52

---
title: why does react context need the provider?
published: true
description: 
tags: react, help
---

Hi everyone, i wondered why using context provider is necessary and couldn't find the answer (besides that it's the react api) and therefore posted a stack overflow question with more details. I would love your opinion

 https://stackoverflow.com/questions/61693937/why-does-react-context-needs-a-provider
Free illustration, icons for websites & apps
Tags: icons, illustrations, animatedillustration, freetouse
Published: 2020-05-09 08:25:36

Here are some list of website which provides free illustrations and icons to use for websites and apps. Some of you already know about it or someone may not.

1.https://undraw.co/illustrations 
  - Open-source illustrations for any idea you can imagine and create.
  - A constantly updated design project with beautiful SVG images that you can use completely free and without attribution.

2. https://www.humaaans.com/
  - Mix-&-match illustrations of people with a design library

3. https://icons8.com/
  - Free Icons, Photos, Vectors, Music, and Tools
  - here you get all icons, photos, vectors, music and tools free to use.

4. https://www.drawkit.io/
  - Beautiful, free illustrations. Updated weekly. 100% free, hand-drawn vector illustration resources, perfect for your next project 

5. https://www.opendoodles.com/
  - Open Doodles A Free Set of Sketchy Illustrations
  - Here you can find SVG and PNG.

6. https://stories.freepik.com/
  - Customize our illustrated concepts and animate them to make your landing page, app or presentation stand out 
  - Awesome illustrations for your next project
  - You can animate illustration parts individually.

7. https://iconscout.com/free-illustrations
  - Its provides Icon, photos and Illustrations are available for personal and commercial use. 

8. https://www.pixeltrue.com/free-illustrations 
  - Free Vector Illustrations & Animations. To be the first to know about upcoming free illustrations.
  - These Free SVG Illustrations AND Lottie Animations are available for free for personal and commercial use (MIT License). In other words: you can do whatever you want with them.

9. https://www.openpeeps.com/ 
  - A hand-drawn illustration library.
  - It provides character illustration free to use

10. https://www.ls.graphics/ 
  - Free Mockups and Design Tools.
  - Exclusive and free mockups for your presentations and UI tools.
  - Assets for Photoshop, Sketch, XD, Figma, free for your commercial and personal projects.
Migrating to Dev.to
Published: 2020-05-09 08:19:08

I had a blog section setup on my site using poet(node) and some custom styling, later realised it's not easy to write or maintain it. I'll only migrate the posts which I feel are still relevant and add a note on top with the original date. 

Also working on a static website to replace my rather heavy and old portfolio/blog. Leaving a link to the original here, [wolfsbane](https://wolfs-bane.herokuapp.com/)