teleren/devto huggingface dataset:
Build statically linked Rust binary with musl (and avoid a common pitfall)
Tags: rust, musl, linux, openssl
Published: 2024-02-13 19:25:17

#### Introduction
I was required to produce a x86-64 statically linked Rust binary for a containerized workload at work. This guide briefly outlines the process of doing so using **musl**, a lightweight C library. Unlike traditional compilation with **glibc**, musl eliminates dynamic dependencies, resulting in a single, external dependency-free executable.

#### A quick word on why **musl** is preferred over **glibc** 
Even if a program is statically linked with glibc, it still requires to dynamically load the c library in order to satisfy loading of some NSS and iconv modules. {% cta https://stackoverflow.com/a/57478728 %} ref {% endcta %}

#### Steps

- Create a new cargo project 
  ```
  $ cargo new --bin static-rust-binary
  ```
- Build the default binary
  ```
  $ cd static-rust-binary
  $ cargo build 
  ```
- Check it is dynamically linked
  ```
  $ file ./target/debug/static-rust-binary 
./target/debug/static-rust-binary: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=774a033de72094a3ea8a7ac99261b57a86603173, for GNU/Linux 3.2.0, with debug_info, not stripped
```
- Change build target to musl and re-compile
  ```
  $ cargo build --release --target=x86_64-unknown-linux-musl
  ```
- Check if the binary is now statically linked
  ```
  $ file ./target/x86_64-unknown-linux-musl/release/static-rust-binary 
./target/x86_64-unknown-linux-musl/release/static-rust-binary: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, BuildID[sha1]=e3880597fbf7adcb623d246b69c52d9aee6fe867, with debug_info, not stripped
  ```

🎩✨ Voilà! ✨🎩 
The statically linked rust binary is ready which can now be put in a scratch container to be run on #docker #kubernetes etc.

---

#### ‼️ Attention! ‼️
In my experience I've run into trouble generating a statically linked binary if the project dependencies have implicitly or explicitly included `openssl-sys` crate. For example - 
```
$ cargo build --release --target=x86_64-unknown-linux-musl
   ...
   Compiling openssl v0.10.63
   ...
   Compiling openssl-sys v0.9.99
error: failed to run custom build command for `openssl-sys v0.9.99`
```

In this case the simplest way I've been able to fix the problem is to explicitly add the openssl crate (latest version) with the features = `vendored` conditional dependency to the `Cargo.toml` (Note: as of today "v0.10.63" is the latest version of openssl crate).
```
[dependencies]
...
openssl = { version = "0.10.63", features = ["vendored"] }
```

Re-running the build compiles successfully.
```
$ cargo build --release --target=x86_64-unknown-linux-musl
   Compiling openssl v0.10.63
   ...
   Compiling openssl-sys v0.9.99
   ...
   Compiling static-rust-binary v0.1.0 (/home/abhishek.pareek/src/rust/simple-static-rust-binary)
```

🤞 Hopeful this will help someone get unstuck in the future! 🌟 And don't hesitate to comment if this approach worked or not! 🚀
Study material (ruby loops)
Published: 2024-02-13 19:17:14


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

There is also the loop method: https://www.codecademy.com/courses/learn-ruby/lessons/loops-iterators/exercises/the-loop-method

cheat sheet: https://www.codecademy.com/learn/learn-ruby/modules/learn-ruby-looping-with-ruby-u/cheatsheet
STOLEN BITOIN RECOVERY SPECIALIST DIGITAL WEB RECOVERY
Published: 2024-02-13 19:14:15

Had I known about the negative reviews regarding people losing their funds to investment platforms, I would have refrained from engaging with one. Unfortunately, I realized the workings of the crypto market too late. I have always been skeptical about what I put my money into but I guess these guys were too good because they had documents to back each claim and that made them look legitimate at first.

After my recent research about crypto, I think it’s much better to buy and hold in your wallet instead of investing with any platform that might claim to be either trading your assets or mining them for profits because as it currently stands I don’t think there’s still any real trading platform out there, I’m speaking from personal experiences with 2 separate platforms that claimed to be legitimate but at the end all turned out to be fake, I have totally given up in any online investment, Losing your hard-earned money to a virtual investment can really drive one nut if not carefully handled, I can now say I’ve seen it all and I know all the petty tricks they use to lure people into believing them and investing a huge sum, thanks to Digital Web Recovery I got involved with after I learned about the company being a fraudulent company. Altogether I lost a total of about 580,000 Euros to a fake investment platform, the good part of it all was that they didn’t get away with all of it, My research on how to get my funds back turned out to be helpful after getting in touch with Digital Web Recovery, I did everything possible making sure that the recovery team had every resource needed to retrieve my money back to my wallet.

If you ever come across this before. I can vouch for digital web recovery to be able to assist you with any crypto-related issues. Digital web recovery can be reached via either email address; digitalwebrecovery(@)mail-me.com
WhatsApp; ‪+14033060588
A quick way to run axe-core from python
Tags: a11y, python, selenium
Published: 2024-02-13 19:13:05

---
title: A quick way to run axe-core from python
published: true
description: Call the CLI via npx in a subprocess
tags: accessibility, python, selenium
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2024-02-13 18:43 +0000
---

I used this code snippet today to run [axe-core](https://www.npmjs.com/package/@axe-core/cli) from a python selenium test. It calls out to the command line interface, using [npx](https://docs.npmjs.com/cli/v7/commands/npx) so I don't have to worry about managing node packages:

```python
    def check_for_accessibility_issues(self):
        command = ["npx", "@axe-core/cli", "-q", self.selenium.current_url]
        output = subprocess.run(command, capture_output=True, text=True)
        self.assertEqual(output.returncode, 0, output.stdout)
```

This should work with anything that runs your app in a browser, not just selenium.

Axe is an automated tool to detect some (but not all) [web accessibility](https://web.dev/articles/accessibility#what_is_accessibility) issues. It's not a substitute for actual usability testing with real people, but it's still useful. For a rough idea of what it can do, check out this blog post: [Axe-Core vs PA11y](https://www.craigabbott.co.uk/blog/axe-core-vs-pa11y/). In the author's testing, axe-core detected 27% of known issues on a test page.

I was originally hoping to use [axe-selenium-python](https://github.com/mozilla-services/axe-selenium-python) for this. It uses selenium's `execute_script` to inject the axe javascript into the page, similar to [this method](https://www.browserstack.com/docs/automate/selenium/accessibility-testing#python). Unfortunately, [axe-selenium-python has been unmaintained since its author left mozilla](https://github.com/mozilla-services/axe-selenium-python/issues/192#issuecomment-1675245578). [It looks like some nice people are going to take this over](https://github.com/mozilla-services/axe-selenium-python/issues/192#issuecomment-1936997374), but I wanted a workaround in the meantime.

*Note: There is also [Deque DevTools](https://www.deque.com/axe/devtools/), which appears to have python bindings, but this is not open source.* 😞
How Much JavaScript Do You Need for Web Development? A Beginner's Guide
Tags: webdev, javascript, programming
Published: 2024-02-13 19:12:26


The amount of JavaScript you need to learn for web development depends on your specific goals and ambitions within the field. Here's a breakdown based on different scenarios:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/21arxwdp2lalzkh35f5p.jpg)
Basic Web Development:

Fundamentals: To build simple static websites with basic interactivity, a solid understanding of core JavaScript concepts like variables, data types, operators, functions, control flow, and DOM manipulation is essential. This might take 3-6 months of dedicated learning, depending on your prior programming experience.
Front-End Frameworks (Optional): If you aim for more dynamic and complex websites, consider popular frameworks like React, Angular, or Vue.js. However, mastering these frameworks requires a strong foundation in core JavaScript first.



Advanced Web Development:

Backend Development: Building web applications with server-side functionality demands mastering Node.js, which uses JavaScript in a different environment. Expect additional learning time, depending on your Node.js goals.
Full-Stack Development: Combining front-end and back-end skills requires expertise in both core JavaScript and its various application areas. This path involves significant dedication and time investment.

Remember:

Quality over Quantity: It's not just about the amount of code learned, but about understanding the concepts deeply and being able to apply them effectively.
Practice is Key: Build projects to solidify your knowledge and gain practical experience.
Continuous Learning: Web development is constantly evolving, so be prepared for ongoing learning throughout your career.
Here are some helpful resources to get you started:

Codecademy's Learn JavaScript course: https://www.codecademy.com/learn/introduction-to-javascript


The Odin Project's Full-Stack JavaScript curriculum: https://www.theodinproject.com/paths/full-stack-javascript


FreeCodeCamp's Responsive Web Design Certification: https://www.freecodecamp.org/learn/2022/responsive-web-design

I HOPE THIS HELPS YOU, COMMENT YOUR QUESTIONS.
Micro-Post: Stop using `rm` to delete things!
Tags: programming, beginners, bash, learning
Published: 2024-02-13 19:02:46

The `rm` shell command is probably the most dangerous command in popular use. You can accidentally delete things you never meant to delete. As such, there are several precautions one should take to avoid any horrific situations.

The following are some simple things you can set in your shell's configuration files (i.e. `.bashrc`, `.zshrc`, etc.) that should come in handy!

(1) Always adding `-i` to request confirmation before deletion and `-v` to see exactly what you are deleting, like so:
```
alias rm='rm -i -v'
```
Note that this approach may still fail if you add `-f` which forces the deletion operation, so be aware that, though useful, this strategy is not a panacea.

(2) Avoiding use of `rm` completely and switching to a custom soft-delete method as shown below:
```
function softdelete() {
  local -r path=$(realpath -q "${1}")
  [[ -z "${1}" || -z "${path}" ]] && {
    echo "No valid path was found for argument '${1}'"
    return 1
  }
  local -r backup ="/tmp/$(echo -n "${path}" | tr /' '_')"
  mv -v ${path} ${backup}
}
```
Note that this approach is less versatile since you don't have all the command-line options `rm` provides. However, the benefits should far outweigh the costs since this method effectively soft-deletes files/folders alike to the `/tmp` directory. Though you could always modify this to point to any other directory of your choosing.

Another benefit of this method is that it preserves the original file path with `/`'s replaced with `_`'s so you don't have to remember the file's original path. This also helps with filename collisions to some extent.

Hope others find this useful!
Contentrain 2.0 is Live on Product Hunt! 🚀
Tags: javascript, react, webdev, programming
Published: 2024-02-13 19:00:27

🌌 When the internet was a baby, everything was rendered in server-side(SSR).

🛰️ Fast Forward: In the era of Client-Side Rendering(CSR) apps, and despite the better user experiences, search engine visibility(aka SEO Scores) began to decrease.

Contentrain entered the scene to tackle the challenges of CSR apps. It’s your trusted tool to manage your content(#CMS).

Join the discussion today; We’ve launched Contentrain 2.0 👇🏻
https://www.producthunt.com/posts/contentrain-2


New version simplifies UI complexities, better role and permissions systems and asset management, and ultimately boosts efficiency.
Rails 7 deprecate enum definition by keyword.
Tags: webdev, programming, rails, ruby
Published: 2024-02-13 18:41:56

Rails 7 deprecate enum definition by keyword arguments, From Rails 7.3 this old syntax will not be available...[Read More](https://sparkrails.com/rails-7/2024/02/13/rails-7-deprecated-enum-with-keywords-args.html)
Embracing the Ruby and Rails Journey
Published: 2024-02-13 18:31:09

Greetings, fellow adventurers!

I'm Sandip, and my journey with Ruby and Rails began way back with Ruby 1.8.6 and Rails 1.2.0. 🚀 Over the years, I've had the privilege of working with almost every major version of Ruby and Rails, witnessing the evolution and growth of these incredible technologies.

Today, I find myself immersed in the latest offerings: Ruby 3 and Rails 7. It's been an exhilarating ride so far, filled with countless opportunities to innovate and create. 💡

But my journey doesn't end with Ruby and Rails alone. Along the way, I've explored other realms of development, delving into frameworks like Backbone, Marionette, Angular, and React. And when it comes to databases, I've traversed the landscapes of MongoDB, MySQL, and PostgreSQL.

Join me on this exciting journey as we explore the wonderful world of Ruby and Rails. From building robust web applications to diving into the intricacies of backend development, we'll uncover the magic of Ruby's elegant syntax and Rails' powerful conventions.

Whether you're a seasoned developer or just starting out, there's always something new to learn and discover in the Ruby and Rails ecosystem.

Let's embark on this adventure together! 🌟 #Ruby #Rails #NodeJS #AWS #PostgreSQL #ElasticSearch #Sidekiq #Redis #Rspec #Cypress #TechJourney 🚴‍♂️
Understanding Strict Mode and Explicit Binding in JavaScript
Tags: javascript, webdev, programming, beginners
Published: 2024-02-13 18:16:37

In JavaScript, there are advanced features and techniques that can enhance the robustness and clarity of your code. In this post, we'll explore two important concepts: Strict Mode and Explicit Binding.

**Strict Mode:**

Strict Mode is a feature introduced in ECMAScript 5 that allows you to opt into a stricter set of rules and behaviors for JavaScript. When enabled, Strict Mode helps catch common coding mistakes and discourages the use of certain practices that are considered error-prone.

Here's how you can enable Strict Mode in your JavaScript code:

```javascript
'use strict';
```

Enabling Strict Mode at the beginning of a script or a function enables a set of strict rules for the entire script or function scope.

Some benefits of Strict Mode include:

- **Error Handling:** Strict Mode catches common coding mistakes and throws errors that would otherwise be ignored in non-strict mode.
- **Restrictions on Reserved Words:** It disallows the use of certain keywords as variable names, such as `arguments`, `eval`, and `implements`.
- **Avoids Global Variables:** It prevents accidental creation of global variables by requiring variable declarations with `var`, `let`, or `const`.
- **Makes `this` Binding More Predictable:** In non-strict mode, `this` can sometimes refer to the global object, leading to unexpected behavior. Strict Mode makes `this` binding more predictable by disallowing it to default to the global object in functions and methods.

**Explicit Binding:**

Explicit Binding refers to the ability to manually specify the value of `this` within a function or method. This is particularly useful when you need to control the context in which a function is executed.

JavaScript provides three methods for explicit binding: `call`, `apply`, and `bind`.

- **`call`:** The `call` method allows you to call a function with a specified `this` value and arguments provided individually.
- **`apply`:** The `apply` method is similar to `call`, but it accepts arguments as an array.
- **`bind`:** The `bind` method creates a new function with the specified `this` value and arguments, allowing you to store it for later execution.

Here's an example demonstrating the use of `call`, `apply`, and `bind`:

```javascript
const person = {
  name: 'John',
  greet: function(message) {
    return `${message}, ${this.name}!`;
  }
};

const alice = { name: 'Alice' };

console.log(person.greet.call(alice, 'Hello'));
console.log(person.greet.apply(alice, ['Hi']));
const greetAlice = person.greet.bind(alice);
console.log(greetAlice('Hey'));
```

Understanding and leveraging Strict Mode and Explicit Binding can help you write more reliable and maintainable JavaScript code. Whether you're working on large-scale applications or small projects, these concepts can make a significant difference in the quality of your code.
Mastering Loops and Iterations in JavaScript: A Comprehensive Guide
Tags: javascript
Published: 2024-02-13 18:15:37

Loops and iterations are fundamental concepts in JavaScript programming, enabling developers to execute code repeatedly under various conditions. In this guide, we'll explore the different types of loops, conditional statements, and exception handling mechanisms available in JavaScript.

**1. The for Statement**

The `for` statement is a classic loop construct in JavaScript, allowing developers to iterate over a block of code a specified number of times. It consists of three optional expressions: initialization, condition, and iteration statement.

**2. The do...while Loop**

The `do...while` loop is similar to the `while` loop but with one key difference: it always executes the block of code at least once before checking the condition.

**3. The while Loop**

The `while` loop repeatedly executes a block of code as long as the specified condition evaluates to true. It's suitable for scenarios where the number of iterations is unknown.

**4. Conditional Statements: if...else and Switch**

Conditional statements like `if...else` and `switch` allow developers to execute different blocks of code based on specified conditions.

**5. Iterating Over Arrays and Objects: for...in and for...of Loops**

The `for...in` loop iterates over the properties of an object, while the `for...of` loop iterates over the elements of an iterable object like arrays, strings, or maps.

**6. The break and continue Statements**

The `break` statement allows developers to exit a loop prematurely, while the `continue` statement skips the current iteration and proceeds to the next one.

**7. Labeled Statements**

Labeled statements provide a way to identify loops or blocks of code, allowing developers to break or continue execution from nested loops or blocks.

**8. Exception Handling with try...catch...finally**

Exception handling is crucial for dealing with errors in JavaScript. The `try...catch...finally` statement allows developers to handle exceptions gracefully, ensuring that code continues to execute even in the presence of errors.

**9. Utilizing Error Objects**

JavaScript provides built-in error objects like `Error`, `SyntaxError`, `TypeError`, and `RangeError`, which developers can use to create custom error messages and handle different types of exceptions.

By mastering loops, conditional statements, and exception handling in JavaScript, developers can write more efficient, robust, and error-tolerant code. Whether you're a beginner or an experienced developer, understanding these fundamental concepts is essential for building reliable and scalable applications.
Mastering JavaScript Equality Comparisons: == vs. === vs. Object.is
Tags: javascript
Published: 2024-02-13 18:15:12

Equality comparisons in JavaScript can be a source of confusion for many developers due to the presence of multiple equality operators and comparison algorithms. In this article, we'll dive deep into JavaScript's equality comparison mechanisms, covering the differences between ==, ===, and Object.is, as well as exploring various equality algorithms.

**Understanding Equality Operators**

JavaScript provides two main equality operators:

1. **Loose Equality (==)**: The loose equality operator compares two values for equality after performing type coercion if necessary. This means that values of different types may be considered equal if they can be coerced into the same type.
   
2. **Strict Equality (===)**: The strict equality operator compares two values for equality without performing any type coercion. It checks both the value and the type of the operands, ensuring that they are identical.

**The Object.is Method**

Introduced in ECMAScript 6, the Object.is method provides a more reliable way to compare values in JavaScript. Unlike == and ===, Object.is follows the "SameValue" comparison algorithm, which treats NaN and -0 differently from their counterparts.

**Equality Algorithms**

JavaScript defines several equality algorithms to handle various scenarios:

1. **isLooselyEqual**: This algorithm performs a loose equality comparison, similar to the behavior of the == operator.
   
2. **isStrictlyEqual**: This algorithm performs a strict equality comparison, similar to the behavior of the === operator.
   
3. **SameValueZero**: This algorithm is used for comparison in contexts like Array.prototype.indexOf and Array.prototype.includes. It treats NaN and -0 as equal and considers all other values according to strict equality.

4. **SameValue**: The SameValue algorithm, used by Object.is, distinguishes between -0 and +0, as well as NaN values.

**Choosing the Right Comparison Method**

When comparing values in JavaScript, it's essential to choose the right comparison method based on the desired behavior and context of your code. For most cases, strict equality (===) is recommended to avoid unexpected type coercion behavior. However, Object.is provides a more precise comparison method, especially when dealing with edge cases like NaN and -0.

**Conclusion**

Understanding JavaScript's equality comparison mechanisms is crucial for writing reliable and bug-free code. By mastering the differences between ==, ===, and Object.is, as well as the underlying equality algorithms, developers can ensure their code behaves predictably and accurately in all scenarios. Whether you're a beginner or an experienced JavaScript developer, a solid understanding of equality comparisons is essential for writing high-quality code.