teleren/devto huggingface dataset:
First time with Flutter: build a simple app
Tags: flutter, crossplatform, opensource
Published: 2022-07-15 17:19:07

I'm always excited to try new libraries/languages/tools (who don't be?) and some time ago I create my first app with Flutter: DoRPA.

**DoRPA** stands for **Do**wnload **R**icevute **P**ortale **A**lloggiati. 
Portale Alloggiati: it's the Police portal which turist's structures must send daily data about who is arrived.
Ricevute (receipt): daily PDF to download that certifies the right sending of data

TLDR: see the repo https://github.com/lomby92/download-ricevute-portale-alloggiati

## 📍 Context
Each turist's structure need to send data every day, o download the receipt from the Portale Alloggiati and to keep the receipt for 5 years. Also: receipts are available for 30 days in the Portale and then there is no way to download them.

Early this year, the Police has published the Web-Service to send data without login in the Portale, that was no so accessible and user-friendly. Many PMS added the possibility to send data but the staff member of the hotel still need to access in the Portale to download receipts.

## 🎉 Solution
Let's make a very simple app to download receipts!

## 🧑‍💻 Development
I started to follow the official guide, it's well done and easy to jump-in: https://docs.flutter.dev/get-started/install

After the first steps I choose the UI and how it should work:
1. login page: the user need to insert required data and non-sensitive data should be saved for subsequent logins
2. download page: one input for the date and a simple submit button

As you can see, the UX is very simple, following the initial purpose.

Internally, the app doesn't have too much logic. There is a service to handle HTTP calls to the Web-Service and to handle errors.

I develop the app under Linux but for now it's available only for Windows. The power of Flutter: add MacOS and Linux will be really easy, without change the app itself.

## 🖼️ UI
The login page:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uf97jjxhr8g0au8z382l.png)

The download page and the date picker:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rpw2vflczn7qndt4a87u.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7md3qab2qalvl6a0bs84.png)

## 📦 Release
I played with GitHub Actions and in few minutes I was able to create the package needed to release the app. And, it's free!

Release pipeline: https://github.com/lomby92/download-ricevute-portale-alloggiati/actions/workflows/release.yml
Release page: https://github.com/lomby92/download-ricevute-portale-alloggiati/releases

## 💭 Conclusion
It was my first app, even if it's simple it was a pleasure to build it and release it. There always some work to do but for now it works and it's used at least for one hotel (every day) and this is a win experience for me!
Add Two Numbers II | Leetcode Problem Solution With Explanation
Tags: leetcode, competitiveprogram, algorithms, java
Published: 2022-07-15 17:06:24

## Problem Statement
You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.

You may assume the two numbers do not contain any leading zero, except the number 0 itself.

**Sample Input**
l1 = [7,2,4,3], l2 = [5,6,4]

**Sample Output**
[7,8,0,7]

