teleren/devto huggingface dataset:
Quick Way to Assign Colour Values to Administrative Boundaries in QGIS
Tags: gis, qgis
Published: 2021-04-08 03:22:43

A while back, I was tasked to assign RGBA colour values (derived from an existing field) to each administrative boundary in a shape file.

The first approach I tried was to assign the RGBA colour values to each administrative boundary manually. This manual approach was fine for shape files with small number of administrative boundaries. However, as I dealt with more shape files with larger numbers of administrative boundaries, it was obvious that this approach was not going to work. It would take me ages to complete assigning colour values to all the boundaries!

My supervisor and I explored different approaches to do this tedious task quicker. After a few tries, we decided on an approach that fits our needs and is relatively quick to do. In this article, I'll share how we assigned colour values to a shape file representing more than 1000 Switzerland's municipalities.

#Chosen Approach
1. Select layer and right click then `Open Attribute Table`
2. Find out which field to use for colour assignment. In this case: `GDENR`
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wal49fcnt7wemgiwcpeo.jpeg)
3. Under `Processing` tab, select `Toolbox`. In the `Processing Toolbox`, expand `Vector table` and double click `Field calculator`
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a9opiwsw162yqunamjg1.jpeg)
4. In the `Field calculator` window,
   1. Ensure `Input layer` is the layer to reference from
   2. Enter a name in the `Output field name`. In this case: `B`
   3. Set `Output field type` to be `Integer`
   4. Set `Output field width` to be `3`
   5. In the `Expression` tab, key in `GDENR%256` for `B`
   6. Click on `OK` and a temporary layer will be created
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6yuewv0hkfy5a4u7npdn.jpeg)
5. Check newly created temporary layer for newly created field
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8f1z7m96czi89ym3kokj.jpeg)
6. Repeat step 4 for the rest of the colour channels, modifying only steps 4.2 and 4.5
   * Enter either `R`, `G` or `A` in `Output field name`
   * For `R`, key in `floor((GDENR/65536)%256)` in the `Expression` tab
   * For `G`, key in `floor((GDENR/256)%256)` in the `Expression` tab
   * For `A`, key in `255` in the `Expression` tab

That's it! Hope this helps and do share if you know of better ways to do this in the comments.
Angular VS React 🥊
Tags: react, angular, webdev, discuss
Published: 2021-04-08 03:04:06

Una de las preguntas que más me hacen en las entrevistas laborales es: **'¿Cual es mejor para ti? ¿Angular o React?'**. Lo que tenemos que tener claro es que ambos tienen características que pueden o no ayudarte en el desarrollo de tu aplicación. A continuación entraremos más en detalle.

##Peso de la aplicación el producción##

Un punto bastante importante es el peso final del bundle de nuestros proyectos, en este caso una aplicación estándar de react bien desarrollada genera un bundle mucho más ligero que una aplicación desarrollada en Angular con similares características.

##Flexibilidad vs trabajo estricto##

En mi opinión personal y habiendo trabajado con ambas herramientas en proyectos grandes y medianos, puedo decir que React ofrece cierta libertad que no encuentras en Angular. Además, posee mayor cantidad de compatibilidad con *third party libraries* lo que puede ser beneficioso para agregar funcionalidades de forma rápida. Por otro lado, con Angular el manejo de la aplicación es más estricta y rigurosa, haciendo que desarrollemos bajo patrones estrictos. Un claro ejemplo sería el patrón MVC o MVP. Además, al tener como base TypeScript, nos obliga a tener nuestras variables tipadas.

##Manejo de formularios##

Si bien en React podemos utilizar Formik, React Hooks Form u otra forma para manejar formularios, cuando usamos Angular tenemos la característica de los **reactive forms**, que son bastante poderosos si se usan de forma correcta. Nos permite manejar formularios dinámicos con campos a donde podemos suscribirnos y escuchar por cambios.

##Estructura de carpetas##

Angular tiene bien definida la estructura a seguir para las aplicaciones. Almacenando métodos compartidos en **servicios**, manejando transformadores de data en **pipes** e incluso agrupando componentes en **módulos**. Por otro lado, React tiene mucha más flexibilidad y te permite ordenar tus componentes como mejor te parezca. Si bien esto se oye genial, puede causar que los principiantes creen proyectos enredados y poco mantenibles.

