teleren/devto huggingface dataset:
Code refactoring
Tags: opensource
Published: 2022-10-11 19:39:12

Hi !

Today I've been working on my project and did the code refactoring. It turns out there are so many things that could be improved. Code is not always written within the rules.

### Refactoring

For now, I know 4 things that **must be** refactored:

- Change the variable names (to make it clear what they are here for)

- Extract certain logic and put into function, so that we are able to reuse it and if we have an error, we just need to fix one function

- Improve code readability, because sometimes we just write a lot of code, and we want to make it work, but we don't really care about the readability, though it's very important if other people will work on your code. We don't want the programmers to feel the pain when they try to understand our code :)

- Splitting the code into multiple functions. That's a very good approach, since we don't go along with just one index.js file, containing 1000 lines of code. We have 5 files and each of them not big and very easy to manage.

After I've done multiple commits in a refactoring branch, where each commit held only one refactor(e.g. extract logic into function), I had to do rebase all commits into one.

### Overall 

I didn't break any functionality, hence code refactoring was successful, but there is always a way to improve :)
BNB NFT Course Overview
Tags: blockchain, nfts
Published: 2022-10-11 19:34:47

## Course Overview
{% embed https://www.youtube.com/watch?v=BCJoMkM7_QE %}


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z96afhyt5rqhqci90y42.png)
Paracetamol.js💊| #190: Explica este código JavaScript
Tags: javascript, webdev, spanish, beginners
Published: 2022-10-11 19:10:59

## **<center>Explica este código JavaScript</center>**
#### <center>**Dificultad:** <mark>Básico</mark></center>

**¿Cuál es la manera correcta de llamar a un setter?**

```js
class Dog {
  #peso;
  constructor({ color, tamanio, peso=10, cola=true}){
    this.color = color;
    this.tamanio = tamanio;
    this.#peso = peso;
    this.cola = cola;
  }

  set setColor(nuevoColor){
    this.color = nuevoColor;
  }
}

const boby = new Dog({
  color: "cafe",
  tamanio: "grande"
});

console.log(boby.color); //cafe

boby.setColor("rojo"); //A 
boby.setColor = "rojo"; //B
```

A. `A`
B. `B`
C. `Ninguna de las anteriores`

Respuesta en el primer comentario.

---
Symbol vs String Keys
Published: 2022-10-11 19:20:19

symbols: "map **immutable strings** to internal values" - kinda constant-like. cannot concatenate 
-symbols are immutable, will refer to the same object and same place in memory

-every time a string is written, it creates a new object with new place in memory (even if identical to something existing)
-string may also hurt program's memory if string objects are repeatedly created and destroyed (when same object could have been reused in their place 
-mutable objects can cause bugs that are difficult to detect

> IF TEXTUAL CONTENT OF OBJECT IS IMPORTANT, USE STRING
> IF IDENTITY OF OBJECT IS IMPORTANT, USE SYMBOL
Golang Tutorial
Tags: go, tutorial, typeassertion, beginners
Published: 2022-10-11 19:19:29

## Golang Course Overview and Tutorial
{% embed https://www.youtube.com/watch?v=Ja-kX_Dn5Go %}

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lbhi0h5a7vibkc775s6b.png)
Day 11/100: The refresh
Tags: 100daysofcode, react, devjournal, webdev
Published: 2022-10-11 19:07:06

Cleaning up and optimising was on the agenda today. Spent the majority of my day reading up more on react and conditional rendering. 
 
Some of my day was also spent editing most of the icons on the page and looking at the general colour scheme of the site. I'm unsure of which colour palette and colour theme is needed. This uncertainty led me down a rabbit hole that left me on the doorstep of "Toggle buttons for themes". That why I can have a everything I want and I can give the user the chance to choose whatever they want.
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5sffa74lotbcbaui0sls.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vkb1ab2do669770b9z3n.png)
Go high performance http server with Forker
Tags: go, echo
Published: 2022-10-11 19:03:47

{% embed https://github.com/Ja7ad/forker
 %}

Get high performance http requests with fork process (forker inspired prefork feature in web servers)

prefork is a solution which is also used by other webservers

A server instance is opened for each processor core and incoming requests are shared between these instances

In order to distribute the load more evenly and handle more requests per second, there is a master that starts by the user, which then starts child processes on the other processor cores based on configuration

