teleren/devto huggingface dataset:
Kubernetes workshop in a box
Tags: kubernetes, k8s, workshop
Published: 2020-04-09 08:26:05

We recently organised an internal Kubernetes workshop at our office. Each participant got their own 3-node Kubernetes cluster and all they needed was a laptop with an SSH client, no other software had to be installed! How? Read on to find out!

## Why

I wanted participants to have a real cluster to experiment with, but didn't want to ask everyone to install Minikube. It's heavy weight, can be a bit of a hassle to setup and I just didn't want people to have to mess with stuff like this. Workshops should have a low as possible barrier to entry.

To pull this off I used [Kind](https://kind.sigs.k8s.io/) (Kubernetes In Docker) + a bit of scripting and Unix magic! 💪

## The setup

The setup works as follows:

1. A **single**, beefy cloud server is used to host all Kubernetes clusters.
2. Kind creates true Kubernetes clusters inside Docker containers. This way, each cluster is fully isolated from the other clusters and clusters can run side-by-side on a single host machine. Every cluster consists of one master and two worker nodes.
3. The clusters are (automatically) provisioned in advance to the workshop, as creating the clusters is quite resource intensive and takes a couple of minutes per cluster.
4. During the workshop participants can claim their own cluster via SSH and then access their private cluster via a new SSH session.

You can see the process from a participant perspective in action below:

![GIF Kubernetes Workshop](//images.ctfassets.net/8v4g74v8oew0/tvE1HoF8b7N7QoFARJ6xd/6c8844b64ac82f4c890a0268afce8161/demo.gif)

## Hardware & costs

A Kind cluster is quite resource intensive, though in part it depends on the workloads your workshop participants are running of course. For our workshop with 15 participants we used an AWS `m5.8xlarge` machine. This machine type has 32 VCPU's and 128GB of RAM. It costs $1,712 per hour (in `eu-west-1`) and we needed it only for about 3 hours so that's about $5 total 🙂.

In hindsight, this machine was way over provisioned for this number of clusters, so you could go even cheaper 😀

## You can use this too to run your own Kubernetes workshops!

We've open-sourced the tooling we built to do this here: [https://github.com/kabisa/k8s-workshop-in-a-box](https://github.com/kabisa/k8s-workshop-in-a-box). Feel free to use it and if you do please reach out to me I'd love to hear from you! ❤️
How Do You Answer The Question 'Why Do You Want To Work Here?'
Tags: discuss, watercooler, career, interview
Published: 2020-04-09 08:15:13

Let's talk about one of the most common questions during interviews...

#### "WHY DO YOU WANT TO WORK HERE?"

How do you approach, attitude and strategy answering this question?

Let me know your thoughts...

![MS](https://media.giphy.com/media/3rgXBSoAqe32YRwTGE/giphy.gif)
More shared projects at Github than Euros in my bank account
Published: 2020-04-09 08:12:55

I have more projects under free software license in Github, than Euros in my bank account.

I usually smoke marijuana, but I cannot afford it with less than 100 euros.

They say Covid is a nightmare. And human rats are not?

Look at them. They act like zombies, they are insensitive to information.

8 people concentrate the same wealth than half humanity, this is 4.000.000.000. No reaction. Big up, Bill, big up...

Average salary in the neighbour country is less than half of here. No reaction.

TV news only talk about these specific countries, we are not being informed about the world, only about the world some people (you do not know) want to tell you. No reaction.

There is more, of course.

But... guess what. Exactly, NO REACTION.

OK. I better keep "hungry, foolish", as Stebe Jobs would say.

Thanks rats, this is your game, not the mine.
Top Technology Telegram Channels for IT professionals
Tags: bigdata, datascience, machinelearning, python
Published: 2020-04-09 08:05:14

<p><span style="font-weight: 400;">Telegram Channel - Your best friend to learn the latest cutting-edge technologies like Python, Machine Learning, Data Science, Big Data and many more.</span></p>
<p><span style="font-weight: 400;">List of </span><strong>Top Technology Telegram Channels</strong></p>
<ul>
<li style="font-weight: 400;"><a href="https://t.me/dataflair"><strong><em>DataFlair</em></strong></a><span style="font-weight: 400;"> - Get updates on latest cutting-edge technologies</span></li>
<li style="font-weight: 400;"><a href="https://t.me/pythonpundits"><strong><em>Python Telegram Channel </em></strong></a><span style="font-weight: 400;">- Work on Python practicals &amp; live projects</span></li>
<li style="font-weight: 400;"><a href="https://t.me/datasciencemorons"><strong><em>Data Science Telegram Channel</em></strong></a><span style="font-weight: 400;"> - Learn Data Science with the projects</span></li>
<li style="font-weight: 400;"><a href="https://t.me/MLmorons"><strong><em>Machine Learning Telegram Channel</em></strong></a><span style="font-weight: 400;"> - Master ML concepts with real-time practicals</span></li>
<li style="font-weight: 400;"><a href="https://t.me/big_data_psychos"><strong><em>Big Data Telegram Channel </em></strong></a><span style="font-weight: 400;">- Learn Apache Hadoop, Spark, Kafka</span></li>
<li style="font-weight: 400;"><a href="https://t.me/RPundits"><strong><em>R Programming Telegram Channel</em></strong></a><span style="font-weight: 400;"> - Become a Data Scientist with R</span></li>
</ul>
<p><span style="font-weight: 400;">There are a huge 2.2 million and 2.8 million apps available for download on the Apple App Store and Google Play Store respectively. And the number of apps that are really helpful and productive for a person would barely be in hundreds only.</span></p>
<p><span style="font-weight: 400;">For me, the most productive app has been Telegram. Its amazing learning Telegram channels have taken my career to a whole new level.</span></p>
<p><span style="font-weight: 400;">If you are looking for a boost in your career join these Telegram channels and start learning new technologies</span></p>
<p><br /><br /><br /><br /><br /><br /></p>
Do not pay for education: steal it and share it
Tags: education
Published: 2020-04-09 07:35:43

I know, I know. You now want some appealing introduction. With symbols you recognize and you feel closed to.

But no, this is simpler.

When you pay for education, you force others to pay to stay competitive, and you make some fall apart from competitive education.

Do not pay for knowledge.

If they cannot understand or stand ideas sharing, keep calm. Life is short, ignorance given, ignorants will remain.
Precise and programmable Office Suite?
Tags: discuss, watercooler
Published: 2020-04-09 07:33:57

What do you use? MS Word and PowerPoint aren't being easy to be precise. PDF should be a possible output. Not sure about LibreOffice...

Programmable or CSS-based might be nice. Should also be semantically correct. (Like heading being h1.) Diff-able with Git would be nice.
How to clear screen in python terminal
Tags: python, tutorial, todayisearched, todayilearned
Published: 2020-04-09 07:33:03

Originally posted on my [blog](https://lewiskori.com/blog/how-to-clear-screen-in-python-terminal/).

When working with the python interactive shell, you may end up having a cluttered screen. For Windows and Linux users, one can run `cls` or `clear` to clear their screens. But this doesn't seem to cut it while working in the python shell. Here are a few quick tips to achieve this in python. 

We need to get into python shell first 😆. To do this, type `python` in your terminal or if you want to access the Django DB shell, `python manage.py shell` will suffice.

### first method

The simplest method is using `ctrl+l` for Linux/OS X terminals.

### second method

Another handy way is by using the [os module](https://docs.python.org/3/library/os.html) that ships with the standard python library. This module provides a portable way of using operating system dependent functionality.

```python
from os import system

clear = lambda: system('clear')
```

We are utilising python's [lambda functions](https://www.w3schools.com/python/python_lambda.asp) to achieve this functionality. By calling on the underlying os `clear` function for UNIX based system and assigning that to our newly created clear function.

This way if we want to clear the screen we can call the function like so `clear()`

for windows systems, the following would work just as well.

```python
from os import system

cls = lambda: system('cls')
```

and call the function in the python shell by running `cls()`

Note that you don't have to declare the function as clear or cls. You can name them whatever you want, as long as you use that name when calling them.

## Other useful tricks you can use with the os module

### Getting the current working directory

```python
import os
os.getcwd()
```

In my case, this returned `'/Users/me/Projects'`

### Changing the current working directory

```python
os.chdir('..')
```

This should work similar to `cd ..` returning `'/Users/me'`

### listing items in a directory

```python
os.listdir('directory_path')
```

similar to the `ls` command.

### get currently logged in user operating the terminal

```python
os.getlogin()
```

For more information on the os module, check out the [documentation](https://docs.python.org/3/library/os.html)

Thanks for reading and feel free to contact me if you have any questions on [twitter](https://twitter.com/lewis_kihiu).
The Byte - Mirantis Acquires Docker and What this Means
Tags: podcast, docker, devops
Published: 2020-04-09 07:23:19

Mirantis acquired Docker and split Docker Enterprise to Mirantis. Now Docker is focusing on Developer Tools, and returning to its roots supporting Open Source, and integrating with CI/CD tools

{% spotify spotify:episode:0Jq1H0jqiNmYF0BXvIj9vP %}

* Mirantis - https://www.mirantis.com/
* Docker Regroups - https://techcrunch.com/2020/03/10/docker-regroups-as-cloud-native-developer-tool-company/?guccounter=1
* Mirantis Docker Swarm extends support -https://devclass.com/2020/02/25/mirantis-to-keep-docker-swarm-buzzing-around-pledges-new-features/
* Docker Roadmap - https://github.com/docker/roadmap/projects/1
* Docker Birthday discounts - https://www.docker.com/blog/mydockerbday-discounts-on-docker-captain-content/
Counting Elements – LeetCode challenge JavaScript solution
Tags: programming, javascript, codequality
Published: 2020-04-16 12:13:49

---
title: Counting Elements – LeetCode challenge JavaScript solution
published: true
date: 2020-04-09 07:14:14 UTC
tags: Programming, javascript, codequality
canonical_url: https://rajeshroyal.com/counting-elements-leetcode-challenge-javascript-solution/
---

## Counting Elements Problem statement:

[LeetCode](https://leetcode.com/)

Given an integer array `arr`, count element `x` such that `x + 1` is also in `arr`.

If there’re duplicates in `arr`, count them separately.

**Example 1:**

```
**Input:** arr = [1,2,3] 
**Output:** 2 
**Explanation:**  1 and 2 are counted cause 2 and 3 are in arr.
```

**Example 2:**

```
**Input:** arr = [1,1,3,3,5,5,7,7] 
**Output:** 0 
**Explanation:**  No numbers are counted, cause there's no 2, 4, 6, or 8 in arr.
```

**Example 3:**

```
**Input:** arr = [1,3,2,3,5,0] 
**Output:** 3 
**Explanation:**  0, 1 and 2 are counted cause 1, 2 and 3 are in arr.
```

**Example 4:**

```
**Input:** arr = [1,1,2,2] 
**Output:** 2 
**Explanation:**  Two 1s are counted cause 2 is in arr.
```

**Constraints:**

- `1 <= arr.length <= 1000`
- `0 <= arr[i] <= 1000`

## Counting Elements ES6 solution

```
/\*\* \* @param {number[]} arr \* @return {number} \*/

var countElements = function(arr) { 
   let count = 0; 
   for(let i = 0; i < arr.length; i++){ 
     if(arr.includes(arr[i]+1)) count++; 
   } 
   } 
   return count;
};
```

## Submission Output on LeetCode:

![code output - Counting Elements - LeetCode challenge JavaScript solution](https://rajeshroyal.com/wp-content/uploads/2020/04/image-1-1024x110.png)
Quickly install elixir using asdf
Tags: elixir, asdf, erlang
Published: 2020-04-09 04:54:56

[ASDF](https://github.com/asdf-vm/asdf) is a cli used to manage the installation and runtime versions of several popular languages. I've recently found out about asdf, and used it to run a quick update on my local machine. This article will provide a quick tutorial on the installation and update process.

##1. Install ASDF.
To install asdf, first clone the most recent stable release from the github repository:

`git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.7.8`

Then, add it as an environment variable to bash

`echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bashrc`
##2. Install Erlang and Elixir
You can then install any language from these [list of plugins](https://asdf-vm.com/#/plugins-all). We will be installing the most recent version of erlang and elixir using these plugins.

###Install erlang:
`asdf plugin-add erlang https://github.com/asdf-vm/asdf-erlang.git`

###Install elixir:
To install elixir, the installation instructions dictate you must have unzip installed first. Run the following commands
`sudo apt install unzip && asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git`

####Optional: Install hex and rebar.
You can install hex and rebar by running the following command
`mix local.hex --if-missing --force && mix local.rebar --if-missing --force`

##Final: Set up your .tool-versions.
The `.tool-versions` file is the file which asdf uses to determine which installed version of the language your project uses. U can set up a global `.tool-versions` for asdf to fall back on if your current folder doesn't have a `.tool-versions` present. Run the following command.

`echo -e '\n elixir 1.10.2 \n mix 1.10.2' >> $HOME/.tool-versions`
Set up your own mail server
Published: 2020-04-09 07:06:34

Claim back your mail

Most people have casual emails such as Gmail, Yahoo, Microsoft or other free providers: that might be OK, in a sense. Most companies in the IT industry have their own domain names for professional use, but they entirely give up the ownership of their data by subscribing to the same services that random users have for unprofessional, sporadic use.

This is stupid.

I think companies and institution should by default own their data.

Managing your own mail server is a way to own your data.

https://kevwe.se/article/mailserver/
The virtuous cycle of CI/CD
Tags: devops, sre
Published: 2020-04-09 06:09:26

From [here] (https://landing.google.com/sre/workbook/chapters/canarying-releases/).

![The virtuous cycle of CI/CD](https://dev-to-uploads.s3.amazonaws.com/i/t20x6amdgqgzyw1nlogk.png)
Why informatics turned into a philosophical battle (for money!)
Tags: informatics, philosophy, economy
Published: 2020-04-09 05:53:31

Well. There is a battle in informatics. Not only one, but a lot of them.

Operative systems: Windows, Linux, Mac, then Android, iOS...

**It all starts with the booting.**

But it does not finish that soon.

Programming languages: xASM, C/C++, PHP, JS, Ruby, Python, ...

Then frameworks for each topic. Coding styles. Methodologies. IDEs, editors, compilers, etc.

Do not you see that there is a continuous, unstoppable and delivered marketing battle between brands?

Windows? Or Apple? Or Linux? Or Temple OS maybe?

It is unavoidable the branching of technologies. But I am sure that no other area of knowledge has as many abbreviations and brand names as informatics.

**It satures the brain**. It is already difficult to code. It is already difficult to learn. But, in the meanwhile and on the road, there is people wanting to make money with the ignorance of others, to take profit of the "less clever".

I usually think of humans as a mount of rats fighting with each other to take some breath like climbing the mountain they build with the dead bodies they leave on their ways.

There are still maths to find out to know how a User Interface is more efficient (and not only damnedly beautiful, bitches!)

There is no science in design. But because there is no universal message, there is no universal intentionality in each and every interface.

Look. Ethics talk about good and bad. The good and the bad need also and intention. Drinking poison is bad? It is not if you **want to** die. You see, different intention, different good-bad things.

In any case, there is a batlle in the realm of humans, we are divided by language, countries, and then traits and interests. What is the purpose, the intention of this? Did you wonder?

Informatics grows with standarization.

Standarization gets stronger with maths.

Maths of today lack of natural language integration.

But programming languages are there to rescue that part of the maths that decided to forget that semmantics explained numbers to us before.

And, if it was not enough, they make you pay to get qualified knowledge, aka. **to study from university**.

Whatever, male bitches, whatever, if I get fed up of your game, at least, I know where the door is.
How to work the keyword: this ?
Tags: javascript
Published: 2020-04-09 05:16:32

---
title: How to work the keyword: this ?
published: true
description: How to work the keyword: this ? 
tags: Javascript
---
In this article, i don't want to take more times to explain how the `this` keyword work. I will explain in clear terms and fastly. In fact, more developers are confused about the `this` keyword. 

# What is ?

**the `this` keyword references the object that is executing the current function**.

1. if a function is a method in a object, `this` reference that object

2. if a function is a regular or anonymous function, `this` reference the global object which is the window object in the browsers and global for nodejs

## How it Work ?

> if a function is a method in a object, `this` reference that object

let's to create our first example and to explain in more details. we are going to create a simple user object with object syntax literal
```js
const user = {
  name: "Emmanuel",
  country: "Ivory Coast",
  getAddress() {
    console.log(this)
  }
}
console.log(user.getAddress())
```
as we can see in the user object we have a method called `getAddress()` and inside the method we have called the `console.log(this)` to show in the console the result of our `this` reference: 
```sh 
{
  name: 'Emmanuel',
  country: 'Ivory Coast',
  getAddress: [Function: getAddress]
}
```
we can see that `this` reference our user object. if we want to access for example the key name or country on each line inside the getAddress() method we can do that:
```js
const user = {
  name: "Emmanuel",
  country: "Ivory Coast",
  getAddress() {
    console.log(this.name),
    console.log(this.country)
  }
}
```
In the console, the result is 
```sh
  Emmanuel
  Ivory Coast
```
With ES6 classes is the same. 

```js
class Person {
  constructor(name, country){ this.name = name, this.country = country}
  getAddress() {console.log(this)}
}

let person = new Person('Emmanuel', 'Ivory Coast').getAddress()
console.log(person)
``` 
as we can see, we have to create a Person class and this class has the `getAddress()` method to show the `this` in the console, then we create a instance of our Person class and show the result: 
we can see that the `this` keyword reference our Person class

> if a function is a regular or anonymous function, `this` reference the global object which is the window object in the browsers and global for nodejs

we are going to create a simple function called getVideos() and show the `this` keyword in the console
```js
function getVideos() {
 console.log(this)
}
console.log(getVideos())
```
when we show the result in the console, we can see a global object window in the browser or global object in nodejs
Tired of selecting and copy pasting the data from functions?
Tags: python, clipboard, utility, productivity
Published: 2020-04-09 04:24:10

Often we require to print some value then select it and copy paste to different places to compare or debug, we can save some time using python's `pyperclip` which is very simple to use:
```
def copy_data_to_clipboard(string_data):
    import pyperclip
    pyperclip.copy(string_data)
    spam = pyperclip.paste
```
just have this function in your code and use it whenever you need.
How to make a Show More Component in React.
Published: 2020-04-09 04:22:00

### Introduction

Recently I had to make a Show More Component for a body of text. Here I will outline the basic steps to make this component.

1. Have a truncate text function
```
function truncateString(str, num) {
  // If the length of str is less than or equal to num
  // just return str--don't truncate it.
  if (str.length <= num) {
    return str
  }
  // Return str truncated with '...' concatenated to the end of str.
  return str.slice(0, num) + '...'
}
```
2. Have an internal state variable that tracks if the text should  be truncated and likewise use the show more text or the show less text.

```js
import React from 'react';

export type ShowmoreProps = {
  /**
   * Props to be passed to the Showmore component.
   * @params text: string - a node to be rendered in the special component.
   * @params truncateLength: number - the number of characters to show before truncating.
   */
  text: string;
  truncateLength?: number
};

function truncateString(str, num) {
  // If the length of str is less than or equal to num
  // just return str--don't truncate it.
  if (str.length <= num) {
    return str
  }
  // Return str truncated with '...' concatenated to the end of str.
  return str.slice(0, num) + '...'
}

export function Showmore({text, truncateLength = 50}: ShowmoreProps) {

    const [showMore, setShowMore] = React.useState(false);

    if (showMore) {
        return(<div>
          <p>{text}</p>
          <button onClick={() => setShowMore(false)}>Show less</button> 
          </div>
          );
    }
    return (
        <div>
            <p>{truncateString(text, truncateLength)}</p>
            <button onClick={() => setShowMore(true)}>Show more</button>  
        </div>
    );
};
```

Find more posts like this at [my blog](https://friendlyuser.github.io)