teleren/devto huggingface dataset:
Rust for Python developers : Rust Data Types for Python Developers
Published: 2024-07-14 04:02:13


## Rust Data Types for Python Developers

## Scalar Types

### Integers

**Python:**

```python
x = 5
y = -3
```

**Rust:**

```rust
fn main() {
    let x: i32 = 5;
    let y: u32 = 10;
    println!("x = {}, y = {}", x, y);
}
```

### Floating-Point Numbers

**Python:**

```python
pi = 3.14
```

**Rust:**

```rust
fn main() {
    let pi: f64 = 3.14;  // f64 is a 64-bit floating-point number
    println!("pi = {}", pi);
}
```

### Booleans

**Python:**

```python
is_active = True
is_deleted = False
```

**Rust:**

```rust
fn main() {
    let is_active: bool = true;
    let is_deleted: bool = false;
    println!("is_active = {}, is_deleted = {}", is_active, is_deleted);
}
```

### Characters

**Python:**

```python
letter = 'a'
```

**Rust:**

```rust
fn main() {
    let letter: char = 'a';
    println!("letter = {}", letter);
}
```

## Compound Types

### Tuples

**Python:**

```python
point = (3, 4.5)
```

**Rust:**

```rust
fn main() {
    let point: (i32, f64) = (3, 4.5);
    println!("point = ({}, {})", point.0, point.1);
}
```

### Arrays

**Python:**

```python
numbers = [1, 2, 3, 4, 5]
```

**Rust:**

```rust
fn main() {
    let numbers: [i32; 5] = [1, 2, 3, 4, 5];
    println!("numbers = {:?}", numbers);
}
```

## Strings

**Python:**

```python
greeting = "Hello, world!"
```

**Rust:**

```rust
fn main() {
    let greeting: &str = "Hello, world!";
    let mut dynamic_greeting: String = String::from("Hello, world!");
    dynamic_greeting.push_str(" Welcome!");
    println!("{}", dynamic_greeting);
}
```

read next tutorial use enums
Mount share folder in QEMU with same permission as host
Tags: qemu, 9p
Published: 2024-07-14 04:15:32

## Background

I would like to share a folder between guest and host in QEMU. File permission should be the same as the user in host.

## Solution

1\. Create a folder called `shared` in host

```
mkdir -p shared
```


2\. Add a parameter `virtfs` when starting VM with QEMU

```
-virtfs local,path=shared,mount_tag=shared,security_model=mapped-xattr
```

3\. After the VM is started, login to the VM and create mount point

```
mkdir -p /mnt/shared
```

4\. Mount the folder

```
sudo mount -t 9p -o trans=virtio,version=9p2000.L shared /mnt/shared
```

5\. Check the permission of mount point

```
ls -l -d /mnt/shared
```

