teleren/devto huggingface dataset:
Master Python - Loops
Tags: python, beginners, codenewbie
Published: 2023-09-14 12:44:08

## Introduction 
When it comes to programming, one of the essential concepts you'll encounter is the use of loops. Loops are like the workhorses of your code, allowing you to perform repetitive tasks with ease. In Python, a beginner-friendly and versatile programming language, loops come in two main flavors: `for` loops and `while` loops. In this article, we'll explore both types of loops, providing examples and practical insights to help you understand how to use them effectively.

## The `for` Loop

The `for` loop in Python is a powerful tool for iterating over a sequence (like a list, tuple, or string) and performing actions on each item within that sequence. It follows a straightforward structure:

```python
for item in sequence:
    # Code to be executed for each item
```

Here's a simple example that prints the numbers from 1 to 5:

```python
for number in range(1, 6):
    print(number)
```

In this code, `range(1, 6)` generates a sequence of numbers from 1 to 5, inclusive. The `for` loop then iterates through this sequence, printing each number.

You can use `for` loops for a wide range of tasks, such as processing data in a list, searching for specific elements, or performing calculations on a set of values.

## The `while` Loop

The `while` loop, on the other hand, is used when you want to execute a block of code repeatedly as long as a certain condition is true. Its structure looks like this:

```python
while condition:
    # Code to be executed as long as the condition is true
```

Here's an example of a `while` loop that counts from 1 to 5:

```python
count = 1
while count <= 5:
    print(count)
    count += 1
```

In this code, we start with `count` equal to 1 and keep incrementing it as long as it's less than or equal to 5. The loop stops when the condition `count <= 5` becomes false.

`while` loops are handy when you need to perform an action until a specific condition is met, and you might not know in advance how many iterations are required.

## Loop Control Statements

Python provides additional control statements to enhance the functionality of loops:

1. **`break`:** This statement allows you to exit a loop prematurely if a certain condition is met. For example, you can use `break` to stop a loop when you find a specific item in a list.

2. **`continue`:** With `continue`, you can skip the current iteration of a loop and move to the next one. This can be useful when you want to skip certain items in a sequence.

## Conclusion

Loops are fundamental in Python programming, and mastering them is essential for automating repetitive tasks and processing data efficiently. By understanding the differences between `for` and `while` loops and learning to use loop control statements like `break` and `continue`, you'll have a solid foundation to start building more complex and useful Python programs. Practice, experimentation, and problem-solving are the keys to becoming proficient with loops in Python, so don't hesitate to dive in and start coding!
Translation HTTP Request Stuck in Pending Status with ngx-translate/http-loader
Tags: angular, programming, javascript, coding
Published: 2023-09-14 12:43:22

  
Hello everyone,
I've been encountering an issue while using the ngx-translate/http-loader library for translation in my project. The problem revolves around setting an HTTP path and passing it to the translation library, specifically the "TranslateHttpLoader."

Most of the time, the HTTP request remains in a pending status. Surprisingly, despite the pending status, the translated text is not coming through.

Since this request is being handled by the ngx-translate library, I'm struggling to find a solution to this issue.
This translation HTTP request **fails 50% **of the time and works **correctly 50%** of the time, as expected.


Here are some relevant details from my package.json file:

`"@ngx-translate/core": "^14.0.0",
"@ngx-translate/http-loader": "^7.0.0"
`

In my AppModule, I have set up the TranslateModule as follows:

`
_import { TranslateModule, TranslateLoader, MissingTranslationHandler } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';

// ...

imports: [
  // ...
  TranslateModule.forRoot({
    loader: {
      provide: TranslateLoader,
      useFactory: HttpLoaderFactory,
      deps: [HttpClient]
    },
    missingTranslationHandler: { provide: MissingTranslationHandler, useClass: MissingTranslationHelper },
  }),
  // ...
]

```

```
`


In my constructor, I have initialized the translation as follows:

`
translate.setDefaultLang('en');
translate.use('en');
`

And here is the HttpLoaderFactory:



`
export function HttpLoaderFactory(http: HttpClient) {
 
  return new TranslateHttpLoader(
    http,
    'http://myapp/locale/messages_',
    '.json'
  );
}
`
I would greatly appreciate any insights or solutions to this issue. Thank you in advance for your help!
Master Python - Conditionals
Tags: python, codenewbie, beginners
Published: 2023-09-14 12:40:49

## Introduction

Python is renowned for its simplicity and readability, making it an ideal choice for beginners in programming. One fundamental concept in Python, and in programming in general, is the use of conditionals. In this article, we'll explore conditionals in Python, helping you understand how they work and how to use them effectively in your code.

