teleren/devto huggingface dataset:
Install Kafa to Raspberry Pi 4
Tags: kafka, raspberrypi, iot, eventstore
Published: 2020-09-05 09:20:22

I wanted to run kafka on my raspberry pi 4 as i wanted to do a POC on an IoT project. Here are the steps on how to install it. I use SSH to login to my Rpi.

##1. Install Java:
+ Run the following command to install it:
```
$ sudo apt update
$ sudo apt install default-jdk
```
+ Check version to test if the installation is successful. It should show you the version installed as shown below.
```
$ java --version
openjdk 11.0.8 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Raspbian-1deb10u1)
OpenJDK Server VM (build 11.0.8+10-post-Raspbian-1deb10u1, mixed mode)
```
##2. Install Kafka:
+ Download kafka. Goto to [https://apachemirror.sg.wuchna.com/kafka/](https://apachemirror.sg.wuchna.com/kafka/) site and select the latest version. At the time that i was writing this post the latest is 2.6.0.
```
$ wget https://apachemirror.sg.wuchna.com/kafka/2.6.0/kafka_2.12-2.6.0.tgz
```
+ Extract Kafka. Using the tar command. Once extracted, go inside the directory and create /data folder with /kafka and /zookeeper subfolders.
```
$ tar -xzf kafka_2.12-2.6.0.tgz
$ cd kafka_2.12-2.6.0
~/kafka_2.12-2.6.0 $ mkdir data
~/kafka_2.12-2.6.0/data $ mkdir kafka
~/kafka_2.12-2.6.0/data $ mkdir zookeeper
```
+ Edit config/zookeeper.properties
```
$ sudo nano kafka_2.12-2.6.0/config/zookeeper.properties
```
  Find and change **dataDir** value to **/home/pi/kafka_2.12-2.6.0/data/zookeeper**. 

> dataDir=/home/pi/kafka_2.12-2.6.0/data/zookeeper

  Press **Ctrl+X** then **Y** to save it.

+ Edit config/server.properties
```
$ sudo nano kafka_2.12-2.6.0/config/server.properties
```
  Find and Change **listeners** value to **PLAINTEXT://{your_ip_address}:9092**. Ensure to replace *{your_ip_address}* with your device ip address.

>listeners=PLAINTEXT://{your_ip_address}:9092

  Next is to locate and update **log.dirs** value to **/home/pi/kafka_2.12-2.6.0/data/kafka**.

> log.dirs=/home/pi/kafka_2.12-2.6.0/data/kafka

##3. Test Kafka
* Start Zookeeper
```
~/kafka_2.12-2.6.0 $ bin/zookeeper-server-start.sh config/zookeeper.properties
```
* Start Kafka
```
~/kafka_2.12-2.6.0 $ bin/kafka-server-start.sh config/server.properties
```
* Create a topic
```
~/kafka_2.12-2.6.0 $ bin/kafka-topics.sh --create --bootstrap-server {your_ip_address}:9092 --replication-factor 1 --partitions 1 --topic TestTopic
```
It will show you the message below as reponse for topic created.
> Created topic TestTopic.

* Check for the created topic
```
~/kafka_2.12-2.6.0 $ bin/kafka-topics.sh --list --bootstrap-server {your_ip_address}:9092
```
This will show you the newly created topic
> TestTopic

* Start Kafka Producer
```
~/kafka_2.12-2.6.0 $ bin/kafka-console-producer.sh --broker-list {your_ip_address}:9092 --topic TestTopic
```
* Start Kafka Consumer
```
~/kafka_2.12-2.6.0 $ bin/kafka-console-consumer.sh --bootstrap-server {your_ip_address}:9092 --topic TestTopic
```

Once both Producer and Consumer is up and running start typing on the producer window. Each message should show in the consumer window.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/8djq9pw6h213gbq31j19.png)
Kill that pesky process, the really lazy way
Tags: bash, productivity, beginners, linux
Published: 2020-09-05 09:12:52

This is going to a be a quick one, today i'm going to share a small bash script that has saved me precious seconds or maybe even whole minutes over the years, every time i want to kill a process to free up a port.

## Why

```
Something is already running at port 9000
```

I run into one of these every once in a while. 