It should be something like the following. On my host machine, my user ID is 501 and primary group ID is 20. (It's common setting in MacOS). In the guest VM, the group with ID 20 is called dialout. (You can check in /etc/group). 

```
drwxr-xr-x 3 501 dialout 96 Jul 14 03:44 /mnt/shared
```

However, my user in guest VM has uid 1000 and the primary group id is 1000 too. We need to make a mapping.

```
id
uid=1000(franz) gid=1000(dev_users) groups=1000(dev_users),27(sudo)
```

6\. Install bindfs in guest VM

```
sudo apt install -y bindfs
```

7\. Create the mapping

```
sudo bindfs --map=501/1000:@dialout/@1000 /mnt/shared /mnt/shared
```

8\. Check the permission of mount point again

```
ls -l -d /mnt/shared
```

This time the permission is correct.

```
drwxr-xr-x 3 franz dev_users 96 Jul 14 03:44 /mnt/shared
```

Reference: [9p/virtfs share not writable](https://github.com/utmapp/UTM/discussions/4458#discussioncomment-3818945)
Using Flexbox for Layouts
Tags: sass, scss, css, tailwindcss
Published: 2024-07-14 04:17:37

## Introduction

In recent years, web design has evolved to focus more on responsive and flexible layouts. This is where flexbox comes in. Flexbox is a CSS layout model that allows for the creation of flexible and responsive web layouts with ease. It provides developers with a more efficient way to arrange, align, and distribute elements within a container. In this article, we will discuss the advantages, disadvantages, and features of using flexbox for layouts.

## Advantages

One of the main advantages of using flexbox is its ability to create dynamic and responsive layouts. It eliminates the need for complicated CSS hacks and allows for easier vertical and horizontal alignment. Flexbox also makes it easier to reorder elements for different screen sizes, making it perfect for creating responsive designs. Moreover, it reduces the reliance on floats and clears which improves website performance.

## Disadvantages

However, flexbox is not without its drawbacks. It can be challenging to learn for beginners and has limited browser support. This can lead to compatibility issues and require the use of fallback options for older browsers.

## Features

Flexbox has an array of features that make it ideal for layouts. It allows for flexible spacing between elements, even distribution of space between multiple items, and the ability to set a fixed or proportional size for elements. Other features include the ability to change the order of elements on different screen sizes and easily switch between column and row orientations.

### Example of Flexbox Layout

```css
.container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
}

.item {
  flex: 1 1 200px; /* Grow, shrink, basis */
  margin: 10px;
}
```

This example demonstrates a flex container that adjusts its children (`item`) with flexible widths but ensures they never shrink below 200px. The items are spaced out evenly and centered vertically within the container.

## Conclusion

In conclusion, flexbox is a powerful and flexible tool for creating responsive and dynamic web layouts. Its advantages, such as efficient alignment and easy reordering, outweigh its disadvantages. With the growing demand for responsive web design, learning flexbox is a valuable skill for any web developer to have.
Make Money as a Frontend Developer 🤑
Published: 2024-07-14 07:58:16


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yj3rcgqplf7uw8irunyh.png)
Career Paths
Working for a Company
If you choose to work for a company, you can earn a good salary and potentially negotiate higher pay based on your skills and experience.

Freelancing
As a freelance developer, you have the flexibility to set your own rates and work on a variety of projects. By charging a high hourly rate, you can make a good living.

Essential Skills
To succeed as a frontend developer, you need to be proficient in:

[HTML](https://acrelicenseblown.com/e9msagb7?key=81a03c9597124ad2b0b057c8adabef59)
[CSS](https://acrelicenseblown.com/e9msagb7?key=81a03c9597124ad2b0b057c8adabef59)
[JavaScript](https://acrelicenseblown.com/e9msagb7?key=81a03c9597124ad2b0b057c8adabef59)
These are the core technologies used in frontend development. Additionally, understanding web browsers and how they work is crucial.

Design Principles
Having a good grasp of design principles is also essential. This knowledge will help you create attractive and user-friendly interfaces, which are highly valued by employers and clients alike.

Independence and Teamwork
To thrive in this field, you must be able to work independently as well as collaborate effectively with a team of developers. Strong communication and project management skills will also enhance your ability to succeed, whether you're freelancing or working within a company.
How to Connect to an EC2 Instance in a Private Subnet
Published: 2024-07-14 05:15:16

## Prerequisites

Before you start, ensure you have the following:
- An EC2 instance running in a private subnet.
- AWS Systems Manager (SSM) Agent installed and running on the instance.
- An IAM role attached to the instance with the necessary permissions to use SSM.
- AWS CLI configured on your local machine.

## Step 1: Attach an IAM Role to the EC2 Instance

1. **Create an IAM Role** (if you don’t have one):
   - Go to the **IAM** service in the AWS Management Console.
   - Choose **Roles** and then **Create role**.
   - Select **AWS service** and choose **EC2**.
   - Attach the **AmazonEC2RoleforSSM** managed policy.
   - Name your role and complete the creation process.

2. **Attach the IAM Role to your EC2 Instance**:
   - Go to the **EC2 Dashboard**.
   - Select your instance.
   - Click on **Actions** > **Security** > **Modify IAM Role**.
   - Attach the IAM role you created or an existing role with the necessary SSM permissions.

## Step 2: Verify SSM Agent Installation

1. **Check if SSM Agent is Installed**:
   - Connect to your instance using an existing method (if possible) or check the instance launch configuration.
   - For Amazon Linux, the SSM Agent is pre-installed. For other AMIs, you might need to install it manually.

2. **Install SSM Agent Manually** (if not installed):
   - For Amazon Linux:
     ```sh
     sudo yum install -y amazon-ssm-agent
     sudo systemctl start amazon-ssm-agent
     sudo systemctl enable amazon-ssm-agent
     ```

## Step 3: Connect to the Instance Using SSM

1. **Configure AWS CLI**:
   - Open your terminal or command prompt.
   - Configure the AWS CLI with your credentials and default region:
     ```sh
     aws configure
     ```
   - Follow the prompts to enter your AWS Access Key ID, Secret Access Key, Default region name (e.g., us-east-1), and Default output format (e.g., json).

2. **Start an SSM Session**:
   - Use the following command to start a session with your instance:
     ```sh
     aws ssm start-session --target <instance-id>
     ```
   - Replace `<instance-id>` with the actual instance ID of your EC2 instance in the private subnet.

### Example

Assuming your instance ID is `i-0a677d0c4370bebab`, you would run:
```
aws ssm start-session --target i-0a677d0c4370bebab
```

We are now connected and can run simple commands like `hostname` and `uptime`.

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



Note: If you have trouble for any reason, you can reference this [deployment guide](https://aws.amazon.com/solutions/implementations/linux-bastion/) and use the CloudFormation template provided.
A list of lists in Python
Tags: learnpython, coding, programming
Published: 2024-07-14 05:30:20

**Python Tip: Creating a List of Lists**

When creating a list of lists in Python, it's important to understand how list multiplication works.

Using:

```
m = [[]] * 7
```
creates seven references to the same list. Modifying one list will affect all others because they reference the same object.

Instead, use list comprehension to ensure each list is independent:

```
m = [[] for _ in range(7)]
```
This way, each empty list in 'm' is a separate object, avoiding unwanted side effects.
Empathetic Product Story For Readability
Tags: product, engineering, leadership
Published: 2024-07-14 05:00:00

There was some interest on the last product post so I figure I follow up with some clarification on some of the ideas.

---

**Empathetic Product Story For Readability** is a formal proposal of user story. It contains 3 stories of user journeys for the proposed  new context.

For information on the interesting formatting decisions of the previous positing, please join the discussion at [the common room](philosophy-club.mn.co).

**Empathetic Product Story For Readability** frames the goals of a software program from the perspective of a role identity which interacts with the software. For practicality, three roles are always mapped. The Target Audience Member, The Owner Admin, and The Developer Admin.

**The Target Audience Member** Is the One Who Just Wants A Button To Do The Function They Thought Of. (p:Make A Product Video)

**The Owner Admin** Is A Dedicated Team Member To The Universe. This interface may be defined as multiple product stories; one for each care owner. (p:w-2 employee)

And **The Developer Admin Product** Story Defines The Software Owner Interface. (p:cli dev)

Perfect Product Definition is the collection of Product Stories by role.
OwnerGroup1 is Owner Admin.
Owner Group 2 is Target Audience.

Perfect Product Understanding is a collection. It is the understandings of "How is it possible for me to" from the perspective of the identified roles.

How is it possible for me to **book vacation** as a **user**?
How is it possible for me to **manage bookings** as an **intern**?
How is it possible for me to **oversee bookings** as a **software dev**?

### The Next Step

An Engineer takes over after that answer and produces specifications answering "What Infrastructure Makes That _possible_ Scenario **Possible**?"

The Specifications Document Is A Major Milestone

[(the previous post)](https://dev.to/theholyspirit/a-product-engineering-understanding-332k)
My Wins of Week 🌟 [14/07/24]
Tags: weeklywins, weeklyretro, 100daysofcode
Published: 2024-07-14 06:32:57



![hello by duck](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gtiopf9jitqtp296w1md.png)



<br>
<br>
> _Ahhhh...⚡
This week has been full of exciting developments, achievements & Ups and Down. I would like to share my wins with you all. Let's dive in!_ 🌊

---

### 🎯 Coding this week #100daysofcode

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

<br>
Here is Github repo link Where i Share my 100daysofcode!
🔗 : [100 days of code log](https://github.com/developedbyjk/100daysofcode/) 

> ⌛ <br> _want to more consistence in <br/> this journey with goal of coding 2 hr_





---
<br>
### 💾 Working this week: 

<br>
**😁 Meme Maker** : 
- I am still working on this project as of 14 july. This week i added features like `moveable text` on the meme and also made them `draggable`.
- I also made them downloadable by using canvas but still need to update the text when it move to the canvas, will work on that following week
- Improved the Design and user experience!

>_💡note: Early think to make the text on the meme image as static but wasnt satisfied by the output wanted to make it more useful and creative... definitely it will take time but learn a lot **Progres>>>>Perfection**_

{% twitter 1811725873474863508 %} 


<br>
**🧩 Portfolio** :

- Added the [Lab section](https://junedkhan.me/#labs) where i share my experiment project 
- Improved Design and Fix some bugs



---
<br>
### 🧠Learning This Week : 

- Share Coding journey daily to X & Github as its helpful for understanding weekly progress! 📈
- Learned Framer motion with Next Js... checkout [this video](https://youtu.be/znbCa4Rr054?si=V-Mw89_R1kQF5la8) 📺
- Read up again 3x its so imp 💎
- There are many helpful packages and libraries for accomplishing task in react ⚛️


<br>
<br>
---

### 🍵 Next Week Goals :

- Learn Typescript
- Share PMS to Social 
- Share intro video to Social 
- Press more on J btn
- Work on clg stuff

<br>
<br>
<br/>
![Thanks](https://media.tenor.com/IV90UuSlVOQAAAAi/line.gif)

<center>

Thank you for reading about my journey this week! If you have any suggestions or feedback, please leave a comment below. Let's keep building and learning together!
</center>


![bye](https://c.tenor.com/Pa5WtRlDH0gAAAAC/tenor.gif)
<center>
Happy Weekend ❤️
</center>
A Simple Python Tkinter-based Ollama GUI with no external dependencies
Tags: ollama, python, tkinter, llm
Published: 2024-07-14 06:08:35

Hello everyone, I would like to share with you [ollama-gui](https://github.com/chyok/ollama-gui) - a lightweight, Tkinter-based python GUI for the Ollama.

## Overview

The project is very simple, with no other dependencies, and can be run in a single file.

![ollama-gui-1 2 0](https://github.com/user-attachments/assets/a4bb979b-68a4-4062-b484-7542f2a866e0)

It can serve as a first GUI page for beginners, without the need for Docker, VM or other dependencies, just Python (if not using the binary).


## Features

+ 📁 One file project.
+ 📦 No external dependencies, only **tkinter** which is usually bundled.
+ 🔍 Auto check ollama model list.
+ 🌐 Customizable ollama host support.
+ 💬 Multiple conversations.
+ 📋 Menu bar and right-click menu.
+ 🗂️ Model Management: Download and Delete Models
+ 🎨 UI Enhancement: Bubble dialog theme
+ 📝 Editable Conversation History

## Run
Choose any way you like:

### source code

```
python ollama_gui.py
```

### using pip

```
pip install ollama-gui
ollama-gui # or python -m ollama_gui
```

### binary file
I have provided some Windows, Mac, and Linux binaries for convenient direct use, could be downloaded from the GitHub release page.

## Motivation

While looking for a UI interface for Ollama to experiment with large models locally, I found that many had heavy installation dependencies. Since I don't have particularly high requirements for the interface and UI, I decided to write an extremely minimalist UI using Python.

The project home is at https://github.com/chyok/ollama-gui

I would be most appreciative if anyone were interested, and also be tremendously grateful for any feedback or suggestions that anyone may have to offer.

Thanks,
chyok
Ten Drops: A Python Pygame-CE Game Inspired by Splash Back
Tags: python, pygame, gamedev
Published: 2024-07-14 06:16:02

I would like to introduce my pygame project, [Ten Drops](https://github.com/chyok/ten-drops) - a fun and addictive water droplet game built using Pygame-CE. This game is a loving tribute to the classic Flash game "Splash Back," reimagined for modern platforms.

![example](https://github.com/chyok/ten-drops/assets/32629225/b8409169-dd31-4912-a91e-5fed288a833c)

## What is Ten Drops?

Ten Drops is a simple yet engaging game where players click on water droplets to make them explode, with the goal of clearing the screen. It's a perfect blend of strategy and quick reflexes that will keep you entertained for hours.

## Key Features
1. Simple, intuitive gameplay
2. Colorful water droplet graphics
3. Inspired by the beloved Flash game "Splash Back"
4. Built using Pygame-CE for smooth performance

## How to Play
The objective is straightforward - click on the water droplets to make them burst. Keep clicking until you've cleared all the droplets from the screen. It's easy to learn but challenging to master!

## Installation:
You can easily install Ten Drops using pip:

```
pip install ten-drops
```

Once installed, simply run:

```
ten-drops
```

For Windows users, I've also provided a binary file that can be directly executed to play the game.

## Future Plans
I'm continually working on improving Ten Drops and adding new features. Some ideas I'm considering include:
- Multiple difficulty levels
- A scoring system
- Sound effects and background music
- Power-ups and special droplets

## Conclusion
Ten Drops is more than just a game - it's a nostalgia trip for those who remember the Flash era and a fun, accessible entry point for new gamers. Whether you're looking for a quick distraction or a new coding project to contribute to, Ten Drops has something for everyone.

Project page: https://github.com/chyok/ten-drops


Thanks!
chyok
Embarking on a 6-Month Learning Journey: Join Me in Building and Growing!
Published: 2024-07-14 06:27:42


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6yetpjkcsmevkff0mzuk.jpeg)
---

Excited to share my plans for the next 6 months! 🎉

I will be dedicating this time to learning and building projects, focusing on enhancing my skills and bringing innovative ideas to life. As I dive deeper into backend development, I aim to create robust applications using JavaScript, Node.js, Express.js, NoSQL, and MongoDB. Additionally, I will be expanding my knowledge by learning frontend technologies, including HTML5, CSS, Tailwind, Bootstrap, and Figma, to become a more versatile developer.

I invite you all to be my partners in this learning journey! Your feedback and support will be invaluable, so feel free to review my progress and share your thoughts.

Stay tuned for updates on my progress and the projects I'll be working on. Looking forward to this journey of growth and development!

#LearningJourney #BackendDevelopment #FrontendDevelopment #HTML5 #CSS #Tailwind #Bootstrap #Figma #TechProjects #ContinuousLearning #Innovation #CommunitySupport

---
My rails performance tips compilation
Tags: rails
Published: 2024-07-14 06:43:11

---
title: My rails performance tips compilation
published: true
description: 
tags: #rails
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2024-07-14 06:32 +0000
---
This serves as a compilation of rails performance tips I posted on Twitter. This is an ongoing work. I will post tweets from others too.

{% embed https://x.com/Haseebeqx/status/1809099067555000712 %}
{% embed https://x.com/Haseebeqx/status/1812363772549566546 %}
{% embed https://x.com/Haseebeqx/status/1812003525599039489 %}
🌟 JavaScript Learning Journey: Two Weeks of Progress! 🌟
Published: 2024-07-14 06:51:18

Over the past two weeks, I've been diving deep into JavaScript, and I'm excited to share my progress with you all! 🎉

🔍 Here's what I've been working on:

Fundamentals of JavaScript:
Understanding variables, data types, and operators.
Learning about control structures like loops and conditionals.

Functions and Scope:
Writing reusable functions and grasping the concept of scope.
Exploring function expressions and arrow functions.
Understanding and implementing pure functions.

Objects and Arrays:
Manipulating objects and arrays to store and manage data.
Using methods to interact with arrays and objects effectively.

📚 Resources I've Been Using:

MDN Web Docs: Comprehensive documentation and tutorials on JavaScript.
Eloquent JavaScript by Marijn Haverbeke: An in-depth book covering the basics and advanced concepts.
freeCodeCamp: Hands-on exercises and projects to reinforce learning.
JavaScript.info: Detailed articles and tutorials on various JavaScript topics.
YouTube Channels: Traversy Media, The Net Ninja, and Academind for video tutorials and walkthroughs.
These two weeks have been a rewarding experience, and I'm thrilled with my progress. I look forward to continuing this journey and building more complex projects in the coming weeks.

Code Link : [Github Repo](https://github.com/nittinkumarhr/java-scripts/)

Stay tuned for more updates, and feel free to share your own learning experiences in the comments! 🚀


#JavaScript #LearningJourney #WebDevelopment #Coding #Tech
Day 13 of 100 Days of Code
Tags: 100daysofcode, webdev, javascript, beginners
Published: 2024-07-14 06:59:38

Sat, Jul 13, 2024

Today I began the last Codecademy lesson of the first course, Responsive Design. Now that all course material is new for me, my focus going forward will be on learning rather than hitting targets. I may not make JavaScript by Monday, but I'm going to responsively design my way to JavaScript as soon as possible!

The reason I've given Codecademy so much praise is not only that the lessons are thorough yet concise, but also they have practical exercises and bonus topics that serve as a basis for lessons and tie them together. For example, including UX in Web Development Foundations makes the course more spirited, plus I've seen at least a starter version of the topic, but also in terms of the learning process, it improves memorization to start with problem-solving, top-down, which is how I most like to work.

While macOS is the best development environment imo, most of my experience is with Windows and Linux. While I've made big strides learning macOS, occasionally, the Apple-isms can be frustrating. However, this MacBook has exceeded my expectations, and I'm looking forward to window snapping and AI features coming this fall in the next macOS release, Sequoia.

Regarding expectations for this 100 days of code challenge, I started on July 1, and anticipate taking about 120 days to complete Codecademy's Full-Stack Engineer certificate, so aiming for late October. My dashboard shows me at 12%.

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