PO: ambas herramientas tienen una finalidad, desarrollar componentes del lado del cliente. Si bien la forma de trabajo es distinta, lo ideal es poder entender bien las bases y trabajar con el que te sientas más cómodo. Algo que casi seguro es que si dominas uno y dominas **JS/TS**, podrás trabajar con cualquier framework frontend. 😎
BFE.dev #8. can you shuffle() an array?
Published: 2021-04-08 02:52:23

> [BFE.dev](https://bigfrontend.dev) is like a LeetCode for Front End developers. I’m using it to practice my skills.

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


This article is about the coding problem [BFE.dev#8. can you shuffle() an array?](https://bigfrontend.dev/problem/can-you-shuffle-an-array)

## Analysis

The goal is to shuffle an array, seems pretty easy. Since shuffle is choose one of the all possible permutations, so we can choose the item one by one randomly from rest possible positions.

```js
function shuffle(arr) {
  for (let i = 0; i < arr.length; i++) {
    const j = i + Math.floor(Math.random() * (arr.length - i))
    ;[arr[i], arr[j]] = [arr[j], arr[i]]
  }
}
```

## Code Not working

```js
function shuffle(arr) {
  for (let i = 0; i < arr.length; i++) {
    const j = Math.floor(Math.random() * arr.length)
    ;[arr[i], arr[j]] = [arr[j], arr[i]]
  }
}
```

Above code looks working but actually not. It loops all the positions and randomly swaps with another. 

Suppose we have an array of [1,2,3,4]. 

Let's look at number 1. The first step is to swap 1 with all 4 positions, chance is high that it is moved to the positions other than itself and later it is traversed and swapped again.

Now let's look at number 4. It is last number to be traversed, and it might be also swapped before its turn and never be traversed again.

So 1 and 4 have different chances of be swapped, 4 is obviously lower, so the result array is not randomly shuffled.


## Passed

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

Here is my video explaining: https://www.youtube.com/watch?v=FpKnR7RQaHM


Hope it helps, you can have a try at [here](https://bigfrontend.dev/problem/can-you-shuffle-an-array)
indigenous linguistic app hopeful
Tags: linux, swift, android, ios
Published: 2021-04-08 02:31:49

I am a college student and basic indigenous language learner and instructor (southern interior salish language Moses-Columbia dialect) and I am stumbling my way to learn how to build web-based, cloud-based, teaching learning tools that will aid and direct a new generation of indigenous peoples in the use of carrying on languages and traditions which in the new age of techmology are being lost. Hopeful to gain insight and partnerships to acheive meaningful work to help the people.
Why your website should have a Skip Link?
Tags: webdev, css, html, codenewbie
Published: 2021-04-08 01:47:46


It's critical that any web pages you create are accessible to all. Unfortunately, it's something that's often ignored and neglected.

This quick and easy tutorial will show you how to add a skip link to your page to make it more accessible. It's usually a good idea to incorporate accessibility into something you're making because it usually results in a much better overall product.

---

### What is skip link? 

It is a link that lets the user skip to the main content of the page. It's usually hidden and becomes visible when it's in focus. 


### When and Why you need? 

If a user is navigating a site with their keyboard they will usually is the tab key to go through the links and bottoms in your page. 

So this means they will have to tab through each link in your navigation (since it's usually at top) before they get to the main content every time they navigate between pages. 

(WHICH IS ANNOYING😬😬)

Having a link that will skip past all that and scroll straight to the main content of the page will make the process less frustrating and more accessible. 

Let's see

HTML: 

```html
<body>
  <a class="skip_link" href="#main">
    Skip to main
  </a>  
            <!--HEADER AND NAVIGATION HERE -->
   <main id="main"> 
     <h1>Heading</h1>
     <p>First paragraph...</p>
   </main>
</body>   
```

CSS: 

```css
.skip_link {
    position: absolute;
    top: -1000px;
    left: -1000px;
    height: 1px;
    width: 1px;
    text-align: left;
    overflow: hidden;
}

.skip_liink:active, 
.skip_link:focus, 
.skip_link:hover {
     left: 0;
     top: 0;
     width: auto;
     height: auto;
     overflow: visible;
}
```

Have you used skip links? No? Give it a try!

---

🚀Thanks For Reading | Happy Coding🌃
Dart Bencode Package 
Tags: dart, dartlang
Published: 2021-04-08 00:19:30

Update Dart Bencode Package

https://github.com/kyorohiro/dart2.bencode

- support SDK  
 - dart:io
 - dart:html

```
sdk: '>=2.12.0 <3.0.0'
```

- for dart v1 is here    
https://github.com/kyorohiro/dart.bencode

# Usage

```yaml
dependencies:
  info.kyorohiro.dart2.bencode:
    git:
      url: https://github.com/kyorohiro/dart.tiny_parser.git
      ref: v0.0.2
```

```dart
import 'package:info.kyorohiro.dart2.bencode/bencode.dart';
import 'package:dart2/dart2.dart';

{
  var out = Bencode.encode(1024);
  unit.expect('i1024e', convert.utf8.decode(out.toList()));
  num ret = Bencode.decode(out);
  unit.expect(1024, ret);
}

{
  var out = Bencode.encode('test');
  unit.expect('4:test', convert.utf8.decode(out.toList()));
  var text = Bencode.decode(out) as type.Uint8List;
  unit.expect('test', convert.utf8.decode(text.toList()));
}

{
  var l = [];
  l.add('test');
  l.add(1024);
  var out = Bencode.encode(l);
  unit.expect('l4:testi1024ee', convert.utf8.decode(out.toList()));

  List list = Bencode.decode(out);
  unit.expect('test', convert.utf8.decode(list[0].toList()));
  unit.expect(1024, list[1]);
}

{
  var m = <String, Object>{};
  m['test'] = 'test';
  m['value'] = 1024;
  var out = Bencode.encode(m);
  unit.expect('d4:test4:test5:valuei1024ee', convert.utf8.decode(out.toList()));

  Map me = Bencode.decode(out);
  unit.expect('test', convert.utf8.decode(me['test'].toList()));
  unit.expect(1024, me['value']);
}
```


# What is Bencode

B-encode is the encoding for BitTorrent network.
support  following type of values.
- byte strings
- integers
- lists
- dictionaries

Bencode's unique point compare to json format is to use bytes data.

https://en.wikipedia.org/wiki/Bencode
When does it make sense to self-host?
Tags: operations, cost, devops, productivity
Published: 2021-04-11 07:46:20

---
title: When does it make sense to self-host?
published: true
date: 2021-04-08 00:00:00 UTC
tags: operations, cost, devops, productivity
canonical_url: https://jhall.io/archive/2021/04/08/when-does-it-make-sense-to-self-host/
---

As frequently happens when consulting with small projects and startups, this week I was asked “Should we manage our own service, or use a hosted solution?”

My answer is pretty consistently the same: Start with a hosted service, and switch to self-managed only if and when it makes financial sense.

This question, and my answer, are generally applicable to all sorts of services: Kubernetes, log search, service monitoring, databases, mail automation, etc.

But when does it make financial sense to self-manage?

For small business, usually never. Unless the service in question is central to your business, my rule of thumb is to use a managed service unless self-hosting would save the equivalent of at least 25% of an engineer’s salary.

This might sound a bit extreme. Wouldn’t it make sense to self-host as soon as it saves you _any_ money? If self-hosting were completely free, maybe. But there are many hidden costs in self-hosting:

- You must pay the salary of someone to manage the service.
- You must pay for the hardware (or VMs) that run the service.
- Many self-managed services will experience more frequent outages than the equivalent managed service, due to the experience of those managing the managed service.

There are many other factors that can figure into the equation, depending on the exact nature of the service, and your business, so the 25% salary rule is not at all a hard-and-fast one. But the truth is that most people I work with are tempted to self-manage services _far too early_ than makes good business sense. In such cases, the 25% salary rule serves as an excellent rule of thumb to challenge these inclinations.
Isolated Process Models for Azure Workers .Net Core 5
Tags: azure, webdev, beginners, tutorial
Published: 2021-04-08 15:23:00

---
title: Isolated Process Models for Azure Workers .Net Core 5
published: true
date: 2021-04-08 00:00:00 UTC
tags: azure,webdev,beginners,tutorial
canonical_url: https://www.rupeshtiwari.com/isolated-process-models-for-workers/
cover_image: https://i.imgur.com/62zzw70.png 
---

> .Net running on-process till dotnet Core 3.1 & dotnet **isolated workers** are coming on .Net 6 onwards & you can deploy Azure Function Apps in production.

## Isolated Models for Workers

In future all **Azure Functions** will be running in **Isolated Model** only. Therefore, every Azure Functions will run as isolated worker process. 
- New way of building .Net Application called as Isolated Models that decouples the Azure Functions from .Net Function Runtime.
- This gives full control of the process & it’s dependency graph.
- This will be the future of all Azure Functions
- Durable Functions are in the process only.

### No more WebJobs Dependency

For each extension you need different set of packages. For Http, Worker and Worker SDK. ![](https://imgur.com/hbobPof.png)

Azure Functions in Isolated models will no more extending WebJobs dependencies. Therefore, you must get all features of WebJobs by adding different set of packages.

### Benefits of Isolated Models

- You can debug the host process before even debugger is attached to your functions.
- `--dotnet-isolated-deub` will help you to debug very early. It helps to remove race conditions while debugger attaching and the process executing the entry code. ![](https://imgur.com/jfPtJKM.png)

## Middleware on Azure Functions

In Azure out of proc Functions you can inject custom code in to the execution/dispatch pipeline. Middleware is a code that you can run before your Azure Functions are executed just like Express Middleware in JavaScript.

- You can modify the response from Middleware
- You can do authentication/ authorizations on Middleware
- Any cross-cutting concerns you can do in Middleware. ![](https://imgur.com/omYQfeC.png)

## What is next in Azure Functions

![](https://imgur.com/LbmMBDv.png)

## References

1. https://www.youtube.com/watch?v=4n0QbG0wYEI
How to show a 'Are you sure to leave?', 'Leave Site?', etc. dialog box in the browser before the user leaves using JavaScript?
Tags: javascript
Published: 2021-04-08 00:00:00

---
  title: How to show a 'Are you sure to leave?', 'Leave Site?', etc. dialog box in the browser before the user leaves using JavaScript?
  published: true
  tags: JavaScript
  date: Thu Apr 08 2021 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/show-are-you-sure-to-leave-dialog-box-in-browser-javascript
  cover_image: https://melvingeorge.me/_next/static/images/main-6d6a9b6fb6b5fd6e1713be1abad7ce38.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/show-are-you-sure-to-leave-dialog-box-in-browser-javascript)
  
To show 'Are you sure you want to leave?', 'Leave Site' or to show the dialog box which gives attention to the user when he/she closes the browser or reloads a tab, you can attach an event listener called `beforeunload` to the global `window` object using JavaScript.

It can be done like this,

```js
// Show "Leave Site?" Dialog Box

window.addEventListener("beforeunload", (event) => {
  // set a truthy value to property returnValue
  event.returnValue = true;
});
```

- The callback function in the `addEventListener` function will be passed an `Event` object, there you need to set a truthy value to the `returnValue` property in the `Event` object. In our case, we have set the value of boolean `true` to the property `returnValue`.

It would show a dialog box when the user leaves the browser like this,

![dialog-box-shown-in-browser](https://melvingeorge.me/_next/static/images/dialog-box-03d26145d3a943ded0cd417c3447be1c.png)

There is one more way you can do the same thing by directly attaching the `onbeforeunload` function which returns a truthy value to the global `window` object like this,

```js
/* Show "Are you sure to leave?" Dialog Box */

// Alternate Way of doing same thing
window.onbeforeunload = () => {
  return true;
};
```

That's all! 🔥

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

---
I love the way knowledge is shared in the programming world
Published: 2021-04-07 23:54:27

Hello guys, today I want to share something with you that I love so much. So ...., I love to read code from other programmers and developers, I like to spend some time reading posts about the best programming practices, that somehow I feel better, sometimes I find myself discussing the code of another developer. And I feel that every time I read how my skills increase, my sense of criticism becomes smarter, how my practices improve and not like that, code from other programmers has served as inspiration for. I confess to you, everything I learned from programming I learned on the web, reading, watching video lessons and always practicing. I realize that there is no way to improve without seeing how others do it, without having feedback from other people, even though they don't know you, but through their codes you will have feedback, and this is what I love in the programming world, the way how knowledge is shared without any restrictions, without selfishness or self-centeredness. There are code projects all over the world, communities forming around technology ... I love it, I love this way of transmitting knowledge. For me, being a software engineer, programmer or developer is very noble. "I love how knowledge is shared in the programming world."


Francisco Inoque.
I love the way knowledge is shared in the programming world
Published: 2021-04-07 23:40:21

Hello guys, today I want to share something with you that I love so much. So ...., I love to read code from other programmers and developers, I like to spend some time reading posts about the best programming practices, that somehow I feel better, sometimes I find myself discussing the code of another developer. And I feel that every time I read how my skills increase, my sense of criticism becomes smarter, how my practices improve and not like that, code from other programmers has served as inspiration for. I confess to you, everything I learned from programming I learned on the web, reading, watching video lessons and always practicing. I realize that there is no way to improve without seeing how others do it, without having feedback from other people, even though they don't know you, but through their codes you will have feedback, and this is what I love in the programming world, the way how knowledge is shared without any restrictions, without selfishness or self-centeredness. There are code projects all over the world, communities forming around technology ... I love it, I love this way of transmitting knowledge. For me, being a software engineer, programmer or developer is very noble. "I love how knowledge is shared in the programming world."


Francisco Inoque.
Writing a PR description 
Tags: beginners, codenewbie, webdev, devjournal
Published: 2021-04-07 23:38:25

This isn't going to be an in-depth article or all that technical. But I've been itching to write over the last couple of weeks and this 30-min article is short enough to finish in one sitting right after work. My brain is at that perfect level of fatigue, where the words still come easy, but the thought of reading pages on a topic feels painful 😪

Last week, I made my first PR for my first feature. After weeks of learning, video watching and question asking, I created a new Azure function that logs hello, world to the terminal.

My PR description said as much:
> 1. Creates Azure function
> 2. Logs hello, world

Simple. Right?

But then I got PR comments. 

The comments themselves weren't the issue, but my logic was. I assumed everyone, being familiar with the "hello, world" approach, would understand this PR was the basis for the Azure function that was to come. Not realizing that even in the shell of a project, decisions have been made-- how to set up the code, what conventions are followed, what triggers make sense etc etc. 

So I took a step back, read the comments, stepped away again, re-worded the description, read the comments and then read some PRs and then read the comments again. 

Reading the other PRs was the most illuminating. Re-reading the comments at each step helped me piece together what information the reviewer needed. Reading the other PRs showed how different devs approached this. 

While short, most of the descriptions were helpful to a new set of eyes. Assuming 0 knowledge of the PR or the associated feature, they offered enough information for the reviewer to proceed.

### PR description template

In addition to commit small, frequent PRs, this is the PR template I have so far:
1. This PR will accomplish _____
2. This will in turn have _____ impact on _____
3. Not included in scope for this PR is _____ because of _____

Photo by Karolina Grabowska from Pexels
🚀🐧 What's your current OS and why do you use it?
Tags: discuss, help, watercooler, productivity
Published: 2021-04-07 23:09:42

## Show off your Operative system set up

I've been learning programming for over a year. But I've always been interested about the best tools available to achieve my objectives, and one of the most important is the OS.

Yeah, that thing that is processing all the tasks of our music players 🎵 and code editors 👨‍💻 the whole day.

### My current OS

At this moment (April, 2021), I'm using a Linux based operative system called **Manjaro**.

For me it's almost perfect, because I can do whatever I want with the look and feeling of it, I can Install window managers like [Qtile](https://github.com/Daniel1404/Qtile-Config) or [Awesome](https://awesomewm.org/), and I'm able to install practically any open source software available, due to the Arch User repositories.

And the best of all! I can use it in a low resources machine 😊.

**Some screenshots of my desktop**

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/21dtmz8300l8fxpscd9h.png)
 
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/paeg98qzs12yqpv4efdt.png)

Unfortunately this weekend I must to get rid of Manjaro in order to install **Windows**, because of school. (Some software is only available for windows 😓)

However I still able of install other Linux distribution alongside windows later 😁.

### So my question is:

What operative system are you using and why?

Do you have any advantage for using it?

What is the most common software you use in your operative system, and does it retain you from changing?

What is the best part of it 🤔?

Lastly feel free to share your desktop screenshots, show off how beautiful is your daily driver 🖥️.