teleren/devto huggingface dataset:
Number of Lines To Write String
Tags: javascript, leetcode
Published: 2022-09-18 04:09:26

```js
var numberOfLines = function (widths, s) {
  let dummyAlphabet = "abcdefghijklmnopqrstuvwxyz";
  let map = new Map();
  let maxCountInLine = 100;
  let rows = 0;

  for (let i = 0; i < dummyAlphabet.length; i++) {
    map.set(dummyAlphabet[i], widths[i]);
  }

  for (let i = 0; i < s.length; i++) {
    let char = s[i];
    let width = map.get(char);
    maxCountInLine = maxCountInLine - width;
    if (maxCountInLine === 0) {
      rows++;
      maxCountInLine = 100;
    } else if (maxCountInLine < 0) {
      rows++;
      maxCountInLine = 100;
      maxCountInLine = maxCountInLine - width;
    }
  }
  let nextLineUsed = 100 - maxCountInLine;
  let fRows = nextLineUsed > 0 ? rows + 1 : rows;
  return [fRows, nextLineUsed === 0 ? 100 : nextLineUsed];
};


```
AWS CodeArtifact Cheat Sheet
Tags: 30daysofaws, day10, certifieddeveloperassociate, codeartifact
Published: 2022-09-18 04:02:08


## About

AWS CodeArtifact is a fully managed artifact repository service that makes it easy for organizations of any size to securely store, publish, and share software packages used in their software development process.

