teleren/devto huggingface dataset:
How to Fix issue of SSL Handshake Exception on Android
Tags: android, kotlin, programming
Published: 2021-06-10 21:58:44

Recently I was working on a chat application for the android platform, everything regarding the remote/networking implementation worked flawlessly. I used the Retrofit networking library and socket.io. At the time, the base url was without SSL (that is the HTTP scheme - http://api.example.com)

Just before we rolled out the MVP for beta testing, we acquired a domain name and enabled SSL on the server. This meant the base URL scheme became HTTPS (e.g https://api.example.com).

The change on the app to use a secured URL broke the entire app. All the endpoints were not connecting to the server successfully. Basically the network handshake process between the client and server wasn't successful. Below is what the the error on the log was like

```
<-- HTTP FAILED: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
```


After doing a little research I discovered it was an issue with the server certificate not being trusted by the android system. This could be because of any of the reasons below:

1. The Certificate Authority (CA) that issued the server certificate was unknown.

2. The server certificate wasn't signed by a CA, but was self signed.

3. The server configuration is missing an intermediate CA.

In my case, this issue existed because the server certificate was self signed.

From android documentation there is a clean way to configure the app to trust your own self-signed certificates, which I will outline in 3 steps.



###Step 1
**Add the crt file to the raw folder.** 

This file will be retrieved from the server.  You can request for the digital certificate from the backend engineer. It should come in a .crt extension.

![crt file](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1luv828ildbepq5ost7l.png)



###Step 2
**Create an XML network security config file (network_security_config.xml) like below:**

![XML network security config file ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2i0nl9473kn4hla3q003.png)

`network_security_config.xml`
```
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config>
        <domain includeSubdomains="true">api.example.com</domain>
        <trust-anchors>
            <certificates src="@raw/certificate" />
        </trust-anchors>
    </domain-config>
</network-security-config>

```


###Step 3 
**Specify the network configuration settings in the `Manifest.xml` file of your application.**

![android manifest file](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l43qjdhv0ywgxudkxop8.png)

With these 3 steps done, you should connect seamlessly with the backend without any further issues.
How to import several folders with files into WordPress Media Library using wp-cli
Tags: developer, howto, linux, ssh
Published: 2021-06-10 22:08:32

---
title: How to import several folders with files into WordPress Media Library using wp-cli
published: true
date: 2021-06-10 21:54:14 UTC
tags: Developer,Howto,Linux,SSH
canonical_url: https://diegocarrasco.com/how-to-import-several-folders-with-files-into-wordpress-media-library-using-wp-cli/
---
![Code in terminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aciu6wkw1w6h626zlcs4.png)
I was in a pinch. I needed to import 12.000+ files with different filetypes into a Wordpress Media Library. The easy part, uploading the files with the folder structure to `wp-content/uploads` was done quickly, but Wordpress Media Library didn’t “see” the files. 

After some quick reading I found out that they need to be imported into the Library, and after some more reading I found wp-cli works with ‘xargs’ in Bash.

Helpful links at [Dev Notes](https://dev-notes.eu/2016/07/bulk-import-images-using-wp-cli/ "Bulk Import Images Using WP-CLI - Dev Notes") and [StackOverflow](https://stackoverflow.com/questions/4638874/how-to-loop-through-a-directory-recursively-to-delete-files-with-certain-extensi)

The command I ended using is as follows through SSH:

```bash
find /tmp -name '*.pdf' -or -name '*.doc' -or -name '*.jpg' -or -name '*.xls' -or -name '*.docx' -or -name '*.xlsx' | xarg wp media import
```

Then you can regenerate all the thumbnails using
```bash
wp media regenerate --all
```

I recommend using `screen` as the import could stop if the connection gets down, because for me on a Digital Ocean server with 2gb took around 2-3 hours.


[Source](https://diegocarrasco.com/how-to-import-several-folders-with-files-into-wordpress-media-library-using-wp-cli/)
Understanding Where an Object’s Prototype Comes From
Tags: javascript, devops, tutorial, beginners
Published: 2021-06-10 21:19:36

* Just like people inherit genes from their parents, an object inherits its `prototype` directly from the constructor function that created it. For example, here the `Dog` constructor creates the `beagle` object:
```
function Dog(name) {
  this.name = name;
}

let beagle = new Dog("Snoopy");
```
* `beagle` inherits its `prototype` from the `Dog` constructor function. You can show this relationship with the `isPrototypeOf` method:
```
Dog.prototype.isPrototypeOf(beagle);
```
* This would return `true`.

#### Understand the Prototype Chain
* All objects in JavaScript (with a few exceptions) have a `prototype`. Also, an object’s `prototype` itself is an object.
```
function Dog(name) {
  this.name = name;
}

typeof Dog.prototype; // yields object
```
* Because a `prototype` is an object, a `prototype` can have its own `prototype`! In this case, the `prototype` of `Bird.prototype` is `Object.prototype`:

* How is this useful? You may recall the `hasOwnProperty` method from a previous post:
```
let beagle = new Dog("Snoopy");
beagle.hasOwnProperty("name");
```
* The `hasOwnProperty` method is defined in `Object.prototype`, which can be accessed by `Dog.prototype`, which can then be accessed by beagle. This is an example of the `prototype` chain. In this `prototype` chain, `Dog` is the `supertype` for `beagle`, while `beagle` is the `subtype`. `Object` is a `supertype` for both `Dog` and `beagle`. `Object` is a `supertype` for all objects in JavaScript. Therefore, any object can use the `hasOwnProperty` method.
AWS Workshop: cicd with Jenkins
Published: 2021-06-10 21:18:14

# About
In this workshop, we integrate AWS CodeBuild and AWS CodeDeploy with Jenkins and execute the CICD pipeline to build and deploy the application. We will also spin up an infrastructure with ALB and EC2’s on which the application would be deployed.
Read more: https://third-party-integration-codebuild-codedeploy-plugins.workshop.aws/en/

# Unzip Sample Application

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ubss1fybtkj3wc49r1b.PNG)

# Commit the files to Github Repo

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

# Cloudformation stack contains

Amazon S3 bucket
IAM S3 bucket policy
JenkinsRole
CodeDeploy application
CodeDeploy service role
CodeDeployRole
CodeBuildRole
Jenkins server
CodeBuild project
Auto Scaling group
Auto Scaling launch configurations
Security groups

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

# ELBDNS generated in output

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

# Sample page generated by ELB

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/98pncriz1t8k6ju9p75u.PNG)

# SSH into Jenkins server

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

# Retrieve password for Jenkins server - SSH 

`/var/lib/jenkins/secrets/initialAdminPassword`

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

# Jenkins Configuration & deployment

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

# Plugins installation

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ko2l3ulwjqo87or75s9.PNG)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6pch8l13knt2ft63zevi.PNG)



