teleren/devto huggingface dataset:
Setup Kubernetes Anywhere with Single Command
Tags: devops, kubernets, linux
Published: 2023-03-06 01:12:53

---
title: Setup Kubernetes Anywhere with Single Command
published: true
date: 2023-03-03 21:25:27 UTC
tags: devops,kubernets,linux
canonical_url: https://avilpage.com/2023/03/setup-k8s-anywhere-k3d.html
---

{% youtube Vo0mAsXe-hI %}

#### Introduction

In an earlier article, we have seen how to set up [Kubernetes on M1 Mac](https://avilpage.com/2022/10/local-kubernetes-with-k3s-on-mac.html). That involved spinning up a VM and installing Kubernetes<sup id="fnref:kubernetes"><a href="https://avilpage.com/2023/03/setup-k8s-anywhere-k3d.html#fn:kubernetes">1</a></sup> on it. In this article, we will see how to set up Kubernetes directly on Docker so that we can use the same set-up on any operating system.

#### Prerequisites

Ensure you have Docker installed on your system. If you are on a Mac or Windows, you can install Docker Desktop<sup id="fnref:docker-desktop"><a href="https://avilpage.com/2023/03/setup-k8s-anywhere-k3d.html#fn:docker-desktop">2</a></sup>.

#### k3s/k3d

k3s<sup id="fnref:k3s"><a href="https://avilpage.com/2023/03/setup-k8s-anywhere-k3d.html#fn:k3s">3</a></sup> is a lightweight Kubernetes distribution by Rancher. It is a single binary that can be run on any Linux machine. But it doesn't work on Mac or Windows.

k3d<sup id="fnref:k3d"><a href="https://avilpage.com/2023/03/setup-k8s-anywhere-k3d.html#fn:k3d">4</a></sup> is a wrapper around k3s that allows you to run k3s on Docker. It is a great option for running Kubernetes on your local machine.

#### Installation

k3d can be installed using the following command:

```
$ brew install k3d # mac
$ chocolatey install k3d # windows
$ curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash # linux

```

Once it is installed, we can create a cluster using the following command:

```
$ k3d cluster create demo

```

This will launch a cluster with a single node. We can verify the cluster is up and running using the following command:

```
$ kubectl get nodes

```

We can also use GUI tools like Lens to manage and navigate the cluster. In the above video we have used Lens to create a Jenkins deployment as well.

#### Conclusion

In this article, we have seen how to set up Kubernetes on Docker. This is a great option for running Kubernetes on your local machine. We can also use this to run production setup for small applications.

* * *

1. [https://kubernetes.io/](https://kubernetes.io/) [↩](https://avilpage.com/2023/03/setup-k8s-anywhere-k3d.html#fnref:kubernetes "Jump back to footnote 1 in the text")

2. [https://www.docker.com/products/docker-desktop/](https://www.docker.com/products/docker-desktop/) [↩](https://avilpage.com/2023/03/setup-k8s-anywhere-k3d.html#fnref:docker-desktop "Jump back to footnote 2 in the text")

3. [https://k3s.io/](https://k3s.io/) [↩](https://avilpage.com/2023/03/setup-k8s-anywhere-k3d.html#fnref:k3s "Jump back to footnote 3 in the text")

4. [https://k3d.io/](https://k3d.io/) [↩](https://avilpage.com/2023/03/setup-k8s-anywhere-k3d.html#fnref:k3d "Jump back to footnote 4 in the text")
How to know if your test is flaky?
Tags: javascript, node, testing, jest
Published: 2023-03-03 20:38:43


## What are Flaky Tests

Flaky tests are tests that pass sometimes, this can be due to some inconsistency inside it or other reasons.

## How to debug a Flaky Test?

A way to find if a test is flaky is to run them N times, if at any point they fail this means that they are flaky.

Instead of repeatedly running tests and manually checking for failures, you can streamline the process by utilizing this script:

```bash
function jest-many-times-sequential() {
  i=1
  successes=0
  failures=0
  totalTests=$2
  SUCCESS_CHECKMARK=$(printf '\342\234\224\n' | iconv -f UTF-8)
  CROSS_MARK=$(printf '\342\235\214\n' | iconv -f UTF-8)

  until [ $i -gt $2 ]; do
    if yarn jest $1 --silent; then
      ((successes = successes + 1))
      echo "  $SUCCESS_CHECKMARK tests passed"
    else
      ((failures = failures + 1))
      echo "  $CROSS_MARK tests failed"
    fi
    ((i = i + 1))

  done

  echo "\n
  Ran Tests $totalTests times.\n
  ✅ Succeeded: $successes/$totalTests
  ❌ Failed: $failures/$totalTests
  \n
  "
}
```

To use this script, just paste the code block into your terminal's configuration file (.zshrc or .bashrc) and then restart your terminal.

Then you can run the script as follows:

```sh
$ jest-many-times-sequential <path-of-your-test> <times-to-run>
```

By running the tests N times sequentially, the script will automatically track the number of successful and failed runs, providing you with a final tally at the end.

Here is an example:

![](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ox5acfgkxugkxrrf71sp.png)

Now with this script we can validate if our tests are flaky or not.

---

[Woovi](https://woovi.com/) is a Startup that enables shoppers to pay as they like. To make this possible, Woovi provides instant payment solutions for merchants to accept orders.

If you want to work with us, we are [hiring](https://woovi.com/jobs/)!

---

Photo generated by [DALL-E](https://openai.com/dall-e-2/)
json-front, light-weight front-end library for HTTP requests
Tags: showdev, library, frontend, json
Published: 2023-03-03 20:25:00

---
title: json-front, light-weight front-end library for HTTP requests
published: true
description: Small front-end library
tags: showdev,library,frontend,json
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-03-03 20:17 +0000
---

I've created a small library that can be used in front-end apps, it allows HTTP requests to server, when data that is being sent, you only pass it as JS object, lib does the converting to JSON for you. When receiving, data is converted to JS object so it is available immediately on response end.

`json-front` also allows creation of API URL instances that can be reused across whole project.

Methods implemented:
`GET`
`POST`
`PUT`
`DELETE`

Try it out, if you want, and let me know any suggestions that you may have.

https://www.npmjs.com/package/json-front
Functional Programming
Tags: python
Published: 2023-03-07 17:17:09

---
title: Functional Programming
published: true
date: 2023-03-03 20:20:07 UTC
tags: python
canonical_url: https://dlcoder.medium.com/functional-programming-f9a61a41e88a
---

[![](https://cdn-images-1.medium.com/max/600/0*jkjVclLpQ9jWOeVC.png)](https://dlcoder.medium.com/functional-programming-f9a61a41e88a?source=rss-93bca1b4c1e9------2)

Functional programming differs from imperative programming in that the latter focuses on describing how the program should be executed…

[Continue reading on Medium »](https://dlcoder.medium.com/functional-programming-f9a61a41e88a?source=rss-93bca1b4c1e9------2)
2 year experienced software engineer in India Top company's should Work
Published: 2023-03-03 20:13:13

There are several top companies in Bangalore where you could land a high level salary job. Here are some of the top companies in Bangalore:

- Amazon
- Google
- Microsoft
- IBM
- Cisco Systems
- Intel Corporation
- Accenture
- Wipro Limited
- Infosys Limited
- TCS (Tata Consultancy Services)
- NAVI
- SLICE
- VAHAK
- VEDANTU
- WALMART
- EY
- PWC
- LTI Mindtree


GO these companies Website create career Profile and apply relevant Opportunities.

Attached Resume + Cover Latter


These companies have a reputation for offering competitive salaries and benefits packages to their employees. In order to land a high level salary job, you will need to have a strong technical skill set and a proven track record of success in your previous roles. Additionally, it can be helpful to have experience working with specific technologies or programming languages that are in high demand in the industry. It's also important to network and connect with professionals in your field, as this can help you discover new job opportunities and make valuable connections that can help you advance your career.
Newton's Light Bulbs 💡😎
Tags: codepen
Published: 2023-03-03 19:31:52

<p>Saw an animation of a Newton's cradle made of light bulbs so figured I'd try create my own with GreenSock 👍</p>

<p><strong>EASTER EGG</strong> 🥚: Type numbers to update the hue of the bulbs!</p>

<p>Enjoy! </p>

{% codepen https://codepen.io/jh3y/pen/abzeaWJ %}
Using EventEmitter in React
Tags: react
Published: 2023-03-03 17:32:18

I have an issue where handlers subscribed to a custom event see all the updated state (from calls to `setSomething()`) **except the last one that was set**. Specifically:

```
const [counter1, setCounter1] = useState(1);
const [counter2, setCounter2] = useState(1);

const increment = useCallback(async () => {
  events.emit('beforeIncrement');

  await someAsyncAction();  // <-- There's an async call.

  setCounter1((x: number) => x + 1);
  setCounter2((x: number) => x + 1);

  // React 17:
  //    Handlers of the following event will see counter1 updated value but not counter2.
  // React 18 with Automatic Batching:
  //    Handlers of the following event will not see see counter1 or counter2 updated value.
  // What is the best way to emit an event here and ensure that handlers see the updated state?
  //    setTimeout(() => events.emit('afterIncrement')) ??

  events.emit('afterIncrement');
}, []);
```

The following repo demonstrates this behavior:

https://github.com/cmermingas/event-emitter-react-17

* Why is this happening?
* What is the right way to emit an event to ensure that handlers have access to all the updated state?

Thanks in advance!

[edit]

The example I provided is a simplified version of the real situation. A more generic description would be:

```
const doWork = useCallback(async () => {
  events.emit('beforeWork');

  // Asynchronous calls where React state gets updated.

  events.emit('afterWork');
}, []);
```

The `Asynchronous calls` section triggers state updates, possibly outside of the body of this callback.

I want all `afterWork` handlers to have the most up-to-date state from React. I imagine an API like this:

```
const doWork = useCallback(async () => {
  events.emit('beforeWork');

  // Asynchronous calls / Promise chains here
  // where React state gets updated.

  // Work is done. When React has updated, emit an event:

  afterReactWork(() => events.emit('afterWork'));
}, []);
```
Create a plot with dual y-axes (using twinx) in Python
Tags: python, plot, programming
Published: 2023-03-03 19:01:20

```
import matplotlib.pyplot as plt

# Data
years = [2015, 2016, 2017, 2018, 2019]
percentage = [float('NaN'), 3.31, 3.92, 2.79, 2.34]
n_students = [28099, 29030, 30167, 31008, 31733]

# Create figure and axes
fig, ax1 = plt.subplots(figsize=(8, 6)) 

# Plot percentage on left axis
ax1.plot(years, percentage, color='blue', marker='o', label='Population Growth')
ax1.set_ylabel('Population Growth', color='blue', fontsize=12)
ax1.tick_params(axis='y', labelcolor='blue', labelsize=10)
ax1.set_ylim([0, 5])  # set the y-axis limit to start from 0
ax1.set_xlabel("Year", fontsize=12)

# Create a twin axes object on the right
ax2 = ax1.twinx()

# Plot number of students on right axis
ax2.plot(years, n_students, color='red', marker='s', label='Number of Population')
ax2.set_ylabel('Number of Population', color='red', fontsize=12)
ax2.tick_params(axis='y', labelcolor='red', labelsize=10)
ax2.set_ylim([27000, 32500])  # set the y-axis limit to show the values better

# Set title and labels
plt.title('', fontsize=14, fontweight='bold')
ax1.set_xticks(years)  # set the x-ticks to the years
ax1.set_xticklabels(years, fontsize=10)  # set the x-tick labels to the years

# Add legend
lines, labels = ax1.get_legend_handles_labels()
lines2, labels2 = ax2.get_legend_handles_labels()
ax1.legend(lines + lines2, labels + labels2, loc='upper left', fontsize=10)

# Add grid
plt.grid(linestyle='--')

# Show the plot
plt.show()
# Save the plot as a PNG image
#plt.savefig('timeline_Shaqlawa_Population.png', dpi=300, bbox_inches='tight')
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wjgrj39828e89lgr4len.png)
Functions and Package in Go
Tags: go, programming, beginners, tutorial
Published: 2023-03-03 18:48:06

This session contain information about go function and go package:
1. Golang functions syntax and creation.
2. Golang Packages.
3. How go create and use packages inside go programs.

[Functions and Package in Go](https://www.youtube.com/watch?v=_JTiBHC97pg&list=PLZ6pHHPq5DrkgYL2c7Int7wq2TwCDDeMu)

{% embed  https://www.youtube.com/embed/_JTiBHC97pg %}
Initialization of the cluster, Creating a graph, and Adding a node (PART 2: Installing Apache and PSQL from source)
Tags: postgres, database, apacheage, agedb
Published: 2023-03-03 18:47:23

Have you ever wanted to use AGE (AgensGraph Extension) with PostgreSQL but struggled with initializing the cluster and adding nodes? In this article, we will walk you through the steps of initializing the cluster, making a graph, and adding nodes to it.

In a previous article, we discussed how to install Apache AGE and PSQL from source on your machine. If you haven't done that yet, you can find the article here[](https://dev.to/hammadsaleemm/how-to-istall-apache-age-and-psql-from-source-on-ypur-machine-i6h).


## Initialization
The first step is to initialize the cluster. To do this, open your terminal and enter the following commands:

```
cd postgresql-11.18/

# intitialization
bin/initdb demo
```
For now, db name is demo.

## Server start
Once the cluster is initialized, you can start the server by running the following commands:
```
bin/pg_ctl -D demo -l logfile start
bin/createdb demodb
```
The first command starts the server, and the second command creates a database named "demodb." You can now see the files and the database in your terminal.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fvquc29bzw7vj62t4r4x.png)

## Querying Start

Now that the server is up and running, you can connect to the database and start manipulating it. To do this, run the following command:

```
bin/psql demodb
```
The last step is to load the extension for AGE by running the following commands:

```
CREATE EXTENSION age;
LOAD 'age';
SET search_path = ag_catalog, "$user", public;
```
Your terminal should now look like this:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xl5c15nsgho1ss1gf8re.png)

You can now try some queries with Cypher commands. For example, you can create a graph, add a node to it, and then display the node. Run the following commands:

```
SELECT create_graph('demo_graph');
SELECT * FROM cypher('demo_graph', $$ CREATE (n:Person {name : "hammad", bornIn : "Pakistan"}) $$) AS (a agtype);
SELECT * FROM cypher('demo_graph', $$ MATCH (v) RETURN v $$) as (v agtype);
```
The output of these commands will add the node to the graph, and you should see something like this:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hbcgby9t6mqglt7bz07q.png)

Congratulations! You have now initialized the cluster, created a graph, and added a node to it using AGE and PostgreSQL. In the next article, I will be telling about age-viewer to make graph and nodes easily
Constants and environment variables in Go
Tags: go, programming, tutorial, beginners
Published: 2023-03-03 18:46:14

Tutorial illustrates about:
What is a constant.
Syntax of constant.
How to use a constant in Go.

[Constants and environment variables in Go](https://www.youtube.com/watch?v=KhFjqcqpTrk&list=PLZ6pHHPq5DrkgYL2c7Int7wq2TwCDDeMu)

{% embed https://www.youtube.com/embed/KhFjqcqpTrk %}
Ansible and Python
Tags: beginners, python, devops
Published: 2023-03-03 18:32:03

- Firstly, Ansible is written in the Python programming language and has a quite minimal learning curve. 
- Ansible setup is pretty simple and functionality it provides is widely used in the IT services automation.
- Python is the preferred language to use to develop as it is quite compatible and easy to sync with ansible.


## Ansible with Python:

**Ansible Playbooks:**

> Simple yml formatted files which helps the developers to define a streamline flow of tasks to be achieved while performing a job. These Playbooks can be referred to as automated bots which helps us perform for example shell commands, python scripting and many more additional features.

`Basic Programming language add ons are present to like storing data in variables and modifying the same. Can be reused, recyclable for other used cases. Sometimes separate tasks are created and included like classes in C++.`

**Action Plugins:**

> To talk about in a nutshell, these are basically python scripts itself just that some extra functionality and classes are added to integrate them with the playbooks. Action Plugins act as a programming soldier that inputs data declared by the playbook and modify the data for the used case as programmed by us. We can return the data to the playbook such that further tasks can be performed on that data. 

`Mainly purpose is to automate the manual steps and reduce vulnerabilities.`

**Ansible Tower:**

> Ansible Tower can be called as a hub of the ansible playbooks which makes the playbooks easier to maintain, run and debug while development. Tower is an open source tool which can be altered as per the requirements by the organizations. Tower provides too many functionalities like scheduling the playbooks and automating them, add separate projects directly and easily as its UI is clean and easy to use. After a basic understanding debugging is easy to execute and trustworthy process is cultivated for a long term.

`Ansible Tower is the Manager of the Ansible Playbooks which assists the developers on more than what I offered in this article.
Will create a detailed article on this though. Checkout for more.`
You do not need a certification or a degree to work in CyberSecurity
Tags: cybersecurity
Published: 2023-03-03 18:26:27

You do not need a certification or a degree to work in #CyberSecurity.

Truth. 

Because cybersecurity isn't a job, it's an entire industry.

You must do the research for the job you want.  

You don't need a cybersecurity certification for any of these roles:

Cybersecurity & Data Privacy Lawyer
-- Law degree

Contracts and Compliance Specialist
-- Experience in contract negotiation and DFARS knowledge 

Product Manager
-- Business acumen and sales experience

Threat Researcher
-- Masters/PhD with published research

Forensic Analyst
-- State/federal affliation/licensing

Cybersecurity Project Manager
-- Project management certification

DevOps Engineer
-- Cloud automation and open frameworks experience

Identity and Access Management (IAM) Architect
-- Business function integration experience and Cloud certification

Information Systems Auditor
-- Bachelors, experience in insurance/finance fields

Application Security Engineer
-- Frameworks (OWASP/NIST), programming, SDLC

Fraud Defense Specialist
-- Bachelors, experience with Splunk/SIEM tools and data visualizations

Plus more...there are tons of other jobs in cybersecurity. 

The industry is filled with a variety of roles and positions across a myriad of different companies in various countries that all have differing requirements in terms of education, certification, and qualification. 

There is no one path. 

There is no required cert or degree that crosses all of the jobs in cybersecurity. 

Stop trying to break into "cybersecurity".

Instead, focus on getting into the specific job or role you want. 

Talk to people working in the role(s) you're interested in and learn what is actually needed. Look at the job ads in your area, in companies of interest, in roles you want.

There certainly are roles in cybersecurity that you will need to show technical background and skills. These roles often list certifications in the job ads, thus to be competitive you would want to acquire those certifications. 

Do the research. 

Understand what you need for the role you want. Then go get it. 

It's your path to follow and your career. 

#YourPath #DoTheResearch #NoOneKnowsWhatYouWantToDo
Minesweeper with CustomTkinter
Published: 2023-03-03 18:25:11

This game was built as my final project on codecademy's cs101. The assignment was to build a game and I chose the classical “minesweeper”. 

 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ub1a8gkrxefo2u9zb37.jpg)
The game is built with the CustomerThinker module and consists of a class called "Cell" that uses a for loop to create a grid that is displayed to the user as buttons. The size of the grid depends on the user's choice of "small" (5x8 with 9 minis), "medium" (10 x12 with 15 minis) or "large" (15x16 with 20 minis). The "min" attribute is assigned to the cells using the "random module". Each cell must display the amount of mines surrounding them, this is done with a function called "count_mines" which is called when the "cell button" is left clicked

[GitHub link](https://github.com/LindaMolsson/python_projects/blob/master/minesweeper.py)
7 ChatGPT 🤖 Must Have Chrome Extensions🤯
Tags: chatgpt, webdev, productivity, programming
Published: 2023-03-03 18:19:14

## A Brief Overview Of ChatGPT For Developers👨‍💻

- ChatGPT is a new technology that has been developed to help developers create natural language processing (NLP) applications. 

- This technology enables machines to understand and respond to human conversations, making it easier for developers to create interactive chatbot experiences. 

- With ChatGPT, developers can quickly develop sophisticated conversational AI solutions that are able to effectively engage with users in real-time conversation scenarios. 

- The main benefit of using ChatGPT is the ability for machines and humans alike to communicate more naturally through text or speech-based interactions. 

- By leveraging powerful deep learning algorithms, this system can understand complex user input while providing relevant responses based on the context of the conversation without requiring any additional coding from the developer's end. 

- Additionally, as an open-source platform built on top of Google’s TensorFlow library, it allows for easy integration into existing NLP systems such as Dialogflow or Amazon Lex so developers don't have to start from scratch when building their own custom bots or applications powered by ChatGPT's capabilities.

- Furthermore, it also provides support for multiple languages which makes it useful in international markets where different dialects may be spoken.  

- Overall, Chat GTP offers a great opportunity for developers who want to build advanced conversational AI solutions quickly and efficiently.

- By utilizing its powerful deep learning algorithms, they can easily integrate this system into their existing NLP systems or use its prebuilt models to build custom bots and gain access to multilingual support which will help them reach out to more global customers with ease.

- It is definitely worth considering if you're looking for an effective way to create rich conversational experiences in no time at all!


🎥 {% youtube HS--JW2384A%}


#### Bonus

###### Web developers tools 🛠️ you need to know💡👩‍💻  

🎥 {% youtube lj4ZBJbV5yk%}


### Connect with Me 😊

#### 🔗 Links

[![linkedin](https://img.shields.io/badge/linkedin-0A66C2?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/mahmoud-el-kariouny-822719149/)

[![twitter](https://img.shields.io/badge/twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white)](https://twitter.com/Mahmoud42275)