teleren/devto huggingface dataset:
Brief detail about conditional statements, loops, and control flow in Python
Tags: python
Published: 2023-05-29 05:58:21

Here's a brief detail about conditional statements, loops, and control flow in Python, along with three challenges to solidify your understanding

## Conditional Statements (if/else)

Conditional statements allow you to perform different actions based on different conditions. In Python, the `if` statement is used to execute a block of code if a certain condition is true. The `else` statement can be used to execute a different block of code if the condition is false.

Challenge 1: Write a Python program that takes a user's age as input and prints whether they are eligible to vote or not.

Challenge 2: Create a program that determines whether a given year is a leap year or not. A leap year is divisible by 4 but not divisible by 100, except if it is also divisible by 400.

## Loops (for/while)

Loops allow you to repeatedly execute a block of code until a certain condition is met. In Python, the `for` loop is used to iterate over a sequence of elements, while the `while` loop is used to repeat a block of code as long as a certain condition is true.

Challenge 3: Write a Python program that prints the sum of all numbers from 1 to 100 using a loop.

## Control Flow

Control flow statements allow you to alter the execution path of your program. The `break` statement is used to exit a loop prematurely, while the `continue` statement is used to skip the current iteration and move to the next one.

Challenge 4: Create a program that asks the user to enter a series of numbers. Implement a loop that keeps asking for numbers until the user enters a negative number. Print the sum of all the positive numbers entered.

Challenge 5: Write a program that generates a random number between 1 and 10. Allow the user to guess the number, and provide feedback if their guess is too high or too low. Repeat the guessing process until the user guesses the correct number.

These challenges will help you practice and reinforce your understanding of conditional statements, loops, and control flow in Python. Feel free to explore additional concepts and experiment with different scenarios to further enhance your skills. Happy coding!
Daily used Git commands.
Tags: git, github
Published: 2023-05-29 05:40:59

Let's consider an example where you have a project named "my-project" and you want to use Git for version control. Here's how you can use Git commands in your daily workflow:

1. Initializing a Git Repository:

    ```
    $ cd my-project
    $ git init
    ```

2. Adding and Committing Changes:

    ```
    $ git add <file1> <file2>  # Add specific files
    $ git add .               # Add all files
    $ git status              # Check the status of the repository
    $ git commit -m "Initial commit"
    ```

3. Cloning a Remote Repository:

    ```
    $ git clone <repository-url>
    ```

4. Pulling and Pushing Changes:

    ```
    $ git pull origin <branch>  # Fetch and merge remote changes
    $ git push origin <branch>  # Push local changes to remote repository
    ```

5. Creating and Switching Branches:

    ```
    $ git branch                   # List all branches
    $ git branch <new-branch>      # Create a new branch
    $ git checkout <branch>        # Switch to a different branch
    ```

6. Merging Branches:

    ```
    $ git checkout <target-branch>  # Switch to the target branch
    $ git merge <source-branch>     # Merge the source branch into the target branch
    ```

7. Viewing Commit History:

    ```
    $ git log                # Show commit history
    $ git log --oneline      # Show condensed commit history
    ```

8. Checking Differences:

    ```
    $ git diff               # Show differences between working directory and staging area
    $ git diff --staged      # Show differences between staging area and last commit
    ```

9. Adding Remote Repositories:

    ```
    $ git remote add <name> <url>    # Add a remote repository
    $ git remote -v                  # List all remote repositories
    ```

10. Discarding Changes:

    ```
    $ git checkout -- <file>    # Discard changes in a specific file
    $ git reset --hard          # Discard all local changes and reset to last commit
    ```

These commands should give you a good starting point for using Git in your project. Remember to replace `<file>`, `<branch>`, `<repository-url>`, and `<new-branch>` with the appropriate values specific to your project.
How to Enable Lazy Loading in Magento 2
Tags: webdev, magento, magento2tutorials
Published: 2023-05-29 04:29:33

Lazy Loading is a viable method for upgrading site execution, where assets like pictures are possibly stacked when required. 

This approach can accelerate your site stacking time as the program doesn't need to stack every one of the assets on a page in one go. Magento 2 gives a straightforward strategy to empower sluggish stacking for better site execution, and in this blog, we will direct you through the cycle bit by bit for **_how to enable lazy loading in Magento 2._**

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

