teleren/devto huggingface dataset:
DRY Code aplicado a Funciones
Published: 2022-01-01 00:03:24


Mas allá de los dilemas, un buen código siempre aprovechara la potencia de su lenguaje de programación para evitar realizar las mismas tareas.

```javascript
const addFive = number => {
  const fiveAdded = number + 5;
  console.log(`Your number plus 5 is ${fiveAdded}`);
}
 
const addTen = number => {
  const tenAdded = number + 10;
  console.log(`Your number plus 10 is ${tenAdded}`);
}
 
const addTwenty = number => {
  const twentyAdded = number + 20;
  console.log(`Your number plus 20 is ${twentyAdded}`);
}
```

Como ves en el código anterior, estas tres definiciones de funciones no son replicas exactas entre si, una aplicación bien diseñada será lo suficientemente flexible para unir funciones en un solo elemento.

```javascript
const addNumber = (number, addend) => {
  const numAdded = number + addend;
  console.log(`Your number plus ${addend} is ${numAdded}`);
}
```

El código que realiza la misma tarea en varios lugares es repetitivo, y el credo del codificador de calidad es "Don't Repeat Yourself" (DRY). Si un programa realiza tareas similares sin refactorizar en una función, se dice que "viola DRY". “Violar DRY” es la forma en que un programador se queja: “¡Este script dice lo mismo una y otra vez! ¡Podemos hacer lo mismo con menos código! " Tratemos de no repetirnos en esta base de código reutilizando algunos de los códigos repetidos más evidentemente en funciones que podamos llamar.
2022 Goals
Tags: goals
Published: 2022-01-01 00:00:00

---
title: 2022 Goals
published: true
description: A review of last years goals and setting of new ones for 2022
date: 2022-01-01 00:00:00 UTC
tags: goals
canonical_url: https://www.funkysi1701.com/posts/2022-goals-24nj
//cover_image: https://direct_url_to_image.jpg
---

Lets have a look at what my goals were for 2021. I had eight of them, lets look at them one by one.

1. **Azure certification**. In May of this year I sat and passed the Azure Fundamentals exam. I am calling this goal as achieved. 

2. **Mentoring**. I didn't do anything about working with others or mentoring, so not sure I achieved this one. However I do now work in a development team and I have been reviewing others code and having my own reviewed. We have a junior developer and I am enjoying the opportunities I have to work with him and share my wisdom.

3. **F#**. I have done zero work with F# in 2021, so this one I didn't achieve.

4. **Cosmos db/Mongo db**. I have worked with both of these technologies in 2021. I used Cosmos the most with my website, and storing data for it. I used Mongo/Atlas for auditing for a project I did for my previous job. I wouldn't say I was expert in either of these, but I am starting to get a flavour of non SQL Server databases. I should also note that I am using mysql a lot in my latest job, so another non SQL Server technology that I get to use on a daily basis.

