teleren/devto huggingface dataset:
#10daysofcodechallenge by Ingressive for Good (#Day 7)
Published: 2022-09-27 22:48:38

I am close to the end of a 10-day coding challenge organized by Ingressive for Good and I'll be sharing my thoughts on Day 7 of the challenge.

Let me briefly describe how the challenge works before I share my experience with you. From September 21 through October 30, 2022, the challenge is to solve one common algorithm problem every day for ten days.

Today's “UTF-8 Validation" It is the 393rd algorithm challenge on "Leetcode.com".

Here is the question:

> Given an integer array data representing the data, return whether it is a valid UTF-8 encoding (i.e. it translates to  a sequence of valid UTF-8 encoded characters).

> A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules:

> For a 1-byte character, the first bit is a 0, followed by its Unicode code. For an n-bytes character, the first n bits are all one's, the n + 1 bit is 0, followed by n - 1 bytes with the most significant 2 bits being 10.
This is how the UTF-8 encoding would work:

     Number of Bytes   |        UTF-8 Octet Sequence
                       |              (binary)
            1          |   0xxxxxxx
            2          |   110xxxxx 10xxxxxx
            3          |   1110xxxx 10xxxxxx 10xxxxxx
            4          |   11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
> x denotes a bit in the binary form of a byte that may be either 0 or 1.

> Note: The input is an array of integers. Only the least significant 8 bits of each integer is used to store the data. This means each integer represents only 1 byte of data.

I'll now discuss my algorithm solving experience. I created a variable and initialized it with a value of zero. The homogeneity of each byte in the array was verified by comparing it to the UTF-8 constant. The value of the variable was increased if there was no homogeneity.

This task was completed in javaScript, took 111 milliseconds to execute, and consumed about 44 MB of memory.
Adopt a Growth Mindset
Published: 2022-09-27 22:48:00

Not sure what I'm suppose to write but, I'm trying to develop a new habit of sharing what I have learned this week.

