teleren/devto huggingface dataset:
My frequent mistake in Go
Tags: go, mistake
Published: 2024-06-10 09:36:53

---
title: My frequent mistake in Go
published: true
description: 
tags: golang,mistake
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2024-06-10 08:46 +0000
---

My frequent mistake in Go is overusing pointers, like this unrealistic example below:

```Go
type BBox struct {
	X1 float64
	Y1 float64
	X2 float64
	Y2 float64
}

func ShowWidth(b *BBox) {
	w := math.Abs(b.X2 - b.X1)
	fmt.Println(w)
}

func main() {
	b1 := BBox{X1: 10.1, Y1: 100.2, X2: 1024.4, Y2: 4096.188888}
	b2 := BBox{X1: 10.1, Y1: 100.2, X2: 2024.4, Y2: 4096.188888}
	b3 := BBox{X1: 10.1, Y1: 100.2, X2: 3024.4, Y2: 4096.188888}
	ShowWidth(&b1)
	ShowWidth(&b2)
	ShowWidth(&b3)
}
```

I pass a pointer of BBox to _ShowWidth_, which according to [@meeusdylan's post](https://medium.com/@meeusdylan/when-to-use-pointers-in-go-44c15fe04eac), it slows down my program because the garbage collector has to determine if a _BBox_ must be in stack or heap.

In the alternative code below, I don't use pointer.

```Go
func ShowWidth(b BBox) {
	w := math.Abs(b.X2 - b.X1)
	fmt.Println(w)
}

func main() {
	b1 := BBox{X1: 10.1, Y1: 100.2, X2: 1024.4, Y2: 4096.188888}
	b2 := BBox{X1: 10.1, Y1: 100.2, X2: 2024.4, Y2: 4096.188888}
	b3 := BBox{X1: 10.1, Y1: 100.2, X2: 3024.4, Y2: 4096.188888}
	ShowWidth(b1)
	ShowWidth(b2)
	ShowWidth(b3)
}
```

I worried that my program will copy the entire _BBox_ every time ShowWidth is called. So, I checked the generated asssembly code. It looks like this:

```
	ShowWidth(b1)
  0x48098e		f20f10059ab60300	MOVSD_XMM $f64.4024333333333333(SB), X0	
  0x480996		f20f100d9ab60300	MOVSD_XMM $f64.40590ccccccccccd(SB), X1	
  0x48099e		f20f10159ab60300	MOVSD_XMM $f64.409001999999999a(SB), X2	
  0x4809a6		f20f101daab60300	MOVSD_XMM $f64.40b000305af6c69b(SB), X3	
  0x4809ae		e82dffffff		CALL main.ShowWidth(SB)			
```
So, what I worried was true. MOVSD_XMM is for copying value from a member of a _BBox_ in memory to a register one-by-one. You may see MOVSD_XMM was called 4 times per each ShowWidth call.

I didn't measure which one is faster or slower. I've heard that Skymont support loads per cycle. And, I wish they meant loading float64 using MOVSD_XMM as well. So, copying entire _BBox_ is hopefully fast. And, at least, as far as I have been told, a BBox will definitely remain in stack without a need of checking by the GC.

Moreover, passing by value seems to comply to Go community better than pointer. So it will look familiar, and everyone will be happy to see passing by value.

My plan is avoiding pointer by default, and I will use it only when I have to. About performance, I think I may have to benchmark before using a pointer. Or if the speed is acceptable, I won't optimize.
C++ 3-dars
Published: 2024-06-10 12:07:52

#include <iostream>
using namespace std;

int main(){
// o'zgaruvchiga nom berish shart
  /* int a        int a,d 
     string b     strin b,c
     int d      qilsa bo'ladi  
     string c        */
  // int yoki string data typeni o'zgartirmay qiymatini o'gartirish mumkin
  return 0;
}
int main4(){

int yosh = 25;
int yosh1 = 26;
int yosh_ = 30;
int _yosh = 21;
int yosh5 = 45;

  cout << yosh - yosh1 - yosh_ + _yosh + yosh5 << endl;
   
  return 0;
}
int main3() {

  // Veriable = o'zgaruvchi=>o'z ichida qiymat saqlaydigan konteyner
  // 1-turi: string => o'zini ichida faqat matn saqlatdigan o'zgaruvcholardir;
  // 2-turi: integer = int => o'z ichida faqat butun son saqlaydi;
  // data tapy(ma'lut turi) name(ism) = value(qiymat)

string ismim = "Ahmadjon";
int hozirgiyil = 2024;
int ozimniyilim = 2010;  
cout << "Mening ismim" << ismim << endl;
cout << "Men " << hozirgiyil-ozimniyilim << " yoshdaman";
  
  return 0;
}
int main2() {

  cout << "Birthdate\n";
  cout << "Enter Month:" << 3 << endl;
  cout << "Enter Date:" << 5 << endl;
  cout << "Birthdate is 0" << 3 << "-0" << 5 << "(mm-dd)";
  return 0;
}
int main1() {

 cout << "Bu tekst/n";
 cout << 12345 << endl;
 cout << "345"<< endl;
 cout << 10+104 << endl;
 cout << 23/10 << endl;
 cout << 23-10 << endl; 
 cout << "23/10" << endl;
 cout << "23-10" << endl;
  
  return 0;
  }
Achieving Academic Success: How To Help Your Child
Published: 2024-06-10 12:06:57

Patents must support children when they are on their journey to achieving academic success. If you see your child struggling with things, you can work with an [online academic coach](https://peakacademiccoaching.com/academic-coaching/) who can offer the right help to support them in this journey. To become successful, they need to stay committed throughout their journey and focus on their strengths. The academic coach will also help identify the learning style of your child that will motivate them to study with dedication. So, let’s discuss how you can support your child in this journey.

Creating the right environment

When your child wishes to achieve academic success, you need to help them with a routine. Most children create unrealistic routines that are difficult to follow. So, with the [online academic coaching](https://peakacademiccoaching.com/academic-coaching/) expert, you can create a suitable environment and craft a routine that your child can consistently follow.

The perfect location for studying

To get into the right mind space for studying, it is important to choose a suitable location. So, make sure to choose a space that does not have too much noise. This can. distract your child. For instance, they should not study near the television or with a mobile phone as it will distract them from their studies.

Organize everything

When there is no clutter, your child can easily find their things and focus only on studying. So, you should help them with organizing all the study materials and keeping them in the right place. This way, they will easily find whatever things they are looking for and can just focus on studying.

Avoid distractions

There can be a lot of distractions. However, if you want your child to not get distracted and only focus on their studies, you should remove all the distractions from the study area. So, make sure to remove all the toys or other things that can grab their attention when they are trying to focus.

Focus on their passion

What are the interests of your child? You should discuss this with them and also support them in the area they are most interested in.

About Peak Academic Coaching:

Peak Academic Coaching is one of the leading websites that you can check out if you are looking for an [ADHD coach online](https://peakacademiccoaching.com/adhd-coach/) for your child. The coaches working here are highly experienced and can provide the best experience.

To get more details, visit https://peakacademiccoaching.com/

Original Source: [https://bit.ly/4bYScHg](https://bit.ly/4bYScHg)
Authentic Study Material SY0-701 Exam Dumps for CompTIA Security+
Published: 2024-06-10 12:04:16

<a href="https://dumpsarena.com/comptia-dumps/sy0-701/">SY0-701 Exam Dumps</a> Additionally, using SY0-701 Exam Dumps from reputable sources like dumpsarena ensures that you are working with accurate and up-to-date information. Cross-referencing the dumps with official study guides and other reliable resources can provide a more holistic view of the subject matter. Engaging in online forums or study groups can also enhance your preparation by allowing you to discuss tricky questions and share insights with peers.

In conclusion, a strategic approach to using SY0-701 Exam Dumps involves structured study plans, simulating exam conditions, thorough review, and cross-referencing with reliable resources. <a href="https://dumpsarena.com/comptia-dumps/sy0-701/">CompTIA Security+ Exam 2024,</a>  These strategies can significantly enhance your preparation, increasing your chances of passing the CompTIA Security+ Exam 2024 on the first attempt.

Common pitfalls to avoid while using exam dumps
While using SY0-701 Exam Dumps can be an effective preparation tool for the CompTIA Security+ Exam 2024, it is essential to avoid common pitfalls that can undermine your success. One major pitfall is over-reliance on dumps. Although they provide valuable insights into the exam format and types of questions, relying solely on them can lead to a superficial understanding of the subject matter. It is crucial to complement dumps with comprehensive study materials and practical experience.

Click here more info >>>> https://dumpsarena.com/comptia-dumps/sy0-701/
Wisephone 2 Discount Code
Published: 2024-06-10 12:03:41

Use Techless Wisephone Discount Code “**Vokeme**” to Get $75 Off.

## Techless Wisephone for Sale

WisePhone 2 is a simplified smartphone designed for users who want to escape the complexity and distractions of traditional smartphones.

Techless Wisephone focuses on basic communication, such as calling and texting, with a very limited range of additional apps. It emphasizes essential features over broad features.

The design is simple and user-friendly, perfect for those prioritising minimalism and digital well-being.

## Techless Wisephone Discount Code

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

The Techless Wisephone costs $399, but you can save $75 off your PreOrder by using coupon code “VOKEME” at checkout.

**[Order Now](https://techless.com?aff=VOKEME)**
HTML classes and HTML class attribute
Tags: css, learning, webdev, html
Published: 2024-06-10 12:03:09

## **HTML class Attribute**
The HTML class attribute is used to specify a class for an HTML element.
The class attribute is often used to point to a class name in a style sheet.
we have three `<div>` elements with a class attribute with the value of `"city"`. All of the three `<div>` elements will be styled equally according to the. city
we have two `<span>` elements with a class attribute with the value of "note". 
Both `<span>` elements will be styled equally according to the. note style 
```HTML
<!DOCTYPE html>
<html>
<head>
<style>
.city {
  background-color: tomato;
  color: white;
  border: 2px solid black;
  margin: 20px;
  padding: 20px;
}
</style>
</head>
<body>

<div class="city">
  <h2>London</h2>
  <p>London is the capital of England.</p>
</div>

<div class="city">
  <h2>Paris</h2>
  <p>Paris is the capital of France.</p>
</div>

<div class="city">
  <h2>Tokyo</h2>
  <p>Tokyo is the capital of Japan.</p>
</div>

</body>
</html>
```
## **Syntax:**
write a period (.) character, followed by a class name. Then, define the CSS properties within curly braces {} to create a class.
```HTML
<!DOCTYPE html> 
<html>
 <head> 
<title>
Example
</title>
 <style>
 . myClass
 {
 color: blue; font-size: 20px;
 }
 </style>
 </head>
 <body>
 <p class="myClass">This is a paragraph with the class "myClass”. </p> 
</body>
 </html>
```
## **Multiple Classes**
HTML elements can belong to more than one class.
`<h2>` element belongs to both the city class and also to the main class
## **Example**
```HTML
<h2 class="city main">London</h2>
<h2 class="city">Paris</h2>
<h2 class="city">Tokyo</h2>
```
## **Different Elements Can Share Same Class**
Different HTML elements can point to the same class name.
 both `<h2>` and `<p>` point to the `"city"` class and will share the same style:
## **Example**
```HTML
HTML
<h2 class="city">Paris</h2>
<p class="city">Paris is the capital of France</p>
```
## **Use of The class Attribute in JavaScript**
JavaScript can access elements with a specific class name with the `getElementsByClassName()` method
```HTML
<script>
function myFunction() {
  var x = document.getElementsByClassName("city");
  for (var i = 0; i < x.length; i++) {
    x[i].style.display = "none";
  }
}
</script>
```
How to configure simple settings in a Azure Storage Account
Tags: beginners, tutorial, cloud, azure
Published: 2024-06-10 12:00:22

## Azure Storage Account
Azure Storage accounts provide scalable, durable, and highly available cloud storage for various data types, including blobs, files, queues, and tables. Here are some key settings to configure when creating and managing an Azure Storage account.

Steps to configure simplesettings on Azure Storage Account
Note; before starting these steps you must have create a **storage account** and a** resource group**. check previous post to learn how to create both storage account and a resource group.

Step 1
In your storage account, in the Data management section, select the Redundancy blade to ensure your storage is on Locally-redundant storage (LRS)
![redundancy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dtut4vzxo9390v9mmdrf.png)

Step 2
In the Settings section, select the Configuration blade.
![configuration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xggyhcxg5vh62beiz8gd.png)

Step 3
Ensure Secure transfer required is Enabled.
![secure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9s84ndycc8rethmisqjh.png)

Step 4
In the Settings section, select the Configuration blade.
![configuration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xggyhcxg5vh62beiz8gd.png)

Step 4
Ensure the Minimal TLS version is set to Version 1.2.
![TLS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wedqqhvlk5lzrxiyf4ml.png)

Step 5
In the Settings section, select the Configuration blade.
![configuration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xggyhcxg5vh62beiz8gd.png)

Step 6
Ensure Allow storage account key access is Disabled, be sure to save your changes
![Key access](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/50z9qg8kkuopcakgldmw.png)

Step 7
In the Security + networking section, select the Networking blade.
![networking](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9hm66wuhla6v9ee69shk.png)

Step 8
Ensure Public network access is set to Enabled from all networks and save
![access](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3f50q6wfb2l57muvgjg4.png)

Conclusion: **Configuring Simple Settings in an Azure Storage Account**
Configuring an Azure Storage Account with simple settings involves making key decisions on account type, performance, replication, networking, and security to best meet your needs.
Launched AIOps Startup
Tags: llm, observability, murnitur, rag
Published: 2024-06-10 11:53:17

We are thrilled to announce the launch of our AI observability platform, Murnitur. This platform offers a simple SDK for seamless integration, along with features for LLM tracing, evaluation, and guardrails to ensure optimal performance. Additionally, we provide a playground for testing and experimenting with your AI models. We would greatly appreciate it if you could take a moment to check it out or share it with anyone who might find it useful. Your support means a lot to us. Thank you!

[murnitur.ai](https://murnitur.ai)

🙏🏾🙏🏾
Today I have learned about function , filter using an array and lamda functions in PHP.
Tags: php, webdev, beginners, css
Published: 2024-06-10 11:40:27

## Important, must read

1. I hope that you have setup your vs code application on your system.

2. If you don't have then followed this link https://code.visualstudio.com/download to download vs code for practice to learn PHP.

## Diving in code 🐬
In a fresh vs code project (version 1.90 at the time of creation), we need following dependencies:

1. HTML
2. CSS 
3. PHP 
4. Function and filter 
5. Lamda function 

## On VS Code Side 😎 

1. Document Type

```html
<!DOCTYPE html>
```
It tells that document is in HTML type 5.
 
  

## HTML5 Structure 
Basic structure to write a document in HTML.
```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>You have read in dark mode </h1>
</body>
</html>
```

## CSS on body tag

```css
    <style>
        body {
            display: grid;
            place-items: center;
            font-family: sans-serif;
            height: 100px; 
            margin: 20px; 
        }
    </style>
```

## Function to filter books by author
    
Functions are initialised once in code and then these are used in their scope by calling them with name that is given at declaration time. Let sum is a function and it's function call is as `sum();`
```php
<?php
    function filterBooksByAuthor($books, $author) {
        $filteredBooks = array_filter($books, function($book) use ($author) {
            return $book['author'] == $author;
        });
        return $filteredBooks;
    }
```

## Array of books

```php
    $books = [
        ['name' => 'Web', 'author' => 'Philip K. Dick', 'purchaseUrl' => 'http://example.com'],
        ['name' => 'OOP', 'author' => 'Andy Weir', 'purchaseUrl' => 'http://example.com'],
        ['name' => 'Database', 'author' => 'Jeffery', 'purchaseUrl' => 'http://example.com']
    ];
```

## Filter books by author using the function
 

```php
   $filteredBooks = filterBooksByAuthor($books, 'Andy Weir');
```
## List of filtered books
When this code execution is completed, it shows a list of filtered books as a output.
```php
    <ul>
        <?php foreach ($filteredBooks as $book) : ?>
            <li><?= $book['name']; ?> - by <?= $book['author'] ?></li>
        <?php endforeach; ?>
    </ul>
```
## Lamda function in PHP 
Lamda/Anonymous functions have no name at the time of declaration. These can be used with variables.
```php
    <?php
    $sum = function($a, $b) {
        return $a + $b;
    };
    echo "Result of lambda function: " . $sum(3, 4);
    ?>
```

  I hope that you have understand everything clearly.

Thanks for reading 😘🤗
Polymorphism
Tags: java, programming, learning, beginners
Published: 2024-06-10 11:39:14

Polymorphism means that a variable of a supertype can refer to a subtype object. The three pillars of object-oriented programming are encapsulation, inheritance, and polymorphism. You have already learned the first two. This section introduces polymorphism.

First, let us define two useful terms: subtype and supertype. A class defines a type. A type defined by a subclass is called a _subtype_, and a type defined by its superclass is called a _supertype_. Therefore, you can say that **Circle** is a subtype of **GeometricObject** and **GeometricObject** is a supertype for **Circle**.

The inheritance relationship enables a subclass to inherit features from its superclass with additional new features. A subclass is a specialization of its superclass; every instance of a subclass is also an instance of its superclass, but not vice versa. For example, every circle
is a geometric object, but not every geometric object is a circle. Therefore, you can always pass an instance of a subclass to a parameter of its superclass type. Consider the code in program below:

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

The method **displayObject** (line 12) takes a parameter of the **GeometricObject** type. You can invoke **displayObject** by passing any instance of **GeometricObject** (e.g., **new CircleFromSimpleGeometricObject(1, "red", false**) and **new RectangleFromSimpleGeometricObject(1, 1, "black", false)** in lines 7–8). An object of a subclass can be used wherever its superclass object is used. This is commonly known as _polymorphism_ (from a Greek word meaning “many forms”). In simple terms, polymorphism means that a variable of a supertype can refer to a subtype object.
DevHunt
Tags: marketing, devtools, growth, traffic
Published: 2024-06-10 11:37:19

Join DevHunt and Be Part of the Software Development Uprising – Where your innovative creations no longer languish in obscurity, but are thrust into the spotlight, gaining the acclaim they rightfully deserve.

Visit [our website](https://devhunt.org/) for more info

Member of [marsx.dev](https://marsx.dev/) family
Got a question or wanna say hi?
I’m on Twitter: [@johnrushx](https://twitter.com/johnrushx/)
Exploring the World of Coding with CodingTequila
Published: 2024-06-10 11:34:41

Welcome to [CodingTequila](https://www.youtube.com/channel/UCMlXPzAOWeGv91tLRfUC94g), your go-to YouTube channel for all things coding! Whether you're a beginner looking to dive into the world of programming or a seasoned developer seeking to enhance your skills, CodingTequila has something for everyone.

## **About the Channel**

CodingTequila is dedicated to providing high-quality tutorials, tips, and tricks on various programming languages and technologies. From JavaScript and Python to advanced topics like machine learning and artificial intelligence, the channel covers a broad spectrum of subjects to help you stay ahead in the tech world.

## **What You’ll Find**
Step-by-Step Tutorials: Detailed guides on popular programming languages and frameworks.
Project-Based Learning: Practical projects that help you apply your knowledge in real-world scenarios.
Coding Challenges: Engaging challenges to test your skills and enhance problem-solving abilities.
Tech Reviews and Tips: Insightful reviews of the latest tools and technologies in the coding community.
Why Subscribe?
By subscribing to CodingTequila, you gain access to a wealth of knowledge and resources that can accelerate your coding journey. The channel's engaging content and clear explanations make learning enjoyable and effective.

## **Join the Community**
Become a part of the CodingTequila community today. Subscribe to the channel, leave comments, ask questions, and share your coding experiences with fellow learners and enthusiasts.

Visit [CodingTequila](https://www.youtube.com/channel/UCMlXPzAOWeGv91tLRfUC94g) on YouTube and start your coding adventure now!
The Object Class and Its toString() Method
Tags: java, programming, learning, beginners
Published: 2024-06-10 11:33:33

Every class in Java is descended from the **java.lang.Object** class. If no inheritance is specified when a class is defined, the superclass of the class is **Object** by default. For example, the following two class definitions are the same:

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

Classes such as **String**, **StringBuilder**, **Loan**, and **GeometricObject** are implicitly subclasses of **Object** (as are all the main classes you have seen in previous posts so far). It is important to be familiar with the methods provided by the **Object** class so that you can use them in your classes. This section introduces the **toString** method in the **Object** class.

The signature of the **toString()** method is:

`public String toString()`

Invoking **toString()** on an object returns a string that describes the object. By default, it returns a string consisting of a class name of which the object is an instance, an at sign (**@**), and the object’s memory address in hexadecimal. For example, consider the following code for the **Loan** class defined in Loan.java, [here](https://dev.to/paulike/class-abstraction-and-encapsulation-2flo):

`Loan loan = new Loan();
System.out.println(loan.toString());`

The output for this code displays something like **Loan@15037e5**. This message is not very helpful or informative. Usually you should override the **toString** method so that it returns a descriptive string representation of the object. For example, the **toString** method in the
**Object** class was overridden in the **GeometricObject** class in lines 46–48 in SimpleGeometricObject.java, in [here](https://dev.to/paulike/inheritance-superclasses-and-subclasses-5ede) as follows:

```
public String toString() {
return "created on " + dateCreated + "\ncolor: " + color +
" and filled: " + filled;
 }
```

You can also pass an object to invoke **System.out.println(object)** or
**System.out.print(object)**. This is equivalent to invoking **System.out
.println(object.toString())** or **System.out.print(object.toString())**. Thus, you could replace **System.out.println(loan.toString())** with **System.out.println(loan)**.