- [Documentation](https://aws.amazon.com/codeartifact/)
- [User Guide](https://docs.aws.amazon.com/codeartifact/?id=docs_gateway)

![Amazon CodeArtifact Flow](https://d1.awsstatic.com/diagrams/CodeArtifact_HIW_Diagram.9640a3361d4c20f79fbca661ee00d6a0ea706316.png)

CodeAr­tifact is a secure storage, publishing, and sharing of software code packages used in a development process organisation's software development. CodeAr­tifact makes it easy for small organisations to store, publish, and share software packages.

CodeArtifact can be configured to automatically fetch software packages and dependencies from public artifact repositories.

CodeArtifact works with commonly used package managers and build tools like Maven, Gradle, npm, yarn, twine, pip, and NuGet making it easy to integrate into existing development workflows.

## Price

Pay only for what you use – the size of the artifacts stored, the number of requests made, and the amount of data transferred out of an AWS Region. CodeArtifact includes a monthly free tier for storage and requests

[Current price](https://aws.amazon.com/codeartifact/pricing/)

## Use Cases

Type: Developer Tools

### Alternatives

- JFrog Artifactory
- Docker hub
- Sonatype Nexus Platform
- Helm
- Azure DevOps Services
- Github

### Usage

```bash
$ aws codeartifact list-domains --region us-east-1
```

## Practice

[Getting started using the console](https://docs.aws.amazon.com/codeartifact/latest/ug/getting-started-console.html)

> - [Questions](https://dev.to/romankurnovskii/aws-ec2-top-
questions-certified-developer-exam-27oo)
Accentable Pill Check/Radio Buttons
Tags: react, webdev, html, css
Published: 2022-09-18 03:57:10

I needed some neat way to advertise that certain filtering buttons would yield data in a particular state.  The requirement was that all possible filters needed to be displayed all the time, and that the presence of this particular data state needed to be immediately visible.

This is what I came up with:
![Accentable Pill Buttons](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x0rxva7zwov2q14hhl5d.png)

The various states, in order, are:

1. Normal
2. Accented.
3. Selected.
4. Selected accented.
5. Disabled.

If you would like to use them, I created a quick [Gist](https://gist.github.com/webJose/221fdba1242549bceb685108f1de033e) demonstrating these (and of course the necessary CSS is there).
How to Speed Up WordPress Website
Tags: wordpress, tutorial
Published: 2022-09-18 02:06:58

Speed is an essential part of the Page Experience Ranking Signal, your WordPress Website simply needs to load faster if you wish to get more SEO Traffic from Higher Rankings. 

Before you go through the steps that I'm about to show you, you can use Pagespeed Insights to check the speed of your WordPress Website and then compare it to your site's speed after the optimization process.

If you noticed any improvement, do well to tell us in the comments so others now that this works.  

Let's Take a look at How you can Speed Up your WordPress Website:

1. Compress and Convert Images to Next Gen Formats (WebP or AVIF) using the [Converter for Media WordPress Plugin](https://wordpress.org/plugins/webp-converter-for-media/). 

2. Enable Page Cache using [Cache Plugins](https://ebukaval.com/2022/04/27/best-and-free-wordpress-cache-plugins-to-speed-up-your-website-top-10/) (preferrably WP Rocket), you don't need this if you already use Ezoic Leap and the Ezoic Caching App. 

3. Switch to a Good Hosting with fast server like [Hostinger](https://ebukaval.com/go/hostinger-impact/), if you understand the whole process of a loading a URL in a browser, you'll understand the need for a fast server.

4. Use a Content Delivery Network (mostly prefer CloudFlare), A CDN typically stores a static version of your Website on servers all over the world, so whenever a user visits, your content on the server nearest to him or her will be displayed.
 
After implementing all these Speed optimization steps on your WordPress Website, did your site's speed improve? Let me know in the comments. 

**Copyright Disclaimer**: This content on How to Speed up WordPress Website was originally appeared on [ebukaval.com](https://ebukaval.com/2022/05/04/how-to-speed-up-your-wordpress-website-easily-in-2022/) and was written by [Ebuka Val](https://ebukaval.com).
SSGo - a Static Site Generator built with Go
Tags: opensource, ssg, go
Published: 2022-09-18 01:42:04

Yeah... I know, the name isn't that creative, but this is actually a new project I just published on GitHub! Come check it out at https://github.com/devils2ndself/SSGo

### So... what does it actually do?

SSGo is a simple Static Site Generator (SSG) that can turn .txt files into proper and styled HTML files. You can either pass a single .txt file or a path to a folder, where SSGo will search and turn every .txt file into HTML.

You can find setup and usage instructions in the GitHub repository :)

## Usage

- `ssgo --input [in] --output [out[` - Generate HTML from .txt file at `in` path (can be a single .txt file or directory) to `out` path.  
`--output` is optional, default out is `dist` folder in current directory

- `ssgo --version` - Display installed version of SSGo

- `ssgo --help` - Display detailed help message

Please note, that if built locally, some users will need to use `./ssgo` instead of `ssgo`.

## Features

- Generates HTML files for each .txt file in `input`.

- Encloses every paragraph of text separated by a blank line in `<p>` tag.

- If the first line of the .txt file is followed by 2 empty lines, it will be used as a title. The `<title>` will be assigned to it and it will be enclosed into `<h1>` tag instead of regular `<p>` - _optinal feature #1_.

- The name of the generated HTML files will be the same as the original .txt files.

- Also provides a cool style to generated HTML - _optinal feature #6_.

- Generated files go to `dist` folder unless any other path is specified with `--output` flag. If the new output path does not exist, it will create a new directory to accomodate - _optinal feature #2_.

- If output directory is `path`, each time new text is used for HTML generation, the directory will be wiped completely. Careful, don't lose valuable files there!

- If `--output` is specified, the directory at path will not be erased like with `dist` folder. Just in case someone specifies `--output C:\`...
Program Architect
Published: 2022-09-18 01:26:18

Program architect serves as the chief technologist for the entire initiative. The individual filling this role is responsible for evaluating technologies and products, determining and enforcing standards, architecting the models to be used to exchange control and data among various components, and most everything else technology- and architecture-related. Even though the program manager does need to be technology- and architecture-savvy, the program architect – who reports to the program manager – is the “voice of authority” for all technology and architecture matters. Essentially, this individual serves as the CTO at the program level.
How to install MinGW on Windows (10, 11)?
Tags: cpp, c, programming
Published: 2022-09-18 01:20:06

1. First, let's access the official MinGW website:
[mingw.org](https://www.mingw-w64.org/)

2. Now let's go to the downloads tab, which is in the upper left corner:

![Home page of mingw.org.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m298409un0qnn3tehtjq.png)
3. On the download page choose option `MingW-W64-builds`:

![download page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mc5mix3mrbqfvdmu4ntm.png)

4. Now click the direct link to github: 

![download page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rbmlwt3mfy2vihg0kld5.png)

5. On the github page, choose the following option: `x86_64-12.2.0-release-posix-seh-rt_v10-rev0.7z`

![GitHub page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tj4ve82ck2cu8bymhcql.png)


Now you will download the file and unzip it using [winrar](https://www.win-rar.com/predownload.html?&L=9) (or any other file extraction tool).

After unzipping the file, go to the location where you unzipped it
and copy the path of the bin folder:

![folder path](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ebmu44k35ii2vglsr7jo.png)

That done, to windows settings -> system -> about -> advanced system settings.

Click environment variables -> system variables -> path -> edit -> new -> paste the bin folder path you copied earlier.

Okay, now open your terminal (`win` + `r`) and type `cmd` and type the following command  `g++ --version`, if everything went well, the g++ version will appear.
Web/React Project Contest
Tags: challenge, javascript, beginners, react
Published: 2022-09-18 01:08:31

Hey Community,

Win prizes worth **₹150,000**
We invite you all to the Web/React project competition: 

🏆**First 100 submissions win ₹1,000 each**🏆
🏆**Grand Prize ₹50,000**🏆

**Requirements:**

1. You have to use [Logify](https://logify.id) as login service in your project.
2. Project should be accessible online.

**Helpful resources:**

https://logify.id/articles/react-logify-basic
To know more, visit: https://logify.id/contest/

**Successful Submissions**
1. Gunvant Panchal - https://www.linkedin.com/posts/logify-id_react-logify-challenge-activity-6977397715521454080-hGmT/
5 Unusual Ways Bias Can Sneak into Your Models
Tags: ai, datascience, career, machinelearning
Published: 2022-09-18 00:58:22

These "Generally Good Practices" have their downsides.

We should be using more AI solutions by now. But there's this bias issue to consider!

We've seen AI models perform differently for underrepresented groups. These issues have been debated heavily in recent years. In search of why bias arises, we found that there are more ways than a human trainer's intention could cause bias.

Yet, when other people's lives and jobs are concerned, the innocence of a creator is not excused. Customer backlashes, public opinion, and badmouthing could harm your reputation, and it may be tough to recover from them.

Thus it's critical to understand AI bias. You can't manage something you don't understand.

[Here are five situations where bias can sneak into your models.](https://towardsdatascience.com/5-sources-of-bias-in-ai-ml-729acbec3215?sk=17e0674f35ef1c7aeda4a542ad90cd7a)
Sharing Leetcode Solution
Tags: python, leetcode
Published: 2022-09-18 00:34:28

After last week, I have hosted 5 sessions on solving leetcode together. A bunch of easy questions, 3 medium questions and 1 hard question. 
I learnt a lot during the sharing. There are basic concepts that I didn't fully understand but I start using. Sometimes I assumed my thoughts are fully explained while the reality is that those thoughts never get out of my head. My sharing sometimes only consider my understanding rather than take audiences' pace into consideration.
Most importantly, I realized the difficulty of explanation. If solving leetcode questions requires some understanding on the techniques needed for solution, then sharing and even teaching require understanding of the concepts to not only details but also one symbol. Questions could be from anywhere or about anything. I could still be able to adapt, sometimes I get prepared while other times I will look up the questions and test them out together with my friends.
I was suggested about an extension called LeetHub, which is useful not only that it help me upload my submission on leetcode to GitHub. But it also contains the problem description and all graphs. This makes things a lot better.
Next week I need to leave for a travel so I have to pause. Will continue when I get back. Ohh I should start video explanation which saves time (maybe).
[GitHub](https://github.com/yluo3421/Leetcode-Solutions
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iho3bbu0z95puote6zas.jpeg))
Simple Way to Print Array in Java
Tags: tutorial, beginners, programming, java
Published: 2022-09-18 00:09:27

Back in the days when I first learned arrays in the Java programming language, I was very impressed with the visualization of arrays on the internet like the following example...

![Visualization of an array](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pyk4eiw4r91zg08geode.png)

..so I want such array visualization to appear in my output to make it easier for me to debug if something goes wrong in my program.

Can you guess what I did?

Yes, I'm trying to print the object array as you can see in **_Source code 1_**.

**_Source code 1:_**
```java
int[] arr = {1, 2, 3, 4, 5};

System.out.println(arr);
```

Which will produce the following output...

**_Output 1:_**
```
[I@24d46ca6
```

Then I realized that if we try to print an object in Java, the memory location of the object will be printed.

---

Then I thought, I have to implement the code for my own array visualization to be able to achieve the result I want.

Therefore, I decided to implement the code as you can see in **_Source code 2_**.

**_Source code 2:_**
```java
int[] arr = {1, 2, 3, 4, 5};

System.out.print("[");
for (int i = 0; i < arr.length; i++) {
    if(i == arr.length-1)
        System.out.print(arr[i]);
    else
        System.out.print(arr[i] + ", ");
}
System.out.println("]");
```

It was a success, because my code was able to print the array as I wanted it to look like in Output 2.

**_Output 2:_**
```
[1, 2, 3, 4, 5]
```

---

After reading the documentation for the `Arrays` class in Java, I know that there is one method that can be used to print an array. The method is `.toString()`, and it takes one parameter as you can see in **_Syntax 1_**.

**_Syntax 1:_**
`public static String toString(int[] a)`
* `a` is the array.

**_Source code 3_** is the implementation of this method.

**_Source code 3:_**
```java
int[] arr = {1, 2, 3, 4, 5};

System.out.println(Arrays.toString(arr));
```
And with far fewer lines of code, the implementation of this method has the same result as **_Source code 2_**.

**_Output 3:_**
```
[1, 2, 3, 4, 5]
```

---

So, if you are trying to print an array with a good look, you can use the `toString()` method which comes from the `Arrays` class. And also a note, although in this article I use array of integers as the example, but this method can also take arguments with various datatypes such as `short`, `boolean`, etc.

---

Cover image:
https://i.picsum.photos/id/354/1920/720.jpg?hmac=WuwPQPiZ87_tIKjOq3jreJ3EtT-b-Mn4HpETLfusBv4

Other image:
https://www.kirupa.com/html5/images/shuffled_200.png
How can we trust automated tests in life-or-death scenarios?
Tags: qa, continuousdelivery, regressiontesting, testautomation
Published: 2022-09-19 19:59:14

---
title: How can we trust automated tests in life-or-death scenarios?
published: true
date: 2022-09-18 00:00:00 UTC
tags: qa,continuousdelivery,regressiontesting,testautomation
canonical_url: https://jhall.io/archive/2022/09/18/how-can-we-trust-automated-tests-in-life-or-death-scenarios/
---

One of the more frequent arguments I hear against automated testing, and by extension, [continuous delivery](https://jhall.io/glossary/#cde), is the idea that some problems are too important to trust to automated tests. Someone might die if a bug gets through. Or maybe billions of dollars would be lost.

Common examples are things like: firmware for pacemakers, self-driving cars, and Mars landers.

I guess this question seems reasonable on the face of it, because it comes up _all the time_.

But hidden within this question is the erroneous assumption that manual testing is more reliable than automated testing.

What makes it worse is that the assumption isn’t _always_ wrong. The problem lies in the fuzzy definition of “testing.” Some kinds of testing definitely do require an actual mind, which can reason about things, apply intuition, etc.

But that’s not the kind of testing we’re talking about when we discuss automated tests, or continuous delivery, is it? We’re talking about rote regression testing. “Run through these 10,000 scenarios, and make sure none of them behave in unexpected ways.”

This is exactly the sort of testing that humans are notoriously _bad_ at doing. And not only because they’re dreadfully slow, but also because they easily make mistakes. They also tend to get bored, and the better ones require salary increases every now and again.

Would you rather hop behind the… eh, wheel(?) of an autonomous vehicle that had the last software update tested automatically, by a computer that can examine 10,000 corner cases per second, or by a human sitting in the, er… driver’s(?) seat, trying to trigger unusual scenarios to ensure that the car behaves correctly?

When you stop to think about it, this common question “How can we trust automated tests in high-stakes scenarios?” is exactly backwards.

How can we possibly trust _manual tests_ in high-stakes scenarios?

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
hai myself is teddy , i am new here, i have a dobt while working on js, the webpage i created not working as i intended.
Tags: javascript, html, webdev
Published: 2022-09-17 23:13:03

1. `<!DOCTYPE>


`
2. <html>
3.     <head>
4.         <style>
5.             button {
6.                 font-size: 40px;
7.                 padding:10px;
8.                 border-radius: 10px;
9.                 margin: 20px;
10.             }
11. 
12.             #container {
13.                 text-align: center;
14.             }
15. 
16.             #btntwo{
17.                 text-align: center;
18.             }
19. 
20.             #fo-nt {
21.                 font-size: medium;
22.             }
23. 
24.         </style>
25.         </head>
26.     
27.     <body background = "https://st4.depositphotos.com/4717421/24397/i/1600/depositphotos_243974600-stock-photo-oslo-norway-august-2018-view.jpg">
28. 
29.     <h1 id = "pass-en" style="text-align:center">Passenger Counter App</h1>
30.         <div id = "container">
31.         <button  onlcick = "increment()">Increment</button>
32.         <p style = "font-size:35px";   id = "co-nt">0</p>
33.         </div>
34.         <div id ="btntwo">
35.         <button  onclick = "save()">Save</button>
36.         <p style = "font-size:35px"; id = "s-a"></p>
37.         </div>    
38.         
39.     </body>
40.     <script>
41.         let a = document.getElementById("co-nt");
42.         let b = document.getElementById("s-a");
43.         let count = 0;
44. 
45.         function increment() {
46.                       
47.                    count += 1;
48.                   
49.                    a.innerText = count;
50. 
51.         }
52. 
53.         function save() {
54. 
55.                   b.innerText = count;
56. 
57.         }
58.     </script>
59.     </html>`
60. 
-
hai myself is teddy , i am new here, i have a dobt while working on js, the webpage i created not working as i intended.
Tags: javascript, html, webdev
Published: 2022-09-17 23:09:41

I attaching my code here:
<!DOCTYPE>
<html>
    <head>
        <style>
            button {
                font-size: 40px;
                padding:10px;
                border-radius: 10px;
                margin: 20px;
            }

            #container {
                text-align: center;
            }

            #btntwo{
                text-align: center;
            }

            #fo-nt {
                font-size: medium;
            }

        </style>
        </head>
    
    <body background = "https://st4.depositphotos.com/4717421/24397/i/1600/depositphotos_243974600-stock-photo-oslo-norway-august-2018-view.jpg">

    <h1 id = "pass-en" style="text-align:center">Passenger Counter App</h1>
        <div id = "container">
        <button  onlcick = "increment()">Increment</button>
        <p style = "font-size:35px";   id = "co-nt">0</p>
        </div>
        <div id ="btntwo">
        <button  onclick = "save()">Save</button>
        <p style = "font-size:35px"; id = "s-a"></p>
        </div>    
        
    </body>
    <script>
        let a = document.getElementById("co-nt");
        let b = document.getElementById("s-a");
        let count = 0;

        function increment() {
                      
                   count += 1;
                  
                   a.innerText = count;

        }

        function save() {

                  b.innerText = count;

        }
    </script>
    </html>
Opinions on Programming: Eliminating one-off variables with Object#then
Tags: ruby
Published: 2022-09-17 22:42:12

Ruby is a pretty versatile language. It can be used to write OOP and Functional code at once. Ruby provides multiple meta-programming facilities as well.

One of the features of Ruby's Objects that i've come to like, is a method, namely `#then`. 

It accepts a block, proc, or a lambda. That receives the object itself as the only argument, these "callbacks" then can modify or "tap" into the object's state. Eventually, it returns the last line from the passed lambda, which can be used to store inside a variable(which it's sibling `#tap` would not do)

Every Object in ruby responds to a then method. It evaluates the passed proc in the context of the caller(i.e the Object itself), then returns the last line executed inside the block. Take this class

```ruby
class Person
  attr_reader :first_name, :last_name

  def initialize(first_name, last_name)
    @first_name = first_name
    @last_name = last_name
  end

  def name
    "#{first_name} #{last_name}"
  end
end
```

Given this Person class above, let's say we want to get the name of the person. We could do this,

```ruby
user = Person.new "John", "Doe"

user_full_name = user.name
```

Here we're storing the new Person object inside the user variable, which we're only using in a single place(to log the name to the console). With then, we can do

```ruby
user_full_name = Person.new("John", "Doe").then(&:name)
```

The code gotten shorter. Because we're not storing an extra variable(the `user`), after this code execute, the garbage collector can safely remove this Object since no reference to it exists anymore.

This really shines inside conditionals, this snippet assumes you have Rails installed(or any other database-backed table)

```ruby
@buyer = if Buyer.find_by(id: 123).nil?
  SomeExternalService.api(...).then do |response|
    Buyer.create(response.body)
  end
else
  ## do something else
end
```

We don't need to store the `response` into a variable then do `Buyer.create` from the response. Here is how it might look like without using then.

```ruby
@buyer = if Buyer.find_by(id: 123).nil?
  response = SomeExternalService.api(...)
  Buyer.create(response.body)
else
  ## do something else
end
```

Personally, i've grown to like `Object#then` more and more, not to mention it's sibling, `Object#tap`. 

Thanks for staying until the end. Hope you enjoyed this, have a wonderful day, and happy coding.

### Resources

- [Object#then](https://ruby-doc.org/core-2.6.3/Object.html#method-i-then)