What Are Conditionals?

Conditionals are control structures in programming that allow you to make decisions based on certain conditions. They enable your program to execute different code blocks depending on whether a given condition is true or false. In Python, you can achieve this using the `if`, `elif` (short for "else if"), and `else` statements.

The `if` Statement

The most basic form of a conditional statement in Python is the `if` statement. It allows you to execute a block of code if a specified condition is true. Here's a simple example:

```python
age = 18

if age >= 18:
    print("You are an adult.")
```

In this example, the code inside the `if` block only runs if the condition `age >= 18` is true.

The `else` Statement

The `else` statement follows an `if` statement and is used to execute a block of code when the `if` condition is false. Here's an example:

```python
age = 15

if age >= 18:
    print("You are an adult.")
else:
    print("You are a minor.")
```

In this case, since `age` is not greater than or equal to 18, the code inside the `else` block executes.

The `elif` Statement

Sometimes, you need to check multiple conditions in a sequence. You can achieve this using the `elif` statement. Here's an example:

```python
grade = 85

if grade >= 90:
    print("A")
elif grade >= 80:
    print("B")
elif grade >= 70:
    print("C")
else:
    print("F")
```

In this example, Python evaluates each condition in order. If the first condition is true, it executes the corresponding block and skips the rest. If none of the conditions are true, it executes the `else` block.

Logical Operators

Python also provides logical operators (`and`, `or`, and `not`) that allow you to combine multiple conditions. For example:

```python
age = 25
is_student = True

if age >= 18 and not is_student:
    print("You are an adult, not a student.")
```

In this case, both conditions must be true for the code inside the `if` block to execute.

Conclusion

Conditionals are a fundamental building block in Python programming. They allow you to create dynamic and decision-based logic in your code. By using `if`, `elif`, and `else` statements, along with logical operators, you can make your programs respond to different situations and conditions. As you continue your Python journey, mastering conditionals will be essential for building more complex and functional programs. Happy coding!
Welche sind beliebte Kategorien für Gutscheinangebote, etwa Essenslieferung, Reisen oder Mode?
Tags: discount, react, discuss, productivity
Published: 2023-09-14 12:39:41

