teleren/devto huggingface dataset:
is-web-monetized
Tags: gftwhackathon, showdev, javascript, webmonetization
Published: 2020-05-12 15:56:40

While browsing and reading articles here in `DEV`, I found this interesting `hackathon` on my feed and started to read some resources and amazing ideas/projects of other developers around the globe for this API so called `web monetization`. The `docs` is straight forward but sadly I'm having a hard time for searching a website that actually use a `web monetization`. So..... heres what I did!

## What I built
:money_with_wings: I built a very... very... very... simple `npm package` to let you easily check if a certain website is web monetized 

![webmonetization.org](https://user-images.githubusercontent.com/10413754/81672858-5a001880-947d-11ea-8721-1b0396db9b35.png)
https://webmonetization.org/

### Submission Category: 

Foundational Technology


## Demo
You can easily try the tool by installing it globally and running it on your terminal

### Installation
```bash
  npm install is-web-monetized
```

### Usage (via CLI)
```bash
  monetized https://testwebmonetization.com/demo.html
```
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/lt9arcsp62y7rwl0hlkl.gif)

> :bulb: I want to show it in table format. what do you think?

### Usage (as dependency)
```javascript
  const { isWebMonetized } from 'is-web-monetized'
  const url = 'example.com'
  
  isWebMonetized(url).then(obj => {
    /*
      {
        monetized <boolean>,
        url <url>,
        content <wallet>,
      }
    */
    console.log(obj)
  }).catch(err => console.log(err))
```

## Link to Code

{% github https://github.com/jkga/is-web-monetized %}


## How I built it 
If you recall, I said **SIMPLE** and it is!. This tool is basically just reads the `monetization` meta in a website

**dependencies**
- [jsdom](https://github.com/jsdom/jsdom) - for me to easily read the `metas`
- [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch)
What are your most used aliases?  
Tags: discuss
Published: 2020-05-12 15:55:43

These are my favourite aliases.

```bash
alias c="code .";
```

```bash
alias life="cd ~/Desktop/Life";
```
> `Life` is the folder where I store all my codes :)

```bash
alias deleteDSFiles="find . -name '.DS_Store' -type f -delete"
```
> I guess this small command saves a lot of mac users.

```bash
alias yas="yarn start";
```

```bash
alias ..='cd ..'
alias ...='cd ../..'
```

P.S: There are more, but these are my fav and most used.

Please comment down your favourites or something which think would help others.
100daysofcode Flutter
Tags: 100daysofcode, flutter
Published: 2020-05-12 15:40:09

day 64/100 of #100daysofcode #Flutter
Learning Flutter , courses Udemy from
@maxedapps

Today implement put instead of patch, make favorite belong to user ,
https://github.com/triyono777/100-days-of-code/blob/master/log.md
What internal tooling have you built around Amazon SES?
Tags: aws
Published: 2020-05-12 15:33:14

Hey all,

I'm considering using SES for transactional emails for my side project, but I'm a little put off by the lack of features of SES compared to other email providers.

I'm curious to hear about tooling other people have built to make SES more useable. What internal or external tools do you use?

Thanks :)
Introducing jquery-events-to-dom-events (and jboo)
Tags: javascript, events, jquery
Published: 2020-05-12 15:30:37

---
title: Introducing jquery-events-to-dom-events (and jboo)
published: true
description: Capture jQuery 'events' with DOM event listeners
tags: javascript, events, jquery
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/szjbsyorfln5dvy35jik.jpg
---

Did you know that **jQuery events aren't events**?

It's true - and it'll really mess up your night if you need to capture events from legacy jQuery components. Looking at you, `hidden.bs.modal`.

I needed a way to make `$(document).trigger('fart')` emit a standard `$fart` DOM event, so I wrote it:

https://www.npmjs.com/package/jquery-events-to-dom-events

This library is short and sweet, with zero dependencies - including jQuery. It's just two functions: `delegate` and `abnegate`. It is [Mutation-First](https://leastbad.com/mutation-first-development); designed to work great in Stimulus and supports Turbolinks out of the box.

It even has the secret ability to listen for DOM events with jQuery event listeners, but don't tell anyone.

