teleren/devto huggingface dataset:
Does Your Company Have a Reusable Module Library?
Tags: angular, api
Published: 2020-11-25 16:39:57

<sub>When carpenters go onto a job site, they bring their tools. Some of them have so many tools, they bring the truck and the trailer. They instantly set up shop and start building without tool dependencies. 

**Observations**
I've worked as a contractor for most of my IT career. I fell into it by accident, taking a job offer for a contracting company due to my immediate need at the time. It's clear that companies want contractors for a number of reasons and the goodness of it for the programmer is this:

>We must always keep upgrading our skills. 

This is how we stay employed in the fast changing IT world.

**Reusable Libraries**
I've worked for many major companies. Only one of them had a fantastic reusable API. That company was IBM. They produced APIs for customers, but carried the same concepts to their own OS layer(s) where everything was discoverable. 

**Must Be Exposed**
If an API is un-discoverable or unknown, it doesn't get used. There are many tools today that help make creating them easier. Today's best tools all expose the APIs via HTML. Two such tools are Swagger (for ASP.NET backend), and CompoDoc for Angular (frontend). 

**Here's an Example of CompoDoc for Angular**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/cxbf9rzjy2mdttba83vv.png)
 
If we use naming conventions as shown in the image above, we are able to learn all the internals of our reusable code merely by knowing where we are in the code and what we want to accomplish. In the image above we used the following conventions:

- All reusable bullet-proof functions start with the letters func. The allows intellisense to show all functions in the project.
- The next two or three areas relate the function to a specific component or "speciality"
- The remaining text is for drill down.
- Intellisense in VS Code or Visual Studio is the discovery tool. 

e.g. We want to create a "Postable" address.
- funcADR  gets us to the reusable address functions
- funcADRp Will show us all reusable post functions in the ADR module. 
- We pick funcADRPostableAddress
- As soon as we type the open bracket we see this:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vomae3q316s6fep6ezkb.png)
- If we don't know how to use it and want to see examples, we just right click and select "find all references"

This makes using JSDOC important. It allows future developers to cut the time in getting to know the API. The better it's documented the quicker they will understand it. 

ASP.NET has the exact same concept, where code comments are used for the API documentation. 

**APIs from the Web Site**
The advantage to seeing the API in a web site, is that it allows both high-level overview and a drill-down into details. By using naming conventions as mentioned earlier we've been able to mock this ability using intellisense and specivity rules. 

Either way, it's all good and a further enhancement to our software assembly line. Remember, never ever do it twice, it's way better to put it into a reusable library as soon as it's needed twice. Start your libraries today.
The Best Way To Learn To Code - Newbie Developers
Tags: codenewbie, coding, learntocode
Published: 2020-11-25 16:27:23

