teleren/devto huggingface dataset:
Flow Control
Published: 2023-02-02 08:07:47

Flow control is a way to control the flow of execution in a program. In Python, flow control is accomplished through statements such as `if-else`, `for loops`, and `while loops`. This concept allows programs to make decisions based on certain conditions and iterate through a certain sequence of items. This helps make programs more flexible and allows for more complex logic in programming.

Flow control in Python can be done using statements such as if-else, for loops, and while loops. Following are the details of each statement and a case study example:

Here's a simple example using an` if `statement:

```
age = 18
if age >= 18:
    print("You are eligible to vote.")
else:
    print("You are not eligible to vote.")

```

In this example, the code inside the `if` statement will be executed `if` the value of `age` is greater than or equal to 18. `If` it is not, the code inside the `else` statement will be executed instead.

Another example of flow control in Python is the `for` `loop`, which is used to iterate over a sequence of elements and execute a block of code for each element:

```
fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
    print("I like", fruit)

```
In this example, the code inside the `for` `loop` will be executed once for each element in the fruits list, with the variable fruit taking on the value of each element in turn.

You can also use the while loop to repeatedly execute a block of code as long as a certain condition is met:

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

```

In this example, the code inside the `while` `loop` will be executed repeatedly as long as the value of `count` is less than or equal to `5`. Each time the code is executed, the value of `count` is incremented by 1, so eventually the `condition` will no longer be met and the loop will stop.
A Fun Programming Joke To Start Your Day
Tags: jokes, dailydeveloperjokes, watercooler
Published: 2023-02-02 08:00:20

---
title: "A Fun Programming Joke To Start Your Day"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes, #watercooler
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1258fbc6e41.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit._

<!--
Joke text:
___Q:___ You know what the best thing about booleans is?

___A:___ Even if you are wrong, you are only off by a bit.
 -->
Translation in React Applications
Tags: react, internationalization, i18next, webdev
Published: 2023-02-02 07:46:59


When building web applications to a global audience, it's important to provide translated content to users in different languages. 

One common approach to translation is to store translation strings in a separate repository, such as a GitHub repository, and retrieve them at runtime. This allows you to manage and maintain translations outside of your main application code and collaborate with a team of translators.

## Using React and react-i18next with Separate Translation Repository

[React](https://reactjs.org/) is a popular JavaScript library for building user interfaces. [react-i18next](https://react.i18next.com/) is a library that integrates with React, providing an easy and efficient way to add internationalisation (i18n) support to your application. This library provides a simple API for handling translations and makes it easy to translate your content into different languages.

With react-i18next, you can configure the library to retrieve translations from a separate repository, such as a GitHub repository. The translations can be stored in JSON files, one for each language, and fetched at runtime using the `i18n.loadNamespaces` method.

Here's an example of how you might use react-i18next with a separate translation repository:

```typescript
import React from "react";
import i18n from "i18next";
import { initReactI18next } from "react-i18next";

i18n.use(initReactI18next).init({
  lng: "en",
  fallbackLng: "en",
  ns: ["translations"],
  defaultNS: "translations",
  backend: {
    loadPath: "https://github.com/your-username/your-translation-repo/blob/master/{{lng}}/{{ns}}.json",
  },
});

const Greeting: React.FC = () => {
  const { t } = useTranslation();
  return <h1>{t("greeting")}</h1>;
};

