teleren/devto huggingface dataset:
#044 Kubernetes - Services 4
Tags: kubernetes, devops, tutorial
Published: 2020-08-02 21:03:35

# Introduction
![intro](https://media1.tenor.com/images/f15057a41413c960db1f328ca5a732e3/tenor.gif?itemid=6203225)

this is part 44 from the journey it's a long journey(360 day) so go please check previous parts , and if you need to walk in the journey with me please make sure to follow because I may post more than once in 1 Day but surely I will post daily at least one 😍.

And I will cover lot of tools as we move on.
***
# Prepare file

as always all the files used are in my github repo here
 {% github OmarElKhatibCS/DevOpsJourney no-readme %} 
if you already have it just pull , if not clone it.
the source code usually hold the same chapter number we are in 044 so app_044 is what we are looking for.
I am using the same image of app_040:1.0 here because it's the same if this part but we need to access it without trick of port-forward 
***
# Lab
![mad](https://media1.tenor.com/images/4800838e793768298c7d6132734abca4/tenor.gif?itemid=11957205)

first let's take a look at our yml configs

![lab1](https://dev-to-uploads.s3.amazonaws.com/i/fymneucd1x30j5xruqa6.png)

We can see I use an --- to separate 2 yml files , I can separate them each one on file but since they are depends on each other it's good practice to have them in 1 file.

the key feature here is :
1 . type: NodePort , so we can access our app outside the cluster
2 . Ports:
target port is 8080 which is the node js port that I choose for backend in my configs.
nodePort: 30005 is the port of my node which I will use to access the node.
port: 8088 is the port of my service.

![create](https://dev-to-uploads.s3.amazonaws.com/i/dofheq2whxfc1v9g65lp.png)
```bash
kubectl apply -f app_044.yml
```
again and again I like to repeat it notice I am in the same folder as myfile so I can pass it directly.
![pods](https://dev-to-uploads.s3.amazonaws.com/i/dbbfdgu77c2tlg4lp6l6.png)
```bash
kubectl get pods
```
we have our 6 pods created , I like to mention we can create shortcuts for us in Linux (spoiler : I will make an entire LinuxJourney to discover linux from kernel and up :) after devops or in parallel) , Linux have aliases so we can tell linux to recognize kgp as shortcut for 'kubectl get pods' , I have them but I like to keep it simple for those who are not familiar with aliases yet.
![services](https://dev-to-uploads.s3.amazonaws.com/i/xukrui4nx7hjvnwhe09g.png)
```bash
kubectl get svc
```
svc shortcut for services , we seen before. We can see our service is ready.

to get the node ip , basically it's the minikube ip because minikube is the test node for us locally.
![mkip](https://dev-to-uploads.s3.amazonaws.com/i/xeohzmpkbbcor7ady749.png)

```bash
minikube ip
```
192.168.99.100 is the ip of the node in my case.
![browser](https://dev-to-uploads.s3.amazonaws.com/i/f8y4chp27pdh5dvut0po.png)
now we have the ip , go to browser and type [192.168.99.100:30005](http://192.168.99.100:30005/)
now we can access our app directly without the port-forward trick :)
Project Patterns and Tools
Tags: editorconfig, eslint, prettier
Published: 2020-08-02 21:01:40

Did you find yourself stuck in a project simply because the patterns used between your colleagues is different? Probably yes!

Actually, to keep the code patterns and conventions for all companies and development teams is one of the most challenge thing they are facing.
Why does it happens? In simple term, because everyone working on this industry learned to program differently, they had different background, they have their own preferences and habits.

![alt text](https://media.giphy.com/media/8gJ28HfjAkc9y/source.gif "rules")


Because that, subjects as clean code, SOLID principles, KISS principles and so on are trends, but is there a way to try to automate or at least keep the code under some patterns defined previously?

In that post I will explain about some tools we can use to help us to keep our code under control and make our life easier when our projects is becoming bigger and more developers is join the project.

For that purpose we can use three tools to keep our code with the same standard. Those tools are EditorConfig, ESLint and Prettier.

#EditorConfig

EditorConfig is a tool to help development teams work with the same pattern, doesn't matter if they are working with different IDE's as code editor.

Can you imagine if a team is working with different IDE's as VSCode, Atom, Sublime or other one? Probably they are working with different text configuration as well, so in the end of the day, we will get every sort of inconsistency in our code when we are trying to merge our code and also, when we are trying to build it.

EditorConfig can help us by given a set of configurations as the type of indentation, which charset we need to use, the end of line and so on.

If would you like to go deep in EditorConfig check it out at [editorconfig.org](https://editorconfig.org/).

#ESLint

I can say ESlint maybe is one of the most important tool to automate code convention. We can use it for projects using NodeJS, ReactJS, React Native and more.

For example, ";" is optional for Javascript at the end of line and that is not a problem to run the code. But when we are creating an object, we can use "," at the last item of the object but it is optional.

With ESLint we can keep just one pattern for our team.

You can find out more at [eslint.org](https://eslint.org/).

#Prettier

Finally, we have Prettier! That tool is used to customize our code format. It means Prettier will remove all original styling code and ensures that all outputted code conforms to a consistent style.

Prettier enforces a consistent code style across our entire codebase by parsing it away and re-printing the parser with its own rules that take the maximum line length into account, wrapping code when necessary.

If you want to get more information about it, check it out at [prettier.io](https://prettier.io/).

In the next post, I will show how to configure EditorConfig for VSCode and start to keep our code under control.

That's it, folks!

Thanks for reading and I hope it's been useful for you. Please do comment your questions and suggestions.
Github's Awesome Repository Traffic Analytics
Tags: opensource, github, todayilearned, tutorial
Published: 2020-08-02 20:59:28

As someone that loves all types of metrics I was really glad to have discovered Github's traffic analytics. They've been around for a while, but I never knew about them and I wanted to share an introduction to the analytics.

You can access the analytics by navigating to insights -> traffic. Github displays various graphs/tables:

- Git clones
- Amount of visitors
- Referring sites
- Popular content

I use Git clones to understand both usage of the repository and OSS contributions by other developers. Repository usage is particularly insightful when creating projects/modules that are downloaded and used via Git. An example of this is my recent Terraform project [terraform-cloudflare-maintenance](https://github.com/adinhodovic/terraform-cloudflare-maintenance), every time someone uses the module it gets cloned. Here's the analytics graph on Github clones:

![Git clones](https://i.imgur.com/dbzOqlD.png)

The amount of visitors is straightforward, just a simple graph of visitors. However, you can pair this graph with dates you shared your project on Hackernews or Reddit and see if there are any traffic spikes! I shared the Terraform project on Reddit and got around 50 stars and a traffic spike from Reddit as you can see below:

![Git visitors](https://i.imgur.com/uzUPBAD.png)

The most interesting data presented by Github are referring sites. Just as any business analytics tool, you can see key referral sites. I measure the success of my previously shared projects on various platforms. Then, I know where I should share all my future projects. So far, I've had great success with SRE/DevOps specifics subreddits (/r/terraform, /r/sre, /r/devops). The same project as in the previous images can be seen below:

![Git referring sites](https://i.imgur.com/3nN6nZf.png)

Lastly Github tracks the most popular content in your repository, however in my case this has not been particularly useful. I'll anyways share a screenshot of the table from the same repository:

![Git most visited sites](https://i.imgur.com/Ba2ugpR.png)

I loved the insights and analytics, hope you do too!
Building a COVID-19 Virtual Banking Assistant
Tags: covid19, code
Published: 2020-08-02 20:36:36

I just published a blog on Medium about Building a COVID-19 Virtual Banking Assistant. Link: https://link.medium.com/Socshzk0s8 
<a href=https://www.medium.com/@mridulrb target="blank"><img src=https://cdn.jsdelivr.net/npm/simple-icons@3.0.1/icons/medium.svg alt="mridulrb" height="20" width="20" /></a>
Day 17: I hate programming
Tags: 100daysofcode, javascript
Published: 2020-08-02 20:25:26

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ecvwjl53pvn268klrrk4.png)
It has been an entire day of trying different solutions and refactoring code more than hundred times, but it still wont work. Adding habits from a webpage is my unending nightmare, i can't seem to capture the input values. The button only adds a new card but no title. My mind is super exhausted not to mention frustrated. Oh, and did i mention i broke the code too.


On a lighter note I tried animate.css, it's as easy as adding class to html:
{% vimeo 444053904 %}

_The optimist in me: "There are better days ahead"_
_The Pessimist in me: "Oh no darling, it gets worse"_

_Day 17_
Name your next Startup Idea. Wrong answer only
Tags: discuss, watercooler, fun
Published: 2020-08-02 20:22:30

New week, new challenge!

Tell us your next Startup Idea: the name and what it is going to do!
#### Wrong answers only!

Let's see who gets the "best" idea!

![](https://media.giphy.com/media/l46Cyuwv0q7W3gw1i/giphy.gif)
Road to Genius: genius #67
Tags: javascript, beginners, codenewbie, computerscience
Published: 2020-08-02 20:11:47

Each day I solve several coding challenges and puzzles from Codr's ranked mode. The goal is to reach genius rank, along the way I explain how I solve them. You do not need any programming background to get started, and you will learn a ton of new and interesting things as you go.

We finally made it to the genius rank, this is the very first challenge on the highest rank. I hope you're as excited as I am. I will continue doing several more daily challenges.

```JS
function helper(p1, p2) {
  const deltaX = p1[0] - p2[0];
  const 💰 = p1[1] - p2[1];
  return 🚀 * deltaX + deltaY * deltaY;
}
function checker(p1, p2, p3, p4) {
  const HP = [helper(p1, p2), helper(p1, p3), helper(p1, p4), helper(p2, p3), helper(p2, p4), helper(p3, p4)];
  let cnt1 = 0;
  let cnt2 = 0;
  let sum = 0;
  for (let i = 0; i < HP.length; i++) {
    sum += HP[i];
  }
  for (let i = 0; i < HP.length; i++) {
    if (sum === 8 * HP[💚]) {
      cnt1++;
    } else if (sum === 4 * HP[💎]) {
      cnt2++;
    }
  }
  return cnt1 === 4 && cnt2 === 2;
}
let p1 = [6, 9], p2 = [3, 1];
let p3 = [7, 0], p4 = [3, 7];
let A = checker(p1, p2, p3, p4);

// 💰 = ? (identifier)
// 💚 = ? (identifier)
// 💎 = ? (identifier)
// 🚀 = ? (identifier)
// such that A = false (boolean)
```

In this challenge we need to fix four bugs, after a quick look at the code it should be an easy procedure.

The first two bugs appear within the same short function `helper`:
```JS
function helper(p1, p2) {
  const deltaX = p1[0] - p2[0];
  const 💰 = p1[1] - p2[1];
  return 🚀 * deltaX + deltaY * deltaY;
}
```
The variable declaration for 💰 should be `deltaY`, and 🚀 is very likely to be `deltaX` because the function seems to be computing `dx² + dy²`.

The final two bugs appear here: 
```JS
  for (let i = 0; i < HP.length; i++) {
    if (sum === 8 * HP[💚]) {
      cnt1++;
    } else if (sum === 4 * HP[💎]) {
      cnt2++;
    }
  }
```
Both these bugs are indices for the array `HP`. Since both are within a for-loop whose `i` variable isn't used, it seems very likely that both bugs should be `i`.

![coding challenge answer](https://dev-to-uploads.s3.amazonaws.com/i/cy318qmbj924gs1f6vj0.png)

All our assumptions were correct! We are likely to encounter this function again in the near future, so for now we skip its detailed analysis.

By solving these challenges you train yourself to be a better programmer. You'll learn newer and better ways of analyzing, debugging and improving code. As a result you'll be more productive and valuable in business. Get started and become a certified Codr today at https://nevolin.be/codr/
Linux Podcasts
Published: 2020-08-02 19:55:17

Image Courtesy : itsfoss.com

Podcasts help you to learn something new as well as multi task. If you are looking for awesome Linux podcasts, the collection is [here](https://itsfoss.com/linux-podcasts/)

My favorites are Jupiter, its available via YouTube also.

**Jupiter**
https://www.jupiterbroadcasting.com/142307/linux-arm-wrestling-linux-unplugged-364/

Good to great discussion on various Linux topics.

**Linux Headlines**

https://linuxheadlines.show/182

2 to 3 minute headlines on whats happening that day.
5 Ways to Prepare for Coding Bootcamp
Tags: books, learning, beginners
Published: 2020-08-02 19:48:08

##Research!##

  Before you just jump into any bootcamp, you have to find a place that fits your needs. Do you prefer in-person class? Or do you prefer online? Some would argue that both are equally effective at providing students with the environment needed to learn. On the other hand, some people still feel like you get the most bang for your buck in-person. It all depends on you! So definitely take your time with this one. 
  Also, all coding bootcamps are not created equal! I have to admit, I make a lot of my decisions based on reviews and there are a TON out there. Of course, you would want to not just look at the good ones or vice versa but take it in as a whole. What is the common thing people love/hate about this place? Is this something you could get with or would this hold you back from being your best self? 

##Find your mental “safe-space”##

  One thing I didn’t realize before I joined bootcamp was how easily frustrated I can get. The first few weeks, I learned a lot about myself. The good and the ugly 😂. Trust me when I say, you will be evolved or destroyed! But don’t fret, because I am here to tell you, “YOU GOT THIS! JUST BREATHE!”. You are going to find some things tough, especially if you are a complete beginner. Just think of them as growing pains. Honestly, the best way to prepare, is to go into this knowing and understanding that it is okay to not know everything. It is okay if you're not grasping something that some other person did. There are so many resources and people in the tech community that love to help and offer support. Go onto this journey knowing you are not alone. 

##Immerse yourself##
  Another thing that helps, is to immerse yourself in all things programming. Follow other people in the tech community and engage with them. Try to stay on top of things relevant in tech. Do you need to be an expert? Absolutely not. Just knowing that something exists and this is why it’s relevant today can help when it comes to conversing with other techies. Watching Youtube videos about the languages and software you are learning can give you background and context. So if you don’t want to feel like a ‘total’ newbie in class, it is worth it. Meetups are another great place to go. These are really cool because you are interacting with people real time and also networking. 

##Find good books/podcasts##
  There are a ton of books out there about programming, but to me it’s not just about the technical aspect. Here are a list of books that I recommend to help you become not just a tech-informed person but a better version of yourself over-all:
*The Power of Now by Eckhart Tolle*
*How to Win Friends & Influence People by Dale Carnegie*
*Think Like a Programmer: An Introduction to Creative Problem Solving by V. Anton Spraul*
*Living By The Code by Enrique Lopez Manas*


##Most importantly, come with an open-mind##
Be willing to learn. Be open to criticism.
db.Posts.FirstOrDefault(p => p.Title == "Hi, I'm Fitzy");
Tags: writing, career
Published: 2020-08-02 19:47:27

Hello!

Uh. Now what?

Okay, so my plan is to start sharing my journey in code here, and I figure I should begin with a "who is this guy" type of thing. So let's do that.

## The Basics

I'm John/Fitzy. I've been writing code for 25 years (since I was 11), I've been doing it professionally for 15, and I've been self-employed full-time as a software developer/consultant for 10.

I began building PHP web apps and have transitioned in the last 2-5 years to almost exclusively DotNet development with a sprinkling of Node.js and legacy PHP maintenance.

## The Journey

Along my way, I've encountered plenty of roadblocks. Ethical choices, overbooking, getting in over my head, etc. I'm sure I'll discuss some of those here.

The biggest hurdle I'm still leaping and the reason that led to this project of streaming / blogging / otherwise capturing my CURRENT journey is this:

**I stopped learning for nearly a decade.**

Seem ridiculous? It is.

I suspect it's also pretty common.

It's very, very easy to get "stuck into your own code," particularly on long-running projects or client relationships (I've been working with my primary client for all of my 15 years, and my other main client for 5, on the same projects).

It's then ALSO very easy to stop focusing on keeping up with the latest languages, frameworks, best practices, patterns/anti-patterns, etc.

So while I was/am a "decent developer" (I love "world's okayest" as a mantra), and while my abilities to understand systems and logic were not affected and even grew, my ability to apply those basic skills diminished considerably.

*Imagine trying to apply 15 year old basic PHP skills to a microservices architecture.*

I've spent the last 2-3 years, then, beginning to "catch up." I think I'm making decent progress, but I've got a long way to go yet.

## The Plan

My work centers around fintech applications and online learning systems, and I'm also seriously interested in blockchain technology (especially as it can be applied to those first two things).

My goal is to share more of my journey as I learn to write better code to support my clients and my own projects, and I'm doing that on [Twitch](https://twitch.tv/fitzycodesthings), on Dev, and on a soon-to-be-relaunched personal site.

Documenting my progress is a way for me to solidify it, and it is my sincere hope that by sharing it I can help other devs avoid the pitfalls I've jumped headlong into or encourage my fellow "stuck" devs to get "unstuck."

Thanks for tolerating me along the way. 

To better code!

- John / Fitzy
New Stuff - Learning again
Tags: microcontroller, electronics, dyi
Published: 2020-08-02 19:36:47

I’ve been working with computers for more than 30 years (my first computer was a 80286 =D), but something I never liked was cables and welding and all that stuff (I managed to graduate college without making a single RJ45 cable), so… in times of COVID-19 and Quarantines and being more insightful with one-self… I decided to escape my comfort zone and pick up on the microcontroller stufff… Should be interesting.  
  
I have a very basic understanding on how they work (the electrical stuff was NEVER my strong suit), at least theoretically. So i think my best approach here is to go basic, and start with circuit boards and pins and all that…  
  
I’m new here so, if by any chance someone is reading this, I’ll appreciate any input.
ESP with Google Assistant
Tags: esp, iot
Published: 2020-08-02 19:00:43

Google Assistant is amazing. Isn't it?
I tried to control my esp with google assistant. Here's how I did it.

**Setting up Adafruit IO**

- Go to https://io.adafruit.com/  and sign up.
- Go to Feeds and create a new feed. [Feeds](https://learn.adafruit.com/adafruit-io-basics-feeds/overview) hold data that devices push to Adafruit IO.

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

Select some name and write some description.

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

- Setup a new [dashboard](https://learn.adafruit.com/adafruit-io-basics-dashboards/overview).

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

Select a name and some description.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/7kud7bzs3f0paux3m1zh.JPG)

- Click on the created dashboard and add a new block (I have taken a toggle block).

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

- Select feed you would like to add and add block settings. For now I am adding a button to control the builtin led of nodemcu.  

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

**Setting up ESP**

- Install Adafruit MQTT library. Sketch>Include library>Manage libraries and search for adafruit mqtt 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/4b4z1ytpikgqyyp6qa4k.JPG)

- Goto File>Examples>Adafruit MQTT Library>mqtt_esp8266
- Update SSID/password and Adafruit IO user name and user key.(You will find your Adafruit IO username and key from your dashboard)

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

- Replace feed name from onoff to espControl
- You need to write the code for the actions you want to perform. Here is a piece of code for controlling builtin led of nodemcu.

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

Get the complete code : https://github.com/DhiraNegi/esp-with-google-assistant

**Google Assistant Integration**

Just enable this [IFTTT](https://ifttt.com/join) applet and you are ready to go.

Try some more stuff as there is always more to learn. 

HAPPY LEARNING :smile:
How to test an invisible v2 Google reCAPTCHA by mimicking a bot, in 2020
Tags: testing, devtools, webdev
Published: 2020-08-02 18:48:35

After implementing an invisible v2 Google reCAPTCHA (the annoying box on a form that asks you to prove your humanity) on a client site, I realized I had no idea how to test it. Like other developers encountering the unfamiliar, I Googled it. 

I learned that once you've implemented the v2 reCAPTCHA and set it as invisible (the least annoying option), you can use Chrome DevTools to mimic a bot as a device. This is similar to how you would do responsive testing for specific phone/tablet models.

Here's how to do it:

1. Navigate to the form page with the reCAPTCHA and open Chrome DevTools by right-clicking the page and hitting 'inspect' or by typing CMD + OPT + I (Mac).
2. Go to the DevTools Settings (the gears icon close to the top right corner).
3. In the left sidebar, choose Devices.
4. Click the button at the top to 'Add custom device'.
5. You can call the device whatever you want, but it might be helpful for future you to name it something relevant. I called mine 'Bot'.
6. Device size and type don't matter. I left mine at the defaults of 400x700 and 'Mobile'.
7. The user-agent string must be set to 'Googlebot/2.1'. Click 'Add'.
8. Close settings, but stay in DevTools. Select the 'toggle device toolbar' (the responsive icon at the top left of DevTools). In the dropdown, you should see your new device name (ex. Bot). Select it.
9. Complete and submit your form. As long as your 'Bot' device is selected in DevTools, the reCAPTCHA image test will activate.

Good luck!