It's actually significant that languid stacking can likewise support lessening how much information moved to the client's gadget. This is particularly essential for versatile clients with restricted information plans. By stacking just the vital assets, lethargic stacking can essentially bring down how much information moved to the client's gadget, resulting in a faster and more proficient experience for the client.

For more info, visit **_https://webguru.dev/how-to-enable-lazy-loading-in-magento-2/_**
Rewriting My Personal Website with Markdown: Prioritizing Performance and Meaningful Content
Published: 2023-05-29 05:19:06



## Introduction

In today's web development landscape, it's common to come across websites filled with visual effects and attention-grabbing features. However, this approach can have its drawbacks, demanding more performance resources and resulting in a quickly tiresome experience for site visitors. In this article, I will share my experience of rewriting my personal website with Markdown, prioritizing performance and focusing on meaningful content.

## The Temptation of Visual Effects and Their Impact on Performance

It's understandable that many developers are drawn to the impressive visual effects that can be achieved with the latest front-end technologies and libraries. Sophisticated animations, smooth transitions, and interactive elements can indeed capture visitors' attention. However, these features can come at a high cost in terms of performance.

The excessive use of heavy animations, large images, and complex libraries can lead to a significant increase in website loading time. Visitors with slower connections or older devices may have a frustrating experience waiting for all resources to load. Additionally, visual fatigue can set in quickly, resulting in lower information retention and faster site abandonment.

## Prioritizing Performance and Meaningful Content with Markdown

When rewriting my personal website with Markdown, I decided to prioritize performance and focus on delivering meaningful content to visitors. Instead of investing in flashy visual resources, I opted for a more minimalist and content-centered approach.

Markdown allowed me to express my ideas and share detailed information in a clear and concise manner. With a well-defined content structure, I was able to organize sections, highlight important points, and provide relevant details about my projects and experiences.

Furthermore, by avoiding the excessive use of images and visual effects, I ensured fast page loading times for my website. This resulted in a smoother browsing experience for visitors, without unnecessary distractions and with a focus on the content that truly matters.

## Conclusion

Through rewriting my personal website with Markdown, I have learned to value performance and meaningful content over flashy visual effects. By prioritizing a more minimalist and content-centered approach, I could offer visitors a seamless browsing experience without compromising the quality of the shared information.

Markdown has proven to be a powerful and versatile tool for creating structured and easily readable content. By adopting this markup language, I was able to provide detailed and relevant information while maintaining a fast and accessible website.

I invite you to consider the importance of performance and meaningful content in your own web projects. By balancing these aspects, you can deliver an enjoyable and engaging experience to visitors while prioritizing the accessibility and efficiency of your site.
Vertex AI And GCP Cloud Dataprep VM Instantiation For One JSON Function In A Cloud Shell
Published: 2023-05-29 04:59:38

GCP JSON CLI For One Virtual Machine Instance:

--worker-nodes n1-standard-1
                 n2-standard-2

                     gsutil cp gs://(

1. VM Node 1 In Cloud Shell Browser)
)

2.   --worker-node:1
       n1-standard-1(JavaScript Atomic Function Scalability):

                            index.js: const functions = require('@google-cloud/functions-framework');
functions.cloudEvent('eventStorage', (cloudevent) => {
  console.log('A new event in your Cloud Storage bucket has been logged!');
  console.log(cloudevent);
});
-Now We have to detect the exact function for Cloud Storage Bucket CLI for one cloud event where its downward AI/ML API can be run in ingress Cloud Shell
Full Stack Mastery using Full Stack end to end Applications
Tags: node, javascript, fullstack, react
Published: 2023-05-29 04:57:51

All,

I will be launching another playlist which will talk about Full Stack App development using different Stacks 

- MERN
- MEAN
- T3 Stack 
- Grand Stack 
- JAM Stack 
- Custom Stack using Nest JS/ Next JS - Prisma/TypeORM
- Custom Stack using Express JS/Nest JS/ Next JS - Prisma/TypeORM
- Custom Stack using Express Nest JS/ Next JS/React App - Prisma/TypeORM