With me it often happens when i _SUSPEND_ (<kbd>CTRL</kbd>+<kbd>Z</kbd>) my dev server instead of _KILLING_ (<kbd>CTRL</kbd>+<kbd>C</kbd>) it. 

The next steps would often involve hunting down the `pid` of the process running on that port and killing it.

Easy enough, but here's something easier.

## How

1. `cd` to `/usr/local/bin/`.
2. Create a new file and name it `stop` or anything else you want.
3. Paste the following into it 
    ```
       #!/bin/bash
       touch temp.text
       lsof -n -i4TCP:$1 | awk '{print $2}' > temp.text
       pidToStop=`(sed '2q;d' temp.text)`
       > temp.text
       if [[ -n $pidToStop ]]
       then
       kill -9 $pidToStop
       echo "!! $1 is stopped !!"
       else
       echo "Sorry nothing running on above port"
       fi
       rm temp.text
    ```
    *disclaimer: i didn't write the script, i merely adopted it. Credits below.
4. `chmod +x stop` to make the file executable. `chmod 755` also works.
5. Now you can use `stop 9000` or any other port anytime on the terminal to stop whatever process is running on that port. 
6. Profit. Write once, use always.

_Very briefly, what the script above does is find the `pid` of the process running on the input port, copy it to a temp file and then read the temp file to find the `pid` in it and kill it, finally deleting the temp file. 
`awk` for those curious is a programming language used for text processing._

### Notes
- Here's my [gist](https://gist.github.com/GuhaAG/32ae5f04293e9075e44754785b41f8b9) with the script above.
- Here's the stackoverflow [answer](https://stackoverflow.com/questions/24387451/how-can-i-kill-whatever-process-is-using-port-8080-so-that-i-can-vagrant-up/59986097#59986097) i originally found this script at.