memory between the different processes is not shared, beacuse goroutines are independent processes


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

**Benchmark With oha 200k request with 500 concurrent**

```shell
Summary:
  Success rate:	1.0000
  Total:	24.4907 secs
  Slowest:	0.5000 secs
  Fastest:	0.0004 secs
  Average:	0.0610 secs
  Requests/sec:	8166.3762

  Total data:	2.10 MiB
  Size/request:	11 B
  Size/sec:	87.72 KiB

Response time histogram:
  0.000 [1]     |
  0.050 [82408] |■■■■■■■■■■■■■■■■■■■■■■■■■■
  0.100 [98705] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  0.150 [16180] |■■■■■
  0.200 [2245]  |
  0.250 [361]   |
  0.300 [59]    |
  0.350 [33]    |
  0.400 [3]     |
  0.450 [1]     |
  0.500 [4]     |

Latency distribution:
  10% in 0.0291 secs
  25% in 0.0404 secs
  50% in 0.0557 secs
  75% in 0.0754 secs
  90% in 0.0989 secs
  95% in 0.1170 secs
  99% in 0.1581 secs

Details (average, fastest, slowest):
  DNS+dialup:	0.0259 secs, 0.0001 secs, 0.3010 secs
  DNS-lookup:	0.0000 secs, 0.0000 secs, 0.0239 secs
```

**How to Install?**

```shell
go get -u github.com/Ja7ad/forker
```

**Example**

```go
package main

import (
	"github.com/Ja7ad/forker"
	"log"
	"net/http"
)

func main() {
	srv := &http.Server{
		Handler: GreetingHandler(),
	}

	f := forker.New(srv)

	log.Fatalln(f.ListenAndServe(":8080"))

}

func GreetingHandler() http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte("greeting!!!"))
	}
}
```
Ingest VPC Flow Logs into NewRelic
Tags: aws, kinesis, newrelic, amazonwebservices
Published: 2022-10-11 18:59:25

There are many use cases where we wanted to monitor the VPC Flow Logs to view the data going IN / OUT into our VPC. These network traces helps us to troubleshoot many network-related issues. 

We do have a choice in AWS to save VPC Flow Log either into 

- AWS CloudWatch or 

- AWS S3 Buckets. 

However, both of these solutions don't provide a good user-friendly view and can become cumbersome when trying to find a specific IP Address or Port. 

Well thanks to Kinesis Data Firehose to provide us pretty much option to cope up these situation. We can ingest the data from many possible AWS services into Kinesis Data Firehose and send that to 3rd party monitoring solution to create some AWSome custom Dashboard and monitor the logs. 

I will walk you through step by step to configure this solution in this blog. We can divide this into 3 parts

1. Create Kinesis Data Firehose
2. Create the VPC Flow Logs
3. Transform the Log using Lambda function (Optional)
4. Send the Logs to NewRelic Monitoring Solution

## Create Kinesis Data Firehose
Create a Kinesis Data firehouse and select Source as **Direct PUT** and Destination as **New Relic**. Please note that Kinesis Data Firehose is near real time solution but not the real time solution as Kinesis.

![Chose Source & Destination](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/713sqkco8rvkzxl4ij61.png)

Under Destination Setting - Select HTTP Endpoint URL as **NEW Relic Log - US**. Enter the API KEY (Copy the API Key form New Relic)

Click on following URL, this will land you to NewRelic API-Key screen, as shown below

https://one.newrelic.com/admin-portal/api-keys/home?


![NewRelic API Key](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c0yc9aigg501vqk8rpat.png)



![Kinesis Data Firehose Destination Configuration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/97m1p2ul3272fvwlz05w.png)

## Create VPC Flow Log

Go to VPC --> Action and click on Create flow log

![VPC Flow Log](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6tenjdrwf2j8n3za0i4c.png)

Under **Filter**, select weather you only want to monitor the ACCEPTED Traffic, REJECTED Traffic or ALL Traffic.

Under **Destination**, select **Send to Kinesis Data Firehose in same account** and select the Kinesis Data Firehose 

![Filter VPC Log](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dbvkonormpw5n2naod1m.png)

This will take few seconds and then you will start seeing the data into NewRelic platform 


![NewRelic Logs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2nkw43oefg3hlvzownn1.png)

