teleren/devto huggingface dataset:
Daily Developer Jokes - Tuesday, May 12, 2020
Tags: jokes, dailydeveloperjokes
Published: 2020-05-12 12:00:09

---
title: "Daily Developer Jokes - Tuesday, May 12, 2020"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Tuesday%2C%20May%2012%2C%202020"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1258ef9deee.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit.*

<!-- 
Joke text:
___Q:___ What did the proud React component say to its child?

___A:___ I've got to give you props
 -->
The GitHub COVID-19 Report about Developer Productivity
Tags: podcast, github, developer, devops
Published: 2020-05-18 11:10:46

---
title: The GitHub COVID-19 Report about Developer Productivity
published: true
date: 2020-05-12 12:00:00 UTC
tags: podcast, github, developer, devops
canonical_url: https://share.transistor.fm/s/fd3171ef
---

{% spotify spotify:episode:2gxwGeHNQYhS5eZvoJoEvc %}

 **Octoverse COVID-19 Developer Report -** [https://github.blog/2020-05-06-octoverse-spotlight-an-analysis-of-developer-productivity-work-cadence-and-collaboration-in-the-early-days-of-covid-19/](https://github.blog/2020-05-06-octoverse-spotlight-an-analysis-of-developer-productivity-work-cadence-and-collaboration-in-the-early-days-of-covid-19/)  
  
**State of the Octoverse 2019 -**  
  [https://octoverse.github.com/](https://octoverse.github.com/)  
  
**Key findings:**
- Dev activity remains consistent if not maybe increasing
- Interesting stat. When COVID-19 outbreaks occur a flux in Enterprise Repo issues increases
- Work cadence changes - longer days and weekends
  - Activity between first and last push and more activity on weekends.
  - West Coast US sees a consistent increase in work volume
- Patterns of work indicate potential burnout
- More people are collaborating
- Merge requests are merged faster than previously. Previous 2-3 hour average and now under an hour
- More collaboration tools being used
- Active users increased from the same period last year
Is Why more important than How?
Tags: design, discuss, practices, architecture
Published: 2020-05-12 11:38:34

As developers, we're often eager to start coding the solution. The problem is, sometimes, we start with the solution in mind, but we're not clear as to what the problem is.

I often see myself wondering what's the cleanest way of implementing what I have in mind: but I soon realize I'm focusing so much on the implementation details that I've almost forgotten **why** it is that I want to implement a certain functionality.

When I focus too much on the implementation, the purpose of the functionality starts to become less concrete and I almost forget what the value I wanted to deliver to my users was.

I've seen this happen in many situations. User stories specified starting with the *How* rather than the *Why*. They, deliberately or inadvertently, mandate a specific implementation. But, in doing so, I think they dramatically reduce the possibilities of really delivering something valuable to the user.

Try start with the *Why*, instead. Why do you want to build this feature? What is it that you want your users to be able to achieve? By doing this exercise I often find that the implementation that was originally suggested wasn't really the best way to help the user achieve the intended outcome.

**What's your take on this *philosophical* matter?**
--
Also, if you want to hear more *philosophical* questions from me, **[follow me on Twitter](https://alediaferia.com)**
filtered list for live search
Tags: javascript, tutorial, webdev, vue
Published: 2020-05-12 11:13:11

Sometimes we need to sort a list of different items (names or ….) Specifically and displayed to us.
For example, suppose we have a list of countries and we want to update the displayed list by entering each character to get wich name that we want it.

![alt text](https://miro.medium.com/max/776/1*xco_kFIRCELwG7yn8E4g1w.gif "CodeGif")

The following code snippet can allow us to do this
By filling the main list with the help of the filter method, it only fills the content that includes the characters entered in the search field.

![alt text](https://miro.medium.com/max/1400/1*vD7MxT1hnp6jPOikzhflmw.png "CodePic")

if you want to use it in Vue.js, you can put this method in _computed_ property
also you can use _.includes()_ method instead of _.startsWith()_ for other purposes.

>If you found it useful, you can follow me and also visit my [website](http://mohsenfallah.ir), because there are more ways to connect with me. I hope this would help you to improve your coding skills. Thank you for your attention.
___
_This article was originally published on The [Dev.to](https://dev.to/mohsenfallahnjd) on May 12, 2020 and was written by **Mohsen Fallahnejad**._
Hacker-rank SQL Median calculation
Tags: sql, beginners
Published: 2020-05-12 10:59:13

It was really interesting to calculate Median of entries in the SQL database.

## What is Median ?

Refer the link about [Median|https://en.wikipedia.org/wiki/Median]


## Hackerrank SQL problem

A median is defined as a number separating the higher half of a data set from the lower half. Query the median of the Northern Latitudes (LAT_N) from STATION and round your answer to 4 decimal places.

```sql
SET @index := -1;
 
SELECT
   ROUND(AVG(s.LAT_N), 4)
FROM
   (SELECT @index:=@index + 1 AS index, LAT_N
    FROM STATION
    ORDER BY LAT_N) AS s
WHERE
s.index IN (FLOOR(@index / 2) , CEIL(@index / 2));

```
Journey into Web Monetization - day 3
Tags: gftwhackathon, webmonetization
Published: 2020-05-12 10:58:18

After the first day of idea generation and the second day of learning, I thought I'd get into the more practial side of it and try to get something up to play around with.

Here's what I did:
- Connect to a Interledger testnet with moneyd
- Create an ILP stream server to connect to the moneyd instance.
- Generate stream credentials and send money

Run `npx moneyd local` to start the moneyd instance with a local testnet.

Next, set up a simple node project:
```sh
npm init -y
npm i -S ilp-protocol-stream ilp-plugin @interledger/connection-tag-utils
mkdir src
touch src/index.js
```
```js
// src/index.js
const { randomBytes } = require("crypto");
const { createServer, createConnection } = require("ilp-protocol-stream");
const { encode, decode } = require("@interledger/connection-tag-utils");
const createPlugin = require("ilp-plugin");

// Used for encoding and decoding connectionTag
const SECRET_KEY = randomBytes(32);

async function createStreamServer() {
  const server = await createServer({ plugin: createPlugin() });
  server.on("connection", (connection) => {
    // connectionTag contains encrypted data, in this case about the user account
    const { account } = JSON.parse(
      decode(SECRET_KEY, connection.connectionTag)
    );
    connection.on("stream", (stream) => {
      stream.setReceiveMax(10000);
      stream.on("money", (amount) => {
        console.log(`Received payment from ${account} for: ${amount}`);
      });
    });
  });

  return server;
}

async function sendMoney({ amount, destinationAccount, sharedSecret }) {
  const connection = await createConnection({
    plugin: createPlugin(),
    destinationAccount,
    sharedSecret,
  });

  const stream = connection.createStream();
  await stream.sendTotal(amount);
  await connection.end();
}

async function run() {
  const server = await createStreamServer();

  // Encode the user account here so we can use when we receive money
  const data = encode(SECRET_KEY, JSON.stringify({ account: "userAccountId" }));

  const { destinationAccount, sharedSecret } = server.generateAddressAndSecret(
    data
  );

  const amount = 10000;
  await sendMoney({ amount, destinationAccount, sharedSecret });
  await server.close();
}

run().catch((err) => console.log(err));

```
And finally run it:
```sh
npx nodemon src/index.js

Received payment from userAccountId for: 10000
```

- Plugins such as `ilp-plugin` determines where the server connects. It looks for env variable `ILP_BTP_SERVER` and defaults to `btp+ws://localhost:7768` if not found. This is the local moneyd instance.
- Data such as information about user or invoice can be encoded in the connectionTag. This will allow us to update databases for example.
- To create a stream client and send money we need: `destinationAccount` and `sharedSecret` which we can get from a server.

### Possible next steps
- Connect to a non-local testnet
- Send money between other wallets
- Build a REST server and handle different users and payment pointers
- Build a browser extension to handle the functionality currently in `sendMoney`
LeetCode: Valid Perfect Square
Tags: leetcode, datastructures, algorithms, binarysearch
Published: 2020-05-10 10:15:11

---
title: LeetCode: Valid Perfect Square
published: true
description: 09.05.2020
tags: leetcode, datastructures, algorithms, binarysearch
series: LeetCode May Challenge
---

### Problem Statement

Given a positive integer *num*, write a function which returns True if *num* is a perfect square else False.

**Note:** **Do not** use any built-in library function such as `sqrt`.

**Example 1:**

```
Input: 16
Output: true
```

**Example 2:**

```
Input: 14
Output: false
```

### Solution

```c++
class Solution {
public:
    bool isPerfectSquare(int num) {
        int L = 0, U = num;
        bool result = false;
        while(L<=U)
        {
            long long mid = L + (U-L)/2;
            long long squaredValue = mid * mid;
            if(squaredValue > num)
            {
                U = mid-1;
            }
            else if(squaredValue < num)
            {
                L = mid+1;
            }
            else 
            {
                result = true;
                break;
            }
        }
        return result; 
    }
};
```

### Solution Thought Process

We can solve the problem using linear time, where we are checking every value and it's square starting from 1. We will terminate the loop when we have found a square which is equal to the number. If we haven't found and the squared value is greater than the number, then we return false.



But we can do better here using binary search. We set the `L = 0` and `U = num`. We set the mid according to binary search rules. Then we calculate it's square value, if the square value is greater than num, it means that any number less than mid can have a chance for being the square root. So we adjust the upper limit to `mid-1`.

If we see that the squared value is less than num, then we can say that any number greater than mid can have a chance for being the square root. So we adjust the lower limit to `mid+1`.

If the squared value is equal to `num`, we return true and break the binary search.

Look out for integer overflow, we can solve it by setting `mid` and `squaredValue` into `long long int`.

### Complexity

**Time Complexity:** O(logn), we are just iterating over the points.

**Space Complexity:** O(1).
HOW INSTALL DENO IN ZSH AND RUN WITH JUST TYPING DENO.(NEWBIE-TIPS)
Tags: linux, deno, zsh, newbie
Published: 2020-05-12 10:46:27

It took me around half an hour to figure it out the way to install deno in my linux machine(debian)

and run just "deno"

The installation process is quite easy but newbie like me always gets confused. This is for those like who were not able to find the right way to install it and open the deno with single command deno.

My steps and procedure may be wrong or bad practice but this way I solved it

First step was to install the deno using 
    
     curl -fsSL https://deno.land/x/install/install.sh | sh

Just type it on the shell and it will download the bin file(executable file) file 

After this It will prompt to add the two file in .profile or .bashrc I followed the process was able to run the deno but  I was not able to use the shortcut "deno" what I did was  

     export PATH=~/.deno/bin/deno:$PATH

in our .bashrc file which is found in our ~(home directory of user). just type 
'la' in shell. we will find .bashrc if you are using bash terminal if not create one and add the above statement. I used vim for editing so after saving
and type the command.

      source ~/.bashrc

and by typing the deno it worked for me

If  it still doesn't work for you exit terminal and try it again.

Regarding zsh if the deno is not working we have to put the export command before zsh mentioned in .bashrc
Are you the next (Ruby) Thanos?
Tags: ruby, showdev, rubygems, webdev
Published: 2020-05-12 10:37:12

for fun, I asked myself:

Is there a way to know who is the best Ruby gem maker on the planet? Who is entitled to the title of **"Gemminator"**?

so I decided to write a Ruby script to take some information and get a score.

## Score

The score GS ( Gemminator Score ) is defined by the sum of two values. The RGS (RubyGems Score) and GHS (GitHub Score).

#### RGS

``` ruby
sum(downloads) + (1.0 - 1.0/count(gems))
```

#### GHS

``` ruby
sum(stars + forks) + (1.0 - 1.0/count(repositories))
```

#### GS

```
GS = RGS + GHS 
```

OK! Let's start writing some code!

## Gems

for data collection I use two gems that are:

[Gems](https://github.com/rubygems/gems) - Ruby wrapper for the RubyGems.org API https://rubygems.org
[Octokit](https://github.com/octokit/octokit.rb) - Ruby toolkit for the GitHub API http://octokit.github.io/octokit.rb/

## Script

you need a GitHub personal access token to avoid rate limit. A personal access token is a token you have generated (https://github.com/settings/tokens) that can be used to access the GitHub API.

``` ruby
  require 'octokit'
  require 'gems'

  downloads_count = 0
  stars_count = 0
  forks_count = 0

  client = Octokit::Client.new(access_token: ARGV[1])
  gems = Gems.gems(ARGV[0])
  
  downloads = gems.map do |gem| 
    gem['downloads']
  end
```

fetch counters

``` ruby
downloads_count = downloads.sum
  
gems.select! do |gem| 
  gem['homepage_uri'].to_s.start_with? 'https://github.com'
end

github_repos = gems.map do |gem|
  client.repo(gem['homepage_uri'].split("/").last(2).join("/")) rescue nil
end.compact
  
github_repos.map do |repo|
  stars_count += repo.stargazers_count
  forks_count += repo.forks
end
  
```

get results

``` ruby
rgs = downloads_count + (1.0 - 1.0 / gems.size)
ghs = stars_count + forks_count + (1.0 - 1.0 / github_repos.size)
  
gs = rgs + ghs
```

## Examples

```ruby
ruby gemminator.rb <rubygem_username> <github_access_token>
```


https://rubygems.org/profiles/davidesantangelo

```
➜ ruby gemminator.rb davidesantangelo <token>
110751.675
```

https://rubygems.org/profiles/ankane

```
➜ ruby gemminator.rb ankane <token>
43355989.97872341
```

https://rubygems.org/profiles/sferik

```
➜ ruby gemminator.rb sferik <token>
1519272118.937439
```

## Note

of course, it is a basic demo script without the management of all the exceptions/optimizations that can be found.

If you liked this post follow me [on Twitter!](https://twitter.com/daviducolo)
Swiss and Mithril
Tags: swiss, mithril
Published: 2020-05-09 22:05:03

Continuing my experimentation with [Swiss](https://swiss.netlify.app/), here is an integration with my favorite library

HTML part 
```html
<s-test count="0"></s-test>
<s-test count="10"></s-test>
<s-test count="40"></s-test>
<s-test count="180"></s-test>
```
JS part

```js
/* Look Ma, no hooks :-) */
let Counter = function (el) {
  let count = parseInt(el.getAttribute("count"));
  return  {
    view: () => [
      m("h1", `Counter : ${count}`),
      m("button", {onclick: () => count++}, "Inc")
  ]}
}

swiss.element("s-test", Counter, swiss.renderer(m.mount));  
```
You can play with it Here [Swiss&Mithril](https://flems.io/#0=N4Igxg9gdgzhA2BTEAucD4EMAONEBMQAaEAMwEskZUBtUKTAW2TQDoALAF0fmPSk6IBqEAB4YAWkExOAAkgBXAQF4AOiAAM6gHyiA9JOmdtqqOKmIZ8iEs5qQARi0hdBizJNnDluYpXqAFmdXbw9TcyNrW3sHAA5g-VDjPjwkME5yaGo0DRQNCQBmFAAmAE4QAF8ieiYWEFYAK2oSSAEhThFZUyQ5AGEbNoAnWWVZUiV0zKhZAApEeABKWWBTWVkeqIER2WxMQbwASQE5+FYAc0ROAEFOTkHyACMFQRn1P051BYWAblXZQcuCkG02WfzWADdyIgAO4oWZLZTaWQ0MFrWSMV4gdgOdREWQAA36tkQwzhABJgO8KviFkRUWsMeonrdoLjltAwPByGAANZwmYIpHvADUwqqXRARzAnz+AF0KqYFVBTDBoeQYDBWPNEMxjuokmyiUM8ar1ZqAVB8CSSTNGKxGANOF9vmtTKY+JBGNhKCSRA9MA95iltZMsiIHMU8pVqiAGMwRKwwBqPdBBMI0JVZSQuVAedk6LHaiJGOROOx7rwSEDeGguJxcCg9HolNgeWdExBGHoS2WKwABYqsDSsALd0vlyj28hQRrNECcACe2DqMDA92wHSqNXjaFNyargxrWNuDabLbbHa7e5gfYcrEHDj0+HVnAMao1s74i+XIlX6838pAA)
Developer relations in the post-COVID era with Patrick McFadin
Tags: devrel, podcast
Published: 2020-05-12 10:33:39

**Trick question of the week:**
*What’s in the future of developer relations, especially after COVID-19?*

The pandemic forced all companies to shift strategies mid-Q1. But how does this affect developer relations?

Events, the cause burnouts for many developer marketing, relations, advocates and evangelists are currently out of the mix. So is the opportunity for reaching developers, 1-on-1, face-to-face. Software has come to cover this hole by many applications. What does the future hold and how can we connect to developers when we can’t reach them in person?

Patrick McFadin, VP of DataStax joins us in this episode to discuss connecting with developers in the COVID era and post-COVID era, open source and the challenges developer relations professionals face.

In this episode, we introduce the “Let’s talk Data” section where we pick one graph from the DevRelx Trends page and analyze the results. Patrick's pick for this week: [programming language communities and growth] (https://www.devrelx.com/trends?lightbox=dataItem-k9mq59cz1?utm_source=devto&utm_medium=PatrickMcFadin&utm_campaign=Article).

Listen to the episode [here] (https://www.devrelx.com/podcast/episode/33208599/developer-relations-in-the-post-covid-era?utm_source=devto&utm_medium=PatrickMcFadin&utm_campaign=Article).

**Patrick McFadin** *is the Vice President of Developer Relations at DataStax. He is one of the leading experts of Apache Cassandra and data modelling techniques and has helped build some of the largest and exciting deployments in production. Previous to DataStax, he was Chief Architect at Hobsons and an Oracle DBA/Developer for over 15 years.*

[Originally published at DevRelx News.] (https://www.devrelx.com/news?utm_source=devto&utm_medium=PatrickMcFadin&utm_campaign=Article) 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/e5copzn7cinlyfd8h6gr.jpg)
Solving consent_required Auth0 SPA SDK
Tags: auth, auth0
Published: 2020-05-12 10:26:09

I've been playing with the Auth0 SPA SDK https://auth0.com/docs/libraries/auth0-spa-js

# What's wrong
I keep running into an issue where I an error is thrown with code `consent_required` when trying to initialise the Auth0 client by calling `createAuth0Client` that is brought in from the library `import createAuth0Client from "@auth0/auth0-spa-js"`. 

# Why's it's going wrong
Reading into it this is because the `createAuth0Client` function is calling `getTokenSilently` as part of the creation. This call fails when a user has a current session but the parameters of the authentication have changed to require the user accepts some updated conditions.  

Examples of where this is going to happen are adding or modifying the `useRefreshTokens`, `scope`, or `audience` properties passed to `createAuth0Client`.  

Note: This will only happen the first time that these permissions are introduced for a user. If the logged in user has previously accepted these the prompt will not be required and the client will be created successfully. 

# How to fix it
The short answer is you need to log the user out so that they can accept the updated conditions you've required. There are two options for how to do this. 

If, like me, you're still in the process of experimenting and testing on your local machine. Make sure you've logged your test user out before making changes to the parameters passed to `createAuth0Client`. Possibly undoing the changes, logging the user out, and then making the changes. 

Asking your users to log out so that you can deploy an update isn't going to scale. If you have an application in production or if you've got users on other machines then you'll need a more programatic solution. 

In this case you can use the `Auth0Client` class constructor that can be brought in from the same `@auth0/auth0-spa-js` package to create the auth0 client. Fortunately it takes the same options as `createAuth0Client` so it's an easy switch out. Using this to create an instance of `Auth0Client` you can then programmatically log users out, when they log in again they'll see the prompt and be able to log in and continue using your app.
Do students know this?
Tags: github, beginners, computerscience, codenewbie
Published: 2020-05-12 10:26:03

Did you know that if you're a student and currently enrolled in some course, you can get a free GitHub pro account, access to many online learning resources, and developer tools for free?

Well, I didn't know about it until recently, which means that I have wasted two and a half years of benefits that I could've availed during my course of study. But, better late than never, right?

GitHub offers this pack called [Student Developer Pack](https://education.github.com/pack) where you get the benefits mentioned above and all you have to do is sign up on [GitHub](https://github.com/) and fulfill these [requirements](https://help.github.com/en/github/teaching-and-learning-with-github-education/applying-for-a-student-developer-pack#requirements).

## A Quick Overview

This program offers tons of stuff to choose from. Here I have mentioned some of the highlights of the program:

### For those interested in Data Science 
If you want to become a Data Scientist then using this pack you can get free three months access to [DataCamp](https://www.datacamp.com) which is an awesome platform to learn Python, R, and all the stuff related to Data Science.

### Miscellaneous Learning Resources
If you're interested in Web Development then you can get a free 6-month subscription of [Frontend Masters](https://frontendmasters.com/) or a 1-month subscription of [OneMonth](https://onemonth.com/). If it's other programming skills that you would like to develop then you can get a 6-month subscription of [Educative](https://www.educative.io).

### Preparation for Interviews
This pack provides 3-week access to [Interview Cake](https://www.interviewcake.com) which can help you prepare for your next interview.

### Domains
Want to set up a portfolio site? Get a free domain name for one year from NameCheap, Name.com and .Tech Domains using this pack.

### Unity for Game Developers
If you want to step up your game development skills, then you can get free access to Unity and its resources while you're a student.

### Tools for Developers
GitHub offers a huge list of tools that you can use like Heroku, Bootstrap Studio, Arduino, MongoDB, etc. 

So go ahead and register in the program to get these benefits and make the most of it. Happy learning and happy coding!

If you would like to discuss anything, then feel free to drop a comment or head over to [Twitter](https://twitter.com/HassanSb_), that's where I usually hang out.