# Starting a freestyle Project in Jenkins server

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

# Build step failure

After multiple tries and debugging sessions the build step kept failing.
ERROR: Build step failed - response HTTP/1.1 301 Moved Permanently but no location header

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wanbxg71gt60106xfd3k.PNG)
Flexbox versus Grid CSS
Tags: css, freecodecamp, cssgrid, cssflexbox
Published: 2021-06-10 21:17:06

Today I'm working on the flexbox and grid sections of the Freecodecamp curriculum. 

I've learned a ton about CSS from their curriculum but a lot of it has focused on the how and less on the why. When does one use a Grid versus a Flexbox? Is there a right answer or does it have more to do with the developers comfortability with either style?
Build an idea generator from scratch, part 3: Create dynamic HTML from data [Video]
Tags: video, javascript, tutorial, codenewbie
Published: 2021-06-10 21:12:42

{% youtube 7A5h91F5wuc %}
Hello again folks! This week, for our Idea Generator Tutorial, we'll be focusing on HTML markup. Which tags should you choose? How do you plan your class naming and IDs while thinking of your functionality? And of course - we'll be connecting that data we pulled from the API last time to our markup as well.

If you're new to this series, catch up by checking out [my post on the first tutorial in this series](https://dev.to/ashleykolodziej/build-an-idea-generator-from-scratch-part-1-project-setup-with-github-and-dotenv-video-34mn).