Coupon-Angebote gibt es in verschiedenen beliebten Kategorien, die auf unterschiedliche Bedürfnisse und Vorlieben der Verbraucher zugeschnitten sind. Lebensmittellieferdienste bieten häufig Rabatte und Sonderangebote an, um Kunden dazu zu verleiten, Mahlzeiten online zu bestellen. Reisebezogene [Coupon-Angebote](https://dealznew.de/store/cartonara/) umfassen Rabatte auf Flüge, Hotels, Mietwagen und Urlaubspakete, wodurch Reisen erschwinglicher werden. In der Welt der Mode können Käufer Gutscheine für Kleidung, Schuhe, Accessoires und sogar Luxusartikel finden, die ihnen helfen, stilvoll zu bleiben, ohne ihr Budget zu sprengen. Darüber hinaus gibt es in Kategorien wie Elektronik, Schönheitsprodukte, Einrichtungsgegenstände und Unterhaltung häufig auch Coupon-Angebote, mit denen Verbraucher bei einer breiten Palette von Produkten und Dienstleistungen sparen können.
Master Python - Data Types
Tags: python, codenewbie, beginners
Published: 2023-09-14 12:38:22

## Introduction

Python, known for its simplicity and readability, is an excellent programming language for beginners. One fundamental concept to grasp as you start your journey in Python programming is data types. Data types define the kind of data a variable can hold, and they play a crucial role in how you manipulate and process information in your Python programs. In this article, we will explore the common data types in Python, helping you understand how to use them effectively.

1. **Numeric Data Types**

Python supports several numeric data types:

   - **int**: Represents whole numbers, positive or negative, without any fractional part.
   
   - **float**: Represents real numbers and can include a fractional part.
   
   - **complex**: Used for complex numbers, with a real and imaginary part.

Here's how you can use these numeric data types:

```python
# Examples
x = 10         # int
y = 3.14       # float
z = 2 + 3j     # complex
```

2. **String Data Type**

Strings in Python are sequences of characters, enclosed in single (' ') or double (" ") quotes. You can perform various operations on strings, such as concatenation and slicing.

```python
# Examples
name = "Alice"
greeting = 'Hello, ' + name
```

3. **Boolean Data Type**

A Boolean data type represents either `True` or `False`. Booleans are often used in conditional statements and expressions.

```python
# Examples
is_python_fun = True
is_raining = False
```

4. **List Data Type**

A list is an ordered collection of items, which can be of different data types. Lists are versatile and can be modified (mutable).

```python
# Example
fruits = ['apple', 'banana', 'cherry']
```

5. **Tuple Data Type**

Tuples are similar to lists but are immutable, meaning their values cannot be changed after creation. They are often used for data that should not be modified.

```python
# Example
coordinates = (3, 4)
```

6. **Dictionary Data Type**

Dictionaries store data as key-value pairs. They are useful for storing and retrieving data quickly based on a unique key.

```python
# Example
student = {
    'name': 'Bob',
    'age': 20,
    'grade': 'A'
}
```

7. **Set Data Type**

Sets are unordered collections of unique elements. They are handy for tasks like removing duplicates from a list.

```python
# Example
unique_numbers = {1, 2, 3, 2, 4}
```

Conclusion

Understanding data types in Python is fundamental for writing effective and bug-free code. As a beginner, grasp the concept of different data types, how to declare variables, and how to perform operations on them. Python's simplicity in handling data types makes it an excellent choice for those new to programming. Continue to explore and experiment with these data types to build a strong foundation in Python programming.
Gibt es Websites, die neben Coupon-Ersparnissen auch Cashback anbieten?
Tags: webdev, beginners, react, discuss
Published: 2023-09-14 12:37:58

Ja, es gibt mehrere Websites, die neben Coupon-Ersparnissen auch Cashback anbieten. Diese Websites werden allgemein als Cashback- oder Rabatt-Websites bezeichnet und ermöglichen es Benutzern, einen Prozentsatz ihres Kaufbetrags in Form von Bargeld oder Geschenkkarten zurückzuerhalten, nachdem sie über ihre Affiliate-Links einen Kauf getätigt haben. So funktioniert es normalerweise:

1. Benutzerregistrierung: Zu Beginn müssen Benutzer ein Konto auf einer Cashback-Website erstellen.

2. Einkaufen über Affiliate-Links: Nach der Registrierung durchsuchen Benutzer die Website nach Angeboten und Angeboten. Wenn sie ein Angebot finden, das ihnen gefällt, klicken sie auf den bereitgestellten Affiliate-Link, der sie zur Website des Einzelhändlers weiterleitet.

3. Einen Kauf tätigen: Benutzer tätigen dann wie gewohnt einen Kauf auf der Website des Händlers. Da sie jedoch über den Affiliate-Link gegangen sind, erhält die Cashback-Website eine Provision aus dem Verkauf.

4. Cashback verdienen: Ein Teil dieser Provision wird dann dem Cashback-[Website](https://dealznew.de/store/ls-lebenstil/)-Konto des Benutzers wieder gutgeschrieben. Der verdiente Betrag ist in der Regel ein Prozentsatz des Gesamtkaufpreises.

5. Zahlung: Benutzer können ihre Cashback-Einnahmen sammeln und dann die Zahlung über verschiedene Methoden wie PayPal, Geschenkkarten oder Banküberweisungen anfordern.

Zu den beliebten Cashback-Websites gehören Rakuten (ehemals Ebates), TopCashback, Swagbucks und Honey. Diese Plattformen helfen Verbrauchern, Geld zu sparen, indem sie sowohl Gutscheincodes als auch Cashback-Prämien für ihre Online-Einkäufe bereitstellen, was sie zu einer wertvollen Möglichkeit macht, beim Online-Einkauf maximale Einsparungen zu erzielen.
Some common mistakes to avoid on LinkedIn.
Tags: linkedin, jobs, referral, tech
Published: 2023-09-14 12:37:25

**I have observed some common mistakes that people make when reaching out for a referral or when contacting recruiters for a job on LinkedIn.**

1. Sending a simple "hi" or "hello" message is one of the common mistakes people make when reaching out to recruiters or contacts for job referrals on platforms like LinkedIn.

2. Showing desperation for a job. While it's natural to feel eager and enthusiastic about finding employment, conveying desperation can potentially harm your chances of securing the job you want.

3. Forgetting to attach your resume when you've mentioned that it's attached can be an embarrassing mistake when applying for a job or reaching out to potential employers.

4. Commenting on a recruiter's post with a message like "Interested" or "I'm interested" without providing any additional context or value can often be seen as a less effective approach.

5. Not having a profile picture or updated details about you on LinkedIn can significantly impact your professional image and networking opportunities on the platform.

📌 I have attached a blog link "[How to ask for a referral on LinkedIn](https://dev.to/avinash201199/how-to-ask-for-a-referral-on-linkedin-1g7e)" 👇

In summary, when reaching out for referrals or contacting recruiters:

Avoid common mistakes like sending generic messages, showing desperation, forgetting attachments, leaving unengaging comments, and neglecting an updated LinkedIn profile.

By recognizing and avoiding these errors, you can improve your networking and job search efforts, enhancing your professional image and increasing your chances of success.

📌Please add if I missed anything in the comment section.

Follow me on [LinkedIn](https://www.linkedin.com/in/avinash-singh-071b79175/) for more updates
convertTxtToHtml - A new command-line tool can process .txt files into .html
Tags: java, programming, opensource, html
Published: 2023-09-14 12:23:21

In today's digital age, creating web content is more accessible than ever. Whether you're a blogger, a developer, or simply someone looking to share information online, converting text to HTML is a common task. To simplify this process, I'm thrilled to introduce our new tool, "convertTxtToHtml."
## Installation
1. Download and Install Java Development Kit according to the Oracle [JDK Installation Guide](https://docs.oracle.com/en/java/javase/20/install/overview-jdk-installation.html#GUID-8677A77F-231A-40F7-98B9-1FD0B48C346A).
   
2. Clone this repository to your local machine
    
   `git clone git@github.com:WangGithub0/ConvertTxtToHtml.git`
   `cd ConvertTxtToHtml`

3. Add executable permission to the `ConvertTxtToHtml.java` file
   `chmod +x src/ConvertTxtToHtml.java`


## Examples
`java src/ConvertTxtToHtml.java ./examples`

## Command Options:

* `--help` or `-h`: Display help information.
* `--version` or `-v`: Display the tool's version.
* `path`: Specify the path to a `.txt` file or a directory containing multiple .txt files. If a directory is provided, `tml` will recursively process all `.txt` files within.
* `--output` or `-o`: Specify a custom output directory. The tool will create the directory if it does not exist.

## Features

* Converts single or multiple `.txt` files to `.html`.
* Same directory structure in output directory.
* Allow to specify a different output directory.
* Automatically parsing title from  `.txt` file.

## Github
https://github.com/WangGithub0/ConvertTxtToHtml
Don’t compare and compete with others, instead collaborate
Tags: discuss, career, softwaredevelopment, webdev
Published: 2023-09-14 12:22:44


If you are a person who likes to compare and compete with your colleagues. Let me tell you one important thing. Don't compare or compete, instead help and collaborate.

Being a lone wolf and just focusing on yourself and your progress will certainly get you somewhere. But rather than trying to do everything yourself. You have a group of like-minded people who are all on the same path as you!

Your progression is going to be much:

- faster,
- more exciting,
- more fulfilling.

Compete only with yourself and try to get better every day!

The software development world is smaller than you think. Collaborating and helping each other instead of competing puts you in a position where fellow like-minded people can help you find opportunities.


**A practical example**

If you are searching for a new role, the best way to find it is to get recommended for the position.

If someone from my team recommends a candidate.

I already know 2 things:

He/she already is familiar to an extent with a person on my team, so the collaboration and onboarding would be easier.

He/she has already shown to some extent capability to be able to do the job.

This gives you much better chances right from the start. Make sure to help each other to grow and progress in careers!

What are your thoughts?

> This is part of the newsletter article on my Engineering Leadership newsletter. If you liked this, you are going to love my newsletter. Join here: [Engineering Leadership newsletter](https://newsletter.eng-leadership.com/), 8100+ engineering leaders are already reading it!
UbuntuにJavaの開発環境構築
Tags: wsl
Published: 2023-09-14 12:09:18

Ubuntu に Java(jdk)をインストールする。
バージョン管理は apt の pkg マネージャーに任せる。

会社の PC 設定する時に毎回調べたり、個人 PC の設定忘れがちなのでメモとして。

---

## 目次

- [やること](#やること)
- [jdk のインストール](#jdk-のインストール)
- [環境変数の設定](#環境変数の設定)
- [バージョン切替するとき](#バージョン切替するとき)
- [切替後の確認](#切替後の確認)

---

## やること

1. jdk インストール
1. 環境変数の設定
1. バージョン切替

バージョン切替は付録的な話

---

## jdk のインストール

```
# 提供バージョンの確認
$ sudo apt search openjdk-.*-jdk$

# 利用するバージョンをインストール
## 11と17をインストール
$ sudo apt install -y openjdk-11-jdk openjdk-17-jdk

# インストール確認
$ java --version
openjdk 17.0.8.1 2023-08-24
OpenJDK Runtime Environment (build 17.0.8.1+1-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 17.0.8.1+1-Ubuntu-0ubuntu120.04, mixed mode, sharing)
```

---

## 環境変数の設定

```
# profileに追記
$ echo '# JDK
JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::")
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH' | tee -a ~/.profile > /dev/null

# 再読み込み
$ source ~/.profile
```

---

## バージョン切替するとき

```
# 現在のバージョン
$ java --version
openjdk 17.0.8.1 2023-08-24
OpenJDK Runtime Environment (build 17.0.8.1+1-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 17.0.8.1+1-Ubuntu-0ubuntu120.04, mixed mode, sharing)

# 切り替え可能なバージョン
$ sudo update-java-alternatives --list
java-1.11.0-openjdk-amd64      1111       /usr/lib/jvm/java-1.11.0-openjdk-amd64
java-1.17.0-openjdk-amd64      1711       /usr/lib/jvm/java-1.17.0-openjdk-amd64

# 11に切替
$ sudo update-java-alternatives --set java-1.11.0-openjdk-amd64
```

---

## 切替後の確認
```
$ java --version
openjdk 11.0.20.1 2023-08-24
OpenJDK Runtime Environment (build 11.0.20.1+1-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.20.1+1-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)

$  which java
/usr/bin/java

# 関連バイナリ全部切り替わっているか確認
$ ls -l /etc/alternatives/java*
lrwxrwxrwx 1 root root 43 Sep  9 16:58 /etc/alternatives/java -> /usr/lib/jvm/java-11-openjdk-amd64/bin/java
lrwxrwxrwx 1 root root 53 Sep  9 16:58 /etc/alternatives/java.1.gz -> /usr/lib/jvm/java-11-openjdk-amd64/man/man1/java.1.gz
lrwxrwxrwx 1 root root 44 Sep  9 16:58 /etc/alternatives/javac -> /usr/lib/jvm/java-11-openjdk-amd64/bin/javac
lrwxrwxrwx 1 root root 54 Sep  9 16:58 /etc/alternatives/javac.1.gz -> /usr/lib/jvm/java-11-openjdk-amd64/man/man1/javac.1.gz
lrwxrwxrwx 1 root root 46 Sep  9 16:58 /etc/alternatives/javadoc -> /usr/lib/jvm/java-11-openjdk-amd64/bin/javadoc
lrwxrwxrwx 1 root root 56 Sep  9 16:58 /etc/alternatives/javadoc.1.gz -> /usr/lib/jvm/java-11-openjdk-amd64/man/man1/javadoc.1.gz
lrwxrwxrwx 1 root root 44 Sep  9 16:58 /etc/alternatives/javap -> /usr/lib/jvm/java-11-openjdk-amd64/bin/javap
lrwxrwxrwx 1 root root 54 Sep  9 16:58 /etc/alternatives/javap.1.gz -> /usr/lib/jvm/java-11-openjdk-amd64/man/man1/javap.1.gz
```

大丈夫そう。イイネ！

以上。
Fun with graphics engines
Published: 2023-09-14 12:00:57

Recently, I was watching one of Terry Davis' clips on Youtube. It was the one where he demonstrates the graphical capabilities of TempleOS. 
[](https://www.youtube.com/watch?v=2eK4QRH22Uk&t=482s)
It's a good watch if your mind is able to comprehend the World's Greatest Programmer.
The first thing he does is write a simple program that draws a convoluted pattern to the screen. Rewritten for the p5 JavaScript library, it looks like this:

```
for(let i = 0; i < screenWidth; i+=10) {
    line(i, 0, 0, screenWidth - i)
}
```

Which looks like this when rendered:

![Terry Davis childhood program](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/04p6girwmair4kiih86u.png)

I like this program because from a humble for-loop and line-draw function call it creates a significant amount of visual complexity. Terry makes an offhand comment about how as a child he loved writing this program to the display computers at the Electronics store. Which provides insight into his upbringing, at least as a software engineer. Certainly most of you with computer enthusiast origins have fond memories of modifying a school terminal or other public facing device to do something cool purely for personal amusement. I'm no stranger to Electronics Store shenanigans myself. One of my teenage hobbies was setting the background images of the BestBuy display computers to something unsavory to the average consumer, usually Sonic the Hedgehog fan-art. Kids and teens gravitate towards fun, and fun is the common denominator for a lot of the best engineers in the field. In the spirit of fun, I'm using P5 JS to create really silly or cool computer drawn sketches. I'll keep updating the list as I make them.
1. Kitty Cube
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/usve59gl6oakill00a0j.png)
Really dumb image of a cat on a cube you can manipulate with the "W", "A", "S", "D" keys.
https://editor.p5js.org/belbcode/sketches/FzaKrMdQE