teleren/devto huggingface dataset:
Tribute Web Page
Tags: html, codenewbie, css
Published: 2021-02-19 22:32:41

The is a tribute web page that says little about personal stories and the kind of person that died is in the about section and also 3 grid pictures of his, also footer that contains my slack username, an anchor tag with mailto:myEmail link, mt intern track and current level in the intern side hustle and my social link icons below that is also copyright.

{% codepen https://codepen.io/mercyharbo/pen/wvoqoRL %}
Day 313 : Lightworks
Tags: hiphop, code, coding, lifelongdev
Published: 2021-02-19 22:32:21

_liner notes_:
- Professional : Woke up to some really good feedback on the presentation I gave yesterday. Got invited to a pretty cool Slack channel. Had a team meeting. Helped out a couple of team members with some JavaScript stuff. Pretty good day.

- Personal : Last night, I went through a bunch of tracks for this week's radio show. Spent a little time working on my side project. Pretty chill.

![View of mountain ranges in China with some houses on a cliff](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oqbiy6s08vzcyitcky5k.jpg)

Going to go through a couple of more tracks and finalize the radio show tomorrow. Then I want to watch WandaVision and maybe do some light work on my side project.

Have a great night weekend!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube csCqZ8pB5wI %}
Do you use Linux? Answer for the chance to appear on the DevDiscuss podcast!
Tags: discuss, podcast, linux
Published: 2021-02-19 22:22:45

---
title: Do you use Linux? Answer for the chance to appear on the DevDiscuss podcast!
published: true
tags: discuss, podcast, linux
---