## This video covers:
- How to create a solid HTML markup structure for your JavaScript app
- How to move that markup into templates you can use in your JavaScript
- How to connect the data from an API call to your page
- Some fun new explanations on professional Git development workflows
- Thinking through functionality and writing it down

... and, as usual, a number of other fun tidbits that will help you work more effectively.

## The final product

In this series, we’ll be working toward [this idea generator](https://professorkolodziej.github.io/idea-generator/) as our final product.

## Code links

Follow along by cloning or forking the main branch here: https://github.com/ProfessorKolodziej/idea-generator

You can also start on your own project by using my Student Site Boilerplate template: https://github.com/ProfessorKolodziej/student-site-boilerplate/

**[Catch the new video over here.](https://youtu.be/7A5h91F5wuc)** Happy coding!

---

**I'm always happy to connect!**

🐰 [@ashleykolodziej on Twitter](https://twitter.com/ashleykolodziej)
🐰 [Subscribe to Professor K Explains on YouTube](https://www.youtube.com/c/ProfessorKExplains?sub_confirmation=1)
Lambda Alternative to autoscale HTTP servers using only VMs in your own cloud account
Tags: showdev, javascript, cloud, devops
Published: 2021-06-10 20:42:11

After using Lambda and struggling with cold starts and clunky local dev in my previous job, we came up with a cloud agnostic alternative that deploys and autoscales HTTP servers on VMs in your own cloud account.
https://anycloudapp.com/

Here is a tutorial to deploy and scale a Node.js server in AWS:

https://docs.anycloudapp.com/documentation/tutorials/aws-node
Some of my personal favourite functions
Tags: functional, wordpress, webdev
Published: 2021-06-10 19:58:40

##Using Gravity Forms?

You can only return a US or International Phone Number; using this function we can return a UK Phone Format:

```

// Add UK phone number to Gravity Phone number using REGEX

add_filter( 'gform_phone_formats', 'uk_phone_format' );
function uk_phone_format( $phone_formats ) {
    $phone_formats['uk'] = array(
        'label'       => 'UK',
        'mask'        => false,
        'regex'       => '/^(((\+44\s?\d{4}|\(?0\d{4}\)?)\s?\d{3}\s?\d{3})|((\+44\s?\d{3}|\(?0\d{3}\)?)\s?\d{3}\s?\d{4})|((\+44\s?\d{2}|\(?0\d{2}\)?)\s?\d{4}\s?\d{4}))(\s?\#(\d{4}|\d{3}))?$/',
        'instruction' => false,
    );

    return $phone_formats;
}
```

## Switch from Gutenberg to Classic Editor
This will switch you back to the classic editor and remove the Gutenberg styling

```
add_filter("use_block_editor_for_post_type", "disable_gutenberg_editor");
function disable_gutenberg_editor(){
	return false;
}

//Remove Gutenberg Block Library CSS from loading on the frontend
function remove_wp_block_library_css(){
    wp_dequeue_style( 'wp-block-library' );
    wp_dequeue_style( 'wp-block-library-theme' );
    wp_dequeue_style( 'wc-block-style' ); // Remove WooCommerce block CSS
}
add_action( 'wp_enqueue_scripts', 'remove_wp_block_library_css', 100 );
```

## Reduce the risk of being hacked!

Disabling XMLPRC can help reduce the amount of hackers trying to gain access to your site

```
add_filter('xmlrpc_enabled', '__return_false');
```

## Change the max image size before it's scaled.

```
add_filter( 'max_srcset_image_width', 'plott_max_srcset_image_width', 10 , 2 );

// set the max image width
function plott_max_srcset_image_width() {
    return 2200;
}
```

## Change the url for the logo in WordPress admin login

```
function theme_url( $url ) {
   return get_bloginfo( 'url' );
}

add_filter( 'login_headerurl', 'theme_url' );
```

## Change the category checkboxes to radio buttons

```
<?php
function admin_js() { ?>
    <script type="text/javascript">

        jQuery(document).ready( function () {
            jQuery('form#post').find('.categorychecklist input').each(function() {
                var new_input = jQuery('<input type="radio" />'),
                    attrLen = this.attributes.length;

                for (i = 0; i < attrLen; i++) {
                    if (this.attributes[i].name != 'type') {
                        new_input.attr(this.attributes[i].name.toLowerCase(), this.attributes[i].value);
                    }
                }

                jQuery(this).replaceWith(new_input);
            });
        });

    </script>
<?php }
add_action('admin_head', 'admin_js');
```

There you go; some of best and favourite functions that I use to make my life easier when developing sites for clients that are always in my base theme.
Dev Journey Thoughts - Starting a Coding MeetUp
Tags: devjournal, codenewbie, motivation
Published: 2021-06-10 19:58:06

I've been craving community, and a way to connect with others who are on the journey to becoming a developer. Despite living in a large city, it's been hard to find an already-existing group that seems to hit all the targets. So, I thought I'd create a MeetUp to try and spark a new community.

Peer group formation is a pretty important concept in education, usually tossed around in connection with college cohorts and first-year experience programs. But, the need for cohorts doesn't end at university. One of the reason platforms like freecodecamp, The Odin Project, and countless others draw in such large participation is an inherent need to feel some sense of belongingness. 

Yet it can be hard to find the right balance. In my journey, I've joined a few existing spaces that are devoted to the topic of development and coding. They're fantastic in their own way, but it can be overwhelming to step into spaces where hundreds (sometimes thousands) of other people are already in the middle of discussions. 

So it's not uncommon to split into smaller groups or pairs or teams. But it's easy to forget about the power of local communities, and that's where MeetUps can excel. Right now, we're still in the midst of pandemic restrictions, but eventually the thought of getting together in person to chat over frameworks and other coding topics is incredibly appealing.

I think fostering a sense of shared ownership is a critical part of making something like this succeed. Rather than focusing around an individual or a mentor, there's a great deal of power in working together to solve problems. And that's the kind of community I want.

I tried the "guru-led" variety in the past and it turned into a rather sobering affair. Listening to soapbox ideological rants and essentially arguing for participants to ignore other perspectives or documents. It felt solipsistic. And the amount of fear and anxiety I saw in the faces of other attendees was too much to handle. 

As part of my journey in general, I'd like to chronicle a bit of the formation of this group. It's small and has yet to meet for the first time, but I'm thinking about resources that can be added.

Key among those is a website, but one that is focused on providing members with a space to learn git and practice pull requests by adding themselves to a members list and linking to github portfolios and/or personal sites. Links to resources that are particularly helpful. Nothing out of the ordinary, honestly, but just a way of staying active.

Monthly challenges would also ground some practice and provide a way to collect member examples and compare different code strategies. Essentially, I'm going to be trying to think and find activities that foster engagement and allow the participants to have a stake in the ownership of the group.

Let's see what happens.
Normalization and Functional Dependencies in DBMS
Tags: database, computerscience
Published: 2021-06-10 19:51:41

**Normalization** is the process of removing redundant(repetition) data from your tables in order to:
1) improve storage efficiency
2) data integrity and
3) Scalability

**Normalization** is a technique to store data in database.

**Anomalies(Problems) in DBMS**:

**1) Insert Anomaly:** Data cannot be inserted into a table because of another data due to some sort of violation.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tw2vs0h26lzj326grqf8.png)