export default Greeting;
```

By using a separate translation repository and react-i18next, you can easily manage and maintain your translations outside of your main application code and collaborate with a team of translators. This helps ensure that your application is accessible and inclusive to users from different countries and cultures.
How to Become a More Valuable Employee
Tags: employe, business
Published: 2023-02-02 07:45:26

Here are some tips on how to become a more valuable employee:

Take initiative: Look for ways to improve processes and procedures, and don't wait for someone else to ask you to do it.

Be a team player: Collaborate with colleagues and demonstrate a positive attitude, even in challenging situations.

Continuously learn: Stay up-to-date with the latest industry trends and developments, and seek opportunities to expand your skills and knowledge.

Be reliable: Follow through on commitments, meet deadlines, and maintain high standards of quality in your work.

Communicate effectively: Example like [DGME Employee](https://dolgeneraldgme.com/) Listen actively, articulate your ideas clearly, and be responsive to the needs of others.

Take ownership of your work: Be accountable for your actions and take pride in your achievements.

Be adaptable: Be open to change and embrace new challenges, opportunities, and perspectives.

By consistently demonstrating these qualities, you can establish yourself as a valuable employee who is an asset to your organization.
Scalable chat application in a microservices architecture
Tags: go, microservices, webdev, showdev
Published: 2023-02-02 07:35:41

I'd like to share my side project: [https://github.com/minghsu0107/go-random-chat](https://github.com/minghsu0107/go-random-chat)

This is a random chat application built in a microservices architecture. An user can pair with a random person and chat in real-time.

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


This project is built with scalability in mind. I used websocket for real-time messaging, Kafka for message Pub/Sub (to make chat service stateless), Redis for caching and user matching, Cassandra for message persistence, JWT & session for authentication, and gRPC for inter-service communication. Other common features like Google OAuth2 login, file uploads (object storage), observability (Prometheus & Opentelemetry), dependency injection (wire), CLI (cobra), and config management (viper) are also implemented.

I hope you will find this helpful. Any PR is welcome!
🤔 Suggest me the Tech Stack for 🌐 Browsemates
Tags: webdev, javascript, python, programming
Published: 2023-02-02 07:21:03

## Introduction
Tech enthusiasts unite! 💻 I am excited to announce my latest project - Browsemates. This project is a new venture that aims to revolutionize the way people communicate and collaborate while browsing the web. But, I need your help in making this project a success. That's why I'm reaching out to the tech community and asking for your advice on the best tech stack for this project. 🚀 #Browsemates #TechStack #Startup 💻💻

## Importance?
As a software developer, I understand the importance of choosing the right tech stack for a project. The tech stack you choose can have a huge impact on the success of a project, so it's important to get it right. That's why I'm turning to the tech community for advice on the best tech stack for Browsemates. 🤔

## What I think? 🤔
My personal choice for the tech stack for Browsemates is Python for the backend and ReactJS for the web app. 🐍 I have chosen Python for the backend because it is a powerful, high-level programming language that is widely used in the tech industry. Python is known for its simplicity, ease of use, and versatility, making it a great choice for the backend of Browsemates. 💻

ReactJS, on the other hand, is a popular JavaScript library for building user interfaces. 💥 ReactJS is known for its speed, efficiency, and ability to handle complex web applications. I believe that using ReactJS for the web app will provide a smooth and user-friendly experience for our users. 🤩

## Help 🥲
However, I understand that the tech community is full of experts who have a wealth of knowledge and experience. That's why I'm open to your suggestions and recommendations on the tech stack for Browsemates. If you believe that a different tech stack would be a better fit for this project, I would love to hear from you. 💡

## Let's go 🚀
Let's make this project a success together! The goal of Browsemates is to revolutionize the way people communicate and collaborate while browsing the web. With your help and expertise, I am confident that we can make this project a reality. 🚀💻 #TechStack #Python #ReactJS #Startup 💪

---

Join me on this journey on twitter [@rajesh_j3](https://twitter.com/rajesh_j3)

---

Happy coding
Dental clinic in bellandur.
Tags: dental, dentistry, dent
Published: 2023-02-02 07:10:05

Apollo Dental Clinic in Bellandur is highly rated for its customer satisfaction and world-class dental services. Our staff is dedicated to providing patients with the best possible care and has a good rating. We offer a variety of services such as dental implant, root canal treatment, teeth whitening, and more. We also have a customer feedback system in place to ensure that their customers are satisfied with their services.
contact:1800-102-0288
How do you guys deal with wandering mind at work ?
Tags: discuss
Published: 2023-02-02 06:53:04

When it comes to tackling hard coding questions or hard tasks at work, I often find my mind wandering somewhere else.
In situations like these, I could only hold about 5-10 minutes max, and every time I wander I often feel guilty and even anxious. That my performance would drop because of it. 
I looked around my colleagues and all of them seemed to be attuned with their work. But I guess they wouldn't survive a day without cups of coffee on their desks. 
But do any of you feel the same way and how do you stay focused when confronted by difficult work ?
Need some advice!
Tags: help, discuss
Published: 2023-02-02 06:52:48

Twitter just announced that there will no longer be free access to the twitter API. (https://twitter.com/TwitterDev/status/1621026986784337922)

Hi! I'm Dhravya - a 17 year old maker. I have a small twitter tool - https://twitter.com/poet_this, which includes the website https://tweets.beauty and the API https://api.tweets.beauty

I got some donations at the start which helped me pay for the hosting costs, but that's been it.

And the main problems start here.
I'm a student and indie developer, and I have crucial examinations coming up in just 20 days. I wanted to monetise the bot after exams to create a revenue stream for myself, but the timing is very, very bad.

So, what do I do?
- Loss for a couple of months and monetise later
- Sell the project + twitter acc and start with a new side project right after the exams
- Ask for donations and keep the project free for as long as I can
- Start selling the entire codebase to multiple people (on license basis? not sure.)

If I choose to sell the project, where do I sell a side project? How do I get buyers?

Here's why I kept my project free:
- Proof of work.
- I wanted the maximum number of users so that I could have a boost for later projects
- It wasn't expensive to host or difficult to make, and I don't think I could provide enough value.

What do you think? Any advice would be greatly appreciated!
Beginner's guide to data-attributes in CSS
Tags: tutorial, css, javascript
Published: 2023-02-02 06:47:04

## What are data-attributes?

They are custom HTML attributes, that you can use on any HTML elements. You just need to prefix those custom attributes with **data-**. 

It's recommended not to make your own attributes, i.e., creating attributes _which are not prefixed with **data-**_.

## Syntax

You can use anything after _data-_. And one HTML element can have multiple data attributes.

```css
<div data-category='cars' data-type='luxury'> 
    Audi 