If you like this article then don't forget to hit the like and share with others :)
Ask for new tasks
Tags: beginners, programming, productivity
Published: 2022-10-11 18:59:25

Having a Junior developer in your company is not an easy task, as it requires attention, understanding your doubts and also being able to assist in your progress. It's like a child where he's learning to take his first steps, and you're there helping the novice developer to make the first pull requests.

## Errors

Receiving errors, understanding and working around them is an activity that will make you stand out from other professionals in the market. So, the more problems you solve, the more you will learn. 

It's logical! You go up one level of education at a time, and you always learn something new as you level up, and in the area of ​​technology it doesn't change. So grab more issues! In addition to knowing how to solve problems, the time it takes you to solve them will also add to your evolution.

Learning something new takes time!

Climbing good professionals is not overnight.

## Helping

One of the problems with climbing Juniors evolution is picking up a task and not knowing how to ask for it. Be it for some reason. Juniors must learn to ask more. If you've been on the same issue for more than an hour, search, ask, or post in a community.


## Evolving with communication.

Another problem is not accepting or receiving feedback.

Feedback is a formal response to your professional status, whether positive or negative. Whether you accept it or not, it's a way for you to understand whether or not you're evolving.

Having a follow-up of your evolution with your manager is very interesting for your professional ascension.

So, have more problems, learning to ask more questions, read and write more and align your expectations with your manager about your evolution is a good path to your professional growth.
ArchWSL++ brings Arch Linux to WSL and more
Tags: archlinux, wsl, powershell, windows
Published: 2022-10-11 18:44:11