**2) Update Anomaly:**
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yfw6p4ktadlmo2ozpy8q.png)

**3) Delete Anomaly:** In an attempt to delete some data, other useful data also gets deleted.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ybis08p5hfh3eleec811.png)

**Functional Dependencies** :
1) If an attribute or a set of attributes identify the whole tuple(row / record) uniquely then we can say it is functionally dependent.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e4x2jip85bwnvt49jjxm.png)
From this we can say X->Y (X functionally determines Y).
X : Determinant Attribute
Y : Dependent Attribute

**Types of Functional Dependencies**

**(i) Trivial Functional Dependency:**
If X->Y, and if Y is a subset of X, this is called a Trivial FD.
Examples:
 1) A->A
 2) A->phi
 3) AB->B
 4) ABC->ABC
 5) ABCD->ACDB

**(ii) Non-Trivial Functional Dependency:**
If X->Y, and if Y is not a subset of X, this is called a Non-Trivial FD.
Examples:
 1) A->BC
 2) ABC->BD
 3) MNP->JKL

Stay tuned for the next topic!
Thank You.
100 algos in 100 days (Day 9)
Published: 2021-06-10 19:38:30

##Substring with the most unique, consecutive letters
(https://leetcode.com/problems/longest-substring-without-repeating-characters/)

##My thought process:

How to get all substrings?
Short strings:

1 = 1 substring
2 = 2 + 1 substrings
3 = 3 + 2 + 1 substrings

'aba'
You look at the 3 ... Nope... Take 1 letter off each side

'abc'
You look at the 3.. nope... 

'abagh'

Better approach

// Make a set with uniques
// We know the highest possible length e.g. 3 uniques in 3 letter string is 1. This could be max depth.
// Loop through if has char.. add one to highest so far
// If already has that char reset
// If doesn't have reset current sequence to 1 consecutive unique digit. Update highest


What about as you go through, check the set... If not reset just set it equal to used: false

Is set the best data structure to use? Or could we use a JS object to better effect?

As we loop we use a variable to check the highest so far.
Day 88 of 100 Days Of SwiftUI
Tags: swift, 100daysofcode
Published: 2021-06-10 19:37:37

I just completed day 88 of 100 days of SwiftUI. Today I worked on building FlashZilla. FlashZilla is a flash card memory card. I did the initial setups of views required for the app and i also worked on the implementing swipe to remove card feature.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y5x5q3eyjzep86iqbbn8.png)
#Creating an Application to Give Current Urgent Care Wait Times
Tags: refactorit, ruby, rails
Published: 2021-06-10 19:18:38