</div>
<div data-category='laptop'>
    Lenovo
</div>
```


![data-attribute-meme](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/46j1sp9xbr96vfl13glr.jpg)


## Use Cases

### Javascript


Suppose you want to add custom icons, based on the data-category.


![div elements](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8gca0yzzl54477xljkhu.png)



* You can access data-attributes via `getAttribute(attribute-name)`

```javascript
const data = document.querySelectorAll("[data-category]");
data.forEach((item) => {
  console.log(item.getAttribute("data-category")) 
  // cars or laptop will be the output  
  // Add icons based on cars or laptop
})

```

* You can also access them via `dataset` property. 

If you `console.log(item.dataset)`, you'll see all the data-attributes for that HTML element, in an object. 

```javascript
const data = document.querySelectorAll("[data-category]");
data.forEach((item) => {
  console.log(item.dataset.category) 
  // cars or laptop will be the output   
  // Add icons based on cars or laptop 
});
```

After adding the required Javascript, this is how it looks


![div-elements-with-icons](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a6j9dwdkvkk4pn1qztqo.png)

### CSS

Now, if we want to add custom designs to the elements, based on the data-attributes, we can select them in CSS using the attribute-selector.

```css
[data-category="cars"] {
  background:  #feffd4 ;
}
```

After, adding the required CSS, this is how it looks

{% codepen https://codepen.io/arindam404/pen/ExpwEKy %}

Further Readings:

[How to use the DATA attribute with JavaScript, HTML and CSS](https://www.youtube.com/watch?v=XtEs0SZ_4Y0&list=TLPQMTcwMTIwMjNO6KcSumaVLw&index=3)

[Mozilla Docs](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes)

[CSS Tricks: A complete Guide to Data attributes](https://css-tricks.com/a-complete-guide-to-data-attributes/)
Process management in GNU/Linux
Tags: kill, ps, top, process
Published: 2023-02-02 06:45:41

## Kill

Kill is a program that is used to send signals to a process or process groups. By default **TERM** is sent to the process if no signal is specified. We can send any signal to the process as below

```
$kill -SIGNAL PID
```

The signal can be a name or number. the list of signals with number and name is listed with the below command

```
$kill -l
```

By default, kill will send **SIGTERM** or **15** to the process. This will send the signal to the process and it is handled as per the process. It can be blocked, handled, or ignored by the process. 

```
$kill -9 PID
$kill -KILL PID
```

The above sends **SIGKILL** causes the process and its child processes to terminate immediately. The process can't block or ignore this.

```
$kill -HUP PID
```

The above signal also terminates the program but, the difference is it is sent by the system when a terminal is closed and all the processes started from the terminal will receive **SIGHUP** which means a hang-up signal.

```
$kill -STOP PID
```

The above command sends **SIGSTOP** to the process which suspends the process immediately. It can then be resumed by sending the **SIGCONT** signal.

For the most common use, **killall** is used. It kills a process by its name. For example, to kill chrome below command can be used. The **-w** flag is to wait till all signaled processes die.

```
$killall -w chromium-browser
```

## PS - process status

The ps shows which processes are running currently running. There are 3 styles to the arguments for ps. GNU with long names and double dash, BSD usually without any dash, and UNIX with dashes. The below commands are essentially the same

```
$ps -ef
$ps aux
```

All default columns are self-explanatory except the **STAT** which shows the status of the process. The meaning of each letter for this column is given below.

- R: running
- Z: zombie
- D/S: sleep
- T: stopped
- N: low priority
- l: multithreading
- s: session leader
- +: foreground process group
- <: high priority

```
$ps auxf
$ps auxwww
$ps auxe
```

The **f** is forest, which is used to show process trees in ASCII art. **www** is to expand the width and shows processes with all of its arguments. **e** will display with environment variables.

## TOP

TOP is a cli task manager program. It gives a live update of top users of the system's resources.

```
$top
```

The load average with 3 numbers gives average CPU use in the last 1, 5, and 15 minutes. Each column is described below.

- %CPU: shows percent use of single-core, for the 12-core processor it can be up to 1200%
- %MEM: use of disk space
- COMMAND: command line used to start the process
- RES: the amount of RAM used
- USER: owner of the process
GNU/Linux utilities for system info
Tags: df, free, lspci, uname
Published: 2023-02-02 06:43:47

## df

Disk free or df is used to find the free space under each partition. 

```
$df -h
```

Above command displays the free space in a human-readable format. We can also check if we can create new files with the below command.

```
$df -ih
```

It displays inodes in each partition. If there is none then, new files cannot be created.

## free

Free is similar to disk free. It is used the check the free and used amount of RAM/memory.

```
$free -h
```

The above command displays the usage of memory in a human-readable format.

## lspci

lspci lists all PCI devices in the system. 

```
$lspci
```

Above command lists all PCI devices. The first column has data in the format of **domain : bus : slot . func** followed by the device description.

```
$lspci -t
```

Above command displays in ASCII tree format to show how devices are connected to buses.

```
#lspci -vvvs $ID
```

To display complete information about the device **-vvv** is used. A decrease in character v count reduces the detail of information. **-s** is used to specify a device by its id without which it displays all device information.

```
$lspci -k
```

To get the kernel module for each device using the **-k** flag.

## uname

uname is used to print the system information. The **-a** flag is to display all the information.

```
$uname -a
```

Particular information can be printed with the flags. They are

- o: operating system name, not the distro name
- i: the hardware platform
- p: processor architecture
- v: kernel version
- s: kernel name
- m: machine hardware name
- n: system's name/node network hostname
Please Help!
Tags: thirdweb, nextjs, web3, sanity
Published: 2023-02-02 06:38:46

 
Hey!
Does anyone know how to get balance of token deployed on thirdweb into React app.

**My code is:**

```
const balance = await token.balanceOf(walletAddress);
console.log(balance.displayValue);
```

I'm getting this error: 

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


I am taking reference from 
[Link](https://portal.thirdweb.com/solana-sdk/sdk.token.balanceof)

Thanks in advance!
Initialization and creating a database for testing the installation of Postgres and Age part 2.
Tags: ubuntu, linux, database, postgres
Published: 2023-02-02 06:22:04


# Testing:
In the previous article we learned how to install PostgreSQL and age from source[Part 1 here](https://dev.to/talhahahae/installation-of-apache-age-and-postgresql-from-source-in-linux-part-1-gka).
Now we will create and test whether the installation was successful or not

## Database initialization:
Now we will initialize our database cluster. Let's name it _sample_.

`cd postgresql-11.18/`

## Intitialization
`bin/initdb sample`

When you will execute the command the success message will be shown with the command to start the server.

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

## Starting Server
 

```
# Start server:
bin/pg_ctl -D sample -l logfile start
```

The command will return a message saying that the server has started.

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

## Create Database:
The below command will create the database. We name it _SampleDatabase_.

`bin/createdb SampleDatabase`

## Start querying Database:
Now that AGE has been added to pg successfully. Now we can start testing using pg_sql console.

`bin/psql SampleDatabase`

The above command will start a console now we will type some commands and see what happens after certain commands.


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

When we initialize a new Database we have to load age extension in order to start using age. First, we will set the search path if we didn't set them earlier in the postgresql.config file.

```
CREATE EXTENSION age; 
Load 'age';
```

The above command will load the extension and we also need to set the search path and other variables.

`SET search_path = ag_catalog, "$user", public;`


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

Try below queries using cypher commands:

`SELECT create_graph('demo_graph');`


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

It will create a graph named demo_graph.

```
SELECT * FROM cypher('demo_graph', $$ CREATE (n:Person {name : "james", bornIn : "US"}) $$) AS (a agtype);
SELECT * FROM cypher('demo_graph', $$ CREATE (n:Person {name : "Talha", bornIn : "Lahore"}) $$) AS (a agtype)
SELECT * FROM cypher('demo_graph', $$ MATCH (n) RETURN n $$) as (a agtype);

```

The output of above command will look like this:


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

The last query returns all the rows in the database.


## References:
You can take help from following links they helped me in installing as well:

https://github.com/git-guides/install-git
https://age.apache.org/age-manual/master/intro/setup.html
https://www.postgresql.org/docs/current/install-procedure.html