---
title: ArchWSL++ brings Arch Linux to WSL and more
published: true
description: Bring the power of Arch Linux to Windows Subsystem for Linux.
tags: archlinux, wsl, powershell, windows
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rl9bsq16b748043hf6b5.png
---
Consider this the post that supersedes my [previous post](https://dev.to/jrcharney/how-to-install-arch-linux-for-wsl-184a)! [**ArchWSL++**](https://github.com/jrcharney/ArchWSLPlusPlus) brings ArchLinux to Windows using Windows Subshell for Linux (WSL), but also installs all the stuff that makes WSL look spectacular.

ArchWSL++ builds on top of what [ArchWSL](https://github.com/yuk7/ArchWSL) offers by including visual ["unixporn"](https://unixporn.github.io/)-like features that frankly should be an option when you install WSL.  Plus, I've made some suggestions as to some terminal toys that are fun little features that are sure to either impress your friends or make the jealous.

But there is no need for envy. This Github repo (which will likely be turned into pages on my Github site soon since it is more documentation than download) offers some step-by-step instructions to make your Windows Terminal awesome.  The only thing better would be running a Linux Machine with these features, which sadly my coding boot camp wouldn't let me use my Linux box despite the fact that EVERYTHING can be done on Linux, except for running Slack in an app which probably why we can't use Linux despite it still being possible to use Slack in a web browser. (**FIX YOUR S$#&, SALESFORCE!**)

At any rate, I'm going to keep this post short today.  Any future updates regarding ArchWSL++ will be pushed to the repo on my Github.

Have fun with this!
😬 Company takeovers, what now?
Tags: career, discuss
Published: 2022-10-11 18:41:52

So I'm not going into specifics but I do want to ask, did your company or the company your working for get purchased by an investment company and did you have a long forefilling career after that event, did anything change? 

I'm trying to workout if I should be planning for Armageddon or an amazing time to come. I love where I work and I don't want it to change 

Let me know your experiences in the comments!
Boundaries
Tags: codepen
Published: 2022-10-11 18:38:51

<p>Playing with Threejs and Cannonjs inspired by <a href="https://hpitgroup.glitch.me/" target="_blank">HARUN PEHLİVAN 

> 
</a></p>

{% codepen https://codepen.io/harunpehlivan/pen/WNJLoQz %}
Best React forms library
Tags: react, reactnative, forms, validation
Published: 2022-10-11 18:21:03

We at enfometa has developed a very robust, simple and flexible React forms library which can be used in both React and React Native.
Please check the documentation and samples here.

[Documentation and Samples](https://www.enfometa.com/documentation)

Our team at enfometa is available for free support.
#15
Tags: tdd, zsh, keyboard
Published: 2022-10-05 08:35:34

## Table-driven tests

Go has superb built-in support for good programming practices, such as test-driven development. In fact, I'm learning a lot about TDD while learning Go from this book: “[Learn Go with Tests](https://quii.gitbook.io/learn-go-with-tests/)”. 

If you want to test a bunch of similar inputs and outputs, it's handy to run table-driven tests. What you do is list input values and expected output in an array, then loop through all the test cases.

I found this [blog post by Lorenzo Peppoloni](https://lorenzopeppoloni.com/tabledriventestspy/) quite helpful. It gives examples in both Golang and Python for table-driven tests.

---

## Create your own keyboard layout optimized to reduce finger fatigue

We all push buttons for a living. Most of us spend enormous amount of time with the Qwerty keyboard layout. 

I came across this fascinating video about [making your own perfect keyboard layout](https://www.youtube.com/watch?v=EOaPb9wrgDY).

By perfect, “adumb” refered to the shortest distance your fingers travel while typing on the keyboard. And the corpus he used to calculate the total distance is arXiv abstracts.

He first randomly generated keyboard layouts then crossed over the best ones. Until after 1000 generations of crossover, the total finger travel distance stopped decreasing.

If I were to make a keyboard layout, I would use a larger corpus that includes English, Swedish, Chinese as typed using Pinyin, and a bunch of programming languages. 

On top of the larger number of symbols to rearrange, when you type CJK (and other complex, non-alphabetic) languages, you need to deal with the complicated relationship between the [input method](https://en.wikipedia.org/wiki/Input_method) and the keyboard layout, especially on Linux.

----

## zsh

For quite a while, I found I couldn't use commands I clearly had installed properly (macOS 12.2).

After some digging, I used an `export` command in `.zshrc` file and forgot to include `$PATH:` when setting the PATH value. 

This [answer on StackOverflow](https://stackoverflow.com/a/71099236/13776347) was helpful.
Divide By Zero
Tags: java, exception
Published: 2022-10-11 18:12:36

Mathematically, any number when divided by zero is not defined. However in Java programming, the division by zero usually gets related to an Exception, which is _ArithmeticException_. 

For example:

```
public class DivisionByZero {

   public static void main(String[] args){
      System.out.println( 5 / 0 );
   }

}
```
The above code snippet gives us a _ArithmeticException_ as below:

`Exception in thread "main" java.lang.ArithmeticException: divide by zero`

This could lead most of us to the assumption that whenever we divide a number by zero in Java we get the _ArithmeticException_, but that isn't the case.

What if the datatype of the number being divided by zero is float or double?

Let's check out,

```
public class DivisionByZero {

   public static void main(String[] args){
      System.out.println( 5.0f / 0);
      System.out.println( 6.0d / 0);
      System.out.println( 0f / 0);
      System.out.println( -7.0f / 0);
   }

}
```
When the above code gets executed no exception will be thrown, rather we get the below output:
```
Infinity
Infinity
NaN
-Infinity
```

So why didn't the division by zero with float or double values didn't throw any exception.

It's because, in Java division of an integer by 0 is not covered  by the IEEE 754 standards therefore generates an _ArithmeticException_. In case of division of float or double values Java follows the IEEE 754 standards and have special numeric values that represent the result of such operations such as `NaN, Infinity & -Infinity`.

So to summarize, In Java values such as `Nan & Infinity` are available only for floating-point numbers ( As per the IEEE 754 standards), therefore the division by zero operation on floating-point numbers is allowed. Since no special values like `Nan` are aligned to integer, the division by zero results in _ArithmeticException_. 

Hope this article is useful. Thanks!
Support science and help your favorite charity by participating in a short online experiment.
Tags: javascript, sql, node, help
Published: 2022-10-11 17:55:45

Hi

We are researchers from the University of Zurich, Switzerland, and developed a web application experiment for investigating ways to improve code review. If you have **javascript** knowledge, please help us in this **20 – 30 minutes** experiment by using the desktop version of a browser: https://review.ifi.uzh.ch/

To thank you, we will **donate 5 USD** to the charity of your choice.

We are very grateful if you share the link with colleagues and make them aware of this study. 

Thank you very much,
Lukas and researcher team
Take My Online Courses
Tags: beginners, javascript
Published: 2022-10-11 17:51:22

One of the main causes for why so many students look for online homework assistance is this. You are a working parent, a student, or both, unless you are unemployed and money is not an issue. a student who must balance school, a career, a family, friends, and all else that life has to offer. Did we forget to mention the additional full degree? That's correct That you, like many others, are looking to [Pay Someone to Take My Online Courses](https://onlineclasshelppro.com/take-my-courses.php) for you is not a surprise
Rails Routing
Published: 2022-10-11 17:33:16

Routes
Params
Any time Rails receives a request with a Content-Type of application/json, it will automatically load the request body into the params hash
to avoid mass assignmemt, use strong params:
params.permit(:attribute1, :attribute2...)

```
get '/cheeses/:id', to: 'cheeses#show'
```

CheesesController

```
def show 
    byebug
    cheese = Cheese.find_by(id: params[:id])
    render json:cheese
end
```

The routes.rb file takes in the request to localhost:3000/cheeses/3 and processes it like normal, except this time it also parses the 3 as a URL parameter and passes it to the CheesesController.

From that point, the controller action that you write will parse the 3 parameter and run a query on the Cheese model.

Once we have the correct Cheese instance, we can render a JSON response.

render
By specifically defining what data is being sent via a Rails controller, we have full control over what data our frontend has access to.
Except & Only
```
  def index
    cheeses = Cheese.all
    render json: cheeses, except: [:created_at, :updated_at]
  end

  # GET /cheeses/:id
  def show
    cheese = Cheese.find_by(id: params[:id])
    render json: cheese, only: [:id, :name, :price, :is_best_seller]
  end`
```
methods

```
 render json: cheese, except: [:created_at, :updated_at], methods: [:summary]
```

conditionally rendering custom error messages

```
if cheese
    render json: cheese, except: [:created_at, :updated_at], methods: [:summary]
  else
    render json: { error: 'Cheese not found' }, status: :not_found
  end
```

rails routes [| grep] object-name- review routes for specific object

Example: 
```
resources :pets, only: [:index, :show]
```

status - including this in your render will not change the json response but will provide additional information for the client. Examples include "ok, not_found"
[Status Codes](http://www.railsstatuscodes.com/)

Postman and byebug
In the byebug session, we can access the entire request object by using the request method:

(byebug) request
#<ActionDispatch::Request POST "http://localhost:3000/birds" for ::1>
This request object has all kinds of info about what was sent in the request. Try some of these methods out in your byebug session:

request.request_method
request.headers["Content-Type"]
request.body.read
The last one, request.body.read, will read the body of the request as a string. Nice! We could take it a step further, and parse that string as json:

(byebug) JSON.parse(request.body.read)
{"name"=>"Monk Parakeet", "species"=>"Myiopsitta monachus"}

render json: movie, serializer: MovieSummarySerializer
 render json: movies, each_serializer: MovieSummarySerializer

class BirdsController < ApplicationController
  rescue_from ActiveRecord::RecordNotFound, with: :render_not_found_response
A WooSesh Chat with Paul Maiorana, Kimberly Coleman and Courtney Robertson
Tags: speaking
Published: 2022-12-01 19:01:02

---
title: A WooSesh Chat with Paul Maiorana, Kimberly Coleman and Courtney Robertson
published: true
date: 2022-10-11 17:32:23 UTC
tags: Speaking
canonical_url: https://courtneyr.dev/2022/10/11/a-woosesh-chat-with-paul-maiorana-kimberly-coleman-and-courtney-robertson/
---

> [A WooSesh Chat with Paul Maiorana, Kimberly Coleman and Courtney Robertson](https://dothewoo.io/woosesh-chat-paul-maiorana-kimberly-coleman-courtney-robertson/)

<iframe sandbox="allow-scripts" security="restricted" title="“A WooSesh Chat with Paul Maiorana, Kimberly Coleman and Courtney Robertson” — Do the Woo - a WooCommerce Builder Community" src="https://dothewoo.io/woosesh-chat-paul-maiorana-kimberly-coleman-courtney-robertson/embed/#?secret=j1T1iniZTZ#?secret=qL4Ow0Iera" data-secret="qL4Ow0Iera" width="500" height="282" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>

This article first appeared on:  
 ![](https://courtneyr.dev/wp-content/uploads/2015/11/cropped-CER_LOGO_SQUARE1.png)  
[Courtney Robertson -](https://courtneyr.dev)  
by [<span class='p-author h-card'>Courtney Robertson</span>](https://courtneyr.dev/author/courane01/)