{https://www.youtube.com/watch?v=hiiEeMN7vbQ&ab_channel=StanfordAlumni}

Fixed mindset refers to the belief that impactful learning is based on innate ability. People with fixed mindsets believe that basic abilities, intelligence, and talent are fixed traits that you are born with. In practice, this belief is flawed and limits one's ability to learn new concepts, skills, and behaviors.

Growth mindset, instead, refers to the belief that impactful learning results from hard work, training, and practice. There is progression to someone’s ability based on how much time and effort they invest in it. Talents and abilities can be developed through effort and persistence, no matter where you start.
UTF-8 Validation
Tags: python, algorithms
Published: 2022-09-27 22:21:00

Another [leetCode](https://leetcode.com/problems/utf-8-validation/) challenge on UTF-8 Validation.

**PROBLEM**
Given an integer array data representing the data, return whether it is a valid UTF-8 encoding (i.e. it translates to a sequence of valid UTF-8 encoded characters). - You can use the link above to see more details.

**SOLUTION**
This was quite a challenge! let's look at the step to solve it.

- Loop through the array.

- Find the binary representation for each integer using the format method that takes in two arguments

- Loop through the first octet sequence to determine if it is a valid UTF-8 encoding, by checking if the character is 1 - 4 bytes Long.

- Check the next two bit of the sequence if they follow the rules, to check for validity

**Rules**
A character in **UTF8** can be from **1 to 4 bytes long**, subjected to the following rules:

For a **1-byte** character, the first bit is a 0, followed by its Unicode code.
For an **n-bytes** character, the first n bits are all one's, the n + 1 bit is 0, followed by n - 1 bytes with the most significant 2 bits being 10.

This is how the UTF-8 encoding would work:

```
Number of Bytes   |        UTF-8 Octet Sequence
                       |              (binary)
   --------------------+-----------------------------------------
            1          |   0xxxxxxx
            2          |   110xxxxx 10xxxxxx
            3          |   1110xxxx 10xxxxxx 10xxxxxx
            4          |   11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
```
x denotes a bit in the binary form of a byte that may be either 0 or 1.
Division Solver
Tags: python, programming, math, showdev
Published: 2022-09-27 22:13:16

## Division Solver in python

Need to solve a division problem quick?
Or to lazy to do the division problems on ixl?

Never fear, The [The Division Solver](https://replit.com/@sonicx180/Divison-Solver?v=1) is here!

Thanks for reading, or using!
Phalcon v5.0.2 Released
Tags: phalcon, phalcon5, release
Published: 2022-09-27 22:10:32

---
title: Phalcon v5.0.2 Released
published: true
date: 2022-09-27 21:58:28 UTC
tags: phalcon,phalcon5,release
canonical_url: 
---

We are happy to announce that Phalcon v5.0.2 has been released!

Taking advantage of our now quick release cycle and reports from the community, a couple of bugs have been identified and resolved in this minor release.

Thank you as always to our community!

## Changelog

### Fixed

- Fixed `Phalcon\Html\Escaper::attributes()` to accept any value and transform it to string [#16123](https://github.com/phalcon/cphalcon/issues/16123)
- Fixed `Phalcon\Logger\AbstractLogger::getLevelNumber()` to better check for string levels [#16123](https://github.com/phalcon/cphalcon/issues/16123)

## Upgrade

Developers can upgrade using PECL

```
pecl install phalcon-5.0.2

```

To compile from source, follow our [installation document](https://docs.phalcon.io/5.0/en/installation)
TypeScript
Tags: typescript
Published: 2022-09-27 21:53:15



Typescript (also known as ECMAScript) started its life as a simple scripting language for browsers. At the time it was invented, it was expected to be used for short snippets of code embedded in a web page - writing more than a few dozen lines of code would have been somewhat unusual. Due to this, early web browsers executed such code pretty slowly. Over time, though, JS became more and more popular, and web developers started using it to create interactive experiences.
Furthermore, Typescript won't allow any errors, more so, it would be difficult to learn TypeScript without learning JavaScript! TypeScript shares syntax and runtime behavior with JavaScript, so anything you learn about JavaScript is helping you learn TypeScript at the same time.
Roughly speaking, once TypeScript's compiler is done with checking your code, it erases the types to produce the resulting "compiled" code. This means that once your code is compiled, the resulting plain JS code has no type of information.
This also means that TypeScript never changes the behavior of your program based on the types it inferred. The bottom line is that while you might see type errors during compilation, the type of system itself has no bearing on how your program works when it runs.
Finally, TypeScript doesn't provide any additional runtime libraries. Your programs will use the same standard library (or external libraries) as JavaScript programs, so there's no additional TypeScript-specific framework to learn.
I said earlier that typescript wouldn't allow those buggy programs to run at all. Detecting errors in code without running it is referred to as static checking. Determining what's an error and what's not based on the kinds of values being operated on is known as static type checking.
TypeScript checks a program for errors before execution, and does so based on the kinds of values, it's a static type of checker.
To summarize, typescript catches 50% of bugs. TypeScript is JavaScript's runtime with a compile-time type checker. The way you use a method in TypeScript is the same way you do so in JavaScript.
Move NodeJS server from Windows to Linux VPS
Tags: node, ubuntu, linux, windows
Published: 2022-09-27 21:47:40

Recently, we experienced a crash of hard drive in one of our server. Thanks to the RAID, data weren't lost, but this incident was a great impetus to move our NodeJS-based chatbots to the VPS server of a reliable cloud provider. As there is always a lack of time, the challenge was set to fit in one hour. The task was exacerbated by me being totally Windows guy, with only basic knowledge of Linux. I need to google almost every command. Even `ls`. I'm not joking.

The first step was to set up NodeJS. Obvious `apt install nodejs` got me stable but ancient version 12.x. I turned to the internet and learned about Snapcraft application store. There is a `snap` command to install NodeJS, which turned out to be a costly mistake, as I had lost half of the allotted time just to realize that snap somehow breaks the ability of PM2 to span new processes.

Eventually, I had found the command to download and install the latest version. Quite unpronounceable, though, from a Windows perspective:

```bash
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -
apt install nodejs
```

Then came the Yarn, our package manager of choice:
```bash
npm install -g yarn
```

The whole folder of the chatbot was zipped (excluding node_modules), transferred via FTP and unpacked. A bit of correction was needed to replace system environment variables with `dotenv` package and `.env` text file.

As Windows and Linux line endings differ, git was told to ignore it:

```bash
git config --global core.autocrlf true
```

On Windows, we used system Task Scheduler for launching chatbot server at system startup. Here, PM2 process manager comes to the help. 

```bash
npm install -g pm2 
```

I tried to compel it working with `yarn start` command, but quickly abandoned futile attempts and retreated to calling compiled JS instead.
```bash
pm2 start dist/server.js --name chat-bot --watch
```
Strange, that of two NodeJS servers, one refused to work with `--watch` flag. I didn't have enough time to dive into the problem and just switched off watching for the project. It is not updated often, anyway.

Don't forget to start up projects automatically upon VPS reboot, as it could happen at any moment:
```bash
pm2 startup
```
That is it. Transferring NodeJS servers from Windows to Linux turned out to be not so difficult and long.
Sitecore Tokens for Standard Values
Tags: dotnet, webdev, tutorial, sitecore
Published: 2022-09-27 21:45:57

As Sitecore developers, when we're creating templates, a good practice is to add _Standard Values_ so that fields can have default values, or sample values. 

For this purpose, we can use _Sitecore Tokens_, this will allow us to dynamically add values to fields, according to the item that is being created by the Content Author.

### **Tokens:**

These are the tokens that we can use:

| Token | Utility |
|----------|:-------------:|
| **$name** | The name of the item. |
| **$id** | The ID of the item. |
| **$parentid** | The ID of the parent of the item. |
| **$parentname** | The name of the parent of the item. |
| **$date** | The system date (yyyyMMdd). |
| **$time** | The system time (HHmmss). |
| **$now** | The system date and time (yyyyMMddTHHmmss). |

### **Example:**

Below we can see an example with the `$name` token. In this example, we have a field with the name _Heading_, and at the time of creating a new item, this field will take the name of the item. 

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

### **Thanks for reading!**

Now you know how to dynamically add values to your Standard Values and the different tokens you can use in a general way.

If you have any questions or ideas in mind, it will be a pleasure to be able to be in communication with you, and together exchange knowledge with each other.

See you on [Twitter](https://twitter.com/esDanielGomez) / [esDanielGomez.com](https://esdanielgomez.com).
Using mysqldump without MySQL server installed
Tags: mysqldump, databasebackup
Published: 2022-09-27 21:44:12

If you have a server such as a **Web Server** built using Laravel Forge, it only installs PHP and NGINX.

You plan on using a managed database from Digital Ocean and use the server to run `mysqldump` for database backup, you will not be able to. 

In order to use mysqldump `mysql-client` must be installed on the server.

Log into SSH and run

```sh
sudo apt update
sudo apt install mysql-client
```

Found info at https://mysqldump.guru/how-to-install-and-run-mysqldump.html
DAY 7: UTF-8-VALIDATION
Tags: java, codereview
Published: 2022-09-27 21:37:46

Hey! It's day 7 of 10 days coding challenge with I4G. Today's task was to write a code that validates a utf-8 code.

**Thought process:**
**Understanding of problem:** The problem here is to validate a utf-8 character. a utf-8 character has the following features:

- A valid UTF-8 character can be 1 - 4 bytes long.
- For a 1-byte character, the first bit is a 0, followed by its unicode.
- For an n-bytes character, the first n-bits are all ones, the n+1 bit is 0, followed by n-1 bytes with most significant 2 bits being 10.
- The input given would be an array of integers containing the data. We have to return if the data in the array represents a valid UTF-8 encoding. The important thing to note here is that the array doesn't contain data for just a single character. As can be seen from the first example, the array can contain data for multiple characters all of which can be valid UTF-8 characters and hence the charset represented by the array is valid.

**Solution:** To achieve this task, I used bit manipulation. A right shift if performed on the to check it's results for either 1 byte, 2 byte, 3 bytes or 4 bytes.

**Algorithm:**

- Declare two integer variables: count, i
- Set count = 0;
- Using for loop iterate through the array of integers with condition; i = 0, i < data.length
- perform bitwise shift and compare to the features of utf-8 code
- Return true if condition is met or false if otherwise


Checkout the code here: https://leetcode.com/problems/utf-8-validation/submissions/
DAY 7 CODE CHALLENGE
Published: 2022-09-27 21:34:41

## **UTF-8 VALIDATION**
An integer array "data" representing the data was given to return whether it was a valid UTF-8 encoding. That is, if it translates to a sequence of valid UTF-8 encoded characters.

**PROCEDURE** 

- Track pendingBytes by starting with zero value.

- Iterate through the input data, convert 1 to 00000001.

- If the pendingBytes equalizes to zero(0) at the same time with the first value in byte array (byte[0]), continue.

- Using the loop, iterate through the bit of byte, it must start with 1, if bit is not equal to 1, break and increment pendingBytes.

**NOTES**
If starting, it needs to be > 1, 10 is only for following bytes.
secondly, if greater than 4, it is also invalid.
Lastly, a character in UTF-8 can be from 1 to 4 bytes long.

- Therefore, if pendingBytes is less than or equal to 1 or greater than 4, return false and decrease pendingBytes.

- If the first value in byte array equalizes to "1" and second value equalizes to "0", pendingBytes is decreased while we jump over one iteration in the loop and return false.

- If none pending, it is valid, therefore we return pendingBytes to equalize zero (0).

**OUTCOME**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l4icswn1f532wfbfyvvv.PNG)
Hands on gRPC
Tags: grpc, microservices, protobuf
Published: 2022-09-27 16:34:58

gRPC is becoming the standard to communicate between microservices. It uses HTTP 2.0 (released in 2015) as its underlying transfer protocol which is more faster and efficient compared to HTTP 1.1 that was released at 1997 and still used in the modern days.

And with all that it secures the connections by default with SSL/TLS, so not only performance but also security are included.

Unlike REST APIs which uses json communication which takes a lot of size and latency, it uses what it is called by ProtoBuf (Protocol Buffers) that are way minimal and faster with communications.

For now, gRPC is used a lot in micro services and mobiles, especially for mobiles because it is faster and the transferred data is minimal and can be delivered in minimal time compared to HTTP 1.1. For web it’s still not there yet but there are some workarounds like making some gateways for that matter.

Also one of the cool features about gRPC framework is that it is language agnostic, meaning that it works for any language out there, you just need to write a proto file which has a simple syntax and then let the protoc (proto compiler) handle generating the code for the language you want like C++, Go, Java, … etc. All what you need to care about is the implementation for the services.

There are 4 types of APIs in gRPC, unary, server streaming, client streaming and bi directional streaming. Which holds a new way for communication, especially the streaming ones compared to REST.

In this example, I have created a blogs service that handles all the CRUD operations with MongoDB, it has unary rpc for all the operations and a server streaming to list all the blogs from the database. You can see in action how simple it is, because as I said above you just need to care about the implementation, all other things are generated for you!

To test the example yourself, check this [repo](https://github.com/omdxp/mongo-grpc)
What is Text Wrapping in Excel
Tags: wrapping, text, excel, microsoft
Published: 2022-09-27 21:15:51

If you are working in Microsoft Excel for the first time, the question ‘What is Text Wrapping in Excel’ may have come to your mind. If we only talk about the literal meaning of “wrapping,” it is paper or plastic that covers or protects something. While Text in a cell in Microsoft Excel can be wrapped to display on many lines, you have the option to manually input a line break or format the cell such that the content automatically wraps. Simply, Wrap Text is a feature in Microsoft Excel and other spreadsheet applications that displays all the data in a cell, even if it extends beyond the cell boundary.



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

Read more at:

https://hecodesit.com/what-is-text-wrapping-in-excel/
UTF-8 Validation
Published: 2022-09-27 21:05:33

It's day 7 of the #I4G10DaysOfCodeChallenge. The objective of today's task was to determine whether the set of integers constitutes a valid UTF8 string or not.

You can find more details about the challenge [here](https://leetcode.com/problems/utf-8-validation/)

A character in UTF-8 can be from 1 to 4 bytes long, subjected to the following rules:

1. For a 1-byte character, the first bit is a 0, followed by its Unicode code.
2. For n-bytes character, the first n-bits are all ones, the n+1 bit is 0, followed by n-1 bytes with the most significant 2 bits being 10.

```
     Number of Bytes   |        UTF-8 Octet Sequence
                       |              (binary)
   --------------------+-----------------------------------------
            1          |   0xxxxxxx
            2          |   110xxxxx 10xxxxxx
            3          |   1110xxxx 10xxxxxx 10xxxxxx
            4          |   11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
```

**Syntax**:

1. Start with count = 0.
2. for “c” ranging from 0 to the size of the data array.

3. If the count is 0, then:
- If x/32 = 110, then set count as 1. (x/32 is same as doing x >> 5 )
- Else if x/16 = 1110, then count = 2 (x/16 is same as doing x >> 4 )
- Else If x/8 = 11110, then count = 3. (x/8 is same as doing x >> 3 )
- Else if x/128 is 0, then return false. (x/128 is same as doing x >> 7 )
- Else If x/64 is not 10, then return false and decrease the count by 1. 
4. When the count is 0, return true.

**Result**:
Runtime: 234 ms, faster than 56.39% of Python3 online submissions for UTF-8 Validation.

Memory Usage: 14.1 MB, less than 97.22% of Python3 online submissions for UTF-8 Validation.
Introduction à React: #1 - Initialisation de mon premier projet
Tags: react, javascript, web, french
Published: 2022-09-27 20:58:55

---
title: Introduction à React: #1 - Initialisation de mon premier projet
published: true
description: De quoi j'ai besoin pour et comment initialiser un projet React
tags: react, javascript, web, french
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
---

## Avant propos
Un jour, dans ma jeune vie de developeur, j'avais lu un article d'un gars qui disait "Design for those who don't have time" un truc du genre, bref OSEF.

Le gars expliquait la difference entre le Judo et le Krav Maga

Le Judo contient une philosophie inherente à la mentalité qu'avait Jigoro Kano et puis le coté mojo du samurai et tout... C'est stylé et c'est super respectable, perso c'est la voie que j'aime.

Le Krav Maga à été créé par des juifs qui voulaient se defendre de putains de nazis qui voulait les faire cuire. Les mecs n'avaient pas le temps de philosopher: Il fallait se defendre avant tout. 

C'est un aspect que je respecte et que je salue. Nous allons suivre la voie de ceux qui ont inventé le Krav Maga.

Cette voie signifie que je vais aller droit au but. Ici tu vas apprendre à faire du React proprement et vite. La philosophie et la syntaxe de JavaScript et le type de petit dej qu'a eut la personne qui a créé React etc... osef

## Premier projet
Il te faut installer
- [NodeJS LTS](https://nodejs.org/en/)
- [Visual Studio Code](https://code.visualstudio.com/) (ou Bloc note 🥲)

C'est parti, tu peux ouvrir ton terminal (cmd, gitbash...):

```bash
node -v # Entrée
# v16.17.0
npm -v # Entrée
# 8.15.0
```

Tu vas créer un nouveau projet:
```bash
npx create-react-app mon-appli
# J'entre dans le dossier du projet
cd mon-appli
# Je demarre l'appli
npm start
```


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