_Title Image by [Sammy-Williams](https://pixabay.com/users/Sammy-Williams-10634669) over at [Pixabay](https://pixabay.com)_
Introducing Go tutorial series
Tags: programming, go, tutorial, beginners
Published: 2020-09-05 09:04:29

---
title: Introducing Go tutorial series
published: true
description: Go tutorial series will be covering all fundamentals of Go from scratch
tags: programming, go, tutorial, beginners
series: Go Tutorial Series
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/2ll78votk2xtbe51k2jx.png
---
Hey Devs


I'm starting a tutorial series to learn Go from scratch.

This series will help people to learn the language from scratch and will be covering advanced topics.

Lately, I was reading about learning in public. So I thought of just trying this out in small steps.

And I will be updating all my notes in my blog.

Let's see how it goes :) :)
Codewars Kata: Counting sheep… with Ruby
Tags: ruby, rails, codenewbie, 100daysofcode
Published: 2020-09-05 08:46:55

{% youtube zljCd0ESGdU %}

To solve this problem, we’ll take 5 different approaches.
Enjoy the video 😀🙏

Also written version https://losseff.xyz/katas/010-counting-sheep/ruby/
Docker Introduction
Tags: docker
Published: 2020-09-05 08:32:28


This is the blog version of this video.
To watch the YouTube video, check

[Click here to watch to Video Version](https://www.youtube.com/watch?v=eN_O4zd4D9o)


# What is Docker?
Docker is a platform for both developers and sysadmins to build, run, and share applications using this idea of containers. 

This way to deploy an app using containers is called CONTAINERIZATION. 

Docker is not the only technology that uses containers, but it’s the most famous one, the most used one, and the current de facto standard, so I recommend you to start with Docker first to learn containerization concepts.

# What is a Docker container? 
A Docker container is just a running process with additional features in order to keep it encapsulated and isolated from the host machine and from other containers. The container runs reliably and quickly from one environment to another, and this is the dream for developers and sysadmins. 

# 6 features the containers offer:
Containers are FLEXIBLE, because no matter the complexity, the dependencies, the languages, every application can be containerized.

Containers are also LIGHTWEIGHT, by sharing the same kernel, they don't consume a lot of system resources, so you save money, which is always a good thing.

Another one, the best feature for me, is that they are PORTABLE: You can build locally, then run everywhere Docker is installed.

Containers are also LOOSELY COUPLED: They are well encapsulated and highly self-sufficient. You can replace, upgrade, or delete one, without disrupting the whole system, and this is very good for big projects, where different teams work on different parts of the same, big, system.

Containers are SCALABLE: Indeed you can easily increase/decrease/automatically distribute containers replicas. You can also use an orchestration tool, like Docker Swarm, or Kubernetes. And this will make the difference when you will have a successful app. And you want a successful app, right?

And last but not least, Containers are SECURE, because they apply aggressive constraints and isolations to processes by default, without any configuration required. Of course, in the end, you are in charge of the security of your app!

Each container interacts with its own dedicated filesystem, which is provided by a Docker image. 

# What is a Docker Image?
A Docker image is an executable, packaged file that includes everything you need to run an application: code, runtime, dependencies, tools, libraries, configuration. 

To use a programming analogy, an image is like a class, and a container is an instance of that class, so you can have many containers running from the same image at the same time

So that’s it for this brief introduction of what Docker is. 

Thanks for reading, and see you next time

[Click here to watch to Video Version](https://www.youtube.com/watch?v=eN_O4zd4D9o)
Recommend here good books and movies.
Published: 2020-09-05 08:17:02

Hi, 
I'm looking for healthy conversation.

Recommend good books which you had read recently.
Also recommend good movies of any languages.
I mainly looking for German,Turkish,Iranian,Spanish movies. And I recommend a book as well as movies.
 
BOOK - "Sapiens: A Brief History of Humankind" by Yuval Noah Harari. 
MOVIES - "Labyrinth of lies" and "Sanctuary"(German: Freistatt) 

Thank you.
Flutter Automation Script
Tags: flutter, windows, batchscript, python
Published: 2020-09-05 07:59:48

I find it cumbersome every time to create a project, upload it to Github, and then start the real work. So, I have created an automation script to do all the work! 

Made with Batch Scripting, Shell Scripting and Python!

Now you're just a line away from creating, uploading to Github and digging into the real meat and patotoes.

What does it to?
- Creates a flutter project
- Uploades it to your github
- Finally, opens with either Android studio or VSCode the choice is yours.

Sadly I cannot post the GIF here due to the 200 frames limit, but you can view it in my Github repo.

Also, for detailed expalanation as to how it works and how to use it, do check out my github. 

### _**UPDATE**:_

Linux scripts are now available! 
Do check out the github repository for more information. 

Drop a star if you like it!

{% github Tushar-OP/Flutter-Automation %}
RFM NAV Customer Classification with Python and Azure Functions
Tags: serverlessseptember, python, machinelearning, azure
Published: 2020-09-05 07:54:18

This article is part of #ServerlessSeptember https://aka.ms/ServerlessSeptember2020 . You'll find other helpful articles, detailed tutorials, and videos in this all-things-Serverless content collection. New articles from community members and cloud advocates are published every week from Monday to Thursday through September.

Find out more about how Microsoft Azure enables your Serverless functions at https://docs.microsoft.com/azure/azure-functions/.

Content here: https://medium.com/@antoniosql/rfm-nav-customer-classification-with-python-and-azure-functions-2ad3b66d2220
More Sound Design for my game (Indie Game Devlog)
Tags: unity3d, devlog, monetization, indie
Published: 2020-09-05 07:33:21

This is the 7th episode in this devlog series, where I document the entire game making processת
this is my first android game that I want to actually publish to the Play Store.

In this episode I added helpers for the first level and also added powerups that you will be able to get only if you will watch 30 seconds ads, so I monetize my game and make some moneyssss

{% youtube tvz6jS9WRDg %}

> Like this post? 
> Consider Support me via [Patreon](https://www.patreon.com/eranelbaz)
> Or Subscribe to my [YouTube Channel](https://www.youtube.com/channel/UCVUNeBGM5wZJKcOx0QwAaTA?sub_confirmation=1)
> You can also follow me on [Twitter](https://twitter.com/elbaz_eran)
Functional Programming in Javascript - Imperative and  Declarative
Tags: javascript, functional, react
Published: 2020-09-05 07:07:29

Hello there, in this post I will be talking about the imperative and declarative concepts. Whenever you have attempted to reduce or map the array without your knowledge, you are good to go to be a functional programmer in javascript. React, Flux, and redux all these are functional programming javascript frameworks.
Now talking of Declarative, its when your application is structured in a way that prioritizes describing what should happen over defining how it should happen.
It would be easier if you compare the imperative and declarative examples here:
```
var string = "hi there , I'm a web developer";
var removeSpace = "";
for (var i = 0; i < i.string.length; i++) {
  if (string[i] === " ") removeSpace += "-";
  else removeSpace += string[i]; 
}
console.log(removeSpace);
```
In this example, we loop through every character in the string, replacing spaces as they occur. Just looking at the code, it doesn't say much. Imperative requires lots of comments in order to understand code. Whereas in the declarative program, the syntax itself describes what should happen and the details of how things happen are abstracted way.
```
const string = "Hi there, I'm a web developer ";
const removeSpaces = string.replace(//g,"-");
console.log(removeSpaces);
```
Isn't this looks more readable and easier to reason about?
Now, let’s consider the task of building a document object model, or DOM. An imperative approach would be concerned with how the DOM is constructed:
```
var headline = document.createElement('h1');
headline.innerText = "Hello World";
```
It would be very hard to make changes, add features, or scale 10,000 lines of code where the DOM is constructed imperatively.
Now let’s take a look at how we can construct a DOM declaratively using a React component:

```
const { render } = ReactDOM
const Welcome = () => (
<div id="App">
//your HTML code 
//your react components
</div>
)
render(
<App />,
document.getElementById('home')
)
```
React is declarative. Here, the Welcome component describes the DOM that should be rendered. The
render function uses the instructions declared in the component to build the DOM, abstracting away
the details of how the DOM is to be rendered. We can clearly see that we want to render our
Welcome component into the element with the ID of 'target'.
PHPUnit: How to Access My Installed Version of PHPUnit on xampp
Tags: php, xampp, phpunit, beginners
Published: 2020-09-05 07:02:29


The inability to access or use your installed PHPUnit is a common error in PHPUnit especially if you are using XAMPP. 

Assuming that in your computer when you run

composer require --dev phpunit/phpunit ^9.2

..to check the version via the command-line interface, you see version 3.7x, then this article is for you. Normally xampp comes with version 3.x.x of PHPUnit. That is what is overriding your installed version.
Bottom line is that if you are building a PHP application on xampp, the preconfigured older version of PHPUnit in xampp will override the newer one you install.

Here is how I resolved this same problem recently along with its associated error messages. 

1.	Go to xampp/PHP/pear directory. There you will see two folders named PHPUnit and PHPUnit2. Delete both folders. 
2.	Go to xampp/php folder you will see two files named PHPUnit and another phpunit.bat. Delete both files. 
3.	Go to environment variable settings. Just type env in your system search bar and hit enter. You will see the panel on the image below. Click the button I circled in red. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/lww2g3pr66wf71acekck.jpg)
4... Once you click the button you will see 

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

Copy the path to your PHPUnit C:\xampp-main\htdocs\projecFolder\vendor\bin
Then click on the places highlighted in red and click “Edit”, click “new” on the panel that will pop up. Add the path you just copied. 
 
5... Restart your command prompt or open another command prompt. Type PHPUnit –version, you will see your installed version. 

That is it. Now you can move on with your adventure in PHP unit testing. 
- Ikechukwu Unegbu
How to connect your DB with an SSH Tunnel and Docker
Tags: docker, database, ssh
Published: 2020-09-05 06:48:08

When using a database like PostgreSQL, we usually use a managed database like Amazon RDS nowadays.

Then we would configure to allow only some servers to connect to the database (e.g. only EC2 servers can connect to a database on RDS).

But sometimes, we want to connect to such a database and check something from our local. In that case, we can use an SSH tunnel way.

This post describes how to do that.

## Docker image

To connect to your database, you have to execute a command like `psql`, `mysql`, or something like that.
So let's prepare a Docker image which is compatible with your actual database.

In this post, I plan to use PostgreSQL as an example, but there is no PostgreSQL specific information. Please select your favorite one.

## SSH tunnel

Let's try to create an SSH tunnel next!

The actual command would be like this:

```bash
$ ssh -L 15432:db.some-service.jp:5432 web.some-service.jp -N
```

To do that, you have to be able to ssh `web.some-service.jp`, if your SSH tunneling failed, please try `ssh -i {your_ssh_key} {your_ssh_user}@web.some-service.jp` or make sure your ssh config is correct.

The above command means forwarding your local's 15432 port to `db.some-service.jp`'s 5432 port.

By specifying `-N` option, the command does not execute a remote command. This is useful for just forwarding ports.

Don't close this command and let's try to actually connect to your database in the next step!

## Connect to your database

Please open a new tab and let's try to connect to your database.

The actual command would be like this:

```bash
$ docker run -it --rm postgres:11.9 psql -h host.docker.internal -p 15432 -U db-user -W db_name

# Enter your db password
Password:
db_name=> SELECT * from users;
...
```

You can connect to the special DNS name `host.docker.internal` which resolves to the internal IP address used by the host.

And then by specifying `15432` which is forwarded in the previous step, you can connect to your database and execute commands there!

At last, don't forget to close your forwarding command!

## Summary

- Using an SSH tunnel and Docker, we can connect to our remote database easily.

## References

- https://docs.docker.com/docker-for-mac/networking/#use-cases-and-workarounds
How to create Item and Button Groups in Svelte efficiently.
Tags: svelte, uiweekly, node, component
Published: 2020-09-05 06:19:55

You can create button groups with the use of `setContext` and `getContext` and slots. See the REPL.

You will get something like this.
```html
<ButtonGroup>
	<Button value="foo">
		Foo
	</Button>
	<Button value="bar">
		Bar
	</Button>
	<Button value="baz">
		Baz
	</Button>
</ButtonGroup>
```

Here is the [REPL](https://svelte.dev/repl/7dae7f254a2348d5ad42ad09d84a137f?version=3.24.1)
Invitation in web organization
Tags: news
Published: 2020-09-05 06:06:13

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


## Why should i join ? 💬
- Get more reach
- member of community
- Grow your knowledge


## How i can join ?

- Step 1: Copy this code and follow step

``` d4bbf76c90e83a6675df5c309b9c156e2f9a5d31987dc73863ca02fae35b730383719e7039befdaa6f52ed7a43d4f24a4fd2 ```

- Step 2: Go to setting
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vmfyd6j5zz105ugx6o0a.png)

- Step 3: click on organization tab
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bjkq9zqlj3h8omfolg63.png)

- Step 4: paste code and click on join organization
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6zs1xd0gsa54rxzw6d8h.png)


welcome 🌹
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/axbyhou43ohmgd0rbt7h.gif)
New version for Tooltip-Sequence 1.0.3 🔥
Tags: showdev, javascript, webdev, productivity
Published: 2020-09-05 05:20:16

Finally I have released a new version for the tooltip-sequence package I was working on.

The new release has reduced size and has the following features
 - Changing the backdrop color.
 - Placement options for the tooltip.
 - Event after complete of the sequence.
 - Quit on outside tooltip click.
 - Arrow heads to point to the active element and avoid confusion.

The package is really easy to use and is available in both npm and cdns. Check [here](https://www.npmjs.com/package/tooltip-sequence) for the installation details.

You can also find the demo site shown in the gif above and try it for yourself [here](https://tooltip-sequence.netlify.app/).

If you really like this package or find it useful. Please leave a star on the [repo](https://github.com/SoorajSNBlaze333/tooltip-sequence) and share it among the people whom you know are in need of this in their web app.
Access host's docker from container
Tags: docker, tutorial
Published: 2020-09-05 04:32:56

We are going to access host's docker from container.

Container requires docker to be installed. (You can also install `docker-compose` if you need)

```
FROM centos:7

RUN set -eux; \
    yum install -y sudo;

# Install docker and docker-compose
RUN set -eux; \
    sudo curl -sSL https://get.docker.com/ | sh; \
    sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose; \
    sudo chmod +x /usr/local/bin/docker-compose
```

Just build the docker image as usual.

```
docker build -t franz/test .
```

We mount docker socket and pass `privileged` flag to get permission to run.

```
docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock --privileged --name test franz/test /bin/bash
```

You can try `docker ps` to see if it is using the `docker` in the host machine.

```
[root@5ef32b67b635 /]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
5ef32b67b635        franz/test          "/bin/bash"         3 seconds ago       Up 2 seconds                            test
```
Clipping Mask
Published: 2020-09-05 04:28:44

 <a href="https://clippasia.com/image-masking-services">Clipping Mask</a> is going to be image-painting on a new canvas. A complicated representation of taken care of transparency in shot masking service manipulates the image artistically. Hence, image exemplifies an important sensation change in the images and so appraised from the product marketing internet business.