My first project in Ruby is a CLI application that scrapes the website of a company that provides urgent care. Urgent care is provided to patients that typically cannot wait until the next business day but are not experiencing an illness or injury that is life-threatening. Many urgent care centers are located throughout Massachusetts to treat patients and prevent long wait times in the Emergency Department. My application lists the next available appointment time at urgent care centers in Massachusetts based on location. This provides a quick and easy way to find care.

The biggest challenge when coding this project was to find the best way to organize the Scraper class. This class scrapes the website for the desired data and stores it in a separate Office class. All of the relevant data that I wanted was located under the node of ('.et_pb_column_1_4'). However, the relevant data for each office was located in two different ('.et_pb_column_1_4'). This required separating each ('.et_pb_column_1_4') into two separate arrays and then zipping them together in order to form one office_details array where each element contains the relevant data for each office. 

```
  def get_clinics;
 		 url_array = [];
		 digits_array = [];
 		 get_page.css('.et_pb_column_1_4').each_with_index do |location, index|
 if index.odd?
	url_array.push(location)
 else
 	digits_array.push(location)
 end;
 						 url_array;
 						digits_array;
 		 end
digits_array[0..16].zip(url_array[0..16]).each_with_index do |office_details, index|
 		end
 end 

 ```
 
After getting past this barrier, scraping from each element of the office_details array was simpler. The next challenge was discovering that the Next Available Appointment Time data that I wanted on the second page was contained within an iframe. This required scraping the link for the individual office page, then the iframe link, and then the appointment time data. 
			

```
doc_d = Nokogiri::HTML(open("https://www.carewellurgentcare.com#{office.url}"));
doc_i = doc_d.css('.locat').attr('src').text;
doc_n = Nokogiri::HTML(open(doc_i.to_s));
    office.next_available = doc_n.css('.panel-heading').text.strip.gsub("\r\n", ' ').split(',')[0]; 
		
```

		
While challenging, these obstacles taught me the importance of proper planning in order to return exactly the data that you are looking for.