teleren/devto huggingface dataset:
How to show specific information to specific users in Postgress
Tags: postgres
Published: 2020-11-27 03:22:31

In the first place, we need to define a view, A view is a database object that is of a stored query. A view can be accessed as a virtual table in PostgreSQL. In other words, a PostgreSQL view is a logical table that represents data of one or more underlying tables through a SELECT statement. 
For this example, we are going to allow students to see their grades for their subjects but we do not want that they can see the grades of their classmates, so we will construct a view where the condition validates the user that is logged in.
```
CREATE VIEW student_view AS
select e.code, e.name, i.code_subject , s.name_subject , i.n1 , i.n2, i.n3 
, ((coalesce(n1, 0))*.35+(coalesce(n2, 0))*.35+(coalesce(n3, 0))*.30) finalNote
from suscribe i
natural join student e 
natural join subject s
where cod_e::text = current_user
```
Next, we need to define a group role which will have permission only to see the information in the view previously created.
```
CREATE ROLE students;

GRANT SELECT ON student_view TO students;
```
The last step is to create with login the users of our students and grant them group students permissions.
```
CREATE ROLE "200001"
LOGIN 
PASSWORD '200001';

GRANT students TO "200001";
```
When the user 200001 log in into the database only the information from the view will be shown as you can see in the example.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/f1g5s92trrsoipfh9vvv.PNG)