**_Link to question:_** [https://leetcode.com/problems/add-two-numbers-ii/](https://leetcode.com/problems/add-two-numbers-ii/)

## Solution (Java)

```
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
public:
    ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
        stack<int> n1, n2, sum;
        ListNode *res=new ListNode();
        ListNode *cur=res;
        ListNode *prev;
        int carry=0;
        while(l1!=nullptr) {
            n1.push(l1->val);
            l1=l1->next;
        }
        while(l2!=nullptr) {
            n2.push(l2->val);
            l2=l2->next;
        }
        while(!(n1.empty() && n2.empty())) {
            if(n1.empty()) {
                sum.push((n2.top()+carry)%10);
                carry=(n2.top()+carry)/10;
                n2.pop();
            } 
            else if(n2.empty()) {
                sum.push((n1.top()+carry)%10);
                carry=(n1.top()+carry)/10;
                n1.pop();
            } 
            else {
                sum.push((n2.top()+n1.top()+carry)%10);
                carry=(n1.top()+n2.top()+carry)/10;
                n1.pop();
                n2.pop();
            } 
        }
        if(carry!=0)
            sum.push(carry);
        while(!sum.empty()) {
            cur->val=sum.top();
            cur->next=new ListNode();
            prev=cur;
            cur=cur->next;
            sum.pop();
        }
        prev->next=nullptr;
        return res;
    }
};
```

## Explanation
Firstly, push the numbers from both the linked lists into two separate stacks. This will store the linked list in reverse order and will also help in doing the addition operation. Now pop the elements from the stacks and add them and push the modulo 10 of the sum in the third stack and store the quotient 10 of sum in the carry (simple mathematical addition, just as we used to do in kindergarten). Lastly popped the elements from the third stack and inserted into the third linked list and that will the resultant linked list.
Codewars Challenge Day 4: ROT13
Tags: javascript, python, programming, challenge
Published: 2022-07-15 16:56:13

## Details

**Name Kata:** [ROT13](https://www.codewars.com/kata/52223df9e8f98c7aa7000062)
**5kuy**
**Description:** How can you tell an extrovert from an introvert at NSA? Va gur ryringbef, gur rkgebireg ybbxf ng gur BGURE thl'f fubrf.

I found this joke on USENET, but the punchline is scrambled. Maybe you can decipher it? According to Wikipedia, ROT13 is frequently used to obfuscate jokes on USENET.

Hint: For this task you're only supposed to substitue characters. Not spaces, punctuation, numbers etc.
**Example:**
```
"EBG13 rknzcyr." -->
"ROT13 example."

"This is my first ROT13 excercise!" -->
"Guvf vf zl svefg EBG13 rkprepvfr!"
```

## My Solutions

### JavaScript

```javascript
const rot13 = (str) => {
  return str.replace(/[a-z]/giu, (x) => {
    return String.fromCharCode(
      x.charCodeAt() + (
        x.toLowerCase() <= 'm' ? 13: -13
      ));
  });
}
```

### Python

```py
def rot13(message: str) -> str:
    rot13 = bytes.maketrans(
        b"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
        b"nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM"
    )
    return message.translate(rot13)
```
Embedded Systems Weekly #109
Published: 2022-07-15 16:45:59

Happy Friday and happy issue #109! If you read an interesting article do not hesitate to share it with me. It helps me a lot to keep the quality high.

Thank you to [Embecosm Limited](https://www.flickr.com/photos/embecosm/8079718499/) for the header's picture.

Happy reading!

### Articles 
[Division algorithms in FPGA](https://www.controlpaths.com/2022/06/20/division-algorithms-in-fpga/)
In this post the author implements three different division algorithms. If one of these days you can need a division on your FPGA you should bookmark this post.

[My business card runs Linux, yours can too](https://dmitry.gr/?r=05.Projects&proj=33.%20LinuxCard)
Impressive work with a $5 BoM (Bill of Material) and a $1 PCB.

[Visualising the Architecture of Qt Embedded Systems: Context and Container Diagrams](https://embeddeduse.com/2022/07/11/visualising-the-architecture-of-qt-embedded-systems-context-and-container-diagrams/)
I discovered the C4 model with this article. It is a kind of concurrent of UML with some interesting aspects interesting for embedded systems. I think it has to be read if you don't know the C4 model either.

[GCC Rust Approved By Steering Committee, Likely To Land For GCC 13](https://www.phoronix.com/scan.php?page=news_item&px=GCC-Rust-SC-Approved)
Rust is finally coming to GCC. Expected delivery with version 13.

[BMW F Series Gear Selector, Part Three: Success](https://www.projectgus.com/2022/07/bmw-f-series-gear-selector-part-three-success/)
I already shared the 2 first parts of this great series. In this last part Angus manages to fully control the gear from his computer. He has even build a GUI for that: the "Bavariatron 5000" :)

[ez-clang](https://echtzeit.dev/ez-clang/)
ez-clang is a tool that runs for you a C REPL on a MCU target. The technical effort is interesting even though I don't have a direct usage of it.

[picow_ntp_client.py](https://gist.github.com/aallan/581ecf4dc92cd53e3a415b7c33a1147c)
In this gist Alasdair Allan shares a Python (MicroPython) code sample to make a Raspberry Pi Pico W talks with a NTP server.

### Misc
[Retbleed: Arbitrary Speculative Code Execution with Return Instructions](https://comsec.ethz.ch/research/microarch/retbleed/)
It's not directly related to embedded systems, but it's an interesting reading for our culture. These exploits can help us to understand the subtle operations of the processors.
Magento 2 Layered Navigation & Product Filter Extention
Published: 2022-07-15 16:37:47

The [Magento 2 Layered Navigation extension](https://plumrocket.com/magento-layered-navigation) provides customers with faster and more convenient product filtering, powered by AJAX technology. Your website users will get instant results without reloading the page when filtering products and selecting filter attributes.

Among the most useful **features to improve customer experience** are:

- _Multi-select filtering_, which allows users to choose multiple values at once within one filter attribute (e.g. search for both “S” and “M” in the Size attribute).
- _Bulk filtering_, which allows users to select multiple filters and then apply them by clicking "Apply Filters" button (handy for customers who search for specific product options).
- _Price Slider with "from-to" inputs_, which is more flexible in specifying a custom price range than native price filter steps.
- _Attribute search box_, horizontal navigation, useful additional filters like Sale, Rating, Stock Status, and much more.

Additionally, the extension **facilitates the admin work** when customizing and adjusting the layered avigation to unique business needs:

- Allow filtering by custom options
- Create category-based filters
- Create filter groups to avoid navigation cluttering
- Visually sort filters as they look in the frontend

Last but not least, website owners can **increase website visibility in search and boost sales** with their reach SEO-optimized pages.

[Frontend Demo](https://demo2.plumrocket.net/product-filter/index.php/women/tops-women.html?product_key=product-filter&__from=plumrocket)
[Backend Demo](http://demo2.plumrocket.net/live/product-filter/?admin_panel)

Screenshots:


![Supercharge Your Store with Rich Layered Navigation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/neuyqfw9z1v9zwwfzpty.png)


![Use Vertical or Horizontal Layered Navigation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xwzunffe76yn56e36o7k.png)


![Choose Instant or Bulk Filtering](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dvqm4lc32isty6p5q4o7.png)


![Select Multiple Filter Options at Once](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sbqhva634fv93t2u65hg.png)


![Add a Search Box with Vertical Scrolling](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2nwwdrv60pvk9ojwa03a.png)


![Use Additional Filters to Fine-Tune the Results](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kipdgksyfxo09e54od3r.png)
Time And Space Complexity
Tags: beginners, codenewbie, computerscience, algorithms
Published: 2022-07-15 16:37:11

### By Annesha Mukhopadhyay

## Why Do We Care About Complexity

If you are someone who has been writing codes for quite some time now, you are bound to have heard of time and space complexity. But why are they important? To understand that, we first need to understand what time and space complexity are.
 

## Time Complexity
 
Time Complexity of an algorithm quantifies the amount of time taken by an algorithm to run as a function of the length of the input.
 
Time Complexity is an umbrella term for the different types of time complexities we can calculate which includes:

- **Worst Case Time Complexity**: This is the maximum number of times an operation needs to be executed before the algorithm is completed

- **Average Case Time Complexity**: This is the average number of times an operation needs to be executed before the code is completed

- **Best Case Time Complexity**: This is the least number of time an operation needs to be completed
 
We should keep in mind that time complexity is not the actual amount of time taken by the machine on which the algorithm is running.
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pmh3krqo2t8wd3pknhid.png)

## Space Complexity
 
Space complexity is basically the total space used by an algorithm with respect to the input size. It includes both auxiliary space (i.e., the temporary space used during the execution of an algorithm) and the space used by the input.
 
It is important to remember that space complexity depends on a variety of factors like the programming language used, the compiler or even the machine running the algorithm.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sl7nmx2rrwa5ooqdpz90.png)
  
 
In simpler terms, given the size of the input, the number of steps the algorithm will need to perform to be completed is the time complexity and the amount of storage the algorithm requires while working, I.e., performing all those steps is the space complexity.
 
 
## Why do time and space complexity matter?
 
In a real world scenario, programmers and developers are bound by the physical constraints of the device they intend to run their applications on and this is where time and space complexity become important. We don’t want an algorithm that exceeds the amount of usable  space a system has at any given point. At the same time, we also don’t want the algorithm to take so long that the application gets slowed down.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4qghpv3unoqlfalzmw25.png)
 
Neither of the two are more important than the other and the key to writing efficient codes is finding the balance between the two. Since space is reusable it is sometimes smarter to use more space to speed up the algorithm. But at the same time using too much space will eventually slow down the application because the total amount of space is fixed for any hardware. So, your algorithms should not have a very high time complexity but should also not have an absurdly high space complexity.

~Mijo
How to run your system PHP at 8.x & Laravel Valet at 7.x
Published: 2022-07-15 16:37:00

**Please see comments for some important updates!**

----------

![Screenshot on how to do this.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ndu5pwmi4yx1ixtwejc2.jpg)

Valet, when told to use a specific version of PHP (using `valet use`) symlinks `$HOME/.config/valet/valet.sock` (on macOS) to a specific version of PHP installed on your system. If you use `valet use`, unfortunately, it switches this symlink _and_ your system PHP version.
 
But all you need to do is (with Homebrew) use `brew unlink php && brew link php@8.1 --force --overwrite` to tell your system to use PHP 8.1.x, that does _not_ tell Valet what version to use, `valet use` does.

If you use e.g. `valet use php@7.4` you can simply use `brew unlink php && brew link php@8.1 --force --overwrite` to re-link your system back to using PHP 8. If you look at `$HOME/.config/valet/valet.sock` you will notice it's still symlinked to `valet74.sock`, and you can confirm with e.g. `phpinfo()`.
 
It's a bit of a hack, but it works for me.

Take a [look at some aliases](https://github.com/aubreypwd/zsh-plugin-my-config/blob/master/my-commands.zsh#L128) I have setup to make this easy with `valet@7` which makes sure my system continues to run 8.1.
How to Comment Code in JavaScript – Best Practices
Tags: javascript, beginners, webdev, tutorial
Published: 2022-07-15 16:32:00

Have you ever built a JavaScript programme only to discover six months later that you have no idea what’s going on in the code? You most likely failed to do something that all programmers forget to do: write comments!

When writing code, you may encounter some complex logic that is difficult to understand; this is an excellent time to add comments to the code that describe what is happening. Not only will this help you remember it later, but it will also help others comprehend it when they look at your code.

A computer programme is a set of “instructions” that a computer will “execute.” These computer instructions are known as statements in JavaScript programming language. However, not all JavaScript statements are “executed”.

Code after a double slash `//`, or between `/*` and `*/`, is treated as a comment. Comments are ignored, and are not executed.

## Single line comments

In JavaScript, you can make a single line comment by putting two slashes “`//`” in front of the code, which JavaScript will disregard.

It is most common to use single line comments in your code.

Here is an example:

```html
<script>
// This is a single line comment
alert(“This is an alert box!”);
</script>
```

## Multiple-Line Comments

Comments that span multiple lines begin with `/*` and conclude with `*/`. JavaScript will ignore any text between `/*` and `*/`.

Here is an example:

```html
<script>
/* This code creates a Javascript popup alert box. 
An alert box is often used if you want to make sure
information comes through to the user.
 */
alert(“This is an alert box!”);
</script>
```

Javascript comments show what the code performs and the decisions that go into code design. They can also inhibit code execution if necessary. Good comments allow us to maintain the code well, come back to it after a delay and use it more effectively.

To learn more about JavaScript why not check out my [blog](https://maxlockwood.dev/category/javascript/)
Easy reddit search via google
Tags: google, reddit, search
Published: 2022-06-28 14:25:00

I ran through a bit of my google search history over the last year or so and over 90% of my searches included `site:reddit.com`.    I thought I was sick of typing that out every time and the data just solidified that thought.    

While there are many ways to not have to type the site specific search parameters manually for every search, I probably took the most ridiculous option and made a site that basically wraps google.com.   The search query gets passed through to google.com along with `site:reddit.com`.

I'm hosting this on GitHub.io and using Cloudflare for DNS.  No tracking, no monetization.  Just made this for ease of use on my side and thought I'd share.   (I'm not sure what, if anything GitHub and Cloudflare collect for usage)

[Source Repo](https://github.com/jason-costello/jason-costello.github.io)

[searchredd.it](https://searchredd.it)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rpiy6bou4uez595agsu7.gif)
Cmd is so annoying, so i made a new shell
Tags: go, window, shell, programming
Published: 2022-07-15 16:10:18

Using cmd in window's for navigating in the project is so annoying, like using doskey and registry for navigating to a custom dir path and if we want to navigate to the nth parent dir in our path, we have to use cd .. for n times.

So i thought "OK, It's time to build a new shell". The main goal of this project is to overcome some of my problems faced while using window's cmd and have some fun.


First i thought of creating a GUI application with stunning UI. But i convinced myself to build a super simple console application which consume less memory and execute faster, so i opened my editor and started to write it in c++. It took me over 2 days(like 4+ hours) to build this project.

Terminal:[Terminal](https://github.com/ATOMMAX-2001/Terminal)

After two weeks, I thought of adding some more features(commands), so i rewrote the entire application again in golang.

BlogTerminal:[BlogTerminal](https://github.com/ATOMMAX-2001/BlogTerminal)

Final Output:

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

Support:[Support](https://www.buymeacoffee.com/abilash)
Write the program to convert the binary to decimal ?
Tags: beginners, javascript, binary, decimal
Published: 2022-07-15 16:09:50

Binary is the number system all digital computers are based on. Therefore it's important for developers to understand binary, or base 2, mathematics. The purpose of Bin2Dec is to provide practice and understanding of how binary calculations
app.js

```
let decimal = document.getElementById('decimal');
let binary = document.getElementById('binary');
let error = document.getElementById('error');
let binaryNumber = '';
let maxInputLength = 10;
binary.addEventListener('keypress', (e) => {
  error.innerHTML = '';
  if (binaryNumber.length == maxInputLength) {
    error.innerHTML = `You can enter only ${maxInputLength} the length of the binary`;
    return e.preventDefault();
  }
  if (!(e.key == 0 || e.key == 1)) {
    error.innerHTML = 'Invalid key press';
    binaryNumber.replace(e.key, '', '');
    binary.value = binaryNumber;
    e.preventDefault();
    return false;
  }
  binaryNumber += e.key
  decimal.innerHTML = binaryNumber;
})
let count = 0;
let decimalNumber = 0;
window.addEventListener('click', (e) => {
  if (!binaryNumber.length) {
    return e.preventDefault();
  }
  for (let j = binaryNumber.length; j > 0; j--) {
    decimalNumber += Number(getDecimalNumber(j,Number(binaryNumber[count])))
    count++;
  }
  decimal.innerHTML = decimalNumber;
  decimalNumber = 0
})

function getDecimalNumber(count,binary) {
  let n = 0;
  switch (count) {
    case 1: n = binary ? 1 : 0; break;
    case 2: n = binary ? 2 : 0; break;
    case 3: n = binary ? 4 : 0; break;
    case 4: n = binary ? 8 : 0; break;
    case 5: n = binary ? 16 : 0; break;
    case 6: n = binary ? 32 : 0; break;
    case 7: n = binary ? 64 : 0; break;
    case 8: n = binary ? 128 : 0; break;
    case 9: n = binary ? 256 : 0; break;
    case 10: n = binary ? 512 : 0; break;
  }
  return n;
}
```

---


index.html
```
<!DOCTYPE html>
<html>
<body>
    <h2 style="text-align: center">Binary to Decimal conversion</h2>
    <div style="text-align: center">
        <form>
            <div id="decimal">0</div><br>
            <input type="text" id="binary" style="width:300px;padding:10px;font-size:16px;font-weight: 500;">
            <div style="font-size:10px;color:red" id="error"></div>
        </form>
    </div>
    <script src="./app.js"></script>
</body>
</html>
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4g8tfu8zo996ptmcsoxg.png)

**Note : It will work only one time for again reload the page**