teleren/devto huggingface dataset:
Paracetamol.js💊| #100: Explica este código JavaScript
Tags: javascript, spanish, webdev, beginners
Published: 2022-04-13 16:34:46

## **<center>Explica este código JavaScript</center>**
#### <center>**Dificultad:** <mark color="">Básica</mark></center>

```js
//Este es el reto #100 🎉🥳
console.log(Math.floor(9.8)); //?
console.log(Math.ceil(9.8)); //?
console.log(Math.round("9.8")); //?
```

A. `10`, `10`, `"10"`
B. `9`, `10`, `10`
C. `9`, `9`, `9`
D. `10`, `10`, `"9"`

Respuesta en el primer comentario

---
Let’s get YouTube to add a “switch off” button for Shorts
Tags: productivity, social, habits, youtube
Published: 2022-04-13 16:31:47


YouTube is currently **forcing its new _Shorts_ feature on its users**.

The aim of this petition is to make YT give users an **option to switch off**:

- Shorts recommendations from the newsfeed
- Shorts shortcut from the navigation bar

Ideally, YT should also add an option to set a minimum length for videos that they can recommend to you.

I created a petition to get YouTube to do this — **[you can sign the petition here](https://www.change.org/p/get-youtube-to-add-a-switch-off-button-for-shorts)**.



It’s common knowledge that YouTube introduced its Shorts feature as a response to the growing popularity of TikTok. Unlike TikTok, YouTube cannot be easily uninstalled from an android device. This makes it much harder to self-manage possible attention, addiction, and productivity issues.
YouTube also contains lots of mid and long-form, valuable content that most users would like to access, without being bothered with Shorts recommendations.

Of course _Shorts_ content, can also be valuable and meaningful, but it’s certainly more addictive.
If YouTube truly cares about the digital well-being of its users, they should leave the choice up to the user. Currently, there is no such option.

— — — — — -
**What you can do now?**

1. [Sign this petition](https://www.change.org/p/get-youtube-to-add-a-switch-off-button-for-shorts) — this will help to show a transparent, undeniable number of people, that would like to see this change introduced
2. **Submit feedback to YouTube on having an option to switch off Shorts** — this, unfortunately, isn’t transparent but will give YT a sign of user needs.
Set up a freshly installed macos Monterey machine as a gitlab-runner host
Tags: gitlab, ci, ios, xcode
Published: 2022-04-20 09:08:19

---
title: Set up a freshly installed macos Monterey machine as a gitlab-runner host
published: true
date: 2022-04-13 16:09:00 UTC
tags: gitlab,ci,ios,xcode
canonical_url: https://jay.gooby.org/2022/04/13/set-up-a-freshly-installed-macos-monterey-machine-as-a-gitlab-runner-host
---

You've got a newly installed macos Monterey machine you want to use as a gitlab-runner host to test and build your ios and macos projects on. What do you need?

## macos command line tools
Get the macos Command Line Tools. In a terminal, run:

```
xcode-select --install
softwareupdate -l

# Then pick the most recent version of Command Line tools, e.g.
softwareupdate --install "Command Line Tools for Xcode-13.3"
sudo xcodebuild -license accept
```
## homebrew
Then install [homebrew](https://brew.sh):

```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

and this `Brewfile` (save it to `~/Brewfile`)

```
brew "asdf"
brew "bash"
brew "bash-completion"
brew "ack"
brew "autoconf"
brew "automake"
brew "coreutils"
brew "curl"
brew "gettext"
brew "git"
brew "gnu-sed"
brew "gnu-tar"
brew "gnu-indent"
brew "gnu-which"
brew "pkg-config"
brew "robotsandpencils/made/xcodes"
```

Then run:

```
brew bundle
```

in the same folder as the `Brewfile` (e.g. `cd ~ && brew bundle`).

## Xcode
And get and install the latest Xcode so you have the ios simulator, etc:

```
XCODES_USERNAME="your_apple_id" XCODES_PASSWORD="your_apple_id_password" xcodes install --latest
```

## `gitlab-runner`
Now install and configure the gitlab-runner:

```
# Install gitlab-runner
# uses `arch` to fetch the correct version
[ "$(arch)" = "i386" ] && sudo curl --output /usr/local/bin/gitlab-runner "https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-amd64" || sudo curl --output /usr/local/bin/gitlab-runner "https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-arm64"

sudo chmod +x /usr/local/bin/gitlab-runner

# Register the runner
gitlab-runner register

# Install gitlab-runner as a user service.
# PLEASE NOTE you must enable autologin to this user
# on the macos machine or your runner will be showing
# as `stuck` the next time your macos machine reboots
# and you don't login.
su - $(whoami)
cd ~
gitlab-runner install
gitlab-runner start
```

## Disable macos sleep for the logged in user
Ensure the mac doesn't sleep, if you don't set your mac not to sleep, it will, and then your runner won't be able to pick up jobs, and will be showing as `stuck`:

```
sudo pmset -a sleep 0; sudo pmset -a hibernatemode 0; sudo pmset -a disablesleep 1
```

## Optional ruby install with `asdf` when using Fastlane
I also need ruby, because I'm using [Fastlane](https://fastlane.tools) to manage the ios and macos builds, and I'm using [`asdf`](https://asdf-vm.com) to manage ruby versions:

```
echo "ruby 2.7.6" > ~/.tool-versions
asdf plugin-add ruby
asdf install ruby 2.7.6
gem install fastlane
```
Diferença entre Any e Unknown do Typescript
Tags: typescript, tutorial, programming
Published: 2022-04-13 16:04:53

## Você sabe a diferença entre any e unknown?

`any` e `unknown` são tipos bem parecidos e podem parecer que são até iguais, mas possuem suas diferenças.

A confusão que se tem sobre esses dois tipos vem do fato de que, se criarmos uma função que recebe dois parâmetros, um do tipo `any` e outro do tipo `unknown`, veremos que podemos passar qualquer variável para ambos os tipos sem erros.

```tsx
const foo = (anyType: any, unknownType: unknown) => {}

foo({}, {})
foo(123, 456)
foo(null, null)
foo(() => {}, () => {})
```

Mas é possível ver a diferença quando se usa essas variáveis.

Com `any`  você pode atribuir qualquer tipo e usar como se fosse qualquer tipo. Já `unknown` você pode atribuir qualquer tipo, mas ao usar ele não é nenhum tipo e você precisará verificar qual é o tipo.

Uma variável do tipo `any` você pode ser usada como uma `string` ou como uma função e até mesmo como um objeto, mostrando que `any` é equivalente a todos os tipos.

```tsx
const foo = (anyType: any, unknownType: unknown) => {
  const str1: string = anyType; // => ok
  anyType(); // => ok
  anyType.foo; // => ok
}
```

Já o `unknown`, mesmo podendo receber qualquer tipo, ele da erro quando se tenta usa-lo como qualquer tipo, portanto não se pode usa-lo como uma `string`, função, objeto ou qualquer outro tipo diferente de `unknown`. 

```tsx
const foo = (anyType: any, unknownType: unknown) => {
  const str1: string = anyType; // => ok
  anyType(); // => ok
  anyType.foo; // => ok

  const str2: string = unknownType; // => erro
  unknownType(); // => erro
  unknownType.foo; // => erro
}
```

Para você poder usar uma variável do tipo `unknown`, é preciso que se verifique o tipo antes. Para atribuir `unknown` para uma `string`, pode-se verificar utilizando `typeof` e ver se o tipo da variável é de fato `string`, e o mesmo pode ser feito para uma função.

```tsx
const str2: string = unknownType; // => erro
if(typeof unknownType === 'string') {
  const str2: string = unknownType; // => ok
}

unknownType(); // => erro
if(typeof unknownType === 'function') {
	unknownType(); // => ok
}
```

Para verificar se uma variável é de um tipo mais especifico, como um objeto com algumas propriedades especificas, é necessário utilizar um [user-defined type guard](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates), que é uma função que o retorno dela define um *type predicate*, ou seja, define que uma variável é de um determinado tipo utilizando `is`.

```tsx
interface Foo {
  foo: string
}

// user-defined type guard      *type predicate*
const isFooType = (foo: unknown): foo is Foo => {
  return (foo as Foo)?.foo !== undefined
}

unknownType.foo; // => erro
if(isFooType(unknownType)) {
	unknownType.foo; // => ok
}
```

Ao utilizar `unknown` ao invés de `any` você permite que seu código seja utilizado de forma muito mais segura.
2 shortcuts that make referencing code easy in GitHub PRs & Issues
Tags: github, productivity
Published: 2022-04-13 15:59:49

There are two parts to this:

1. know the command to copy relative file path in your IDE
2. know the command to launch "go to file" on a GitHub repo

## `Cmd Shift P` in Visual Studio Code

I mostly use VS Code, which comes with a wonderful command palette that you can summon up with `Cmd Shift P` on a Mac. Once summoned, I type "relative" > select File: Copy Relative Path of Active File > hit enter.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1bnpksal6gjq2z8ozzeb.png)

Now that I have the relative path, I need to navigate to the corresponding page on GitHub that displays this page.
 

## Just `T` in a GitHub repo

I open the relevant GitHub repo and simply hit `T` on my keyboard to launch the "Go to file" functionality:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g1z7pcp4vzsiazulz9kv.png)

And you guessed it: `Cmd V` to paste, hit enter, and you're at the right page on GitHub!

## Single or multi-line highlights in GitHub

With those two nifty shortcuts, I've gotten to the right page very quickly. Now all that's left to do is to somehow refer to one or multiple lines of code.

GitHub makes this easy:

1. click the starting line number of the code you're interested in
2. hold shift
3. click ending line number
4. copy the URL, which has changed based on your clicks

Pro tip: hit `Y` after selecting the relevant line(s) of code to generate a snapshot of the code you've selected. If you don't do this, there's a chance that you may be referencing the `main` branch's code by line number, which could refer to something else in the future. The snapshot prevents this by referring to a specific commit.

Now I can paste this URL anywhere in GitHub's commenting surfaces like Pull Requests, Issues, or comments and it will either show up as a link or a rich preview. 

What I haven't figured out is why I sometimes get a rich preview and other times it shows up only as a hyperlink. If you know, please comment on this so I can learn. I love those rich previews!
Download all your leetcode solutions
Tags: leetcode
Published: 2022-04-13 15:55:36

Clone this repo, `git clone https://github.com/theabbie/leetcode_dump`

Run `yarn` to install all required dependencies.

Run `yarn leetcode` to start the process, it will ask for your leetcode cookie which is required to fetch your submissions, it can be found in your browser storage.

It will ask for the path to save all your code files, enter the path and press Enter.

Wait for some time as it fetches 20 submissions / second, if rate limit is exceeded it will wait for 10 seconds before trying again, this usually happens because csrf token is expired, you may use new cookie and continue from where it stopped (number of submissions fetched already).

## Contributing

Thank you for your interest in contributing, If you feel like there's something missing or any new feature can be added, just create a PR and I will see the rest.

## Help

You can contact me on social media, Everything about me can be found [here](https://theabbie.github.io)

### Requirements

* Node.JS
* Linux preferably

## Contact

Contact me anywhere, just visit [my portfolio](https://theabbie.github.io)
How to handle and receive messages?
Tags: luos, api, opensource, embedded
Published: 2022-04-13 15:40:53

💡 **How to handle and receive messages?**
⏩ https://docs.luos.io/docs/luos-technology/message/handling-message
To receive messages with Luos there is an API call `Luos_ReadMsg()`. This API checks the Luos message buffer to see if there is a message for the service. You have to call this API in the loop function of the service synchronously.
Sumriddle, like Wordle but for guessing numbers
Tags: gamedev, javascript, webdev
Published: 2022-04-13 15:36:46

Hi everyone, I have created a wordle like game called Sumriddle but instead of words player has to guess series of numbers. Feedback from the dev community that can help in improving game play is highly appreciated. The game can be played at https://www.sumriddle.com
Design your own security vulnerability #1
Tags: security, web, database
Published: 2022-04-13 15:36:40

The first in probably an even more occasional series... None of these are new. But people keep making the same tired old mistakes.

We begin, as ever, with the best of intentions. As part of our business, let's store some customer data by customer ID, where customer ID is a numeric key on our database of customers. Most databases will happily generate this for you and increment it by one when you add a new customer.

Let's have a web page so the customer can see his own data, say at `https://my-safe-data.biz/customer/NNNNN` where NNNNN is the customer ID. Fine and dandy. No-one but the customer and us know his ID, so he's quite safe. We can just pass that ID to the database, ask it for the data for that customer, and present it. Don't need to password protect it, because the ID is its own password, right - no-one knows anyone else's customer ID, do they, surely?? 

_Wrong_.

You don't _have_ to know anyone else's customer ID. Just make an educated guess on how they're generated.

Enter J Random Cracker, who just happens to have seen one of our URLs because he's a customer. "I wonder", they think, "what happens if I change my customer ID by 1"...

"Oh look. Someone else's records." An hour and a bit of scripting later, and they've pulled out LOTS of records to which they have no right.

"But", you say, "no-one would be that stupid, would they?"

Well yes. [They would](https://www.privacy-ticker.com/data-breach-made-136000-covid-19-test-results-publicly-accessible/?fbclid=IwAR06thzxUwDizuCBTLUhFKjO-4l4VcCa_hHIzcVMgCoXKj24vYFXP04W-_0) (and yes, just one of **many** examples, before you ask).

One easy fix is to require a login before you can access your own data, but that opens more potential vulnerabilities. Of which more later.

Another is to use a different method of generating customer IDs.

Same applies.
New Things Added - Laravel 9.8 Released
Tags: php, laravel, webdev
Published: 2022-04-13 15:17:55

Let's get started quickly I found new things in Laravel 9.8 Released I wanted to share with you.

- The "old" Form Helper Accepts a Model
https://github.com/laravel/framework/pull/41842

```PHP
<input type="text" name="name" value="{{ old('name', $user->name) }}">
 
<input type="text" name="name" value="{{ old('name', $user) }}">
```

- Discover Anonymous Blade Components in Additional Paths
https://github.com/laravel/framework/pull/41637

```php
public function boot()
{
    Blade::anonymousComponentNamespace('flights.bookings', 'flights');
}
```
Here's an example of anonymous component usage
```php
<x-flights::panel :flight="$flight" />
```

- Set Factory Method

```php
// Before
EloquentModel::factory()->create(['name' => 'foo']);
 
// After
EloquentModel::factory()->set('name', 'foo')->create();
 
// Before
EloquentModel::factory()->someMethod()->create(['country' => 'NL']);
 
// After
EloquentModel::factory()->someMethod()->set('country', 'NL')->create();
```

- Allow a Custom Log Level in Exception Handling
https://github.com/laravel/framework/pull/41925

```php
use PDOException;
use Psr\Log\LogLevel;
 
/**
 * A list of exception types with their corresponding custom log levels.
 *
 * @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
 */
protected $levels = [
    PDOException::class => LogLevel::CRITICAL
];
```

I hope you enjoyed with me and to learn more about this release visit the sources and search more. I adore you who search for everything new.

Source :- https://laravel-news.com/laravel-9-8-0
Source :- https://www.youtube.com/watch?v=_qVcZ6jJgr4
Store your notes in github repository
Published: 2022-04-13 15:13:54

What if you could store notes as markdown inside your github repository. Would you use a webapp that allows to store your notes in your private github repository.

If yes, could you please share your feedback on my recent open source project - [https://github.com/vivekweb2013/gitnoter](https://github.com/vivekweb2013/gitnoter)


![GitNoter](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dg0xu2xs1w3eol2mhrdw.gif)
An introduction to python data structures
Published: 2022-04-13 15:11:28

[](url)
![Image descrition](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mjs219khozsihyazjiib.png)
## Introduction
 [](Python machinelearning datascience)
The purpose of this article is to give you an overview of data structures in python. A good grasp of data structures and algorithms and the ways to implement them will assist you solve challenges using code and create robust solutions to real world problems.
##What is a data structure?
The specific way of organizing, managing and storing data in a computer is called a data structure. This efficient way of managing data allows us to perform various operations in the data such as adding, appending and removing as per the requirement of the programs.
##Types of data structures

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/23xxoih0pbbe64za7pm0.png)
In this article we will be covering only the built in data structures.
##List
List is a type of data structure that contains a number of objects in a precise order to form a sequence to which elements can be added or removed. Each item is marked with a number corresponding to the order of the sequence, called index. In python index start at 0.

```
>>> list = [1,2,3,4]
>>> list
[1,2,3,4]
```
### List comprehension 
This is basically creating a new list from a previous list.
The syntax of list comprehension is `new_list = [ new_item for item in list`] in which the new_item are values in your new_list.

## Dictionaries
Dictionaries are really useful as they help to group together and tag related pieces of information.
Dictionaries are data structures in which a particular value is associated with a key value.
The dictionary syntax is `dict={"name":"kelvin", "age":12,}` in which the name and age are the keys while kelvin and 12 are the values. Note that items in a dictionary are separated using a comma.
### Retrieving data from a dictionary.
if you want to retrieve a piece af data from a dictionary, you just tap into the dictionary add a set of square bracket and inside provide the key name.

```
>>>dictionary ={"name": "kelvin", age: 23,}
>>>dictionary["name"]
>>>kelvin
```
NOTE:

- When retrieving something from a dictionary make sure you get the spelling well.

- Make sure you use the correct data type.

### Looping through a dictionary
If you want to iterate the pairs of values in a dictionary you have to use the for-in construct. This is 
possible through the use of the items() function.


```
>>> dict = {"name": kev, "age": 12}
>>> for (key, value) in dict.items():
    print(key)
>>> kev
```
## Tuple 
It is a data type for immutable ordered sequences of elements. Immutable because you can’t add and remove elements from tuples, or sort them in place.

## Sets
Set is a mutable and unordered collection of unique elements. It can permit us to remove duplicate quickly from a list.

Thankyou for reading this article. Hope you learnt something.
Checkout my next article as we go through user defined data structures.
5 Github Repositories You Should Know as a Developer
Tags: programming, beginners, career, github
Published: 2022-04-13 15:00:20

Grab a coffee and be ready to navigate between many helpful resources that can help you improve your developer’s skills.

In this today’s article, we’ll share 5 GitHub repositories with you. Not all of them are super-known, and they can help you grow as a developer by learning, practicing, and reading.

Let’s start with the first one!

## Awesome Roadmaps

The programming world is vast, and many have already asked themselves: “Where should I start if I want to become a [choose a technology] engineer?”.

This GitHub repository curates a list of many topics roadmaps categorized by topics: programming language, web development, mobile development, AI, and even more!

**+1.5k ⭐ ️=> [https://github.com/liuchong/awesome-roadmaps](https://github.com/liuchong/awesome-roadmaps)**

## Free Programming Books

Every article of this type mentions this repository, and we should do the same.

Indeed, this repository lists many programming books freely accessible online. On top of that, there are some for every language and on many topics.

Enjoy your reading!

**+230k ⭐ ️=> [https://github.com/EbookFoundation/free-programming-books](https://github.com/EbookFoundation/free-programming-books)**

## App Ideas

One of our favorite! Have you ever wondered what project to build when learning to code?

This GitHub page shares many projects that you can develop to improve your programming skills, depending on your developer profile.

![Developer Profile — GitHub Repository “App Ideas”](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zjsgcmgy42676yime4ui.png)

A great way to improve your portfolio!

**+49.7k ⭐️ =>[https://github.com/florinpop17/app-ideas](https://github.com/florinpop17/app-ideas)**

## Public APIs

In the previous part, we talked about a repository to find some project ideas. Another great way to build cool projects is to use APIs.

In the below GitHub, you’ll find a curated list of free APIs that you can use in your next application. All of them are categorized, and there is something for everyone (from Art & Design APIs to Blockchain ones).

**+188k ⭐ ️=> [https://github.com/public-apis/public-apis](https://github.com/public-apis/public-apis)**

## Awesome Git

As you may know, at [Flycode](https://www.flycode.com/), we’re helping the product teams work like software engineers using Git, and we crush it!

What’s better than a list of Git tools, resources, and shiny things to finish this post?

* **+1.1k ⭐ ️=> [https://github.com/dictcp/awesome-git](https://github.com/dictcp/awesome-git)**

## Do you know some others?

We hope you enjoyed this list, and it will benefit your career as a developer! If you know some others, [let us know on Twitter](https://twitter.com/FlycodeHQ) (you’ll see we have a lot of content about programming there 😉).