teleren/devto huggingface dataset:
Define a Constructor Function
Tags: javascript, devops, tutorial, beginners
Published: 2021-06-08 00:14:03

* Constructors are functions that create new objects. They define properties and behaviors that will belong to the new object. Think of them as a blueprint for the creation of new objects.

* Here is an example of a constructor:
```
function Dog() {
  this.name = "Anakin";
  this.color = "brown";
  this.numLegs = 4;
}
```
* This constructor defines a `Dog` object with properties `name`, `color`, and `numLegs` set to Anakin, brown, and 4, respectively. Constructors follow a few conventions:

1. Constructors are defined with a capitalized name to distinguish them from other functions that are not `constructors`.

2. Constructors use the keyword `this` to set properties of the object they will create. Inside the constructor, `this` refers to the new object it will create.

3. Constructors define properties and behaviors instead of returning a value as other functions might.
Read/Write to Files in C# with errorLogging example
Tags: csharp, dotnet
Published: 2021-06-08 00:03:24

https://github.com/3Mustard/cSharpCliErrorLogger

Example of how to use ErrorLogger to write one or multiple errors to a file and display them in the console
```
string filePath = System.IO.Path.GetFullPath(@"..\logs.txt");
ErrorLogger eLogger = new ErrorLogger(filePath);

Error err = new Error();
Error err2 = new Error();
Error err3 = new Error();
err.Message = "new error message 1";
err.Date = DateTime.UtcNow.ToString();
err2.Message = "new error message 2";
err2.Date = DateTime.UtcNow.ToString();
err3.Message = "new error message 3";
err3.Date = DateTime.UtcNow.ToString();

List<Error> errors = new List<Error>();
errors.Add(err2);
errors.Add(err3);

eLogger.LogNewError(err);
eLogger.LogAllNewErrors(errors);
eLogger.DisplayErrorsToConsole();
```
A Dogma-Free Approach to TDD
Tags: tdd, practices, testing, video
Published: 2021-06-08 17:50:08

---
title: A Dogma-Free Approach to TDD
published: true
date: 2021-06-08 00:00:00 UTC
tags: tdd,practices,testing,video
canonical_url: https://jhall.io/archive/2021/06/08/tiny-devops-episode-5-a-dogma-free-approach-to-tdd/
---

{% youtube qM1Zc_49Eas %}

Guest Goerge Stocker cuts through the often polarizing debate about Test-Driven Development (TDD) and offers his view on when the practice does and _does not_ make sense, based on technology as well as human factors which are often overlooked. We discuss the concept that TDD is one of a vast array of techniques to choose from, and some of what goes into selecting the right tool for the job.

