teleren/devto huggingface dataset:
Unit testing using JUNIT
Tags: junit, testing, java, maven
Published: 2021-11-12 21:41:59

As a weekly course work, I added JUNIT testing framework into my ssg application. 

### Adding framework

Junit is a most popular testing framework that is being used for Java developers. 
I was able to add Junit API and frameworks using maven dependencies and it was very quick and easy. 
After add the dependencies, I was able to create test class from the class that I want to test. 

### About Unit testing

It was my first time creating testing methods for unit tests.
Unit tests are created based on assert methods that are comparing the expected value and actual value. 

### Wrote first unit test for the simplest method

Below is my first unit testing method, which was to test the function for converting the filename from array of strings to a string. 

```java
void testFileNameReader() {
        String[] fileName1 = {"example", "file", "name.txt"};
        assertEquals("example file name.txt",HTMLBuilder.fileNameReader(fileName1));

        String[] fileName2 = {"sample.md"};
        assertEquals("sample.md",HTMLBuilder.fileNameReader(fileName2));
    }
```

### Core unit testing

As one of the core unit testing, I chose a method in "HTMLBuilder.java" which is created to parse text or md file and write a html file, which was created at the beginning of the project. 
To create a unit testing, I had to create a mock sample file to compare which contain the content that is expected to be created. 
I used a text file for the comparison and used a method "assertTrue". 
Since the compared object is a file, it was easier with using FileUtils library and compare the two files. 

### CONTRIBUTING.md

For contributors, I updated the documentation for the testings, explaining how it works and how to use it. 
In that case, it would be easier to review and merge codes for me, and easier for the contributors to find out any bugs or improvements from the code. 