We will be switching in between Next JS & React JS 
we will be mixing stack for API application using Express JS and Nest JS for API development with Different ORM like (TypeORM, Prisma, Knex)
{% embed https://www.youtube.com/embed/vOmgcmtZ0-8 %}
150. Evaluate Reverse Polish Notation
Tags: leetcode
Published: 2023-05-29 03:17:50

In this problem, we are going to write a program which calculates the value of [Reverse Polish notation](https://en.wikipedia.org/wiki/Reverse_Polish_notation).

Here are some quick thoughts on how to solve this:
- If the token is an operator, we gonna use the value of the two previous numbers for the calculation.
- And since we want to get the latest elements that we have, Stack will be helpful.

<strong>Using Stack</strong>
For example, we have a notation: ["4","13","5","/","+"].
Since the first 3 elements are integer, the stack will push all 3 of them in: `stack = ["4", "13", "5"]`.
Then, the next token is: "/", which is an operator. We pop the two latest element in the stack, which is "13", and "5" to conduct the division, `stack = ["4"]`. The result is 2 since we just take the int value. We push that 2 back in the stack. `stack = ["4", "2"]`.
Lastly, "+" is an operator token, we pop "4" and "2" from the stack to conduct the addition, `stack = []`. The result is "6". Push "6" back into the stack, `stack = ["6"]`.
Since there is no more token to visit, the final result is returned, which is `6`.


With this example, we have the algorithm:
1. Initialize an empty Stack.
2. Traverse through each token in the `tokens` list.
3. If a token is not an operator, add it to the stack.
4. If the token is an operator: pop the two latest element in the stack, compute based on the operator and push back the result
5. Return the last element in stack after visiting all the tokens.

<strong>Here is the solution in Java</strong>
```java
class Solution {
    public boolean contains(String[] operators, String token) {
        for (String op: operators) {
            if (op.equals(token)) {
                return true;
            }
        }
        return false;
    } 
    public int evalRPN(String[] tokens) {
        /**
        Reverse polish notation:
        3 4 + => 3 + 4
        3 4 x 5 6 x + => 3 * 4 + 5 * 6

        - When we hit an operator, pop out the latest 2 operands and calculate the result
            Then put back the result into the stack for later calculation
        - Return the last elements in the stack which is the final result
        */

        String[] operators = {"+", "-", "*", "/"};
        Stack<String> stack = new Stack<>();

        for (String t: tokens) {
            // System.out.println(stack.toString());
            if (!contains(operators, t)) {
                stack.push(t);
            } else {
                int second = Integer.parseInt(stack.pop());
                int first = Integer.parseInt(stack.pop());
                int result;
                if (t.equals("+")) {
                    result = first + second;
                } else if (t.equals("-")) {
                    result = first - second;
                } else if (t.equals("*")) {
                    result = first * second;
                } else {
                    result = first / second;
                }

                stack.push(String.valueOf(result));
            }
        }

        return Integer.parseInt(stack.pop());
    }
}
```
Quick YAML Tutorial
Published: 2023-05-29 04:18:37


YAML is a human-readable data serialization language. It stands for "YAML Ain't Markup Language". YAML files use a simple syntax to represent data structures like lists, dictionaries, and key-value pairs. Here are some basic concepts:

1. YAML syntax uses indentation to define nesting. Use two spaces for each level of indentation.
2. Comments start with the "#" character.
3. Lists are represented by dashes ("-").
4. Key-value pairs are represented by a colon (":").

Here's an example YAML document:

```yaml
# This is a YAML file
name: John Smith
age: 30
address:
  street: 123 Main St
  city: Anytown
  state: NY
  zip: 12345
favorite_colors:
  - red
  - green
  - blue
```

In this example, we have a dictionary with several key-value pairs. The `address` key has a nested dictionary, and the `favorite_colors` key has a nested list.

You can also use YAML to define more complex data structures like objects, arrays, and mappings. Here's an example of a more complex document:

```yaml
# This is a YAML file
invoice:
  id: INV-001
  date: '2022-05-03'
  customer:
    name: John Smith
    email: john@example.com
    phone: '555-123-4567'
  items:
    - id: 001
      name: Item 1
      description: Some item description
      price: 10.99
      quantity: 2
    - id: 002
      name: Item 2
      description: Another item description
      price: 20.99
      quantity: 1
  subtotal: 42.97
  tax: 3.24
  total: 46.21
```

In this example, we have a nested dictionary that represents an invoice. The `customer` key has a nested dictionary, and the `items` key has a nested list of dictionaries.

YAML is widely used in configuration files for software applications, as well as for data exchange between systems. Its simple syntax and human readability make it a popular choice for these use cases.
FEDORA, THE BEST DISTRIBUTION FOR MY HARDWARE
Tags: fedora, gnulinux, opensource, linux
Published: 2023-05-29 04:17:17

#Fedora is the distribution that best accompanies my AMD hardware on my laptop, I normally use it with its official Gnome desktop, but having had some problems with kdenlive, I've made the leap to Plasma, where I hope to find some digital peace.

There are things that can scare anyone with fedora, such as the ram consumption at the beginning of the distribution, in plasma it starts with 1500 MB...too much to be plasma, but in the end when applications start to load and everything overloads, Fedora It gives me a fantastic user experience...I mean, when some heavy work starts to be required, because this distribution offers magnificent background work, offering me the best of the best...it's for that and some other reasons that I plan to stay with this combination for a long time... although if for some mysterious reason something fails and I can't stand it, then I return to my other favorite plasma distribution, #KDENeon with which I have obtained much satisfaction and a great experience of user.
How to Fix Image Upload Issue in WordPress
Published: 2023-05-29 04:01:28

Are you experiencing image upload issues in WordPress ? You can try the following step-by-step solutions to fix the image upload issue in WordPress problem:

Step 1: Clear your browser cache
Step 2: Increase WordPress memory limit
Step 3: Disable plugins and switch
Step 4: Check file permissions
Step 5: Verify file upload size limits
Step 6: Contact your web hosting provider
Step 7: Check the PHP Version
Step 8: Verify file format and image size

If you're confused to fix this problem read more article click [here](https://techzpad.com/how-to-fix-image-upload-issue-in-wordpress)
How do I get into Open Source?
Tags: opensource, beginners, learning, github
Published: 2023-05-29 03:17:10

Hi Developers👋,

I'm new to open source and I'm looking for some help getting started. I've been coding for a few years now, and I'm interested in contributing to open source projects. I'm not sure where to start, so I'm hoping you can give me some advice. Can you all please kindly share me on how to get started with the open source contributions and the skills I need to be equipped with. It would be very grateful  if you all could share me the dos and donts while contributing and the the current open source projects I can contribute to.

Thanks 😊
Make (&Option).as_ref() easier
Tags: rust, option
Published: 2023-05-29 02:54:24

Option itself has a copy trait, but its behaviors depends on what it hold.
```rust
#[derive(Copy, PartialOrd, Eq, Ord, Debug, Hash)]
#[rustc_diagnostic_item = "Option"]
#[stable(feature = "rust1", since = "1.0.0")]
pub enum Option<T> {
    /// No value.
    #[lang = "None"]
    #[stable(feature = "rust1", since = "1.0.0")]
    None,
    /// Some value of type `T`.
    #[lang = "Some"]
    #[stable(feature = "rust1", since = "1.0.0")]
    Some(#[stable(feature = "rust1", since = "1.0.0")] T),
}
```
Example
```rust
let x = Some(5);
let y = x; // copy x not move x
println!("{:?}", x); 
```
```rust
let x = Some(Box::new(5));
let y = x; // moved here
println!("{:?}", x); // compile error
```
So, when iterating over a linked list, you should use `node.next.as_ref()` rather than `(&node.next).as_ref()`
```rust
#[derive(Debug)]
struct Node {
    value: i32,
    next: Option<Box<Node>>,
}

fn main() {
    let mut head = Box::new(Node { value: 0, next: None });
    let second = Box::new(Node { value: 1, next: None });
    head.next = Some(second);

    let mut u = Some(&head);
    while let Some(v) = u {
        print!("{}->", v.value);
        // (&v.next).as_ref() is too verbose
        u = v.next.as_ref(); 
    }
    println!("None");

    println!("{:?}", &head);
}
```
What as_ref does is take in `Option<T>`, then make it `Option<&T>`. This behavior cause a copy not move.
```rust
#[inline]
#[rustc_const_stable(feature = "const_option_basics", since = "1.48.0")]
#[stable(feature = "rust1", since = "1.0.0")]
pub const fn as_ref(&self) -> Option<&T> {
    match *self {
        Some(ref x) => Some(x),
        None => None,
    }
}
```
看不見的字元 '\u202a'
Tags: python, unicode
Published: 2023-05-29 02:50:20

如果你在撰寫程式碼時喜歡複製文字貼上, 就要小心一些莫名奇妙的陷阱, 其中看不見的字元 '\u202a' 是最難纏的, 例如想要從 Windows 檔案總管中檔案或是資料夾的**內容**交談窗的**安全性**頁次內複製路徑貼到 Python 開發環境中, 以 Jupyter 為例, 你可能會遇到以下這樣神奇的結果：

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

你可以看到儲存格 51 和 53 內容是一樣的, 但是透過儲存格 52 和 54 顯示出來的結果卻不一樣, 儲存格 52 的結果在字串中多了 '\u202a' 字元, 這個字元稱為 [LEFT-TO-RIGHT EMBEDDING](https://unicode-explorer.com/c/202A), 如果改用 `print()` 顯示變數內容, 就會完全看不見。

實際上儲存格 51 和 53 內的路徑都是從同樣的交談窗中複製而來, 唯一不同的是儲存格 51 中的是用滑鼠由路徑尾端往左邊選取後複製, 而儲存格 53 中的是用滑鼠由路徑開頭往右邊選取後複製, 微軟啊微軟, 到底為什麼不同方向選取文字會有不同的結果呢？如果沒有注意到這個問題, 就可能會讓你的程式出錯。

相同的問題在其他開發環境下可能也會發生, 以下是我常用的 Thonny：


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

如果是在 Windows Terminal 中, 可以明確看到字串開頭處多了一個奇怪的空白：

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

這可能成為使用 Windows terminal 的好理由, 可以減少錯誤。經過反覆的測試後, 發現使用滑鼠由右往左選取時, 會滑過路徑開頭, 這時就會多出看不見的字元, 但如果你小心翼翼地只選取到路徑開頭就停止, 就不會選到那個看不見的字元了。

另外要注意的是, 我自己很常將程式碼貼到 PPT 上解說, 像是 Arduino IDE 有個貼心的功能可以將程式碼以 HTML 格式複製：

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

這個功能會以 HTML 格式幫你保留程式碼語法標色, 我通常會將複製內容貼到線上的 HTML 檢視服務, 再從該服務上把標色完成的程式碼貼到投影片上。這個轉換的過程中, 也會多出這個看不見的字元, 導致學員從投影片上複製程式碼貼回 Arduino IDE 時編譯出錯, 雖然算是一個強迫學員自己打程式碼的機制, 不過突然遇到時還是會嚇一跳, 以為範例程式寫錯了。

類似的狀況也會發生在從 VS Code 啟用保留語法標色複製程式碼時：

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

在 PPT 上也是以 HTML 格式貼上：

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

也會有同樣的問題, 使用時請多多小心。
Decreasing Frictions in DeFi Hackathon
Tags: hackathon, developers, programming, blockchain
Published: 2023-05-29 02:37:06

0x, Family, Polygon Labs, and AWS are excited to invite you to participate in our “Decreasing Frictions in DeFi” hackathon, an online hackathon where builders can showcase their innovations to solve real-world financial frictions.

“Decreasing Frictions in DeFi” brings together a group of sponsors whose tools work synergistically to help DeFi builders and teams of all sizes to bring their ideas to reality. We are looking for novel financial applications that use ERC20 token swaps to solve real-world financial frictions.

A total of **$30,000** in prizes ($10,000 USD +$20,000 AWS credits) will be up for grabs!

In addition to prizes, we will be showcasing the top 3 winners on 0x’s marketing channels! This is a great opportunity to gain exposure and take your project to the next level.

## Prize Pool
In short, there is a MACI Quadratic Funding prize pool totaling $10,000, plus three winning projects will receive $20,000 AWS credits for a total of $30,000 worth of prizes.

0x + Family + Polygon: $10,000 USD Quadratic Funding Pool
AWS 1st Place: $10,000 in AWS credits
AWS 2nd Place: $5,000 in AWS credits
AWS 3rd Place: $5,000 in AWS credits
‍
## Schedule
Over the course of the hackathon, we will be holding virtual workshops on building with 0x. For more information on workshops, check out the full schedule.

June 2 - July 2: Hackathon starts and submission period begins
July 2: Hackathon ends at 11:59PM PT
July 3 -July 7: Review and Judging
July 10: Winners announced
‍
## How to Join
Step 1: Read through the requirements 📖
Step 2: Fill out the signup form 📝
Step 3: Join 0x Discord. After you submit the form, you will be added to the #defi-2023-hackathon channel to coordinate 🤘
Step 4: All team members should register on DoraHacks ✅
Step 4. Attend the workshops and build your projects 🌱
Step 5: Submit your entry with all teammates included via DoraHacks based on the submission requirements and judging criteria 🤖
‍
[Click here to register!](https://dorahacks.io/hackathon/decreasing-frictions-in-defi/detail)

We are looking forward to meeting all the builders and seeing what novel financial applications you build to help solve real-world financial frictions!