You can [**try it now** on CodePen](https://codepen.io/leastbad/pen/VwvQxxJ?editors=1011) or even better, [clone a sample Rails project](https://github.com/leastbad/jboo) to experiment in a mutation-first context with Stimulus.

The Rails project is called **jboo**. Don't read into the name.

## Usage

**Note**: it is assumed that [jQuery is available in the global window scope](https://github.com/leastbad/jquery-events-to-dom-events#setup) as `$`.

In the most basic configuration, you:

1. `import { delegate } from 'jquery-events-to-dom-events'`
2. Call `delegate(eventName)` for every jQuery event you want to capture.
3. Set up DOM event listeners for those events, **prepending a $ to the event name**.

Let's say that you want to respond to the user closing a Bootstrap modal window:

```js
import { delegate } from 'jquery-events-to-dom-events'
delegate('hidden.bs.modal')
document.addEventListener('$hidden.bs.modal', () => console.log('Modal closed!'))
```

That might be it. Go make a sandwich - you've earned it.

---

You can learn more about working with jquery-events-to-dom-events on [the Github repo](https://github.com/leastbad/jquery-events-to-dom-events).

As always, the right music is important for establishing proper context.

You don't have to listen to music, but your transpiler configuration will almost certainly fail lint checks if you are not listening to "*In Harmony New Found Freedom*" by [The Swirlies](https://en.wikipedia.org/wiki/Swirlies), from their 1996 album "[They Spent Their Wild Youthful Days In The Glittering World Of The Salons](https://www.youtube.com/watch?v=S1rTKIsDS8o)" while you integrate this library.

{% youtube idCfuK4t2vo %}
Kth Largest Element in an Array
Tags: leetcode, algorithms, array
Published: 2020-09-30 02:48:22

---
title: Kth Largest Element in an Array
published: true
date: 2020-05-12 15:16:00 UTC
tags: LeetCode,Algorithms,Array
canonical_url: https://coderscat.com/kth-largest-element-in-an-array
---

## [Challenge Description](https://leetcode.com/problems/kth-largest-element-in-an-array/)

Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.

Example:

```
Input: [3,2,3,1,2,4,5,5,6] and k = 4Output: 4
```

## Approach #1: Sort the array and get by index

Time complexity is O(NlogN), a flaw is we modified the original array.

```cpp
class Solution {
public:
    int findKthLargest(vector<int>& nums, int k) {
        sort(nums.begin(), nums.end());
        return nums[nums.size() - k];
    }
};

```

## Approach #2: Use heak minheap with size K

If we initialize a minheap with the size of K, the top value is what we want.

For minheap, the insertion operation has a worst-case time complexity of O(logN) but an average-case complexity of O(1).

So we have an overall average-case complexity of O(N) and worst time complexity O(NlogN).

```cpp
class Solution {
public:
    int findKthLargest(vector<int>& nums, int k) {
        priority_queue<int, vector<int>, greater<int>> minheap;
        for(int i=0; i<k; i++)
            minheap.push(nums[i]);
        for(int i=k; i<nums.size(); i++){
            if(nums[i] <= minheap.top()) continue;
            minheap.pop();
            minheap.push(nums[i]);
        }
        return minheap.top();
    }
};

```

## Approach #3: Divide and conquer

Just like quicksort, we use a `partition` function to split the array into two parts, the left part of elements are all less than `pivot`, the right part of elements are all greater than `pivot`.

And reduce the search range in every iteration.

The overall time complexity O(N).

```cpp
class Solution {

private:
  void swap(vector<int>& a, int x, int y) {
    int t = a[y];
    a[y] = a[x];
    a[x] = t;
  }

  int random(int a, int b) {
    return (int) (rand() % (b - a + 1)) + a;
  }

  int partition(vector<int>& nums, int left, int right, int index) {
    int pivot = nums[index];
    swap(nums, index, right);
    int i = left - 1;
    for (int j=left; j<=right-1; j++)
      if (nums[j] <= pivot)
        swap(nums, ++i, j);
    swap(nums, right, i+1);
    return i+1;
  }

  int quick_select(vector<int>& nums, int left, int right, int k) {
    while (left <= right) {
      int pivot = partition(nums, left, right, random(left, right));
      if (pivot == k) return nums[k];
      else if (k > pivot) left = pivot + 1;
      else right = pivot - 1;
    }
    return -1;
  }

public:
  int findKthLargest(vector<int>& nums, int k) {
    return quick_select(nums, 0, nums.size() - 1, nums.size() - k);
  }
};

```

The post [Kth Largest Element in an Array](https://coderscat.com/kth-largest-element-in-an-array) appeared first on [Coder's Cat](https://coderscat.com).
Discuss: What was your first experience in deploying to the cloud like?
Tags: discuss, cloud, beginners
Published: 2020-05-12 15:07:02

Tell me about what your first time deploying to the cloud was like!  Did you think the documentation provided was enough?  Did you need help?  Did you use a pipeline?  What were your tests like?  How long did it take you?

Share with me your experience and let's talk about how to make this experience easier for our beginner friends!

You can also reach out to me directly on [twitter](https://jaydestro.org)!

Tell me your story!
Reusing operations for cleaner code
Tags: javascript, node, webdev, undercutjs
Published: 2020-05-12 14:57:55

---
title: Reusing operations for cleaner code
published: true
description: Tips on reusing operations created for the Undercut library in an independent and inline manner.
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/liqffrdhlb4jrddfoe3y.png
tags: javascript, node, webdev, undercutjs
---

Imagine we're getting a list of users from an API:

```js
const users = getUsers();
// [{ id, name, location, ... }, ...]
```

We can do quite a complex processing using [Undercut](https://github.com/the-spyke/undercut) pipelines, but what if we need only to do something quick: like grouping users by a location and just passing the result further? Even calling `pull` may be too much:

```js
sendPreview(pullArray([groupBy(u => u.location)], users));
```

A case with a variable may be distracting too:

```js
const usersByLocation = pullArray([groupBy(u => u.location)], users);

sendPreview(usersByLocation);
```

Fortunately, Undercut operations are framework-agnostic, which means they work by themselves. An operation is just a functions doing something on an Iterables. Arrays are Iterables, so our `users` fit just right and `groupBy(u => u.location)(users)` will return grouped users:

```js
sendPreview(groupBy(u => u.location)(users));
```

Now it's better as we have no noise like `pullArray` and square brackets.

There's another use case: you can define selectors using operations like so:

```js
const groupUsers = groupBy(u => u.location);

// And use later:
const usersByLocation = groupUsers(users);
```

I have specifically chosen `groupBy` because with even shorter actions you will likely go with plain Array methods and Arrow Functions:

```js
render(users.filter(u => u.active));
```

But if you do need more serious job like `flatMap`/`groupBy`/`orderBy`/etc or already using Undercut in other places, consider reusing from the Undercut or your own custom operations.

Undercut docs: [undercut.js.org](https://undercut.js.org)
Previous post: [Lazy data processing using Undercut](https://dev.to/the_spyke/what-is-undercut-js-3ih1)
Daily Challenge #241 - Tip Calculator
Tags: challenge
Published: 2020-05-12 14:56:48

---
title: Daily Challenge #241 - Tip Calculator
published: true
series: Daily Challenge
description: Give tip based on quality of service.
tags: challenge
---
Complete the function, which calculates how much you need to tip based on the total amount of the bill and the service.

You need to consider the following ratings:

`Terrible`: tip 0%
`Poor`: tip 5%
`Good`: tip 10%
`Great`: tip 15%
`Excellent`: tip 20%

The rating is case insensitive (so "great" = "GREAT"). If an unrecognized rating is received, then you need to return:
"Rating not recognized" in JavaScript, Python and Ruby...
...or null in Java
...or -1 in C#

Because you're a nice person, you always round up the tip, regardless of the service.

Examples
calculatetip(30, "poor") => 2
calculatetip(20, "hi")=> "Rating Not Recognized"
calculatetip(107.65, "great") => 17

Tests
calculatetip(78, "good") => 
calculatetip(50, "poor") => 
calculatetip(125, "excellent") => 

Good luck!
***
_This [challenge](https://www.codewars.com/kata/56598d8076ee7a0759000087) comes from Katbow on CodeWars. Thank you to [CodeWars](<https://codewars.com/>), who has licensed redistribution of this challenge under the [2-Clause BSD License](<https://opensource.org/licenses/BSD-2-Clause>)!_

_Want to propose a challenge idea for a future post?  Email **yo+challenge@dev.to** with your suggestions!_
The Pros and Cons of Python
Tags: python
Published: 2020-05-12 13:36:27

Every language has pros and cons. The benefits of the Python programming language are many and can simply be summarized.

The history of <a href="https://python.org">Python</a> goes a long way back:

* Christmas 1989: Guido von Rossum begins writing a compiler for the Python language.
* February 1991: The first Python compiler (and interpreter) is born, which is implemented in C (followed by Java and C# implementations of <a href="https://www.jython.org/">Jython</a> and <a href="https://ironpython.net/">IronPython</a>, as well as other implementations of PyPy, Brython, Pyston, etc.)
* January 1994: Official release of Python 1.0.
* October 16, 2000: Python 2.0 released
* December 3, 2008: Python 3.0 is released
* 2018: Python 3.7.x was released

## Pros

* Simple and clear, there is only one way to do a thing.

```python
print("Hello World")
for i in range(1,10):
    print(i)
```
* The learning curve is low and Python is much easier to get used to than many other languages.

* <a href="https://github.com/python/">Open source</a>, with a strong community and ecosphere.

* Interpretive languages with inherent platform portability.

* Support is provided for both mainstream programming paradigms (<a href="https://pythonprogramminglanguage.com/class/">object-oriented programming</a> and <a href="https://docs.python.org/3/howto/functional.html">functional programming</a>).

* Extensible and embeddable, you can call C/C++ code, or you can call Python in C/C++.

* High level of code specification and readability for people with code cleanliness and OCD.

## Cons

Python's shortcomings focus on the following points.

* The execution is slightly less efficient, so computationally intensive tasks can be written in C/C++.
* Code can't be compiled normally, but now that many companies are selling services instead of selling software, the problem will be diluted.
* There are so many frameworks to choose from during development (there are over 100 for example web frameworks) that where there are choices, there are mistakes.

**Related links:**
* <a href="https://gumroad.com/l/dcsp">Python course and book</a>
* <a href="https://pythonbasics.org/">Python reference</a>
Having a crack at this hackathon
Tags: gftwhackathon
Published: 2020-05-12 14:51:48

Decided to have a crack at the grant for the web hackathon this afternoon
building on something around Web Monetisation, which is an emerging standard I have to admit I was pretty unaware of before today.

I've started working on a basic project which is essentially an updated version of their 'exclusive' content demo. My idea is to create a preview audio element if the user is Web Monetised for an albums tracks.

I started off doing this in React but got a bit frustrated with it after struggling to figure out how to implement the hooks via https://github.com/sharafian/react-web-monetization

So just moved to doing it in html / js, bootstrap and JQuery in the end as I'm purely prototyping and wanted to get something done fast, and React was getting in the way of that (no shade on React more self shade if anything haha). 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/trhqts8tjlciff44n6pa.png)
Here it is in all it's bootstrapped glory

Wanted to keep it quite simple, and it is at the minute, but need to build on this as it's a super simple implementation with drawbacks - like for example, as it says in their own documentation, at present using the method I have used (itself an extension of the methods in the documentation for hiding content) a tech-savy user can still just go to the audio element and rename the class defining the element as hidden. So there is certainly some limitations I will try and iron out. It is early days though still tbh, plus an alert if you don't are not web monetised probably isn't the most user friendly way to display information to someone. 

Github  Repo : https://github.com/drnoir/Web-Monetization-Album-Track-Preview-Hiding
Flatiron's mod4
Published: 2020-05-12 14:42:32

Hello, devs!

Today marks the day when I start my last module at Flatiron's software engineering immersive full-time coding boot camp.

Module 4 covered the fundamentals and core concepts of JavaScript, developing RoR API, client-server communication.

For this mod, I have actually built multiple projects, to get a deep understanding of vanilla JavaScript.

1, trackMyFinance

I have built a personal finance/bill tracking, mobile-focused application using D3.js.


2, You(r)Lister

This project uses Youtube's API to search and render videos from YouTube. The user is able to create and modify playlists, add/delete videos from them.

The last module will cover React/Redux with Rails API. I'm very excited about this section and graduating very soon.

Olly
Who is your hiring team?
Tags: womenintech, career, discuss, bias
Published: 2020-05-12 14:39:39

In many cases, your hiring team is the first exposure a potential employee will get to your company. They should accurately represent the organization and help set expectations for any applicant of what the company values.

Is your hiring team an accurate representation of the diversity and values of your organization? Do they provide a good snapshot or are they discouraging candidates without even knowing it?

Been reading a lot about [unconscious bias](https://technation.io/news/unconscious-bias-in-tech-get-over-it/) lately, and want to know your opinions.
Helping studient
Tags: SliceOfLife
Published: 2020-05-12 14:33:12

Hello, today I want to talk about one of my hobbies. Helping people, particularly students with their lesson in my free time. I don't do it to gain money but for free. If a student wants to pay me, I will obviously accept a really small amount of money if they really want to express gratitude.

I help students in mathematics and physics and don't ask me to help with French or whatever linguistics subjects... And I can't help people where the level is too high, High school is the highest I can do, because I don't have the knowlegde to help and I really don't want to teach something wrong.

I don't do their exercises for them, I'm like a teacher. If they need to do exercises that they didn't understand, I will explain some examples which can help their understanding. I let them do the exercises and I explain where their mistakes are, and how to correct them.

If they want some help because they don't understand something in the lesson, I create exercises which will help their comprehention. I also help when you need to remember some lesson like doing some more exercises or just explain some tips that already helped me.

That's what I'm doing when students ask my help in this two domain.
And you ? Have you already help people with their lesson ?

Léo Ménard
StreamNative Brings Streaming Data To The Cloud Native Landscape With Pulsar - Episode 132
Published: 2020-05-12 14:28:43

<p>There have been several generations of platforms for managing streaming data, each with their own strengths and weaknesses, and different areas of focus. Pulsar is one of the recent entrants which has quickly gained adoption and an impressive set of capabilities. In this episode Sijie Guo discusses his motivations for spending so much of his time and energy on contributing to the project and growing the community. His most recent endeavor at StreamNative is focused on combining the capabilities of Pulsar with the cloud native movement to make it easier to build and scale real time messaging systems with built in event processing capabilities. This was a great conversation about the strengths of the Pulsar project, how it has evolved in recent years, and some of the innovative ways that it is being used. Pulsar is a well engineered and robust platform for building the core of any system that relies on durable access to easily scalable streams of data.</p><p><a href='https://www.dataengineeringpodcast.com/streamnative-pulsar-streaming-data-episode-132/'>Listen Now!</a></p>
Managing Distributed Teams In The Age Of Remote Work
Published: 2020-05-12 14:27:30

<p>More of us are working remotely than ever before, many with no prior experience with a remote work environment. In this episode Quinn Slack discusses his thoughts and experience of running Sourcegraph as a fully distributed company. He covers the lessons that he has learned in moving from partially to fully remote, the practices that have worked well in managing a distributed workforce, and the challenges that he has faced in the process. If you are struggling with your remote work situation then this conversation has some useful tips and references for further reading to help you be successful in the current environment.</p><p><a href='https://www.pythonpodcast.com/sourcegraph-remote-work-episode-262/'>Listen Now!</a></p>
Missing: Universal Watch Mode
Published: 2020-05-12 14:20:44

---
title: Missing: Universal Watch Mode
published: true
description: 
tags: 
---

Having a tight feedback loop for development is essential. At some point, tools like nodemon, hot module reloading, and even codepen gave us the ability to immediately see the results of the code we write. 

The problem is that every tool does it differently, so you have to look it up for each case whether it's from react, vue, angular, webpack, parceljs, typescript, python, haskell, java, jest, jasmine, karma, mocha, nyc, gulp, bash...

What would it take to get everyone using one solution for this?
Custom React Hook - useLocalStorage
Tags: javascript, development, beginners, webdev
Published: 2020-05-12 14:12:59

---
title: Custom React Hook - useLocalStorage
published: true
description: Create a custom hook with Typescript for Local Storage
tags: #javascript #development #beginner #webdev
---

This week I show how to create a custom React Hook for automating Local Storage. And ... it's written in Typescript ;)

{% youtube DZpOZt8ru-0 %}