You can click [here](https://github.com/irenejoeunpark/ssgApplication/commit/cb9a626175fc794451de6f73ab8dd8283dc2a019) to see the changes I made through multiple commits.
Day 57-58/100 Regular Expressions
Tags: 100daysofcode, programming, challenge, motivation
Published: 2021-11-12 21:10:15

"Some people, when confronted with a problem, think ‘I know, I’ll use regular expressions.’ Now they have two problems."

– Jamie Zawinski

![expression](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0neykw0du63626tnreoy.png)
The 3 most interesting C++ posts of October 2021
Tags: bestofdev, cpp
Published: 2021-11-12 20:59:11

Let me share with you 3 interesting [#cpp](https://dev.to/t/cpp) posts from October. I know, it's the middle of November. I've been on vacation, then this week there was [Meeting C++](https://meetingcpp.com/) so I had little time.

As I wrote during the earlier months, I don't take the most popular articles anymore, because I find that while some articles do meet the criteria to add #cpp as a tag, but they are not mostly about C++. So there is a bit of subjectivity to this list. I also try not to include multiple articles from the same author and I don't include the wrap-up of the previous month either ;)

Feel free to share your favourite one in the comments.

***
[Ashish](https://dev.to/aboss123) wrote many popular posts in October, I picked the one that explains the difference between implicit and explicit constructors. Keep up the good work!

{% link https://dev.to/aboss123/c-programming-implicit-and-explicit-constructors-27be %}

***

[Elvis](https://dev.to/elvisoric) picked an interesting topic about lambdas. He answered the question that you probably wouldn't even have thought about; how to inherit from them?

{% link https://dev.to/elvisoric/inheriting-from-lambdas-5cac %}

***

Last but not least, [Ben](https://dev.to/deciduously) shared a very interesting article on creating a compiled binary, using source code hosted on GitHub, for other people to include in their environments.

{% link https://dev.to/deciduously/workstation-management-with-nix-flakes-build-a-cmake-c-package-21lp %}

Happy coding!

## Connect deeper

If you liked this article, please 
- hit on the like button,  
- [subscribe to my newsletter](http://eepurl.com/gvcv1j) 
- and let's connect on [Twitter](https://twitter.com/SandorDargo)!
The whales still swallow whole in web3.
Tags: web3
Published: 2021-11-12 20:40:38

![a whale swallows the words "Dang! The party lost this auction :("](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sk0u2qi3nx5hw620x3ky.png)

The dream of collectivism can be buried by megawealth in 30 seconds or less, a lesson learned for the WTF-are-you-kidding-me price of two-way gas fees.

I joined [PartyBid](https://www.partybid.app/) (a PartyDAO production) to bid on Matthew Ball’s Original [Metaverse Essay](https://www.matthewball.vc/all/themetaverse) NFT, listed on the [FWB Gallery](https://gallery.fwb.help/matthew-ball-metaverse-essay).

Collective ownership of Ball's foundational essay seemed completely right for this time and place. More significant, however, was the influence that ownership confers:

> Contributors will receive tokens proportional to the amount of your ETH used in the winning bid. If the party loses the bid, or not all of your ETH is used to win the NFT, you will be able to claim the remaining unused funds from your bid.

Predictably, however, a whale swallowed us whole (I get that this isn't a thing in nature) for 100 ETH.

As long as money is involved, money will win. The promised trickle-down economy predictably became the gush-the-fuck-upward economy, ensuring a gaggle of fresh and generational billionaires.

What did I learn? That it feels fantastic to be a part of a collective striving for a goal, and that’s why many of us are in the Web3 arena at this particularly pivotal moment in human history. That you have to pay gas to reclaim your ETH after losing, a familiar pattern of financially punishing the masses for not coming out on top. And .. this is the most important thing … that I’m confident that our global Web3 community, as a whole, can work to close some of the gaping loopholes enjoyed by megawealth at the expense of nearly everyone else. The pull towards meritocracy and collectivism is a valid survival instinct.

No regrets. It’s a wild ride, it’s going to be a wild ride. That’s why we’re here.
"La IA y la Transformación de la Tecnología: ¿Qué nos deparará el futuro?"
Tags: ia, gpt3
Published: 2021-11-12 20:22:04

La Inteligencia Artificial (IA) está transformando la tecnología y el mundo a un ritmo acelerado. Desde la automatización de tareas repetitivas hasta la mejora de la eficiencia en la industria, la IA está revolucionando la forma en que vivimos y trabajamos.

Es por ello que es un honor poder escribir este artículo, ya que a través de la tecnología de IA de OpenAI, he sido entrenado para componer textos de manera autónoma y brindar información precisa y actualizada sobre temas tecnológicos.

La IA se está utilizando en una amplia variedad de aplicaciones, desde la medicina hasta el entretenimiento. En el sector médico, la IA está siendo utilizada para analizar grandes cantidades de datos médicos y ayudar a los profesionales de la salud a tomar decisiones informadas y precisas. En el entretenimiento, la IA está siendo utilizada para crear experiencias más personalizadas y entretenidas para los usuarios.

Pero la IA también está transformando la forma en que hacemos negocios. La automatización de procesos empresariales a través de la IA está permitiendo a las empresas ser más eficientes y reducir los costos. Además, la IA también está ayudando a las empresas a tomar decisiones informadas y a mejorar la experiencia del cliente.

Sin embargo, con la transformación que la IA está causando en la tecnología, también surgen preocupaciones sobre la privacidad y la seguridad de los datos. Es importante que las empresas y los desarrolladores de IA trabajen juntos para garantizar que los datos se utilicen de manera ética y se protejan adecuadamente.

El futuro de la IA es incierto, pero lo que es seguro es que seguirá transformando la tecnología y el mundo en general. Desde la automatización de tareas hasta la mejora de la eficiencia en la industria, la IA promete mejorar nuestras vidas y transformar la forma en que hacemos negocios.

En conclusión, la IA es una tecnología que está transformando la forma en que vivimos y trabajamos. A medida que la IA continúa evolucionando, es importante que trabajemos juntos para garantizar que se utilice de manera ética y que se protejan adecuadamente los datos. Este artículo fue escrito por una IA.
Seeding Postgres with Docker
Tags: docker, postgres, productivity
Published: 2021-11-12 19:50:19


Seeding postgres container during local development can be bit cumbersome, at least during the initial setup. Usually, we connect to the container and execute the seed script.

But now, let's see how we can automate that by using `docker-entrypoint-initdb.d`, which runs all the `*.sh` or `*.sql` scripts on initialization. 

**Setup**

Let's assume we have this folder structure:

```
├── Dockerfile
├── docker-compose.yml
└── scripts
    └── db
        ├── dump.sql
        └── init.sh
```

Here, `dump.sql` can be sql script that we want to seed the db with

```sql
-- CreateTable
CREATE TABLE IF NOT EXISTS users (
  "id" TEXT NOT NULL,
  "name" TEXT NOT NULL,
  "email" TEXT NOT NULL,

  PRIMARY KEY ("id")
);

-- Seed
INSERT INTO users (id, name, email) VALUES ('userid', 'Gopher', 'hello@gopher.com');
```

In the `init.sh`, we will just execute our `*.sql` script.

```sh
#!/bin/bash

psql -U $POSTGRES_USER -d $POSTGRES_DB -a -f /app/scripts/db/dump.sql
```

In the `Dockerfile`, we will copy our `init.sh` to `docker-entrypoint-initdb.d` directory.

```dockerfile
FROM postgres:12 as db
WORKDIR /app
COPY ./scripts/db/init.sh /docker-entrypoint-initdb.d
COPY ./scripts/db/dump.sql ./scripts/db/dump.sql
```

We will define our `docker-compose.yml` like below:

```yml
version: "3.8"

services:
  db:
    image: db
    container_name: db
    build:
      context: .
      target: db
    environment:
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=password
      - POSTGRES_DB=database
    ports:
      - 5432:5432
```

Let's start our containers!

```
$ docker compose up
```

**Output**

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

**Conclusion**

I hope this was helpful, feel free to reach out to me on [twitter](https://twitter.com/karan_6864) if you face any issues. Thanks for reading!
VSCode + Terraform Provider Development: Setup Debugging
Tags: terraform, aws, development, debugging
Published: 2021-11-12 19:43:52

---
title: VSCode + Terraform Provider Development: Setup Debugging
published: true
description: How to setup debugging in VSCode for when developing to the AWS Terraform Provider
tags: #terraform #aws #development #debugging
//cover_image: https://direct_url_to_image.jpg
---

_Edit May 2022: This guide now reflects allowing resolution of the service via relative file paths. Previously you had to specify the service via environment variable `PKG_NAME=<specific aws service>`, now instead you set `"env": {"PKG_NAME": "${relativeFileDirname}"}` in `launch.json` and the service is automagically resolved. Thanks to @gdavison for solving this!_ 

To setup debugging while writing to the AWS Terraform Provider, create a `.vscode` dir in the root of your clone `terraform-provider-aws` local repo then create a `launch.json` & `private.env` inside that `.vscode` directory.

## Setup
```
$ git clone git@github.com:hashicorp/terraform-provider-aws.git
$ mkdir terraform-provider-aws/.vscode
```

### Create launch.json
```
$ cat << 'EOF' > terraform-provider-aws/.vscode/launch.json
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch a test function",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${fileDirname}",
            "env": {"PKG_NAME": "${relativeFileDirname}"}, 
            "args": [
                "-test.v",
                "-test.run",
                "^${selectedText}$"
            ],
            "showLog": true,
            "envFile": "${workspaceFolder}/.vscode/private.env"
        }
    ]
}
EOF
```

### Create private.env
```
$ cat << 'EOF' > terraform-provider-aws/.vscode/private.env
TF_ACC=1
TF_LOG=INFO
GOFLAGS='-mod=readonly'
EOF
```

## Usage

Reload VSCode and source a profile for terraform's acc tests to use. You can do this by either opening vscode from a terminal with a profile set or by using [the AWS Toolkit](https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.aws-toolkit-vscode).

Set break-points in your `<resource_name>.go` file, highlight the test you want to run and click the green "play" button in VSCode debug panel (top left). _Note: if you click any other play buttons, it may not work. It must be the debug pane play button that says "launch a function"._ 

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

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



If you found this helpful, please leave me a like :D It helps with many algorithms including my self esteem calculation
New MuPDF App Kits deliver fast, easy, and affordable PDF functionality to Android and iOS developers 
Tags: android, ios, swift, kotlin
Published: 2021-11-12 19:27:21

Artifex Software, Inc., a leading provider of PDF technology solutions, is pleased to announce we have expanded the MuPDF family of products with the development of MuPDF App Kits. These easy-to-implement SDKs were explicitly designed for Android and iOS mobile application developers. Artifex technologies provide essential tools to major print manufacturers, SaaS and Cloud developers, PDF tools/creation companies, and software developers.

The new MuPDF Android and iOS App Kits make it easier and more affordable than ever to integrate PDF functionality into your mobile app projects. With only a few lines of code, application developers can enable powerful PDF features, including view, annotate, sign, fill, redact, and more. 

Built from our highly regarded MuPDF API, the App Kits offer the power of our proven technology in easy-to-integrate SDKs, allowing you to get your product to market faster. In addition, MuPDFs high-performance technology is fast and precise, and its small footprint will not bloat your application.

MuPDF App Kits support many PDF features, including:

- Annotations: The customizable annotations include drawing, comments, highlighting, and more.
- PDF Form Filling: MuPDF App Kits support form fields such as text fields, checkboxes, combo, and list boxes.
- Digital Signatures: MuPDF App Kits support digital signatures and e-signatures, allowing your users to verify and digitally sign PDF documents securely.
- PDF Redactions: Securely and permanently remove sensitive, confidential, or privileged information from PDF documents. Quickly redact text, images, and links.
- Hyperlinks: Enable fast and easy navigation through your publications and more with internal and external link support.
- Default or Custom UI options: The default UI includes a user interface for typical document features and actions. The Custom UI alternative allows complete control over the look and functionality of your applications.

With multi-format support, integrated security features, and detailed documentation, the MuPDF App Kits at just $749 per app per platform will help you get your app to market quickly and affordably.

More information can be found on our [website] (https://artifex.com/products/mupdf/appkit/).
Note Taking 101
Tags: beginners, programming, motivation, todayilearned
Published: 2021-11-12 19:11:33

While going through Flatiron's Pre-Work and part of Phase 1, I've been taking notes in a Moleskine. While it's my favorite way to retain information (I learn well by writing things down in my own handwriting) it definitely leaves much to be desired. Writing out JS by hand is a pain if you're trying to show yourself examples of the concept you're studying. It takes up a lot of paper very quickly with how many lines it takes up, and the hand cramps!

I've started to experiment with different ways to take notes while going through class. My newest method will be to keep notes organized in .js files that give examples of how different functions work. The latest concept I've gone over are Arrow Functions, so I built a file that shows progression from a regular function to a function expression then to an arrow function. It came in handy while doing my lab work, so I will likely continue this to see if it is helpful with more complex concepts.

Long term I'm hoping it will be a go-to resource of my own notes and code examples so that when I come across these concepts later on I have a file that I can go to if I'm having trouble.
The Ideal App
Published: 2021-11-05 18:25:08

If I were able to build an app that would solve a prominent problem in society, it would be an app that tracks the actions and behaviors of the user to identify aspects of their life that need to be improved or eliminated in order for them to function at the highest possible capacity. For example, vaping. The app would track not only the money spent on vaping products coming out of the user’s bank account, but the damage it does to their physical health and create a profile to classify the significance the action has on their overall well-being. Actions that have an extreme adverse effect on the user will be blocked (through blacklisting vendors and disabling nicotine devices), the only way to disable the block being through unsubscribing to the service or receiving a medical clearance from a doctor to continue the activity in question. I witness so many young people developing habits that will unknowingly affect them for the rest of their lives, and as someone who greatly values my health and well-being, I would go to great lengths to prevent it from happening to more people in the future. In addition - the app would provide a large emphasis on the user being incentivized to pursue new hobbies and explore their interests. I find it very common for people to live sedentary lives and engage in recreational activities that are also sedentary, such as watching TV, playing video games and other non-physical activities which I feel must be limited to a very, very small portion of one’s daily routine. One of my favorite quotes of all time is by Socrates, in which he states “No man has the right to be an amateur in the matter of physical training. It is a shame for a man to grow old without seeing the beauty and strength of which his body is capable.” I find this to be especially true today - far more than in the past, and I strongly believe that no human will ever be able to feel at their best without some degree of physical exertion and struggle in their lives. Struggle is a necessary part of the human psyche, both physically and mentally, and avoiding it will only make one weaker throughout the progression of their lives. The app would target people of all shapes, sizes and age groups that genuinely want to improve themselves overall and would most likely require an external accessory such as a bracelet to closely monitor the activities of the user. The information would be encrypted - data stored on the blockchain to maintain confidentiality, collected on an individual basis, and would be used only on the app, not to be sold to other companies and advertising agencies to sell products for money. Helping the people around me better themselves and become better every day has always been one of my greatest passions, and I hope that one day I will be able to create something that is powerful enough to positively influence people the way that apps negatively influence people today. This is what motivates me.
Typescript Support For Cypress
Tags: javascript, cypress, e2e, typescript
Published: 2021-11-12 17:58:18

For someone who has worked with Typescript for the past 5+ years, I really miss it when it's not there. I find adding types to my javascript code a nice comfort. Writing automated tests with Cypress is no exception. With that being said, adding Typescript support to your Cypress applications is easy peasy!

## Getting Started
Cypress ships with [official type declarations](https://github.com/cypress-io/cypress/tree/develop/cli/types) for [TypeScript](https://www.typescriptlang.org/). This allows you to write your tests in TypeScript. The first thing we need to do is install the `typescript` dependency.

```bash
yarn add --dev typescript
```

Next we need to update our `tsconfig.json` file with the following configuration:

```json
{
  "compilerOptions": {
    "target": "es5",
    "lib": ["es5", "dom"],
    "types": ["cypress"]
  },
  "include": ["**/*.ts"]
}
```

Finally we need to rename all of our `.spec.js` integration files to `.spec.ts`. 

## Custom Commands
If you are like me you've found the path to this point super simple! However, if your application is using [Cypress's Custom Commands API](https://docs.cypress.io/api/cypress-api/custom-commands) your Cypress application is now angry.

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

Don't worry this is easy to fix! Let's open the file that contains our custom commands _(usually `support/commands.ts`)_. This file should contain all of your commands as well as a Cypress namespace with a Chainable Interface. It is in this Interface we will add a reference to our custom command(s).

```typescript
declare namespace Cypress {
  interface Chainable<Subject> {
    getBySel(selector: string): Chainable<Element>
  }
}

Cypress.Commands.add('getBySel', (selector: string, ...args: any[]): Cypress.CanReturnChainable => {
  return cy.get(`[data-test=${selector}]`, ...args)
})
```

And voilà our Cypress application is happy and now has full support for Typescript!

### More Resources
- [Our complete guide on adding Typescript support to your application](https://docs.cypress.io/guides/tooling/typescript-support#Install-TypeScript)
- [Typescript Support Doc](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Editor-Support)