Or [listen](https://share.transistor.fm/s/da70d5c2) to this episode as a podcast.

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
Making Code More Reusable with the this Keyword
Tags: javascript, devops, tutorial, beginners
Published: 2021-06-07 23:48:40

* The last post introduced a method to the dog object. It used dog.name dot notation to access the value for the name property within the return statement:
```
sayName: function() {return "The name of this dog is " + dog.name + ".";}
```
* While this is a valid way to access the object's property, there is a pitfall here. If the variable name changes, any code referencing the original name would need to be updated as well. In a short object definition, it isn't a problem, but if an object has many references to its properties there is a greater chance for error.

* A way to avoid these issues is with the this keyword:
```
let dog = {
  name: "Anakin",
  numLegs: 4,
  sayName: function() {return "The name of this dog is " + this.name + ".";}
};

dog.sayLegs();
```
* `this` is a deep topic, and the above example is only one way to use it. In the current context, `this` refers to the object that the method is associated with: `dog`. If the object's name is changed to `husky`, it is not necessary to find all the references to `dog` in the code. It makes the code reusable and easier to read.
Creating a Method on an Object
Tags: javascript, devops, tutorial, beginners
Published: 2021-06-07 23:41:27

* Continued.
* Objects can have a special type of property, called a method.
* Methods are properties that are functions. This adds different behavior to an object. 

* Here is the dog example with a method:
```
let dog = {
  name: "Anakin",
  numLegs: 4,
  sayName: function() {return "The name of this dog is " + dog.name + ".";}
};

console.log(dog.sayName()); // would print the string The name of this dog is Anakin.
```
* The example adds the `sayName` method, which is a function that returns a sentence giving the name of the `dog`. Notice that the method accessed the `name` property in the return statement using `dog.name`. The next challenge will cover another way to do this.
Wizeline Mexico is looking for Functional QA Engineer
Published: 2021-06-07 23:35:36

We are looking for Functional QA Engineer if you define quality strategy, quality processes and the best practices in agile environments #jobs #recruitment #Wizeline you don't live on Guadalajara? no worries! we'll hire you on any Mexican City
Apply here:
https://grnh.se/4e2dd99e1us
Collecting Java Flight Recording (JFR) on openjdk
Tags: jfr, openjdk, azul
Published: 2021-06-07 23:26:17

From OpenJDK 8u262￼ has JFR support as its backported with￼ - JDK-8223147: JFR Backport.

Following is just in case if you want to use JFR on openjdk (possible through azul). We just azul opnjdk and it works on my lab instance for collecting JFR. In case in future if anyone wants to use all steps.

With openjdk JFR `compress=true` don’t work but `settings=profile` does work.

Java Mission Control from oracle was not able to read the file but you can use zulu zmc .

To download azul OSS jdk

https://www.azul.com/downloads/zulu-community/?architecture=x86-64-bit&package=jdk

As my default JMC did not work with .jfr generated by zing jdk I used following.

https://www.azul.com/products/zulu-mission-control/

* Unlock commercial features.

```
sudo -u <user> jcmd <pid>  VM.unlock_commercial_features
```

* Start JFR collection with ```settings=profile```

```
sudo -u <user> jcmd <PID> JFR.start name=<jfr_name> settings=profile
```
* Dump JFR

```
sudo -u <user> jcmd <PID> JFR.dump name=<jfr_name> filename=/tmp/`hostname -i`.jfr
```

* Make sure JFR file is generated.

```
ls -lrt /tmp/`hostname -i`.jfr
```
* Stop JFR process

```
sudo -u <user> /usr/lib/jvm/java-1.8.0-openjdk/bin/jcmd  <PID> JFR.stop name=<jfr_name>
```

* Check if any additional JFR process are runing and stop if its not in use

```
sudo -u <user> jcmd <PID> JFR.check
```
Using Dot Notation to Access the Properties of an Object
Tags: javascript, devops, tutorial, beginners
Published: 2021-06-07 23:26:05

* The last challenge created an object with various properties. Now you'll see how to access the values of those properties.
 
* Here's an example:
```
let dog = {
  name: "Anakin",
  numLegs: 4
};
console.log(dog.name); // would print the value Anakin
console.log(dog.name); // would print the value 4
```
* Dot notation is used on the object name, dog, followed by the name of the property, name, to access the value of Anakin.
Create a Basic JavaScript Object
Tags: javascript, devops, tutorial, beginners
Published: 2021-06-07 23:23:32

* Think about things people see every day, like cars, shops, and birds. These are all objects: tangible things people can observe and interact with.

* What are some qualities of these objects? A car has wheels. Shops sell items. Birds have wings. These qualities, or properties, define what makes up an object. Note that similar objects share the same properties, but may have different values for those properties. For example, all cars have wheels, but not all cars have the same number of wheels.

* Here's an example using these concepts to create a dog object:
```
let dog = {
  name: "Anakin",
  numLegs: 4
};
```
* This `dog` object has two property/value pairs: a `name` of `Anakin` and a `numLegs` of `4`.
Importing from Rmarkdown
Published: 2021-06-07 23:21:37

## Mixed model ANOVA
Very straightforward. 

    #load packages
    library(tidyverse)

    ## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──

    ## ✓ ggplot2 3.3.3     ✓ purrr   0.3.4
    ## ✓ tibble  3.1.2     ✓ dplyr   1.0.6
    ## ✓ tidyr   1.1.3     ✓ stringr 1.4.0
    ## ✓ readr   1.4.0     ✓ forcats 0.5.1

    ## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
    ## x dplyr::filter() masks stats::filter()
    ## x dplyr::lag()    masks stats::lag()

    library(lme4)

    ## Loading required package: Matrix

    ## 
    ## Attaching package: 'Matrix'

    ## The following objects are masked from 'package:tidyr':
    ## 
    ##     expand, pack, unpack

    flum <- read_csv("http://rstats4ag.org/data/FlumiBeans.csv")

    ## 
    ## ── Column specification ────────────────────────────────────────────────────────
    ## cols(
    ##   year = col_double(),
    ##   treatment = col_character(),
    ##   block = col_double(),
    ##   population.4wk = col_double()
    ## )

    head(flum)

    ## # A tibble: 6 x 4
    ##    year treatment                 block population.4wk
    ##   <dbl> <chr>                     <dbl>          <dbl>
    ## 1  2009 Nontreated                    1          55757
    ## 2  2009 Nontreated                    2          45302
    ## 3  2009 Nontreated                    3          38333
    ## 4  2009 flumioxazin + trifluralin     1          13939
    ## 5  2009 flumioxazin + trifluralin     2          27878
    ## 6  2009 flumioxazin + trifluralin     3          31363

    str(flum)

    ## spec_tbl_df [77 × 4] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
    ##  $ year          : num [1:77] 2009 2009 2009 2009 2009 ...
    ##  $ treatment     : chr [1:77] "Nontreated" "Nontreated" "Nontreated" "flumioxazin + trifluralin" ...
    ##  $ block         : num [1:77] 1 2 3 1 2 3 1 2 3 1 ...
    ##  $ population.4wk: num [1:77] 55757 45302 38333 13939 27878 ...
    ##  - attr(*, "spec")=
    ##   .. cols(
    ##   ..   year = col_double(),
    ##   ..   treatment = col_character(),
    ##   ..   block = col_double(),
    ##   ..   population.4wk = col_double()
    ##   .. )

    flum <- flum %>%
      mutate(yrblock = with(flum, factor(year):factor(block)))
    head(flum)

    ## # A tibble: 6 x 5
    ##    year treatment                 block population.4wk yrblock
    ##   <dbl> <chr>                     <dbl>          <dbl> <fct>  
    ## 1  2009 Nontreated                    1          55757 2009:1 
    ## 2  2009 Nontreated                    2          45302 2009:2 
    ## 3  2009 Nontreated                    3          38333 2009:3 
    ## 4  2009 flumioxazin + trifluralin     1          13939 2009:1 
    ## 5  2009 flumioxazin + trifluralin     2          27878 2009:2 
    ## 6  2009 flumioxazin + trifluralin     3          31363 2009:3
Exact path in react-router
Tags: webdev, react, womenintech, reactrouter
Published: 2021-06-07 23:19:52

When I was using *react router* for the first time I used *path* instead of *exact path* as props in <Route> component.
``` javascript
<Router>
  <Switch>
          <Route exact path="/">
            <Home />
          </Route>
          <Route path="/about">
            <About />
          </Route>
          <Route path="/dashboard">
            <Dashboard />
          </Route>
        </Switch>
      </div>
    </Router>
```
In the above code when one replaces *exact path* to *path* it will match every path starting with '/', since the <Route> is inside the <Switch> so, it will match the first path and don't check for the other matches.
The above code after removing *exact* from the <Route> will always show <Home/> component and ignore <Dashboard/> or <About/>.

If one doesn't want to use *exact path* then the below code will work
``` javascript
<Router>
  <Switch>
     <Route path="/about">
            <About />
          </Route>
          <Route path="/dashboard">
            <Dashboard />
          </Route>
         <Route path="/">
            <Home />
          </Route>
        </Switch>
      </div>
    </Router>
```
Hugo Custom Info Boxes
Tags: hugo, custom
Published: 2021-06-07 23:04:15

The other day I got my regular summary from **GoHugo** a [discourse](https://discourse.gohugo.io) site where I am a member. This lead me to an interesting blog, which then lead me to an article on how to add *custom info boxes* to your site if it is not provided by your theme.

### links

- [Hugo Custom Info Boxes](https://roneo.org/en/hugo-custom-warning-infoboxes/)
  - Within this post you will find the instructions to add info boxes.
- [Hugo Module for Info Notices](https://github.com/martignoni/hugo-notice)

**Note**:
Some of the links no longer appear to work. Or have expired certificates.

I also had to add the following to my `config.toml` file. For either of the solutions to work.  

```toml
[markup.goldmark.renderer]
  unsafe = true
```

Anyway. I thought I would share this in case anyone else was looking for similar.
Javascript Project
Published: 2021-06-07 20:24:56

The end of May marks the end of Phase Four for my cohort and the beginning of a new project. This time I had to create a single page application using Javascript and Ruby. On my backend which was all in Ruby, I created an API that had information of my two models: orchestras and instruments. I set up their has_many-belongs_to relationship and created some seed data that would show up on the page. Once I finished all my backend code, I began working on the nitty gritty which was the frontend, where all the Javascript had to be written. 

The idea of my project was to show the names of the orchestras on the page and give users the option to create a new orchestra or edit the name of an already existing orchestra. I also wanted to give users the option to show the instruments of a particular orchestra. So I began by creating functions that had fetch requests to obtain the API info from my backend to be able to do CRUD functions all on one index file. After doing all that, I realized I had to do OOJ (Object Oriented Javascript), so I created a new file where I'd be able to handle all my fetch requests under one class, which I named OrchestraAdapter. 

After creating a file that handled my fetch requests, I created a file that handled my orchestras. I created an Orchestra class with a constructor that had its name and instrument attributes. Within that class I also created methods that would render its instruments and an addToDOM method. Similarly, I made an Instrument class with a constructor containing all of an instruments attributes (name, family, quantity). Creating all these files made my code look less cluttered because of the separation of concerns. 

I was having a lot of trouble trying to understand how certain JS methods worked, like innerHTML and innerTEXT, as well as the difference between using a regular function and an arrow function. As I kept working on my project, these methods became clearer and made my understanding on JS much better.
Day 382 : Talk About It
Tags: hiphop, code, coding, lifelongdev
Published: 2021-06-07 22:17:14

_liner notes_:
- Saturday : Had a really good day. Finally figured out what was happening with the push notifications firing twice and not being able to click to go to a website. Saw a GitHub issue and someone mentioning that the documentation was that clear. So I got everything working in time for the radio show. Got to surprise my co-host with a song that I had some artists make for his birthday. His reaction was awesome even though I couldn't see his face. And as a bonus, a listener also made a song for his birthday. It was a really great show! The recording of this week's show is at https://kNOwBETTERHIPHOP.com

![Radio show episode image of a photoshopped picture of Ice Cube holding a weapon in front of a Tesla Motors trailer and the words Jacked it for Beet with the words June 5th 2021 The Gift](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qsbaiic2sx3ze3cfok6b.jpg)

- Sunday : Spent the day doing laundry and working on my side project. I got all the URLs pointing to the projects. Refactored my push notification code to be able to change more variables from the dashboard. Created a bunch of graphics for icons and images for the project. Got quite a bit done! Glad I pushed the start date back a couple of weeks. Then I watched "Fear the Walking Dead" and "Gangs of London". Both of those episodes were wild! 

- Professional : Had a couple of meetings. Took a compliance training. Gave some feedback on an API. Spent the rest of the day helping out with a question in the Community channel.

- Personal : So I've got the homepage, dashboard and notification section of my side project deployed and linked to URLs. Going to start working on the biggest part which is the section that people go to when the event is live. A lot of moving parts. Good thing is that I worked on small parts as experiments and did similar things in other side projects. Just about putting it all together and controlling the segments from the dashboard. Just remembered that I still have to work on the broadcasting portion. That will also be a large part.

![View from a log on the shore of a lake surrounded by a pine tree forest with a large mountain in the background with some snow at its base at Rawson Lake, AB, Canada](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cdmumfl8l4jnq1u5ptto.jpg)

Going to start working on the live portion of the side project. It's basically different work spaces (that's how I'm thinking of it.) that gets changed from the dashboard I built earlier. So going to lay out the different components each will need. Once I get that working, there's the broadcasting the live video functionality I'll need to work on. Going to work on the project a couple of more days before I start to talk about it.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube gC4t39f0URI %}
Importing from google colab
Published: 2021-06-07 21:56:52



```python
import pandas as pd
import matplotlib.pyplot as plt
```


```python
x = [1,2,3,4,5]
y = [4,5,6,7,8]
xydata = pd.DataFrame({"x": x,
                       "y" : y})
xydata.head()
```




<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>x</th>
      <th>y</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>1</td>
      <td>4</td>
    </tr>
    <tr>
      <th>1</th>
      <td>2</td>
      <td>5</td>
    </tr>
    <tr>
      <th>2</th>
      <td>3</td>
      <td>6</td>
    </tr>
    <tr>
      <th>3</th>
      <td>4</td>
      <td>7</td>
    </tr>
    <tr>
      <th>4</th>
      <td>5</td>
      <td>8</td>
    </tr>
  </tbody>
</table>
</div>




```python
%matplotlib inline
plt.plot(x,y)
plt.scatter(x,y)
plt.title("X and Y plotted")
```




    Text(0.5, 1.0, 'X and Y plotted')




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

## The Goal
Goal of this analysis is to develop a machine learning pathway for identification of the best classifying scheme.
Self Taught Programmer [6.7.2021, post.2]
Tags: devjournal
Published: 2021-06-07 21:28:00

Rushing through the learning process is not going to save you time in the long run; you need to master the fundamentals before mastering the next abstraction. I was trying to rush through the learning process. This week’s post is more focused on the mental approach trying to learn while having a full-time job. It’s tough. Debating returning to school for a CS degree while self teaching, already graduated from college with an unrelated degree. Going back and forth on the pros and cons of returning to school for a CS degree.

Something that I was originally doing for a long time was watching a tutorial without typing the code. Seems self explanatory but at least for me, refrain from even copy and pasting. Type it all out. 

Also, console.log every single function (on freeCodeCamp). Mess around with the code and build on every example. Not only will it help you debug your code, but I found it was helpful thinking about the result and what you are passing into the function. There’s 111 on the first JavaScript section, don’t fly through it. 

Another post I’ve found helpful about returning to difficult questions and memorizing how to complete them: learning how to learn, the power of recalling and spaced repetition. Eat up the hard questions.

I’ve been learning by starting with FCC – moving to Edabit for JavaScript practice and then W3 schools for HTML / CSS practice. Like I said earlier I felt I was moving too quickly through HTML / CSS. Going to continue to do these practice examples as I move to different certs to make sure I am not forgetting.

Workflow so far has been: 
-	FCC course with videos explaining complex sections. Even if I understand it I'll watch the videos. This helps me memorize topics; you can hear the way he verbalizes how he approaches the solution, writing the code and logging to the console. 
-	W3 school to practice HTML / CSS 
-	Edabit to practice JavaScript 
-	During the day when slow at work, watching the CS50 course via EDX. Instructor is phenomenal