![alt text](https://codehance.com/media/images/THE_BEST_WAY_TO_LEARN_TO_CODE.max-755x400.jpegquality-60.png "CODEHANCE | Best Way To Learn To Code")

I wrote a new post on here:  [CODEHANCE](https://www.codehance.com/sh/Fr4L7Rx)  
which I wanted to share with you, maybe it might be of use to you :)

This is a post I wish I read when I was a junior developer. If you get these foundation steps wrong you could end up wasting months or even years and worst-case scenario you give up on your journey to learn to code.

> From my experience, learning any skill, including learning to code requires four main ingredients, namely: dedication, time, persistence and finally a direction.

The fourth ingredient “direction” is often the stumbling block for a lot of newbies learning to code, a lot of time and effort goes into learning programming languages and frameworks but in the end, they find it challenging to land the elusive first coding job. Why is this the case?

In this post, I will outline 7 best ways to learn to code that ensure that you are constantly heading in the right direction, have a solid attainable goal and removes any feeling of being overwhelmed during the process.

**THE BEST WAY TO LEARN TO CODE - 7 PRACTICAL STEPS**

1. [Know WHY you want to learn to code](https://www.codehance.com/blog/the-best-way-to-learn-to-code/#step-1-why-you-want-to-learn-to-code)
2. [Research local vacancies near you](https://www.codehance.com/blog/the-best-way-to-learn-to-code/#step-2-research-local-vacancies-near-you)
3. [Build a learning roadmap](https://www.codehance.com/blog/the-best-way-to-learn-to-code/#step-3-build-a-learning-roadmap)
4. [Start online coding courses](https://www.codehance.com/blog/the-best-way-to-learn-to-code/#step-4-start-online-coding-courses)
5. [Build a community around you](https://www.codehance.com/blog/the-best-way-to-learn-to-code/#step-5-build-a-community-around-you)
6. [Apply for jobs before you are ready](https://www.codehance.com/blog/the-best-way-to-learn-to-code/#step-6-apply-for-jobs-before-you-are-ready)
7. [Document everything as you learn](https://www.codehance.com/blog/the-best-way-to-learn-to-code/#step-7-document-everything-as-you-learn)

To read the post in full details, click the link below:
*[Read Full Article...](https://www.codehance.com/sh/Fr4L7Rx)*
Comments and Docstrings in Python
Tags: python, codenewbie, comments, programming
Published: 2020-11-25 16:05:06

### Comments in Python

As we have seen in a previous post **[Executing a Python Program](https://dev.to/mcscodes/executing-a-python-program-208l)**, a comment is a line (or multiple lines) of code which do not execute when the program is run. The sole purpose of comments is to provide more information about the written code.

Many a times while writing programs, we tend to ignore documenting the steps. This causes an issue not only to others that might read our code in the future, but our future selves too. For example, let us take a look at the following snippets which contain the exact same code -

*Snippet 1:*
```
lst = [1,2,3,4,5]
for i in lst:
    print(i)
```

*Snippet 2:*
```
lst = [1,2,3,4,5] # Creating a list
# Looping over each element in the list
for i in lst:
    print(i) # Printing each element
```
As we can see from the above snippets, the difference in the quality of code varies significantly. Any person can understand the functionality of the code from the second snippet easily as compared to the first snippet. Hence, we can conclude that proper documentation of the code using **comments** is essential while developing any application.

Python has 2 types of comments:
#### Single line comments -

These comments begin with the **_hash_** (**#**) symbol and the entire line after the hash symbol is treated as a comment.

#### Multi line comments -

When we want to comment multiple lines of code, we can do it as follows

*Method 1:*
```
# This is the first comment
# This is the second comment
# This is the third comment
```
*Method 2:*
```
"""
This is the first comment
This is the second comment
This is the third comment
"""
```
*Method 3:*
```
'''
This is the first comment
This is the second comment
This is the third comment
'''
```

### Docstrings

As we have previously seen, multi-line comments are regular strings which have the ability to span multiple lines. If these strings are not assigned to a variable, then they are removed from the memory by the **[garbage collector](https://dev.to/mcscodes/python-memory-management-hcb)**. Hence, using """ (triple double quotes) and ''' (triple single quotes) are not recommended for comments by developers since they occupy memory and delays the complete execution of the program.

The strings enclose within """ or ''' are called **_documentation strings_** or **_docstrings_**. These are useful to create an API (Application Programming Interface) documentation file, that provides a description of various features of a software, language or a product.

API documentation is critical if developers intend to distribute their work. Bad or improper documentation may lead to other developers not understanding the complexity in code, and they may completely reject the code simply because it did not make sense!
Learn Julia (11): My first experience of Linear Regression
Tags: julia, machinelearning, optimization, datascience
Published: 2020-11-25 16:04:47

Though used to doing *Machine Learning* works in **Python**, I have never tried Machine Learning dev work in **Julia**. I know there are already mature tools in Julia for *Machine Leaning*, however, I feel it necessary for me to do some basic exercises by myself in order to get a better understanding of **Julia** basics. Thus I tried this afternoon a simple Linear Regression experiment.

Firstly, I need to know how to solve optimization problems (LP, QP, SQP, etc) in **Julia**. Thanks to google, I quickly learned about the **Optim** module after a simple search. It is also for this exercise that I have done chart plot for the first time in **Julia**. Below is the chart I have plotted in this Linear Regression experiment.

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

Now I would like to share my code of this exercise:

```julia
using Random
using Optim
using Plots

## function for generating samples
# n: number of the sample
# b0 b1: linear params
# err: noise level
# seed: seed for random

function get_simple_regression_samples(n, b0=-0.3, b1=0.5, err=0.08, seed=nothing)
    if seed!=nothing
        Random.seed!(seed)
    end
    trueX =  Random.rand(Float64, n)*2 
	trueX =  trueX.- 1.0
    trueT = (b1*trueX).+b0
    return (trueX, trueT+randn(n)*err)
end


# now we obtain a batch of our sample points and print them
(x, y) = get_simple_regression_samples(20)
println("x: $x")
println("y: $y")

# plot the samples as scatter points
gr() # Set the backend to GR
#  plot our samples using GR
display(plot(x,y ,seriestype=:scatter, title="Sample points"))


## now do the linear regression stuff
#  a is the two coefficients that we want to get , ideal solution should be (0.5, -0.3)
#  func(a):  (Y_estim - y).T * (Y_estim - y)  where Y_estim = (a1*x+a2)
func(a) = sum(((a[1]*x).+a[2] - y) .* ((a[1]*x).+a[2] - y))

# pass the function and the initial vector to optimization solver
res = optimize(func, [1.0,1.0])

# get the solution that minimizes the func
sol = Optim.minimizer(res)
println(sol)

# get the minimized value of the func
minval = Optim.minimum(res)
println(minval)

```

Then execute this script and I got the solution:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/u09pod4qvnmwyygolo5o.PNG)

The real coefficients for generating the samples are `[0.5, -0.3]` and my script has solved it as `[0.52368, -0.29784]`. Wonderful!
BootstrapVue or Vuetify for a Nuxt.js Project?
Published: 2020-11-25 16:00:16

I have been reading on this topic for a couple of days now. I want to pick a UI library for my project and I am mostly torn between these two options. 

Looking at the documentation of both tools, I feel that Vuetify offers a bigger variety of components. Also, Vuetify's data-table component is a clear winner compared to that of BootstrapVue. 

However, even a quick search is enough to show that Vuetify is by no means a clear winner; many seem to prefer BootstrapVue. 

Disregarding any bias against material design (because I don't have any) which would you pick? And why?
std::optional from C++17 vs custom type for optional value
Tags: cpp, programming, todayisearched
Published: 2020-11-25 15:57:35

C++17 has introduced a very useful [template class, `std::optional`](https://en.cppreference.com/w/cpp/utility/optional):

> The class template `std::optional` manages an optional contained value, i.e. a value that may or may not be present.

I have been using this feature a lot since 2017, even for a simple optional integer. Today, I got curious: is this template type effective compared to an equivalent type that I would write myself to achieve the same behavior?

Good question, thank you 😆

Let's try to write some code and use [Compiler Explorer](https://godbolt.org/) to compare both solutions: `std::optional` vs custom type for optional value.

First, let's define two equivalent types:

```cpp
#include <optional>

using StdOptionalInt = std::optional<int>;

struct CustomOptionalInt {    
    bool has_value;
    int value;
};
```

Then, let's write two functions that test if the value is available and return either this value (if available) or a default value (if not available):


```cpp
int getStdOptional(const StdOptionalInt& o) {
    return o.has_value() ? o.value() : 0;
}

int getCustomOptional(const CustomOptionalInt& o) {
    return o.has_value ? o.value : 0;
}
```

Finally, compile the code with Compiler Explorer and compare the output assembly codes (you can try by yourself [here](https://godbolt.org/z/neTPjE)):

![with_compiler_explorer](https://dev-to-uploads.s3.amazonaws.com/i/6dwau2emkq8tsxsxa933.png)

Yeah! 😃 The 2 functions generate the same assembly code. There is no difference of performance. Notice the static assertion at the end of the source code: because the code compiles, it means the footprint are the same. The behavior is the same with gcc and clang for x86-64.

As a conclusion, `std::optional` is as efficient as a custom type to represent an optional integer value. Don't implement your own type, simply use the standard type. You may even get better performance using `std::optional`, as explained on [cppreference](https://en.cppreference.com/w/cpp/utility/optional):

> As opposed to other approaches, such as `std::pair<T,bool>`, `optional` handles expensive-to-construct objects well and is more readable, as the intent is expressed explicitly.

---

By the way, if you happen to speak French:

- I wrote [an article](https://gradot.wordpress.com/2017/11/20/stdoptional-du-c17/) to explain to how to use std::optional.
- I made [a video](https://www.youtube.com/watch?v=GzTkqK8vkeA) to present Compiler Explorer.
Season of Docs, Meeting-13
Tags: github, docker, documentation
Published: 2020-11-25 15:44:34

On 18th of November, I had a meeting with my mentors with regards to Google's Season Of Docs project. The mentors had assigned the following tasks:
1. Making certain corrections to the [user documentation](https://synbiohub.github.io/userdocumentation/), few of which are mentioned as follows:
 * Inserting tables, wherever there is a possibility
 * Creating a section, for **Add to a collection**
 * Making a general section for **Viewing a record**, which includes all the general details as well as parameters a record page contains. Subsequently, create sections for every type of record, which'll contain sections specific to that record.
 * Editing the SPARQL search section.
 * Editing the Downloads section.
 * Replacing numbering with the bullets.

2. Writing the **[Setup](https://synbiohub.github.io/setup/)** section.
3. Editing some minor errors in the **[Installation](https://synbiohub.github.io/installation/)** section.
4. Adding a section/button for **Reporting an error**.

I was able to complete the following tasks:
1. Made certain corrections to the [user documentation](https://synbiohub.github.io/userdocumentation/), few of which are mentioned as follows:
 * Inserted tables, wherever there is a possibility
 * Created a section, for **Add to a collection**
 * Made a general section for **Viewing a record**, which includes all the general details as well as parameters a record page contains. Subsequently, created specific sections for Collection as well as module.
 * Edited the SPARQL search section.
 * Edited the Downloads section.
 * Replaced most of the numbering with the bullets.

2. Wrote the **[Setup](https://synbiohub.github.io/setup/)** section.
3. Edited some minor errors in the **[Installation](https://synbiohub.github.io/installation/)** section.
4. Added a button for **Reporting an error**.

This week I was able to accomplish almost all of my tasks, and I hope to complete all the sub-sections of viewing by the end of next week.
JavaScript Code Daily Challenge #5
Tags: challenge, javascript, beginners, codenewbie
Published: 2020-11-25 15:36:25

# **About**

This is a series of JavaScript Code Daily Challenge. Each day I show a few solutions written in JavaScript. The questions are from coding practice/contest sites such as HackerRank, LeetCode, Codeforces, Atcoder and etc.

> Designer PDF Viewer
> [https://www.hackerrank.com/challenges/designer-pdf-viewer/](https://www.hackerrank.com/challenges/designer-pdf-viewer/)

```javascript
'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}
```
> Complete the function in comment
```javascript
function designerPdfViewer(h, word) {


}
```
```javascript
function main() {
    const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const h = readLine().split(' ').map(hTemp => parseInt(hTemp, 10));

    const word = readLine();

    let result = designerPdfViewer(h, word);

    ws.write(result + "\n");

    ws.end();
}
```
The New Way of the Developer?
Tags: discuss, programming, webdev, codenewbie
Published: 2020-11-25 15:34:19

Back in the days, most developers have had an engineering background or studied computer science; nowadays, the software developer's role becomes more popular. 
New ways to become a developer are approaching on a weekly/monthly basis. 

You can attend Bootcamps, be self-taught, do an apprenticeship, study computer science or a combination of several fields, and many more. 
The possibilities are endless. 

My questions are now: 
- Are there any significant differences between these developer paths?
- Is their mindset on the same page?
- Do you need a computer science degree to become the "better" developer?
- Is a JavaScript developer coming from a Bootcamp worse than a Java Developer shifting towards JavaScript?

I'm interested in everybody's opinion; please feel free to share your thoughts!
🚀 Coding in PHP 7.4 and deploying to 7.1 via Rector and GitHub Actions
Tags: github, wordpress, php, webdev
Published: 2020-11-25 15:31:56

This post has been [originally published in my blog leoloso.com](https://leoloso.com/posts/coding-with-php74-deploying-to-71-guide/)

---

I've written a step-by-step guide about transpiling PHP code, from PHP 7.4 to 7.1, when creating a WordPress plugin:

[Coding in PHP 7.4 and deploying to 7.1 via Rector and GitHub Actions](https://blog.logrocket.com/coding-in-php-7-4-and-deploying-to-7-1-via-rector-and-github-actions/)

It explains all the hows and whys:

- Why the target is PHP 7.1 and not 5.6
- Which are the PHP features from each PHP version that our code can support
- How to find out which 3rd party dependencies must be transpiled
- How to make Rector work specifically for WordPress
- Testing the downgrade through Travis
- Creating the WordPress plugin via GitHub Actions

Enjoy!
How to Build an E-Learning Platform? [Interview with an Industry Expert, Founder of Tutor House]
Tags: elearning, onlineplatformdevelopment
Published: 2020-11-25 15:31:11

How to build an e-learning platform and succeed? 🥇
Learn from the industry expert, Alex Dyer, and his experience creating a leading online learning platform - Tutor House - [in our new guide.](https://apiko.com/blog/how-to-build-an-e-learning-platform-interview-alex-dyer-tutorhouse/?utm_source=LinkedIn&utm_medium=e-learning-tutorhouse&utm_campaign=blogpost)
Blazor, an experience... 
Tags: blazor, csharp, dotnet, webdev
Published: 2020-11-25 15:31:11

So, I've recently started trying to develop single page applications in C#. Because, C# is my favourite language to exist. I love it. Its the ace of my hand, the cream and the hot chocolate. I love it. So when .NET 5 released, started to get curious about ASP.NET as I had heard it got better in dotnet5. So, as always I sacrificed myself sanity, hours of sleep and my heaps of coffee and got to work.

#Day 1
First thing, I love the tag system. Being able to just create a Razor component, sytle it and then use it where I want in what ever component or page I want is actually helpful af. Day one was nothing special, I just made a project, explored a bit and closed it cause I was in biology and my teacher was starting to become suspicious of what I'm doing.

#Day 2
I started trying to integrate API's into it. Sending GET and POST requests to different API's and exploring different ways I can display, render, change and live update data. It was fun.
#Day 3
I attempted to make a simple page where you can login and view the website. So to do that I used the Microsoft. AspNetCore.Identity package and it worked a charm. It was really cool how the Microsoft AspNetCore.Identity.UI package also had so much that comes out of the box. So when I tried to change how it looks, I didn't have a fun time. To override the default UI pages you have to do somthing called Scaffolding. This was a pain in my ass because of all the errors thrown at me. I spent the rest of the week trying to fix it but in the end I gave up. If anyone has any experience with Blazor in C# then please reach out and help me. Much appreciated.

Anyways, that was my week of exploring a new library. Hope you enjoyed.

Stay safe and stay amazing people.