5. **Give a talk**. I said last year that maybe I would make baby steps towards doing this, and I have. In the interview for my new job I gave a short presentation (I thought it was bad, but others didn't!) I also gave a short introduction to Blazor talk which went down well.

6. **Mandlebrot Generator**. Did nothing on this one as well. I may have googled the code but that is as far as I got.

7. **Pwned Pass Mobile App**. I got an increase in users in 2021 and hence it it still running and I still pay for the API key. I am still considering what to do with it.

8. **Time for me**. Achieved this one, had plenty of time for myself.
 
###Not a bad year but what are my goals for 2022?

1. **Video**. I have just purchased a green screen, so my first goal is to learn how to use OBS, how to light myself properly without getting horrible reflections. I have the content for my first talk, the talk I gave at work about Blazor.

2. **Conference**. Attend an in person conference. I am booked to attend Scottish Summit, however it has been postponed due to COVID-19.

3. **Blog More**. I have been neglecting writing blog posts a bit recently, so I want to do more. 

4. **Metrics**. I have been recording various metrics from twitter, github etc and I would like to expand this and make it a service. 

5. **Profile Pic**. My profile pic is getting a bit old, so it would be nice to update the images I use online and improve my personal brand.
My 5 best reads of 2021
Tags: bookreview, devops, softwaredevelopment, productdevelopment
Published: 2022-02-02 18:21:46

---
title: My 5 best reads of 2021
published: true
date: 2022-01-01 00:00:00 UTC
tags: bookreview,devops,softwaredevelopment,productdevelopment
canonical_url: https://jhall.io/archive/2022/01/01/my-5-best-reads-of-2021/
---

2021 is now officially over.

As I read a lot, I thought I’d recap my best reads (books) of the last year, in hopes that you may find something of interest on here for your 2022 reading list.

1. [_Acceleerate: The Science of Lean Software and DevOps: Building and Scaling High Performing Technology Organizations_](https://amzn.to/3EJhNTF) by Nicole Forsgren PhD, Jez Humble, and Gene Kim

2. [_The Knowledge-Creating Company_](https://amzn.to/3mHXSyg) by Ikujiro Nonaka

3. [_Commitment: Novel about Managing Project Risk_](https://amzn.to/3pFPhO9) by Chris Matts, illustrations by Chris Geary

4. [_The Unicorn Project_](https://amzn.to/3FK2ZFy) by Gene Kim

5. [_Failure is Not An Option: Mission Control from Mercury to Apollo 13 and Beyond_](https://amzn.to/3mL9XTe) by Gene Kranz

6. [_The Very Hungry Caterpillar_](https://amzn.to/3eBFfYb) by Eric Carle

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
Getting an edge in a board game (part 0)
Tags: discuss, gremlinsinc, boardgame, datascience
Published: 2021-12-31 23:35:03

I'm on vacation, and because of Covid-19 and Omicron variant, I end up spending a lot of time at home. One of my favourite pass times is to play Gremlins Inc with my friends.

[Gremlins Inc](https://store.steampowered.com/app/369990/Gremlins_Inc/) is a board game available on Windows, macOS and Linux.

This is how the game looks.
![Description of the game board](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/winnaud7q4qm7ov7wbvr.png)

There are three main components at a high level: players, board, and your card deck. An elementary explanation is that you play cards on your turn and move your game piece according to a number displayed on the card. If you play smart, you can play multiple cards during your turn.

Since I'm a developer and want to over-analyze this game even if it does not affect my bottom line, I decided to go and check if I could get some alpha (edge) over my friends.

![Gif with Dr.Evil](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u6flisu9qs9isiapcv0d.gif)
 
## :japanese_goblin: Evil planning 
There are different ways to get an advantage, but I'm interested in the one related to stats and ML (since ML is very 🔥 right now :sunglasses: :money_with_wings:).

Since the game has three main components: players, board and card deck, my edge can come with problem framing for one or more of these components 🔎.

I know that there have been done a lot DS done for HeathStone Game which is another board game that also uses cards although in a slightly different way. I believe in standing on the shoulders of giants so I would shamlessly climb on the research done for HearthStone and try to 🛠️ it into Gremlins Inc.

The first low hanging problem is to learn what's the card distribution in Gremlins Inc and do some DS viz to see if I can spot some actionable insights.

- **Resources for inspiring reasearch**
  - [Dive in HearthStone from a data perspective](https://towardsdatascience.com/dive-in-hearthstone-from-a-data-perspective-e3c0b2851686)
  - [Analysis of gameplay strategies in hearthstone: a data science approachapproach](https://digitalcommons.njit.edu/cgi/viewcontent.cgi?article=2789&context=theses)
Classes Under the Hood
Tags: javascript, tutorial, beginners, programming
Published: 2021-12-31 23:00:32

Ever heard the phrase, "in software engineering, everything is an object"? Well, we are going to delve into three major things: How classes in javascript work under the hood, what classes are built on and also the fact that a class is a function basically. 

In order to understand how classes work under the hood, we need to touch on two concept in javascript: prototypal inheritance and constructor function.

## Constructor Function
When you create a class, you are basically creating a function. This type of function is called a constructor function and it is always initialized with the keyword 'new.' It is a convention in Javascript to start a constructor function with a capital letter. 
![How to create a constructor function](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d69stj9jgw7s0gaxxsak.png)

The (\*) represents the creation of the constructor function, (\*\*) represents how to create an object from the constructor function. The line (\*\*\*) creates an object from the construction function using an inbuilt property 'constructor' (I don't think Ostriches are blue thou). Whenever you create a class you are creating a constructor function.

## Prototypal Inheritance

```
let Animal = { 
  breath: true,
  walk() {
    Alert("All Animal's walk");
  },
};

let Bird = {
  __proto__: Animal, (*) // Bird becomes a prototype of Animal
  fly: true,
};

alert(Bird.walk()) (**) // All Animal's walk
```
All objects have a property called [[prototype]] this is referenced or called when \_\_proto\_\_ is set on the Bird object to Animal. The line (*) signifies I am inheriting or I am a prototype of Animal; therefore I have access to everything inside the Animal object. The \_\_proto\_\_ can go as deep as possible but an object may not inherit from two at a time i.e you can only inherit from one other object.

How does the above tie into classes and how classes work? Well, when you create a class you create a constructor function and when your class has a constructor you are using the constructor property under the hood.

## To sum it all up
```
Class User{
   constructor(name, age){
      this.name = name;
      this.age = age;
   }
}
const user = new User("David" "2")

function User(name, age){ // This is equivalent to creating a class User
   this.name = name;
   this.age = age;
}
const user = new User()
const user1 = new user.constructor("David" "2") // This is what the User class constructor above calls under the hood
```


```
class Animal{
  walk(){
    Alert("All Animal's walk")
  }
}
class Bird extends Animal{ // When you extend animal or you inherit from the Animal class, a __proto__ object property in Bird is created and it refrences Animal
  __proto__: Animal
} 
```
Sharpening My Skills with 100 Days of Code
Tags: career, 100daysofcode, programming
Published: 2021-12-31 22:59:53


I've been creating enterprise-grade software for the better part of the last decade, but between _pandemic-induced burnout_ and _stage 4 cancer_, I haven't done much development work in the last 24 months.  With my health trending in the right direction and the new year upon us, it felt like the right time to rebuild some productive habits.

The [100 Days of Code](https://www.100daysofcode.com/) challenge is a community-driven cohort focused on improving programming skills over the course of 100 days.  The challenge has two rules:

1. Spend at least 1 hour every day programming
2. Post an update on your progress

## Challenge Goals
By participating in the challenge, my goal is to refresh my skills in developing & deploying a full-stack application.  Upon completing the challenge, I hope to have:

- A MVP of a single-feature application deployed for production use.  
- Deployment of the application should be driven using CI/CD.
- The code should have high test coverage (Stretch goal: 100%) 
- The project should leverage third-party services when appropriate to minimize code ownership to the primary feature.

## Progress Updates 
Adhering to the challenge rules, I intend to post daily updates on my progress.  I anticipate most updates will be simple summaries of the work I performed, but perhaps a tutorial or two will find surface as I iterate through the development of the application.  

---
Have you undertaken the 100 days of code challenge?  Share your experiences or questions below in the comments.
Reflection 2021
Published: 2021-12-31 22:25:55

As we coming to the end of this year, I would like to reflect on 2021 and share some of my personal experiences.

2021 was quite a journey for me to be honest. It had lows and highs all over the year. Back in January, I graduated in my studies and started to search for a job right after it. Thanks to my final thesis, I tried in Android Development first. After a month, I had to realize that I was missing a huge thing: a proper portfolio to show off. Therefore, I decided to take Udacity's Android Kotlin Nanodegree Program. It was a really great course which gave me impressive knowledge about that topic.

So when I finished it, I started to apply again for developer positions. Months passed by and I had to face the truth: there is no chance to get an entry job where everyone is looking for an applicant who has 2+ years working experience. In October, switched to different technologies, tried to dive deeper in C#, Kotlin, Python instead of Android.

When almost all hope was gone, I finally got a letter at the end of November. A letter which offered a great possibility after 10 months of searching and learning for my future place. I'm so grateful that my year ends like this and I'm keen to learn more about real world practices of technologies.

That's my story and for sure, I've learnt a lot this year. Now, it's time to say goodbye 2021 and let's roll into 2022 with all the energies. Happy New Year! :)
Self-Taught Developer Journal, Day 29: TOP JavaScript Fundamentals Part 2 - Practice and Knowledge Check
Tags: webdev, beginners, codenewbie, devjournal
Published: 2021-12-31 22:12:18

Today I completed The Odin Project JS Fundamentals Part 2 Knowledge Check Section after reviewing all of the materials.

## Knowledge Check

1. **What are the eight data types in JavaScript?**
Numbers, BigInt, Strings, null, undefined, Boolean, Objects, Symbols
2. **Which data type is NOT primitive?**
Objects
3. **What is the relationship between null and undefined?**
The expression, `null == undefined`, returns true when using the loose equality operator, "==", but not for, "==="
4. **What is the difference between single, double, and backtick quotes for strings?**
Single and double both behave the same. Backtick quotes can format strings with variables and expressions.
5. **What is the term for embedding variables/expressions in a string?**
Template literals
6. **Which type of quote lets you embed variables/expressions in a string?**
Backticks
7. **How do you embed variables/expressions in a string?**
${...}
8. **How do you escape characters in a string?**
Put a blackslash, "\", in front of a character
9. **What are methods?**
Actions performed on Objects
10. **What is the difference between slice/substring/substr?**
Slice extracts a part of a string and returns the extracted part in a new string.
Substring is similar to slice, but can't use negatives indices
Substr is similar to slice, but the second parameter specifies the length of the extracted part.
11. **What are the three logical operators and what do they stand for?**
&& (AND), || (OR), ! (NOT) 
12. **What are the comparison operators?**
Operators that compare values between operands
13. **What are truthy and falsy values?**
Values that return the boolean value true or false
14. **What are the falsy values in JavaScript?**
0, empty string, null, NaN, and undefined
15. **What are conditionals?**
evaluates whether a statement/expression is true or false
16. **What is the syntax for an if/else conditional?**
Refer to end
17. **What is the syntax for a switch statement?**
Refer to end
18. **What is the syntax for a ternary operator?**
`condition ? value1: value2;`
19. **What is nesting?**
Putting a statement inside of another statement, therefore nesting them.

For Question 16:

    if {
      ...
    } else {
      ...
    }

For Question 17:

    switch (condition) {
      case a:
        code block
        break
      default:
        code block
    }

## Resources
[The Odin Project](https://www.theodinproject.com/paths/foundations/courses/foundations/)
Module.createRequire is not a function
Tags: react, gitlap, deployment, nodeversion
Published: 2021-12-31 22:07:07

---
title: Module.createRequire is not a function
published: true
description: Running gitlap yml deployment returns Module.createRequire is not a function
tags: react,gitlap, deployment,nodeVersion
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n2zgkx89i7undg7bpd0i.png
---

_Anayo Debugging 2_

This is one simpler issue, but the simplest bug can be the biggest at times, so I made sure I document it and can help anyone out there too.

# Bug

In my react project's root I have a GitLab-ci.yml file that automatically runs whenever I push a commit to the server. It triggers a notification to the runner I specified, and then it processes the series of tasks I specified.

Which involves building and deploying.

This is a legacy React project, and had long been updated. After upgrading the packages I git committed. Build built successfully but deployment failed. With the following error:

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



#Solution

I read through the error to understand what the problem really was, and I found it:

```
Module.createRequire is not a function
```

That was the only error that was reasonably clear indeed and meant something.

So I Googled it, and I found out that it's an issue with Create React App, it's always on or looking for the latest, which means the Node engine version has to always be the latest and that includes my npm version, else some things might break.

So in essence whatever machine running that project has to have Node >= 14.0.0 and npm >= 5.6


# Fix
1. My GitLab-ci.yml contains a Docker image with a node version of 10.15.3, so there is a need to upgrade.

```
image: giona69/node-10.15.3-aws-eb
```

2. And I temporarily replaced the docker image with the latest node.

```
image: node:14.18.2
```

3. Rebuilt Node-Sass

I added 
`npm rebuild node-sass` 
to the deploy script

And Voila!! That fixed the issue. These weeks has been simple, this is the issues I have been experiencing.

------

My name is Anayo Oleru, I specialise in Backend Development(NodeJS & ExpressJS), but I am experienced with Web frontend(ReactJS) and mobile(React-native). And I am open to offers in these fields.

You can follow me on Twitter at @AnayoOleru or send an email to: anayo_oleru@outlook.com

Cheers and take care.
Create And Delete Kafka Topic Using Python
Tags: kafka, python, eventdriven
Published: 2021-12-31 21:00:03

### Install kafka-python package

Python client for the Apache Kafka distributed stream processing system.

 

```
pip install kafka-python
```



```
from kafka.admin import KafkaAdminClient, NewTopic


admin_client = KafkaAdminClient(bootstrap_servers=[ipaddress:port])


topic_names = ['topic1', 'topic2', 'topic3' , 'topic3']

def create_topics(topic_names):

    existing_topic_list = consumer.topics()
    print(list(consumer.topics()))
    topic_list = []
    for topic in topic_names:
        if topic not in existing_topic_list:
            print('Topic : {} added '.format(topic))
            topic_list.append(NewTopic(name=topic, num_partitions=3, replication_factor=3))
        else:
            print('Topic : {topic} already exist ')
    try:
        if topic_list:
            admin_client.create_topics(new_topics=topic_list, validate_only=False)
            print("Topic Created Successfully")
        else:
            print("Topic Exist")
    except TopicAlreadyExistsError as e:
        print("Topic Already Exist")
    except  Exception as e:
        print(e)

def delete_topics(topic_names):
    try:
        admin_client.delete_topics(topics=topic_names)
        print("Topic Deleted Successfully")
    except UnknownTopicOrPartitionError as e:
        print("Topic Doesn't Exist")
    except  Exception as e:
        print(e)


consumer = KafkaConsumer(
    bootstrap_servers = "ip_address",
    )
create_topics(topic_names)
```
INTRODUCTION TO SECURITY GROUP
Tags: aws
Published: 2021-12-31 13:11:38

**Security Group** are the network security in AWS.It control how traffic is allowed in or out of our EC2 instances.
Security Group contain only **allow** rules.Security Group can reference by **IP or by Security Group**.

**NOTE: Security Group is a instance firewall.**



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

**NOTE :** Security Group is **Stateful**. Stateful means if a request is allowed in inbound, the response for the request is automatically allowed to outbound this is called Stateful.

Security Group regulates:
1. Access to ports.
2. Authorised IP ranges -IPV4 and IPV6
3.Control of inbound network that means from other to the instance.
4.Control of outbound network that means from instance to the other.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6laehxeyviduy49ucaqu.jpeg)

**About Security Group want to know more:**
. Can be attached to **multiple instances**.(That instances have multiple security groups too)
. Locked down to **region / VPC Combination** (We have to create security group for region as well as VPC).
. If the traffic is blocked the EC2 instance won't see it.
. It is good to maintain one separate security group for **SSH access**.
. If our application is not **accessible (timeout)** then it will security group issue.
. If our application is **"connection refused"** error then it must be application error or its not launched.
. All inbound traffic is **blocked** by default.
. All outbound traffic is **authorised** by default.

**In Security Group we want to know more:**

**Classic Ports:** 
1. **22 - SSH (Secure Shell)** - Login to Linux Instance.
2. **21 - FTP (File Transfer Protocol)** - We upload files into a file share.
3. **22 - SFTP (Secure File Transfer Protocol)** - We will upload files using SSH because it is going to be a secure file transfer protocol.
4. **80 - HTTP (Hyper Text Transfer Protocol)** - It is used to access unsecured websites.
5. **443 - HTTPS** - It is used to access secured websites.
6. **3389 - RDP (Remote Desktop Protocol)** - It is used to Login into a Windows Instance.