teleren/devto huggingface dataset:
ML.NET in Google Colab
Tags: dotnet, machinelearning, jupyter, datascience
Published: 2020-12-16 15:48:08

Today, I was thinking to build and test a classification model using ML.NET. I'm very very curious about new technologies and from my curiosity I asked myself, 

> "What if I try doing all these things in Colab? Is it even possible?"

![https://media.giphy.com/media/VIQ2OBrGPCq0o6QQZY/giphy.gif](https://media.giphy.com/media/VIQ2OBrGPCq0o6QQZY/giphy.gif)

From the official documentation of ML.NET I found that there is an option to do all these things from command line using ML.NET CLI. 

**And guess what?** This was as simple as drinking a glass of water 😂. All you need to do is to:

- Install .NET Core SDK in Google Colab.
- Install ML.NET.
- Import dataset.
- Use ML.NET CLI to train the model.
- Test.

I've added a [gist](https://gist.github.com/shunjid/5f633474ba6f4be7db2871fe54e2ef52) below. You can try directly in [colab](https://colab.research.google.com/drive/1MQF2B_chRddk7WFKS6H5wLs_vdI7Xfg8?usp=sharing) from the "Open in Colab" badge.

### **Let's Give it a try :tada:**
[https://gist.github.com/shunjid/5f633474ba6f4be7db2871fe54e2ef52](https://gist.github.com/shunjid/5f633474ba6f4be7db2871fe54e2ef52)

{% gist https://gist.github.com/shunjid/5f633474ba6f4be7db2871fe54e2ef52 %}
How to remove unused Docker resources
Tags: docker, devops, cloud, tutorial
Published: 2020-12-16 15:38:52

<!--
Title: How to remove unused Docker resources
Tags: docker, tutorial, devops, webdev, backend, cloud, beginners, server
-->

# Introduction

Chances are that you've been running Docker for some time and found out that your system's storage is almost full.

This is completely normal as Docker bundles all the needed dependencies with each container and doesn't remove anything if you don't explicitly tell it to do so.

So lets learn how to prune unused and unnecessary **images, containers, volumes and networks**!

> This tutorial will help you liberate space on your system without breaking anything in the process.

---

## Before we start

We will be using the Docker CLI, so I expect you to be a bit familiar with it.

Otherwise just use `docker --help` on the terminal and toy with it a little.

### Requisites

- A little bit of Docker knowledge

---

## Images

Remove all images that are not tagged or referenced by any container

```sh
docker image prune
```

---

## Containers

Remove all stopped containers

```sh
docker container prune
```

---

## Volumes

Remove all volumes not used by at least one container

```sh
docker volume prune
```

---

## Networks

Remove all networks not used by at least one container

```sh
docker network prune
```

---

## Everything

To finalize, lets remove everything --_but volumes_-- with a single command.

```sh
docker system prune
```

If you want to remove volumes too, just append `--volumes` at the end.

```sh
docker system prune --volumes
```

**And voila, that removed every single resource that was unnecessary on your system!**

---

## Troubleshooting

You might find that some images can't be removed because they are used. In this case you want to remove the resource that is using it, most likely a container.

---

## End

### What's next?

If you want to read more, please check out the [official Docker guide to pruning](https://docs.docker.com/config/pruning/).

<!-- INCLUDE -->

### Self promotion

If you have found this useful then you should follow me, I will be posting more interesting content! 🥰

- [GitHub](https://redirect.akbal.dev/github)
- [Twitter](https://redirect.akbal.dev/twitter)
- [Dev.to](https://redirect.akbal.dev/dev.to)
- [Medium](https://redirect.akbal.dev/medium)
- [LinkedIn](https://redirect.akbal.dev/linkedin)

Or support me financially. 💸

- [GitHub Sponsors](https://redirect.akbal.dev/github/sponsor)
- [LiberaPay](https://redirect.akbal.dev/liberapay)
- [PayPal](https://redirect.akbal.dev/paypal)

<!-- /INCLUDE -->

### Conclusion

Today you have learned how to free up space on your system by removing Docker's unused images, containers, volumes and networks.

**Let me know how much space you have recovered in the comments!**
Junior Software Architect
Tags: discuss, career
Published: 2020-12-16 15:36:17

Let me get this straight, software architect is no job title to me, it's a role. A role assigned to one or more persons in the team.

In my experience, the architectural role is taken very naturally by the most experienced or capable developer with great communication skills. Usually, the best ones from us.

Charisma, respect, and natural authority is a good driver for picking up the right person. The role comes with great responsibility and must be accepted by the whole team to succeed.

The hat could be handed over with the time, there could be different architects for different topics or project slices, and so forth.

Are you with me so far? All right, let's move on.

In some (rare) cases, the role can match the job title. For example, the software architect must step out of the team when dealing with outsourcing or open-source community projects.

But I would still expect great programming skills, a lot of experience, and natural authority, right?

Now, let me tell you a true story.

My company hired a new developer. He had almost no experience, poor technical skill, and, worse, no motivation.

I really enjoy working with juniors. They are eager to learn, have plenty of ideas, and brilliant thinking out of the box. Having juniors in the team is always a big benefit (and fun). I advise organizations to hire more of them. All in all, we all used to be juniors once.

This guy was no junior anymore, but hard skills poorer than most of the coding bootcamp graduates. But the worst thing was, he was bullshiting so much! 

His constant lying and excuses made each and every coworker boil blood, and our guy was finally fired. With a lot of drama and emotions, of course.

After several months I saw his profile on LinkedIn. He's got a new job as a *Software Architect* in an international financial institution. 

Wow.

Leaving aside the question of how badly the interview process failed, I have to ask how can anyone with such poor technical skills manage this position for more than a few days?

Maybe, the title *Software Architect* has nothing to do with actual *software architecture*. It's just somehow good to have this position in an organization that is facing a digital transformation, but there is no actual need for him to do anything useful.

Create a few PowerPoint slides, skitch some generic diagrams, don't bother the development team, and don't argue with the management. You'll be happy, everybody will be happy. Win-win. An instant recipe for success. Cool!

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

Everyone knows the sad joke about bad managers to be recruited from good programmers. Has the time come for software architects to be recruited from bad developers?

Is a *Junior Software Architect* a real thing?
C++ length of string
Tags: cpp, oop
Published: 2020-12-16 13:39:55

We all know arrays of chars are known as strings in C++. We can store chars in a string. So, today we are going to learn about the methods of finding the length of a string or we can say a program to calculate how many chars are stored in the string.

---
title: C++ length of string
tags: cpp
canonical_url: https://kodlogs.com/blog/248/how-to-get-the-length-of-the-string-in-c
---

#Methods
Using while loop : using loops to find the string length is an old fashioned way of doing it. Initializing loop from zero and then incrementing it till the end of the string.
Using for loop : similar to while loop, to initialize the counter equal to zero till the end of the string.
Using function strlen() : C library provides  the function size_t strlen(const char*str) which computed the length of the string for us. But it does not include the terminating null character.
Using string::size : This method returns the size of the string but in terms of bytes.
Using string::length : Both string::size and string::length works similarly, they return the size of the string in terms of bytes.

##Program
 This is a universal program. What I mean by universal is that all of the methods are defined in this program down below.

```
int main()
{
    string str= "lengthofthestring";

    // method using size()
    cout << str.size() << endl;

    // method using length()
    cout << str.length() << endl;

    // method using while loop
    int i=0;
    while (str[i])
        i++;
        cout << i << endl;

    //method using for loop
    for (i = 0; str[i]; i++)
        ;    
       cout << i <<endl;
    
    //method strlen()
    cout << strlen(str.c_str()) << endl;
    
    return 0;
}
```
Would you use a chrome extension that makes you google SO answers faster? 🚀
Tags: discuss, productivity, help
Published: 2020-12-16 15:14:23

I found lately that whenever I'm learning a new language or library or I focus on something very specific (like fixing typing errors in TypeScript) I'd lose a lot of time refocusing from vscode to Chrome, retyping a similar query, and having to select the first search result. So I made a chrome extension that does that and I wonder if you'd like to beta test it.

<center>![Brisk Logo](https://dev-to-uploads.s3.amazonaws.com/i/554brdd6eiiyhp2443lw.png)
<sup>*A great excuse to draw a happy squirrel. Brisk's logo.*</sup></center>

It's all based on the assumption that Google is much better at searching SO than SO's built-in search function. The chrome extension is called Brisk and it lets you define a global shortcut (you can trigger it directly from your ide) that will:
1. focus chrome, 
2. open up a window automatically into which you can type in your query 
3. it will then run that (optionally with a prefix defined by you - e.g. 'python' so that you don't have to retype the beginning all the time) query into google 
4. and select the first StackOverflow answer

It's still a bit experimental and even though it works for me I wonder if you'd be up for trying it out (in dev mode before I release it) so that I can adjust it to your needs ☀️
I prefer not to use the keyword “it”
Tags: cleancode, kotlin
Published: 2020-12-16 15:16:00

---
title: I prefer not to use the keyword “it”
published: true
date: 2020-12-16 15:13:17 UTC
tags: cleancode,kotlin
canonical_url: https://le0nidas.gr/2020/12/16/i-prefer-not-to-use-the-keyword-it/
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/ncuox5rghsyd8z0g0qbv.png
---

And the reason is simple:

> I want to be as explicit as possible and allow the reader of my code to have an uninterrupted flow.

Think about it. Every time you encounter the `it` keyword you do, a quick, conversion between what you see and what it represents. Personally I do it even in very small lambdas, imagine if you are two or three lines deep in a lambda and you see an `it`:

{% gist https://gist.github.com/le0nidas/2e932f857a690abc74b024f68f3dc3c3 %}

It might not look much in this simple example but read it now with an explicit value:

{%gist https://gist.github.com/le0nidas/b9b8fcbdefdf39bf74aa4542ed8d6233 %}

You don’t have to do a mental translation and it also provides some details regarding the format of username.

This last part can make the code even more readable since it allows us to describe the values we use:

{%gist https://gist.github.com/le0nidas/c693b7dd41a95dded05350f44f2d42be %}

this hints that (a) values list does not contain usable data and (b) the `of` function will perform some kind of cleaning
Ajax POST v.s. Form POST
Tags: javascript, html
Published: 2020-12-16 15:05:50

There are some concrete details I would love to dive into when it comes to the main differences between using a native html form and using ajax to send data to a server.

The main objective of both a html form and an ajax post is to move data, but there also may be additional goals and needs. One notable one is navigation / redirection, most of the time when a user submits data through a action or event we want to move the user to a different page. 

When a form is submit without any manipulation from JavaScript the user is sent to a completely different url and the data is sent along as well ether as get params or as a body. 

The one benefit of doing this is that a user actually will be redirected to that domain for a brief moment, and in this jump it can set cookies for a user along the way.

Let's say you have two different endpoints on an API. Both use the POST method. One returns JSON, the other returns with a redirect.

When you post data with an ajax request it does not change the navigation or url of the user. So if I hit both urls described above nothing will happen to the users navigation. 

Of course with JavaScript you can perform a redirect by changing the window location. However, this will act as a get request. There is no way for the server to post via the browser.

Both forms and ajax solutions are very similar. The only difference is when using a third party API that redirects the user for you. If you need to use a post request to send data and the location will reroute the user, you will need to use a form post and not an ajax.
Creating a reusable “Token Manager” class in react-native.
Published: 2020-12-16 14:54:20

In any app, especially an app that has user accounts, it is a very common task to check for existing user token and redirects the user either to AuthStack or AppStack according to the token found. So for this common task, we can create our own token manager class which handles the common functionalities related to user token. In today’s code read I will try to document that.

Usually, we store tokens locally in our AsyncStorage, so we have 2 functions in our class. One is to set and the other one is to clear the token.

{% gist https://gist.github.com/Saad-Bashar/dbcae9c49e6ebf732b41580a4912b7b0 %}

Now the next one is the most important function, anywhere in our app where we want to get the valid token for the user we need to check a few things. They are the following:

* First, we check if there is any saved token in our local storage. We check for the tokenObj, that object should have the necessary information about the token. Like token value, expires-at, etc.
* If there is not an existing token, we return null.
* If there is an existing token, we need to check if the token is still valid, meaning if it is still not expired. This information should be passed from API when the user logged in or signed up in the app before.

So with all these steps, our function should look like following

{%gist https://gist.github.com/Saad-Bashar/5a27e4bc8fca20706da0c9a11ea9df88 %}

Finally, we have our new token function where if the token is expired we request for refresh token from the API.

{% gist https://gist.github.com/Saad-Bashar/204ce5cc063127c0f1a04159145886f1 %}

Once we have this class set up, we just need to import this class and create an object to get a valid token from anywhere in our app like the following.

{% gist https://gist.github.com/Saad-Bashar/30a01d3a8a2a95c6169b66bfdd2477e9 %}

The full code for the tokenizer class is given below for reference.

{% gist https://gist.github.com/Saad-Bashar/879815c81cf8827a0392342096f42c63 %}
Adding a dynamic favicon with users scroll percentage
Tags: favicon, javascript, html
Published: 2020-12-16 14:53:28

[See the effect here](https://styxofdynamite.github.io/50days50projects/percentage-scroll/) 

![Favicon Scroll](https://dev-to-uploads.s3.amazonaws.com/i/x6wohgyw2lbmee657vy5.png)

I decided to set myself the challenge of updating a favicon dynamically to show the users percentage scroll through the page.

First up, we introduce a function to generate an SVG as a data URL (which we will use for the favicon)

```
const faviconHref = (value) => {
    return `data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 width=%22256%22 height=%22256%22 viewBox=%220 0 75 75 %22 fill=%22white%22><text x=%2250%%22 y=%2250%%22 dominant-baseline=%22central%22 text-anchor=%22middle%22 font-size=%2258%22 stroke=%22black%22 fill=%22white%22>${value}</text></svg>`;
};
```

This function will take an input value and return a corresponding SVG (as a data URL) with the "value" text drawn on it.

The next step is to introduce a function to update the favicon in the page header.

```
const changeFavicon = (favicon) => {
    if (typeof window === 'undefined') {
        return;
    }
    const link = window.document.querySelector("link[rel*='icon']") || window.document.createElement('link');
    link.type = 'image/svg+xml';
    link.rel = 'shortcut icon';
    link.href = faviconHref(favicon);

    window.document.getElementsByTagName('head')[0].appendChild(link);
};
```

Next we introduce a function to calculate the users sroll and change the favicon using the above functions.

```
const calculateScroll = () => {
    const parent = document.body.parentNode;
    let percentage =
        ((document.body.scrollTop || parent.scrollTop) /
            (parent.scrollHeight - parent.clientHeight)) *
        100;

    percentage = Math.round(percentage);

    changeFavicon(percentage);
};
```

Here we are calculating the users scroll percentage of distance down the page and passing that percentage into the changeFavicon function, which in turns renders an SVG of the passed percentage value.

Finally we need to attach a window Event Listener that will call our calculateScroll function when a users scrolls as well as make an initial call to the function when the script is loaded.

```
window.addEventListener('scroll', calculateScroll);

//  initial call

calculateScroll();
```

The above functions can be added to an HTML page, such that when a user scrolls it will update the favicon
How to import Sass/SCSS mixins global?
Tags: question, react, sass, global
Published: 2020-12-16 14:43:50

At the moment I'm working on a boilerplate based on React.js. In the assets folder I have a `_mixins.scss` and `_breakpoints.scss` file.
```scss
// ../assets/_breakpoints.scss

/* Small (sm) */
$screen-sm-min: 640px;

/* Medium (md) */
$screen-md-min: 768px;

/* Large (lg) */
$screen-lg-min: 1024px;

/* Extra Large (xl) */
$screen-xl-min: 1280px;

/* Two Extra Large (xxl) */
$screen-xxl-min: 1536px;

...
```

```scss
// ../assets/_mixins.scss

// Medium devices
@mixin md {
    @media (min-width: #{$screen-md-min}) {
        @content;
    }
}

// Large devices
@mixin lg {
    @media (min-width: #{$screen-lg-min}) {
        @content;
    }
}

...
```

I import the two `.scss` files in the App.js so I can access the classes/mixins/variables global. But only the classes are accessible.

So for example using a mixin in `App.scss`:
```scss
.container {
  background: red;
    
  @include md {
    background: green;
  }
}
```

You should think this would work (defining a class in the `_mixins.scss` and using in the `App.js` file works) but he gives the error:

`SassError: no mixin named lg`

Anyone who is similar with this problem and maybe can help me?
My personal note on gRPC
Tags: grpc
Published: 2020-12-16 14:43:38


## Basic Concepts

- `gRPC` is a rpc(protocol) framework.
- `Protocol Buffer` is serialization mechanism supported by
    - `IDL(Interface Definition Language)` to write `.proto file`(scheme file) with
    - `protoc(protocol buffer compiler)` which can autogenerate client code & server code
    - Libraries which is used with afformentioned autogenerated scripts




## Steps to use gRPC

1. Write `.proto file`
    - with IDL 
2. Autogenerate client code & server code with `$grpc-gen-grpc` (, which is `protoc` command for ruby). This creates 2 files, which are 
    - `xxx_pb.rb`(`Request class` and `Response class` are defined)
    - `xxx_services_pb.rb`(`Service class` and `Stub class` are defined)
3. Implement `server script` (`Server class` should implemented here)` & `client script (which uses Stub class)` and boot them.


## Technologies behind gRPC

### Protocol Buffers

- As is mentinoned, this is composed of `lang + compiler + libraries`.
- For ruby, compiler command is `protoc-gen-grpc` which provides:
    - plugin to autogenerate message class
    - plugin to autogenerate service class
- Its binary format is compact and quickly (de)serializable.

### HTTP/2

- Stems from SPDY from Google. Transport is totally updated from HTTP/1.1
- Main functionalities are:
    - Multiplexing(多重化) which enables parallel responding (by multiple streams).
    - Header Compression(ヘッダ圧縮) by HPACK. (Originally in HTTP/1, header was 500-800 bytes)



## References

- https://www.wantedly.com/companies/wantedly/post_articles/219429
Becoming a Developer at 39
Tags: career, transition, change
Published: 2020-12-16 14:32:40

---
title: Becoming a Developer at 39
published: true
description: A brief story on my mid-life career transition into software development.
tags: career, transition, change
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/p369jk9sdzs6g2rethob.jpg
---
### **Becoming a Software Developer at 39**
I recently published a [story](https://norm-bell.medium.com/becoming-a-software-developer-at-39-c409586bc6fd) on Medium entitled *Becoming a Software Developer at 39*. I wrote it in the hopes that someone contemplating a similar move might get some encouragement from it.

{% medium https://norm-bell.medium.com/becoming-a-software-developer-at-39-c409586bc6fd %}
Are one liners always pythonic?
Tags: discuss, python, codequality
Published: 2020-12-16 14:29:51

> First of all, if you don't know what pythonic means, see [this question](https://stackoverflow.com/questions/25011078/what-does-pythonic-mean).

I love clean code as much as anyone, but I think we all agree that there should be a limit on how much you put on a single line of code.

For example, looking at some examples on the [Python wiki](https://wiki.python.org/moin/Powerful%20Python%20One-Liners) I came across elegant one liners like:
```python
# Palindrome Python One-Liner
phrase.find(phrase[::-1])

# Find indices of x in a list lst
indices = [i for i in range(len(lst)) if lst[i]==x]
```
but also some others that I don't find that much clean:
```python
# Quicksort Python One-liner
lambda L: [] if L==[] else qsort([x for x in L[1:] if x< L[0]]) + L[0:1] + qsort([x for x in L[1:] if x>=L[0]])
```
Do you have any criteria to limit your one-liners? Or don't you mind about the length of a line as long as it does the work?
Tabnine vs Kite
Tags: programming, productivity, vscode, javascript
Published: 2020-12-16 14:22:52

YouTuber and JavaScript Specialist Ania Kubów took the time and effort to help her dev community decide: which AI code completion tool they should use to get their code done better, and faster. In order to get a fair result, Ania threw a thrilling showdown:

Kite vs. Tabnine - The Ultimate Battle

In the video, Ania displays a split-screen featuring 2 recorded sessions from her code editor. The exact same code is being written in VSCode on both sides of the screen, with only one difference - Tabnine is installed and activated on the left-hand side, and Kite is active on the right-hand side. Can you guess who took the trophy? Press play and find out.
{% youtube 10cO9UNsA3Y %}