Finally, I want to recommend to you guys the user of [DBeaver](https://dbeaver.io/) is a free multi-platform database tool for database administrators and allows to have multiple connections to the same database with different users in a really simple way for PostgreSQL (easier than pgAdmin 4 )

Thank you so much for reading and I hope this information will be helpful to you!!
Visual Studio Code Shortcuts
Published: 2020-11-27 03:21:10

**1. Toggle sidebar: **
`Ctrl + B`
**2. Open settings: ** `Ctrl + ,`
**3. Quick open a file:** `Ctrl + P`
**4. Tab through open files:** `Ctrl + tab`
**5. Move file to split window:** `Ctrl + \`
**6. Close file:** `Ctrl + W`
**7. Search/Replace file:** `Ctrl + F`
**8. Global search/ Replace:** `Ctrl + Shift + F`
**9. Open command pallete:** `Ctrl + Shift + P `
**10. Comment Line:** `Ctrl + K + C`
**11. Uncomment Line:** `Ctrl + K + U`
**12. Navigate Text:** `Hold down alt/ctrl`
**13. Duplicate line:** `Shift+alt+up/down`
**15. Mutiple cursors:** `Ctrl+cmd + click `
**16. Select word:** `Ctrl/cmd + D`
**17. Select all instance of a selected word:** `Ctrl/cmd + Shift + L`
**18. Rename symbol:** `F2`
**19. Jump to funciton defination:** `ctrl/cmd + click `
**20. Zen mode:** `ctl/cmd + K Z`
Code Smell 35 - State as Properties
Tags: oop, tutorial, webdev, programming
Published: 2020-11-27 03:08:05

*When an object changes its state the best solution is to change the attribute, isn't it?* 

# Problems

- Mutability

- Attributes polluting

- Setters

# Solutions

1 - Model states as mathematical set inclusion.

2 - State is accidental, take it away from the object.

# Examples

- State diagrams

# Sample Code

## Wrong

{% gist https://gist.github.com/mcsee/817257ca2966c8f2381dcf9887dfa1a4 %}

## Right

{% gist https://gist.github.com/mcsee/1b98448f97cd23b6b5f8438280b73736 %}

# Detection

If we want to be extreme, we should consider every *setter* to be a potential state change. Linters can warn us. But we might end up getting too many false positives.

# Exceptions

- Over Design

- Performance issues (if a serious benchmark supports it).

{% post https://dev.to/mcsee/code-smell-20-premature-optimization-4moe %}

# Tags

- Mutation

# Conclusion

This technique is very elegant but can lead to over design. For example changing a visual component its color should be a counterexample to this smell. 

We should be aware and very caution like with any other smell.

They are *hints* and not rigid rules.

# Relations


{% post https://dev.to/mcsee/code-smell-28-setters-2hih %}
 
# More info

[Mutants](https://maximilianocontieri.com/the-evil-powers-of-mutants)

# Credits

Photo by <a href="https://unsplash.com/@tomcrewceramics">Tom Crew</a> on <a href="https://unsplash.com/s/photos/porcelain">Unsplash</a>

* * *

> First make the change easy (warning: this might be hard), then make the easy change.

_Kent Beck_
PHP 8!

Tags: php, php8, webdev
Published: 2020-11-27 02:39:33

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/uuentmv7t6edynw4ywbw.png)

PHP 8.0 is a major update of the PHP language.
It contains many new features and optimizations including named arguments, union types, attributes, constructor property promotion, match expression, nullsafe operator, JIT, and improvements in the type system, error handling, and consistency

See the super-slick announcement in 4 languages here:
https://www.php.net/releases/8.0/en.php
Async & await explained in short
Tags: javascript, webdev
Published: 2020-11-27 02:34:05

Async & await basically just syntactic sugar on top of promises. Here is my latest post and very short and amazing explanation of Async and await.

<hr>

If you use the **async keyword** before the function definition, you can then use **await** within the function. Await gives you the power to pause the function in a non-blocking way until the promise is settled. 

If the promise fulfils, you get the value **back**. If not, the rejected value is **thrown**. Here is a perfect example for you below:- 

```javascript
async function fetchUsers( endpoint ) {
  const res = await fetch( endpoint );
  const data = await res.json();
  const usernames = data.map( user => user.username);
  console.log(usernames);
}

fetchUsers( 'https://jsonplaceholder.typicode.com/users'); 
/* 
["Bret", "Antonette", "Samantha", "Karianne", "Kamren", "Leopoldo_Corkery", "Elwyn.Skiles", "Maxime_Nienow", "Delphine", "Moriah.Stanton"]
*/
```

First, the given endpoint is fetched. At this point, the function pauses until the fetch Promise is fulfilled. 

After that, the response is read and parsed as JSON. Because we await that too, `JSON()` is a **Promise** aswel, we pause the function again until it is fulfilled. 

When that's all done we can use the data retrieved and for example map it and log it to the console.  

### What is one of the awaits gets rejected?  

=> We can add a `catch()` to every single await because they're just normal Promises!
 
With the catches added to the awaits, our function will look like the example below. 

```javascript
async function fetchUsers( endpoint ) {
  const res = await fetch( endpoint ).catch(e => console.error(e.message));
  const data = await res.json().catch(e => console.error(e.message);
  const usernames = data.map( user => user.username);
  console.log(usernames);
}
```
<hr>
Read More :- 
- [map() method explained](https://dev.to/rahxuls/map-method-explained-3g6m)
- [filter() method explained](https://dev.to/rahxuls/filter-method-explained-js-39og)
- [Window Object in JavaScript](https://dev.to/rahxuls/window-object-in-javascript-2h7)


<hr>
### Help Needed Plz
Need help in raising fund to buy a Mechanical Keyboard. This pandemic has affected my family badly so can't ask my DAD for it. Please Help Me. 

<a href="https://www.buymeacoffee.com/rahxuls">
![1.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1606540958103/otN4S9TK8.png)
</a>

<hr>

This was something short I wanted to share!              
⚡Happy Coding.
You Could Write Simpler Code in Android: Monitoring Changed Text in An EditText Field
Tags: android, androidlayout, codenewbie, ontextchanged
Published: 2020-11-27 01:57:11

While working on my recent project, several times while trying to implement a feature I came across several articles online whose code advocated writing long lines of code. This could be as a result of the articles being written a long time ago(In android, a long time could be as short as six months). This informed my choice to create a series where I highlight simpler ways of writing code than the ones commonly available online when using ktx extensions.

This article is going to be a short one just to illustrate how much fewer lines of code you could write. A particular scenario you might be faced with is getting the changing text when a user inputs value into an edittext field. The situation might also mean you want a particular event to occur anytime the text in the field changes. 

To accomplish this task, a cursory search on google might take you to a stackoverflow page where the top three answers may look like this one:


![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/knyqmujep3wffgljxcsu.png)


Or this one:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/aw0e3w958cga3c84urb2.png)

After seeing these answers you get the feeling that you are writing a lot of code just to get the text that was changed or to be notified when the text changes. Don't worry I get the feeling. I had the same exact feeling


<img width="100%" style="width:100%" src="https://media.giphy.com/media/cdkQ2bLcwOE1cEzEeL/giphy.gif">

I discovered that it could be accomplished with just three lines of code. A call to the doOnTextChanged was enough to do my bidding.

{% gist https://gist.github.com/kolanse/c565d282c1ab373f8f47d1999239cae2 %}

My next article would be on Navigation drawer stay tuned
KVision v3.17.0 is released (with IR backend support)
Tags: kvision, kotlin
Published: 2020-11-27 01:05:57

---
title: KVision v3.17.0 is released (with IR backend support)
published: true
description: KVision is an open source web framework created for Kotlin/JS.
tags: kvision,kotlin
---

[KVision](https://kvision.io) is an open source web framework created for Kotlin/JS. It allows developers to build modern web applications with the Kotlin language.

I have released KVision 3.17.0, the first version of the framework supporting new [Kotlin/JS IR compiler backend](https://kotlinlang.org/docs/reference/js-ir-compiler.html). All artifacts are published in ["both"](https://kotlinlang.org/docs/reference/js-ir-compiler.html#authoring-libraries-for-the-ir-compiler-with-backwards-compatibility) mode, so you can now choose the legacy or the IR compiler for your applications.

All [examples](https://github.com/rjaros/kvision-examples), both frontend and fullstack, have been tested and are fully compatible with new backend.

However, note that we are still impatiently waiting for Kotlin 1.4.30, which will fix [important bug](https://youtrack.jetbrains.com/issue/KT-41227) and make KVision really usable with IR. Until then, the legacy backend is still the one to be used by default.

For more details about this release see the [changelog](https://github.com/rjaros/kvision/releases/tag/3.17.0).

Don't forget to ⭐️ my [project](https://github.com/rjaros/kvision) if you like it!

As always, any feedback is appreciated!
Concurrency trong Go: Tạo goroutine
Tags: go, concurrency, goroutine, techmaster
Published: 2020-11-27 00:39:08

Video hướng dẫn cách tạo goroutine với từ khóa go:

{% youtube JA-HoQFH5GM %}

Tham khảo code được sử dụng trong bài:
```go
package main

import (
	"fmt"
)

func printNumber() {
	for i := 0; i <= 100; i++ {
		fmt.Printf("%d ", i)
	}
}

func printChar() {
	for i := 'A'; i < 'A'+26; i++ {
		fmt.Printf("%c ", i)
	}
}

func main() {
	go printNumber()
	go printChar()
}

```
Azure Functions University - Queue Lesson (.NET Core)
Tags: azure, serverless, programming, dotnet
Published: 2022-03-16 20:03:02

---
title: Azure Functions University - Queue Lesson (.NET Core)
published: true
date: 2020-11-27 00:00:00 UTC
tags: azure, serverless, programming, dotnet
canonical_url: https://blog.marcduiker.nl/2020/11/27/azfuncuni-queue-lesson-dotnet.html
series: Azure Functions University
---

![Queue Lesson .NET Core](https://blog.marcduiker.nl/assets/2020/11/27/AzureFunctionsUniversity_Queue_Lesson_dotnetcore.png)

Hi serverless friends, we have a new Azure Functions University lesson for you! In this lesson we will learn how to use the Queue trigger and bindings in Azure Functions written in .NET Core 3.1.

<!--more-->
## Lesson

You can find the lesson on GitHub: [Queue Trigger & Bindings (.NET Core)](https://github.com/marcduiker/azure-functions-university/blob/main/lessons/dotnetcore31/queue/README.md).

And you can watch the video on YouTube:
{% youtube nKJUwW6SGZo %}

The lesson consists of the following exercises:

| Nr | Exercise |
| --- | --- |
| 1 | Using the Microsoft Azure Storage Explorer for Queues |
| 2 | Using `string` Queue output bindings |
| 3 | Using custom typed Queue output bindings |
| 4 | Using `CloudQueueMessage` Queue output bindings |
| 5 | Using `dynamic` Queue output bindings |
| 6 | Using `IAsyncCollector<T>` Queue output bindings |
| 7.1 | Creating a default Queue triggered function |
| 7.2 | Examine & Run the Queue triggered function |
| 7.3 | Break the Queue triggered function |
| 7.4 | Change the Queue triggered function |
| 8 | Homework |
HTTP Error Code Cheat Sheet
Tags: http, errors, cheat, sheet
Published: 2020-11-26 23:07:07

Working on some more cheat sheets, if there is a subject or topic you'd like to see Cheat Sheets for let me know in the comments section and I'll make that happen. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/z7f25zkhnws76x7uudbc.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/dfvfejk0cdkofr1ux8qu.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/sgfdt192jmswu321fd29.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/c9q6j8lltugdqiqmqyh6.png)

Download as PDF: 
shorturl.at/nuxOR
How to remove empty elements from an array in JavaScript?
Tags: javascript
Published: 2020-11-27 00:00:00

---
  title: How to remove empty elements from an array in JavaScript?
  published: true
  tags: JavaScript
  date: Fri Nov 27 2020 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/remove-empty-elements-from-array-javascript
  cover_image: https://melvingeorge.me/_next/static/images/main-b3e8f1463f6d93c3b2fc9f6579e4655b.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/remove-empty-elements-from-array-javascript)
  
To remove empty, `null`, or `undefined` elements from an array, we can use the `filter()` array method and pass a function to the method which returns the element currently getting looped.

### This method works because when an empty, `null` or `undefined` item is looped, it evaluates to boolean `false` which will then be filtered out from the array.

Consider this array with some empty elements,

```js
// array with empty elements
const arr = [1, , , , 2, 3, 4, 56, "text", null, undefined, 67, ,];
```

Our goal is to remove the empty elements and also the `null` and `undefined` values from the array.

So let's use the `filter()` array method and pass a function which returns the item itself like this,

```js
// array with empty elements
const arr = [1, , , , 2, 3, 4, 56, "text", null, undefined, 67, ,];

// use filter() array method
// and return the element which is being looped
const newArr = arr.filter((a) => a);

console.log(newArr); // [1, 2, 3, 4, 56, "text", 67] ✅
```

Yay! 😃 We got our new array with all the empty, `null`, `undefined` values removed from the array.

See this example live in [JSBin](https://jsbin.com/bovodinomu/2/edit?js,console).

## Alternate method: Iterating using a `for loop`

Another way is to use a `for loop` and check if the element evaluates to `true` inside the loop and if it does add that element to the new array this,

```js
// array with empty elements
const arr = [1, , , , 2, 3, 4, 56, "text", null, undefined, 67, ,];

// make a new array
// to hold non-empty values
const newArr = [];

// use for loop
// check if element exists
// and if it exists push to the
// new array
for (let i = 0; i < arr.length; i++) {
  if (arr[i]) {
    newArr.push(arr[i]);
  }
}

console.log(newArr); // [1, 2, 3, 4, 56, "text", 67] ✅
```

See this example live in [JSBin](https://jsbin.com/guwiceqowu/2/edit?js,console).

### Feel free to share if you found this useful 😃.

---
Только то, что важно для проверки
Tags: ruby, rspec, testing
Published: 2021-01-19 11:09:02

---
title: Только то, что важно для проверки
published: true
date: 2020-11-27 00:00:00 UTC
tags: ruby, rspec, testing
canonical_url: https://vasily.polovnyov.ru/posts/minimal-expect.html
---

Ситуация: нужно убедиться, что мы списываем с пользователя правильную сумму, когда он воспользовался скидкой. Важный момент: у класса, отвечающего за это, увесистый АПИ с обязательными аргументами. Делаем первый подход:

```ruby
context "when coupon is applied" do
  it "charges user $500" do
    allow(Cashier).to receive(:charge)

    purchase.perform

    expect(Cashier).to have_received(:charge)
      .with(
        user: user,
        sum: 500,
        description: "Покупка абонемента",
        coupon: coupon
      )
  end
end
```

Если оставить тест как есть, он будет отвлекать деталями совершенно не важными для проверки: пользователь, описание списания, купон. Раз мы хотим убедиться, что изменилась сумма, то и проверять нужно только сумму:

```ruby
context "when coupon is applied" do
  it "charges user $500" do
    allow(Cashier).to receive(:charge)

    purchase.perform

    expect(Cashier).to have_received(:charge)
      .with(hash_including(sum: 500))
  end
end
```
Finding the largest favicon with js
Tags: javascript, webdev
Published: 2020-11-26 23:27:16

As part of an audit I wanted to fetch the highest quality favicon for every page that we check. It turned out to be slightly more complicated than I thought:

[These](https://stackoverflow.com/questions/2057636/get-websites-favicon-with-js) [stackoverflow](https://stackoverflow.com/questions/1990475/how-can-i-retrieve-the-favicon-of-a-website) [posts](https://stackoverflow.com/questions/10282939/how-to-get-favicons-url-from-a-generic-webpage-in-javascript) suggest a few ways to get the favicon, but they all share a few issues:


* It depends on a 3rd party (eg [Google](https://www.google.com/s2/favicons?domain=www.bbc.co.uk))


* It ignores the default `/favicon.ico`, or uses it incorrectly


* It returns the first favicon, instead of the largest one



### How the browser chooses a favicon

The standard way to include a favicon is with a link tag `<link rel="icon"..` You can use multiple link tags to specify different sizes, for example:


```
<link rel="icon" sizes="16x16" href="/favicon_16.png">
<link rel="icon" sizes="32x32" href="/favicon_32.png">
```
Another popular variant is `<link rel="shortcut icon"..`


```
<link rel="shortcut icon" href="/favicon_32.png">
```
If none of these tags are present the browser will make a request to the `/favicon.ico` file at the root directory. Some servers are badly configured though and will return an `200 OK` status even if the file is not present, so to be sure you have to check that the file is indeed an image.

### The solution

The following codes combines all these factors, and loops through the available favicons to return the largest one.


```
// Get the largest favicon in the current document, or false if none is found.
let getLargestFavicon = async () => {
  let getSize = el => {
    return (el.sizes[0] && parseInt(el.sizes[0], 10)) || 0;
  };
  let favicons = [
    ...document.querySelectorAll('link[rel="shortcut icon"],link[rel="icon"]')
  ].sort((a, b) => {
    return getSize(b) - getSize(a);
  });
  if (favicons.length > 0) {
    return favicons[0].href;
  }
  // no favicon is specified in the meta tags, lets try the default /favicon.ico
  let defaultLocation = document.location.origin + "/favicon.ico";
  let r = await fetch(defaultLocation);
  if (r.ok) {
    let t = await r.blob();
    if (t.type.indexOf("image") !== -1) {
      return defaultLocation;
    }
  }
  return false;
};
```
 Originally published at <https://blog.pagewatch.dev/post/finding-the-largest-favicon-with-js>
📈 Your Results Indicate You Are a Level 4 Stable Genius
Tags: team, results, management
Published: 2020-11-26 23:23:11

👥 How personality tests are whatever you want them to be...
[Read more...](https://auth0.com/blog/your-results-indicate-you-are-a-level-4-stable-genius/?utm_source=content_synd&utm_medium=sc&utm_campaign=stable_genius)
Dual Track at Adevinta Spain
Tags: agile, product
Published: 2020-11-26 23:11:57



Dual Track is not new, but a trendy concept nowadays within the Agile and Product domains. 

In this short talk (30'), Victor Solà (UX Director at Adevinta Spain) and me, will cover briefly the nuts and bolts of the Dual Track initiative we are running at Adevinta Spain.

This talk was part of the 1st Adevinta Agile Conference, held online in October 2020, across several Adevinta's organizations.

{% youtube 3i-SqdEvrVU %}
Internal CRM update 1.0.7
Tags: motivation, release
Published: 2020-11-26 22:55:53

- Reintroduced matchmaking (beta)
- Added more menus in default
- Matchmaking now reads job description to search for keywords matches
- Added matchmaking listing view
- Preparation for keyword cloud based on job description, and parsing top 3 skills for the matchmaking engine
- Added random quotes on dashboard for inspiration / motivation
My 2k20 experience
Tags: microclubusthb, github, hacktoberfest, opensource
Published: 2020-11-26 22:51:22

Hello **DEV Community** ! *My name is Messaoud Sihem Fadia*, and i usually go by *Mehis*, I'm a freshman year computer science Student at the *University Of Science And Technology Houari Boumediene* in Algiers, And in this post I'm gonna try to talk about my journey so far as a student.
Since this was my first year in university, I'm still a beginner when it comes to computer science. Due to the current pandemic that the world is going through we barely had to go through the basics, But luckily i had the chance to become a part of a student Club based in our university, **MicroClub** to be more specific. [The Microclub facebook page link](https://www.facebook.com/Micro.Club.USTHB),[and Microclub Instagram page link](https://www.instagram.com/microclub_usthb/)
being a member provided me access to a community full of supportive and kind people, that are always willing to help and to share their knowledge, which gave me the opportunity to have a grasp over the basics of *Html, css, js,c* ...ect. It also taught me how to be better at team work and to be more confident when expressing my ideas. More over I had the opportunity to see first hands how events are organized and what goes on in back scenes .
The most recent Event i had to be part of was **Hacktoberfest**, and it was my first contact with the concept of opensource. so even tho i still do not know much about it, i still learned alot
So overall, i can safely state that it provided me with a great working environment, where i learn new things everyday.
Thank you ^^ .