The [DevDiscuss Podcast](https://dev.to/devdiscuss) begins with an interview and ends with commentary from listeners — and we like to feature the actual _voices_ from our community!

To inform an upcoming episode of the show, we'd like to know...

> ### **“Why do you or _don't_ you use Linux?”** 
  
For your chance to appear on an upcoming episode, answer the question above by:

- Calling our Google Voice at +1 (929)500-1513 and leave a message 📞

- Sending a voice memo to pod@dev.to 🎙

- OR, leaving a comment here (we'll read your response aloud for you) 🗣

_Please send in your recordings by Wednesday, February 24th at Midnight, ET (9 PM PT, 5 AM UTC)_

_**Voice recordings will be given priority placement**_ 😉 

---

Plus, don't forget to check out the most recent episode of DevDiscuss:

{% podcast https://dev.to/devdiscuss/s4-e2-a-critical-look-at-distributed-conferences %}
Conditional Workflows and Failures in GitHub Actions
Tags: github, devops, githubactions
Published: 2021-02-19 22:19:13

Coming up on March 1st, GitHub, changing the way GitHub Actions work with Dependabot PRs. This change will treat all these Dependabot PRs as forks to your repo, so they will not have access to things like the **[GITHUB_TOKEN](https://dev.to/github/the-secrets-of-authenticated-github-action-workflow-3i5o)** token. So if you're using Dependabot in any of your projects, consider changing over to [pull_request_target](https://dev.to/github/running-github-actions-on-forks-4e75) after reading up on the [recent GitHub Actions Security vulnerabilities research](https://securitylab.github.com/research/github-actions-preventing-pwn-requests).

I have an example workflow that dumps the context of the runner in my Action logs. This is helpful if you don't want to use tmate or similar to debug. It's an excellent little debugging tool. 

```yml

name: dump

on:
  pull_request:

jobs:
  dump:
    runs-on: ubuntu-latest
    steps:
      - name: Dump context
        uses: crazy-max/ghaction-dump-context@v1
```
Per the changelog, I can update it to use **pull_request_target** so it has access to the GITHUB_TOKEN with write access. But I also only want dependabot PRs leveraging this workflow. To do this, I can add a [conditional expression](https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#about-contexts-and-expressions) to my workflow that checks that the `github.actor` is only `'dependabot[bot]'`.

```yml
name: dump

on:
  pull_request:

jobs:
  dump:
    runs-on: ubuntu-latest
    steps:
      - name: Dump context
        if: github.actor == 'dependabot[bot]' // added condiontal
        uses: crazy-max/ghaction-dump-context@v1
```

Now the conditional will skip the workflow step if the actor is not `'dependabot[bot]'`. But what if I want to fail the workflow from human contributors? I can inverse the conditional, but I can also add a failure, but running `exit 1` like so.

```yml
name: dump

on:
  pull_request:

jobs:
  dump:
    runs-on: ubuntu-latest
    steps:
      - name: Dump context
        if: github.actor == 'dependabot[bot]'
        run: exit 1 // added failure
      - name: the dump
        uses: crazy-max/ghaction-dump-context@v1
```

But keep in mind if you have a conditional, and it's not dependent by any don't want a failure, it'll just skip the job.

I hope you found this helpful. Be sure to keep an eye on the [GitHub Changelog](https://github.blog/changelog/) for future Action updates, as well as other features. 

_This is part of my 28 days of Actions series. To get notified of more GitHub Action tips, follow the GitHub organization right here on Dev. Learn how to build action with Node.js_

{% link https://dev.to/github/build-your-own-github-action-without-a-docker-container-1eic/ %}
Working Around Errors Caused By Poorly-Built AMIs (Networking Edition)
Tags: ami, automation, aws, devicenaming
Published: 2022-06-03 21:11:42

---
title: Working Around Errors Caused By Poorly-Built AMIs (Networking Edition)
published: true
date: 2021-02-19 22:17:00 UTC
tags: AMI,automation,AWS,devicenaming
canonical_url: https://thjones2.blogspot.com/2021/02/working-around-errors-caused-by-poorly.html
---

Over the past several years, the team I work on created a set of provisioning-automation tools that we've used with/for a **_NUMBER_** of customers. The automation is pretty well designed to run "anywhere".

Cue current customer/project. They're an AWS-using customer. They maintain their own AMIs. Unfortunately, our automation would break during the hardening phase of the deployment automation. After a waste of more than a man-day, discovered the root cause of the problem: when they build their EL7 AMIs, they don't do an adequate cleanup job.

Discovered that there were spurious ifcfg-\* files in the resultant EC2s' /etc/sysconfig/network-scripts directory. Customer's AMI-users had never really noticed this oversight. All they really knew was that "networking appears to work", so had never noticed that the network.service systemd unit was actually in a fault state. Whipped out journalctl to find that the systemd unit was attempting to online interfaces that didn't exist on their EC2s ...because, while there were ifcfg-\* files present, corresponding interface-directories in /sys/class/net didn't actually exist.

Because our hardening tools, as part of ensuring that network-related hardenings all get applied, does (the equivalent of) systemctl restart network.service, the resultant fault recorded by systemd gets propagated out to the hardening-automation causing the automation to record a fault. Consequently, our tools were aborting on the apparent fault.

So, how to pre-clean the system so that the standard provisioning automation would work? Fortunately, AWS lets you inject boot-time logic via cloud-init scripts. I whipped up a quick script to eliminate the superfluous ifcfg-\* files:  

```
for IFFILE in $( echo /etc/sysconfig/network-scripts/ifcfg-* )
do
   [[-e /sys/class/net/${IFFILE//*ifcfg-/}]] || (
     printf "Device %s not found. Nuking... " "${IFFILE//*ifcfg-/}" && \
     rm "${IFFILE}" || ( echo FAILED ; exit 1 )
     echo "Success!"
   )
done
```

Launched a new EC2 with the userData addition. When the "real" provisioning automation ran, no more errors. Dandy.

Ugh... Hate having to kludge to work around error-conditions that simply should not occur.
FlexBox
Tags: css, flexbox
Published: 2021-02-19 21:18:16

#¿Que es Flexbox?

es un conjunto de nuevos atributos (propiedades) y valores de CSS que podemos aplicar a los elementos de una página y que permiten simplificar la forma en que los posicionamos y se adaptan a los distintos dispositivos.

###¿Como empiezo a usarlo?

Para usarlo debo crear un contenedor y todo los elementos dentro tendrán las propiedades de Flexbox.

El siguiente ejemplo crea un contenedor que se aplica a la etiqueta html `section` usando css. 

> Código html
```
  <section>
     <article>1</article>
     <article>2</article>
     <article>3</article>
     <article>4</article>
  </section>
```

> Código css
```
section{
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
}

article{
    background-color: #9ef;
    padding: 3px;
    margin: 5px;
    width: 40%;

}
```

En el código css se puede ver que a la etiqueta `section` se aplican 3 propiedades de flexbox:
- `display: flex;` que indica que esta etiqueta será un contenedor flexbox
- `flex-direction: row;` Indica que los elementos dentro de este contenedor tendrán una dirección en forma de filas
- `flex-wrap: wrap;` Si el elemento no tiene espacio pasará a la siguiente linea.



Acá esta el código del ejercicio

{% replit @ManuelOrtega3/flexbox-1 %}


###¿Qué más puedo hacer?

- Cambia la propiedad `flex-direction: row;` por `flex-direction: column;`

- Cambia la propiedad `flex-wrap: wrap;` por `flex-wrap: nowrap;`
Improving your iOS app ratings with SKStoreReviewController

Tags: ios
Published: 2021-02-19 21:03:43

#Why Ratings Matter
One of the first things that users look at before installing an app is the app's rating on the App Store. Having a good rating increases the app's visibility on the App Store; the higher the rating, the higher it will rank. Research shows that users with a negative experience are more likely to rate the app than those who have had a positive experience. That's why it is so important to ask your current users to rate your app. Asking the user to go to the app store to rate your app isn't effective and also annoying to the user. A better experience for the user is to rate the app without having to leave the screen they are on. This is where SKStoreReviewController comes in. It is used for displaying in-app prompt to rate the app.

#Guidelines
Apple recommends that in-app rating prompt be only displayed after the user has shown some engagement with the app. For example, if they were able to successfully perform a task, then it makes sense to prompt them for the review. They shouldn't be prompted on app launch, button click, or if they are in the middle of a time-sensitive task. Allow the user to form an opinion of the app before asking for a review. In short, Apple says "Don't be a pest."

#Using SKStoreReviewController
While using SKStoreReviewController is very simple, the logic for when to use it is the complex part. Here is a sample code:

```
import StoreKit
...
    if shouldDisplayReview(){
        SKStoreReviewController.requestReview()
        reviewDisplayed()
    }
...
```
The shouldDisplayReview method would contain logic that determines if the user is likely having a good experience in the app and hasn't been shown the prompt recently. For example, you can track the number of times the user has opened the app or successfully completed a task in UserDefaults. If the count is above a certain number, you should display the review.

The reviewDisplayed method stores the date when the prompt was displayed. It can also reset any counters you use to determine if the user is having a good experience.

#Limitations
There are many limitations on using SKStoreReviewController:

* You can prompt the user for a rating up to three times within a 365-day period
* Users can go into Settings and turn off in-app ratings prompt
* There are no callbacks in SKStoreReviewController. The app has no way of know if the user rated the app or not.
* The ratings prompt will displayed on XCode builds but the Submit button is grayed out.
* On TestFlight builds, the ratings prompt will not be displayed at all. You will need to create an ad-hoc build if you need to have others test this screen. In my next lesson, I will show you how to create an ad-hoc build.
A closer look at Javascript event listeners & objects
Tags: javascript, html
Published: 2021-02-19 17:15:31

This post isn't meant to be an introduction to Javascript event listeners and the event object; instead it's meant to answer some random questions I had while working on my own event listener system (since I was unable to use `domNode.dispatchEvent`). --edit-- I just discovered `EventTarget`! See [the section below](#eventtarget)

## Questions:


### If there are multiple event listeners, do they receive the same event object or different objects?

They receive the same event object.

```js
var button = document.createElement('button')

var temp1, temp2

button.addEventListener('click', (evt) => temp1 = evt)

button.addEventListener('click', (evt) => temp2 = evt)

button.click()

console.log(temp1 === temp2) // true
```

-----

### If an event is `preventDefault()`-ed, do other listeners still receive that event?

Yes; `preventDefault()` is a signal that the event's _action_ shouldn't happen, but other listeners will still get called. `stopPropagation()` and `stopImmediatePropagation()` is what's used to prevent other listeners from being called. (See questions below)

>The Event interface's preventDefault() method tells the user agent that if the event does not get explicitly handled, its default action should not be taken as it normally would be. The event continues to propagate as usual

[MDN Source](https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)

-----

### If there are multiple event listeners added to the same DOM element, and the first listener calls `stopPropagation()`, do the other listeners receive the event?

Yes. `stopPropagation()` prevents the event from bubbling up to higher-up listeners, but it does not prevent listeners from being fired on the same DOM node. 

>When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object.

[DOM Standards spec](https://dom.spec.whatwg.org/#interface-event)

And that's why `stopImmediatePropagation()` exists; it will prevent ALL other event listeners from being fired. 

>Invoking this method prevents event from reaching any registered event listeners after the current one finishes running and, when dispatched in a tree, also prevents event from reaching any other objects.

[DOM Standards spec](https://dom.spec.whatwg.org/#interface-event)

-----

### EventTarget

If you ever think about implementing your own event listener system, you should consider using `EventTarget` instead! Here's an example:

```js
const target = new EventTarget()

target.addEventListener('myEvent', (evt) => {console.log(evt)})

target.dispatchEvent(new Event('myEvent'))
```

`EventTarget` works in all [modern browsers](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/EventTarget) and [NodeJS >14.5](https://nodejs.org/api/events.html#events_eventtarget_and_event_api). That's a lot easier than doing it yourself! :)
Solve Leetcode Problems and Get Offers From Your Dream Companies
Tags: algorithms, leetcode, career, programming
Published: 2021-02-19 20:55:58

Leetcode 387. First Unique Character in a String

In this series, I am going to solve Leetcode medium problems live with my friends, which you can see on our youtube channel, Today we will do Problem Leetcode 387. **First Unique Character in a String**

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

A little bit about me, I have offers from **Uber India** and **Amazon India** in the past, and I am currently working for **Booking.com** in Amsterdam.

## Motivation to learn algorithms
{% medium https://medium.com/leetcode-simplified/solve-leetcode-problems-and-get-offers-from-your-dream-companies-2786415be0b7 %}

## Problem Statement

Given a string, find the first non-repeating character in it and return its index. If it doesn’t exist, return -1.

**Examples:**

`s = "leetcode"
return 0.s = "loveleetcode"
return 2.`

**Note**: You may assume the string contains only lowercase English letters.

## Youtube Discussion

{% youtube Ymf9Vzh91H0 %}

<figcaption>Leetcode 387. First Unique Character in a String</figcaption>

## Solution

According to the problem, we have to return the index of the first non-repeating character.

**Naive Solution**

Let’s talk about the naive approach to the problem. We can choose a character from the string at index `i` and check for its occurrence in the left substring (0 to i-1) and the right substring (i+1 to the end of the string).

If that character does not appear in any of those we return that index `i` . This will give us a time complexity of `O(n^2)` .

**Optimized solution**

Now let’s try to improve it.

When dealing with problems involving the frequency of characters, we should try to use a [Hash Table.](https://www.educative.io/edpresso/what-is-a-hash-table)

For this problem, we have to count the occurrence of each character and return the first character’s index whose count is 1. Therefore, we can first store the occurrence of all characters and then check for the character which occurs just once.

{% gist https://gist.github.com/sksaikia/f14d4dbafc83941d64d1fbec0c02e0af.js %}

The C++ code is also given below.

{% gist https://gist.github.com/sksaikia/8d7b3e685ac2ec4a9f8188c3fcd10bd6.js %}

Time Complexity: **O(n)**, n is the length of the string

Space Complexity: **O(1)**, at max the hashmap will have 26 keys.

**Similar Problems**

1. [Leetcode 442: Find All Duplicates in an Array](https://medium.com/leetcode-simplified/solve-leetcode-problems-and-get-offers-from-your-dream-companies-9d123345c23a)
2. [Leetcode 1429: First Unique Number](https://medium.com/leetcode-simplified/solve-leetcode-problems-and-get-offers-from-your-dream-companies-4f5e49af2fec)

The code for this problem can be found in the following repository.

{% github webtutsplus/LeetCode %}

**Thank You for reading and Follow this publication for more Leetcode problems!😃**

## [LeetCode Simplified](https://medium.com/leetcode-simplified)
Ruby Underscore
Tags: ruby
Published: 2021-02-19 20:45:43

As a Ruby programmer, you probably have seen methods or blocks look like this:
```ruby
def test(a, b, _); end
proc { |_, a| ... }
```
But what exactly is this `_` thingy, and how is it special?

### Underscore is a valid object identifier
Yes, you can access, and assign values to `_` and you are also able to use it as a method name.
```ruby
def a(_); puts _; end # a(3) prints 3
```
Yet it does not work exactly the way you might expect in IRB, because it’s [explicitly configured](https://github.com/ruby/irb/blob/82450bde35678880aeed2d7c3d602a3f81036fe8/lib/irb/ext/history.rb#L27) to return the last used value in the Ruby console
```ruby
_ = 1
2
_ # returns 2, not 1
```

Not double underscore `__` tho:
```ruby
__ = 1
2
__ # returns 1
```

### Underscore is treated a bit differently than other object identifiers
You could have (>= Ruby 1.9)
```ruby
def test(_, _); end
def test(__, __); end
def test(__x, __x); end
```
however, you cannot have
```ruby
def test(x, x); end # this will cause an error
```

Ruby [explicitly allows](https://github.com/ruby/ruby/commit/6bd65de203c7aaffc8d4241a771491356002ed75) duplicate parameter names when they’re made of underscore `_`.

It is most common for people to use `_` to represent unused parameters (placeholders), yet as the examples above showed, you can use other symbols to avoid “unused var” warnings too :slightly_smiling_face:
JHipster: Create filters dynamically in Angular
Tags: jhipster, angular
Published: 2021-02-19 20:31:28

---
title: JHipster: Create filters dynamically in Angular
published: true
description: Create entity queries dynamically on the go!
tags: jhipster, angular
//cover_image: https://direct_url_to_image.jpg
---
Sometimes, there are cases in which you need to filter your entities according to some conditions. For instance:

``` javascript
if (!this.searchShowOverdue) {
  this.invoiceService
    .filterInvoices({
      page: pageToLoad - 1,
      size: this.itemsPerPage,
      sort: this.sort(),
      'type.equals': this.invoiceType,
    }).subscribe(
      (res: HttpResponse<IInvoice[]>) => this.onFilterSuccess(res.body, res.headers, this.page),
        () => this.onError()
  );
} else {
  this.invoiceService
  .filterInvoices({
    page: pageToLoad - 1,
    size: this.itemsPerPage,
    sort: this.sort(),
    'type.equals': this.invoiceType,
    'status.equals': Status.OVERDUE,
  }).subscribe(
    (res: HttpResponse<IInvoice[]>) => this.onFilterSuccess(res.body, res.headers, this.page),
    () => this.onError()
  );
}
```
Repeat this for as many conditions you need. So I started thinking about how much code that was and decided to do something about it.

As we all know, the service receives `req: any` like `size: this.itemsPerPage` in the example above.

What if I could fill that object according to our own conditions? Well, I did just that :wink:

``` javascript
const req: Record<string, any>[] = [];
req.push({'page': pageToLoad - 1});
req.push({'size': this.itemsPerPage});
req.push({'sort': this.sort()});
req.push({'type.equals': this.invoiceType});
req.push({'active.equals': true});

if (this.searchShowOverdue) {
  req.push({'status.equals': 'OVERDUE'});
}
if (this.toDate && this.fromDate) {
  req.push({'date.lessOrEqualThan': this.toDate.format(DATE_FORMAT)});
  req.push({'date.greaterOrEqualThan': this.fromDate.format(DATE_FORMAT)});
}

const request = {};
(Object.values(req) as Array<any>).forEach(value => {
  request[Object.keys(value)[0]] = Object.values(value)[0];
});
this.invoiceService
  .filterInvoices(request)
  .subscribe(
    (res: HttpResponse<IInvoice[]>) => this.onFilterSuccess(res.body, res.headers, this.page),
    () => this.onError()
);
```
As you can see, the code is cleaner and easier to add more filters.

I know this might not be the best solution, but it did help me clean *a lot* of code in my project, so it will do for now. If you have a better solution, please let me know :smiley: