teleren/devto huggingface dataset:
10 Tips For Improving Database Defenses
Published: 2021-04-24 22:53:43

What kind of methods do you use to protect your database? How do you deal with your sensitive data? 

10 ways was given in the video to keep your database more secure, check below.
[Watch Now(9 mins) >](https://www.youtube.com/watch?v=MteH-TPtdO0)


[ApsaraDB for RDS](https://www.alibabacloud.com/product/apsaradb-for-rds-sql-server)
For secure data store and transactions through TDE(Transparent Data Encryption) and SSL techniques.


[Database Backup(DBS)](https://www.alibabacloud.com/product/database-backup)
Encrypted backups and quick restoration in seconds.

[Data Management (DMS)](https://www.alibabacloud.com/product/data-management-service)
Easy-to-use privilege management and comprehensive useful functions like SQL auditing.

[Data Autonomy Service (DAS)](https://www.alibabacloud.com/product/das)
Prevent you from SQL injection attacks.

Next time, we will have some hands-on labs to help you build your database denfense line step by step.

[Subscribe to get informed for every updates >](https://www.youtube.com/c/AlibabaDatabase/featured)
LeetCode 174. Dungeon Game
(javascript solution)
Tags: algorithms, javascript
Published: 2021-04-24 22:42:42

###Description:
Given a triangle array, return the minimum path sum from top The demons had captured the princess and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of m x n rooms laid out in a 2D grid. Our valiant knight was initially positioned in the top-left room and must fight his way through dungeon to rescue the princess.

The knight has an initial health point represented by a positive integer. If at any point his health point drops to 0 or below, he dies immediately.

Some of the rooms are guarded by demons (represented by negative integers), so the knight loses health upon entering these rooms; other rooms are either empty (represented as 0) or contain magic orbs that increase the knight's health (represented by positive integers).

To reach the princess as quickly as possible, the knight decides to move only rightward or downward in each step.

Return the knight's minimum initial health so that he can rescue the princess.

Note that any room can contain threats or power-ups, even the first room the knight enters and the bottom-right room where the princess is imprisoned.

###Solution:
Time Complexity : O(n^2)
Space Complexity: O(n^2)

```javascript
var calculateMinimumHP = function(dungeon) {
        let n = dungeon.length;
        let m = dungeon[0].length;
        
        // Create dp array
        const dp = Array(n + 1).fill(0).map(() => Array(m+1).fill(Infinity)) 
        // Create base cases
        dp[n][m - 1] = 1;
        dp[n - 1][m] = 1;
        
        // Loop through all the rows
        for (let i = n - 1; i >= 0; i--) {
            // Loop through all the cells
            for (let j = m - 1; j >= 0; j--) {
                // Get the minimum health needed to move to the next cell from the current cell without going to 0
                let need = Math.min(dp[i + 1][j], dp[i][j + 1]) - dungeon[i][j];                
                // If need <= 0 that means that dungeon[i][j] was positive. If a cell is positive the knight's health at minimum can be 1 because it does not cost any health to move there
                dp[i][j] = need <= 0 ? 1 : need;
            }
        }
        return dp[0][0];
};
```
Instant Ubuntu VMs – Multipass

Tags: ubuntu, linux, snap
Published: 2021-04-24 22:19:04

Multipass é uma ferramenta para lançar e gerenciar VMs no Windows, Mac e Linux que simula um ambiente de nuvem com suporte para cloud-init. Obtenha o Ubuntu sob demanda com integração limpa ao seu IDE e controle de versão em sua plataforma nativa.

Para saber mais: https://bit.ly/3sOtvpZ
Pi Day & Introduction to Raspberry Pi Pico with Coding Grace
Tags: raspberrypi, electronics, video
Published: 2021-04-24 21:58:56

Note: I forgot to upload this for [Pi Day](https://www.raspberrypi.org/blog/celebrate-pi-day-with-us/) and it's our very first Coding Grace video, so want to share this first as we are planning a series of them.

Our next video is a big change up and will be following up this Pi Pico video. Enjoy!

---

Happy Pi Day! This is our first Coding Grace video and it's an intro to the recently released Raspberry Pi Pico.

Hosts: Vicky Twomey-Lee & [Michael Twomey](https://twitter.com/micktwomey)

{% user whykay %}
{% user micktwomey %}

### Event to note
Raspberry Pi Foundation Pi Day Event at Sun Mar 14, 7PM GMT. More info on Pi Day: 
https://www.raspberrypi.org/blog/celebrate-pi-day-with-us/

### What we will be covering in this video
Raspberry Pi Pico:
https://www.raspberrypi.org/products/raspberry-pi-pico/

### Credits
Music: So Happy by Scott Holmes Music (Attribution-NonCommercial 4.0 International (CC BY-NC 4.0))
https://freemusicarchive.org/music/Scott_Holmes/happy-background-music/Scott_Holmes_-_01_-_So_Happy

### ABOUT CODING GRACE
An Irish not-for-profit organisation who run events, and advocates diversity in tech. More information: https://codinggrace.com

Questions? Email contact@codinggrace.com
Generate Random Whole Numbers within a Range
Tags: javascript, devops, tutorial, beginners
Published: 2021-04-24 21:52:58

```
function randomRange(myMin, myMax) {
  return Math.floor(Math.random() * (myMax - myMin + 1)) + myMin
}

console.log(randomRange(1, 9));
```
```
// If the values were myMin = 1, myMax= 9, one result could be the following:

// Math.random() = 0.27934406917448573
// (myMax - myMin + 1) = 9 - 1 + 1 -> 9
//  0.27934406917448573 * 9 = 2.51409662257 
// 2.51409662257 + 1 = 3.51409662257
// Math.floor(3.51409662257) = 3
```
 * 1. Randomizing a decimal, then taking 9 - 1 which is 8 then adding it to + 1 which is 9.
 * 2. Then taking the randomized decimal that it gave us and multiply it by 9.  
 * 3. The result of that multiplication will then + 1;
 * 4. Then result will be “rounded” to the largest integer less than or equal to it (eg: 3.5 would result in 3) which in this case will be.
Covid map - React project day 1.
Tags: react, leaflet, project
Published: 2021-04-24 21:51:21

---
title: Covid map - React project day 1.
published: true
description: 
tags: react, leaflet, project
canonical_url: http://makneta.herokuapp.com/post/covid-map-react-project-day-1/
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4pyleg40an0wc3rzuz9f.png
series: Covid Map React Project
---
I've been learning React for a while and I like doing it through writing projects. Yes, I use tutorials and courses although I don't follow them 1 to 1 in my projects. 

Here I want to take notes for my new project: **Covid map** and post them in public. In this project, I want to show the number of Covid-19 cases for each country and maybe vaccine coverage.

## Libraries and APIs I'm going to use:
1. React.js
2. Leaflet.js (https://leafletjs.com/) and React-Leaflet.js (https://react-leaflet.js.org/)
3. Open Disease Data https://disease.sh/

## Things I've done so far:
* Created project with `npx create-react-app covid-map`
* Installed leaflet and react-leaflet with `yarn add leaflet react-leaflet`
* Added MapContainer and Marker with Popup to Map component

## Problems I've encountered so far:
1. After installing leaflet and react-leaflet, even though I copied the example code from react-leaflet website, the map looked weird. It turned out that I needed to import CSS from node_modules like that:
`import "leaflet/dist/leaflet.css"`
2. I had a problem with displaying the Marker icon. Instead of the icon, I could only see a broken image. I found a piece of code that supposed to help:
```javascript
import * as L from 'leaflet'
delete L.Icon.Default.prototype_getIconUrl;
 L.Icon.Default.mergeOptions({
      iconRetinaUrl: require("leaflet/dist/images/marker-icon-2x.png"),
      iconUrl: require("leaflet/dist/images/marker-icon.png"),
      shadowUrl: require("leaflet/dist/images/marker-shadow.png")
    });
```
But I couldn't make it work. 

#### My solution

Instead, I used an icon from a small repo: https://github.com/pointhi/leaflet-color-markers

```javascript
import * as L from 'leaflet'


const redIcon = new L.Icon({
  iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-red.png',
  shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
  iconSize: [25, 41],
  iconAnchor: [12, 41],
  popupAnchor: [1, -34],
  shadowSize: [41, 41]
});

<Marker icon={redIcon}><Marker>
```

I'm not sure yet if I use that icon in the project to the end. 

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

## Next step(s):
* Fetch data from the API.
* Add markers to all countries included in the Open Disease Data API for covid.
* Add information about the number of Covid-19 cases and deaths to popup.
Trust performance advice... but verify.
Tags: performance, go, compiler, optimization
Published: 2021-04-24 21:24:14

Just like most things, performance advice also has an expiration date and it's important to keep this in mind when applying suggestions from blog posts or StackOverflow. That's why my favorite command line flag when building Go apps is `--gcflags="-m=2"`. It enables printing optimizer decisions, making it possible to answer numerous interesting questions affecting performance, including whether function is inlined:
```
cannot inline main: function too complex: cost 523 exceeds budget 80
...
inlining call to largeReturner func() Large { return Large literal }
```
or whether variable escapes to heap:
```
main.go:10:2: i escapes to heap:
main.go:10:2:  flow: ~r0 = &i:
main.go:10:2:    from &i (address-of) at main.go:11:9
main.go:10:2:    from return &i (return) at main.go:11:2
main.go:10:2: moved to heap: i
```
**Bonus:** do you think l will escape to heap in the following code?
```go
24 type Large struct {
25        data [1024]byte
26 }
27
28 func main() {
29        l := Large{}
30        fmt.Println(l)
...
```
If you guessed yes, you are right :)
```
main.go:30:13: l escapes to heap:
main.go:30:13:  flow: ~arg0 = &{storage for l}:
main.go:30:13:    from l (spill) at main.go:30:13
main.go:30:13:    from ~arg0 = <N> (assign-pair) at main.go:30:13
main.go:30:13:  flow: {storage for []interface {} literal} = ~arg0:
main.go:30:13:    from []interface {} literal (slice-literal-element) at main.go:30:13
main.go:30:13:  flow: fmt.a = &{storage for []interface {} literal}:
main.go:30:13:    from []interface {} literal (spill) at ./main.go:30:13
main.go:30:13:    from fmt.a = []interface {} literal (assign) at main.go:30:13
main.go:30:13:  flow: {heap} = *fmt.a:
main.go:30:13:    from fmt.Fprintln(io.Writer(os.Stdout), fmt.a...) (call parameter) at main.go:30:13
main.go:30:13: l escapes to heap
```
Why it matters? Even if the additional memory indirection is not a problem, heap allocations result in extra work for garbage collector and dreaded stop-the-world pauses.

Moral of the story? Know your tools and use them to verify all performance assumptions.
Cómo crear un Quick App usando el QuickApp IDE, les comparto este link que es de mucha ayuda.
Published: 2021-04-24 21:39:03

https://medium.com/huawei-developers-latinoam%C3%A9rica/c%C3%B3mo-crear-un-quick-app-usando-el-quickapp-ide-a7bf7fa25234
Trading memory for fewer allocations.
Tags: performance, memory, go, allocations
Published: 2021-04-24 21:30:10

Even though memory allocations are not always easy to spot, they are fairly expensive due to overhead and garbage collector load. In a seemingly innocent [function](https://golang.design/gossa?id=643aadbf-d10d-4d74-8cf6-e33ec1e73ae1) `print_int`
```go
func print_int(x int) {
	fmt.Println(x)
}
```
compiler claims (`-gcflags="-m"`)
```
x escapes to heap
```
so `runtime.convT64` function is used to convert `x` into a pointer
```
00007 (6) CALL runtime.convT64(SB)
```
which is implemented in [runtime.iface.go](https://github.com/golang/go/blob/e8700f1ce6f4103207f470cce443f04377baa600/src/runtime/iface.go#L360-L368):
```go
func convT64(val uint64) (x unsafe.Pointer) {
	if val < uint64(len(staticuint64s)) {
		x = unsafe.Pointer(&staticuint64s[val])
	} else {
		x = mallocgc(8, uint64Type, false)
		*(*uint64)(x) = val
	}
	return
}
```
The most interesting bit is `x = unsafe.Pointer(&staticuint64s[val])` part, which returns a pointer from a [preallocated](https://github.com/golang/go/blob/e8700f1ce6f4103207f470cce443f04377baa600/src/runtime/iface.go#L521-L555) `staticuint64s` pool of ints between `0` and `255`:
```go
// staticuint64s is used to avoid allocating in convTx for small integer values.
var staticuint64s = [...]uint64{
	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
	...
	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
}
```
It's a fairly cheap way to trade a little memory for allocation reduction and is used in many other managed languages like Java. To make it even more useful, runtime reuses the same cache also for `convT16` and `convT32` functions.

It's such a useful technique that it's also used for dynamic caches, also known as object pools, but the extra flexibility of not being limited by a fairly small range of values comes at a cost of synchronization, so it's important to measure this overhead when evaluating object pools.

In summary, consider using static preallocated caches to reduce allocation count and improve performance.
10,000 hours...?
Tags: beginners, career, devjournal, motivation
Published: 2021-04-24 21:28:45

# How long to reach somewhere substantial?

Malcolm Gladwell (and other writers, some of them with scholarly aptitude) estimate that 10,000 hours of learning puts you on par with true masters in most, if not all fields. Talent may be important, too - especially when it comes to the last 1%. I'd say, previous experience helps as well.

## The implicit question

I assume that only very few jobs require full mastery of coding concepts and related subjects. Yet, I have no idea how many honest hours of work are required to reach to a solid entry level.

## The idea

This is a social experiment with n=1. As such, it is hardly any proof, but might give some guiding clues as to what efforts are required. I am going to keep track of all my activities and time spent becoming a coder. Until I give up or survive on my projects!

## The challenge

My time stretches between family, work, garden and learning. I wouldn't wanna miss out on most if not all - so understanding how much time I spend on learning can quickly become fuzzy and - in hindsight - not very useful to know and tell. I'll try to recap my learning time and list it here on a weekly basis, to get a better understanding of the idea of "developer in a year". I (re-)started coding on March 31, 2021. Never thought about publishing anything, so the first 25 days are lost to oblivion - what I am estimating here is from memory and based on my calendar.

## Backlog #1-#25

* Enrolled in a commercial self-paced JavaScript course - so far I've done about 40% of the contents which cover: basics, arrays, objects, DOM manipulation. **30 hours**
* I had done some HTML about 20 years back, but never pursued that path in my life. **120 hours**
* I went through FreeCodeCamp's web designer course (HTML + CSS), although I did this last year while I was unemployed for a month and I don't remember much of it. I estimate that I spent about 30 hours on it, as I do remember designing some graphics to make the project sites look nicer. **30 hours**
* I've read half of "clean code" and I understood about 95% so far!! **5 hours**
* I realised that I had a git-account which was totally unused, so I started using git (and learning the basics). **2 hours**
* I have helped a few people on freecodecamp with challenges they faced. **6 hours**
* I have started programming a simple card game as a learning project. It's not working yet, but I'll get there! **30 hours**

**Total time spent on learning: _223 hours_**

## Where do I stand today?

I am fairly confident in understanding the language of JavaScript, HTML and CSS, although I have not spent much time understanding patterns. It is just today that I've begun to look into _concepts_, such as block scope, IIFE, MVC and the like.

## What about you?

How many hours would you say are required to become employable? How far are you down the road? How do you overcome hills and mountains?

Keep up! All the best,
Sebastian.
Profile Lookup
Tags: javascript, devops, tutorial, beginners
Published: 2021-04-24 21:21:59

```
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["JavaScript", "Gaming", "Foxes"]
    }
];
```
```
function lookUpProfile(name, prop) {
  for (let i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName === name) {
       if (contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop];
      } 
        return "No such property";
     }
  }
  return "No such contact";
}

console.log(lookUpProfile("Kristian", "lastName")); will display Vos
```

#### Problem Explanation:
* This function includes two parameters, firstName and prop.
* The function looks through the contacts list for the given firstName parameter and to do so we will use a for loop to cycle through the contacts list.
* If there is a match found, the function then should look for the given prop parameter.
* If both firstName and the associated prop are found, you should return the value of the prop. 
We use a nested if statement to first check if the firstName matches, and then checks if the prop matches.
* If firstName is found and no associated prop is found, you should return No such property.
* If firstName isn’t found anywhere, you should return No such contact.
That HDR to SDR message in Final Cut Pro
Tags: todayilearned, finalcutpro
Published: 2021-04-24 21:11:59

I was stitching together some footage from PyLadies for their auction, and I came across this warning...

![Screenshot 2021-04-24 at 22.08.22](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rmczso2njpsmdtu0chx0.png)
 
And the video footage becomes all washed out when you put in your settings.

![yay giphy](https://media.giphy.com/media/UTA0coaUn9x3q/giphy.gif)

Found this video that helped me out (yay to youtube), and just thought to share as I learnt something new today.


{% youtube mpjcY8LH7js %}
JS interview in 2 minutes / == vs ===
Tags: javascript, typescript, beginners, career
Published: 2021-04-24 21:11:43

---
title: JS interview in 2 minutes / == vs ===
published: true
description: Let's try to figure out how to answer common JS questions on interview.
tags: javascript, typescript, beginners, career
cover_image: https://upload.wikimedia.org/wikipedia/commons/thumb/9/99/Unofficial_JavaScript_logo_2.svg/1920px-Unofficial_JavaScript_logo_2.svg.png
---

**Question:**
What is the difference between ` == ` and ` === ` operators?

**Quick answer:**
These are both comparison operators, but the ` === ` also compare types of operands.

**Longer answer:**
Javascript and basically typescript are languages with [implicit type conversion](https://en.wikipedia.org/wiki/Type_conversion#Implicit_type_conversion). This means they try to convert variables to "proper" types when performing operations.

```
let a = 1
let b = '1';
console.log(a+b)
// "11"
```

So when comparing objects it will also try to convert them. 

```
let a = 1
let b = '1'
console.log(a == b)
// true
```

We can reference [this table](https://dorey.github.io/JavaScript-Equality-Table/) for more examples.

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9l1enutrlh4c9yduq4xa.png)

**Real-life example:**
It turned out really hard to provide some realistic example of a real-life issue when you use ` == ` instead of ` === `

We can imagine a case when API returns a JSON object where some field can be in 3 states - present, missing, and null. 

```
[
  ...
  { "username": "admin", roles: ["admin"] },
  { "username": "hacker", roles: null }, // disabled
  { "username": "user" },
  ...
]
```

(It is weird, but I actually had this case myself when API returned `null` instead of `[]` if object property was empty array 🤷)

So if you will write a condition using ` == ` there will be a mistake.
```
// both these cases will be triggered
// since undefined == null is true
if (obj.prop == undefined) { ... }
if (obj.prop == null) { ... }
if (obj.prop) { ... }
```

// yeah, this example is still a bit artificial, but if you can come up with something different, please share it in the comments 🙏

---
Btw I will post more fun stuff here and on [Twitter](https://twitter.com/kozlovzxc) let's be friends 👋
UI Video Platform
Tags: codepen
Published: 2021-04-24 21:11:16

![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6muuq1j65cbyv1di46v7.png)
🔸
 <p>Inspired by Dwinawan 
<a href="https://dribbble.com/shots/14958858--Exploration-Skateboard-Video-Platform/attachments/6676841?mode=media" target="_blank">https://dribbble.com/shots/14958858--Exploration-Skateboard-Video-Platform/attachments/6676841?mode=media</a></p>
🔸
<p><a href="https://video.delgarm.com/">delgarm</a>
🔸
{% codepen https://codepen.io/aradpardaz/pen/qBRgjgL %}
Zendesk: configurando ambiente no Windows 10
Tags: ruby, devkit, windows, zendesk
Published: 2021-04-24 20:53:26

No post de hoje ensinarei a como configurar o ambiente de desenvolvimento do Zendesk para pessoas que usam o sistema operacional Windows 10.

Você provavelmente seguiu as instruções desse link https://develop.zendesk.com/hc/en-us/articles/360001075048 e ainda não conseguiu configurar o ambiente? Pois bem, vamos ao passo a passo:

Primeiro vá na página https://rubyinstaller.org/downloads/archives/. Nela baixe o Ruby na versão **Ruby 2.3.3** (sem ser a versão de 64).

Depois de baixado o Ruby, vai aparecer no momento de instalação alguns campos para selecionar, selecione todos eles e instale. Isso fará com que alguns path seja adicionado as variáveis de ambiente do usuário. Mas adicione também **C:\Ruby23** comando as variáveis.

A partir desse ponto você já pode executar:

``` 
gem install rake
```

Em seguida baixar o seguinte devKit: **DevKit-mingw64–32–4.7.2–20130224–1151-sfx.exe**. Ele está na mesma página que você baixou o **Ruby 2.3.3**.

Descompacte o devKit e coloque numa pasta no **C:**, o nome que eu coloquei para a pasta foi de **devKit**.

Em seguida abra a pasta devKit no terminal e rode os seguintes comandos.

``` 
ruby dk.rb init
ruby dk.rb install
gem install rdiscount — platform = ruby
```

A partir desse ponto você já é capaz de executar:

```
gem install zendesk_apps_tools
gem update zendesk_apps_tools
```

E pronto, você já pode usar o comando **zat new** para criar as suas aplicações.

Espero que tenha ajudado.

Que o código esteja com você!