teleren/devto huggingface dataset:
Understanding valueOf() and toString() in JavaScript
Tags: webdev, javascript, programming, frontend
Published: 2024-04-21 17:34:59

When working with objects in JavaScript, it's crucial to understand how they convert to primitive types, such as numbers or strings. This understanding becomes particularly important during operations like addition (obj1 + obj2) or when converting an object to a string (String(obj)). JavaScript provides two built-in methods, valueOf() and toString(), to handle these conversions.

Detailed Explanation:

**valueOf() Method:**

Purpose: Converts an object to a primitive numeric value.
Usage Scenario: JavaScript automatically invokes the valueOf() method when an operation requires a number, such as in arithmetic operations.
Customization: You can define a custom valueOf() method in your object to specify how it should convert to a number. If not defined, JavaScript uses the default method.

**toString() Method:**

Purpose: Converts an object to a string.
Usage Scenario: This method is called when JavaScript expects a string, like in string concatenation.
Customization: You can define a custom toString() method to control how your object converts to a string. If not defined, JavaScript uses the default method which typically returns "[object Object]".
Examples:




``
``
// Example of valueOf() method
const obj1 = {
  value: 40,
  valueOf() {
    return this.value;
  }
};

console.log(obj1 + 2); // Output: 42
``
``

`// Example of toString() method
`const obj2 = {
  firstName: 'John',
  lastName: 'Doe',
  age: 30,
  toString() {
    return `Name: ${this.firstName} ${this.lastName}, Age: 
           ${this.age}`;
  }
};`

console.log("Name: " + obj); // Output: "Name: John Doe, Age: 30"`

In these examples, we have objects obj1 and obj2. obj1 defines a custom valueOf() method that returns the numeric value 40. JavaScript automatically invokes the valueOf() method, resulting in the number 42.

obj2 defines a custom toString() method that returns a string representation of the person's name and age. JavaScript automatically invokes the toString() method, resulting in the string "Name: John Doe, Age: 30".

Summary:

JavaScript attempts to convert objects to the expected type (number or string) in operations. Defining valueOf() and toString() methods in your objects ensures that these conversions are predictable and aligned with your intentions.
2024-04-21 My weekly dev.to recommendations
Tags: community, git, vscode, bestofdev
Published: 2024-04-21 17:02:30


{% embed https://dev.to/miry/make-an-alias-for-existing-branch-5cf3 %}

It explains how you can tell git to consider accepting `master` when only `main` exists

cc @miry, thanks

{% embed https://dev.to/weseek-inc/11-useful-vscode-shortcuts-for-more-comfortable-development-1f21 %}

cc @weseek-inc, thanks

It's always a good reminder.


{% embed https://dev.to/paulund/how-to-manage-multiple-ssh-keys-for-different-github-accounts-epc %}

Good article about using multiple GitHub account locally.

cc @paulund, thanks

He had a different, but interesting approach to go further than @mbgeorge48 did.

{% embed https://dev.to/mbgeorge48/managing-multiple-github-ssh-logins-on-a-single-machine-1k46 %}
Earth Day CSS ART
Tags: frontendchallenge, devchallenge, css, webdev
Published: 2024-04-21 16:53:01

_This is a submission for [Frontend Challenge v24.04.17](https://dev.to/devteam/join-us-for-the-next-frontend-challenge-earth-day-edition-52e4), CSS Art: Earth Day._

## Inspiration
I chose to create CSS Art inspired by Earth Day. The goal was to convey the beauty and importance of our planet and encourage environmental awareness through creative design.

## Demo 
Unfortunately, I cannot directly embed an editor into this post. However, you can view the live demo on Netlify.
[Project Demo](https://earth-day-celebration.netlify.app/)

## Journey 
Creating this CSS Art for Earth Day was an exciting and challenging experience. I started by sketching out ideas and concepts that represent Earth Day, including elements like the Earth, trees, and recycling symbols.

Throughout the process, I experimented with various CSS techniques to bring these concepts to life. I utilized CSS gradients, shapes, animations, and transitions to create a visually appealing and interactive design.

One aspect I'm particularly proud of is the animation of the Earth spinning, symbolizing the continuous cycle of life on our planet. It was challenging to achieve the smooth rotation effect using CSS animations, but the end result was worth the effort.

## LICENSE
   MIT License
Learning AWS Day by Day — Day 43 — Amazon Athena
Tags: aws, cloud, cloudcomputing, athena
Published: 2024-04-21 16:51:28

Exploring AWS !!

Day 43:

Amazon Athena

Serverless, Interactive query Platform, works on data stored in S3.
It uses standard SQL for querying data
It supports variety of formats: CSV, JSON, Avro, ORC (Columnar), Parquet (Columnar)
Only pay for querying the data
Quickly query unstructured, semi-structured and structured data.
Uses Presto (SQL query engine for Big Data)
Ways to access — AWS Console, Athena API, Athena CLI, JDBC connection
Integrates with AWS Glue Data Catalogue
Integrates with Quicksight for data visualization
Used to query large S3 database
No need to spin up servers or Hadoop Clusters.

-> Query editor, saved Queries, History, Data sources, Workgroup: primary

Use Case: Analyzing CloudTrail/CloudFront/VPC/ELBlogs
Integration through ODBC/JDBC with other visualization tool
Ad-hoc logs analysis

You need to setup a crawler to run periodically, scan your data and automatically populate the Glue Data Catalogue

Cost -> $5 per TB data scanned, no charges for DDL queries and failed queries, charges for cancelled queries
Save -> Columnar formats, using partitions, compression, number of files

Athena Queries:
Query results and metadata information is stored.
You specify output folder in S3 for storing output.
Stored Procedures are not supported.
Certain DDL operation are also not supported.
Athena Federated Query (preview feature).
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/couvu5th52jj39k2kmst.png)
Learning AWS Day by Day — Day 42 — Amazon ElastiCache
Tags: aws, beginners, cloud, cloudcomputing
Published: 2024-04-21 16:50:19

Exploring AWS !!

**Day 42:**

**Amazon ElastiCache**

**Overview:**
- same way as RDS is used to get managed Relational Database, ElastiCache is to get managed Redis or Memcached.
- Cache are in-memory database with really high performance low latency.
- Helps reduce load off of database for read intensive workloads.
- helps make your application stateless.
- AWS takes care of OS maintenance/patching, optimization. setup, configuration, monitoring, failure recovery and backups.
- Using ElastiCache involves heavy application code changes.

**ElastiCache Solution Architecture — Database Cluster:**
- Application queries ElastiCache, if not available get from RDS and store in ElastiCache.
- Helps relieve load in RDS.
- Cache must’ve an invalidation strategy to make sure only most current data is used there.

**ElastiCache Solution Architecture — User Session Store:**
- User logs into any of the application.
- The application writes session data into ElastiCache
- The user hits another instance of our application.
- The instance retrieves the data and user already logged in

**Redis v/s Memcached:**
**Redis:**
Multi-AZ with auto failover
Read replicas to scale reads and have high availability.
Data durability using AOF persistence.
Backup and restore.
**Memcached:**
Multi node for partitioning of data (sharding)
No high availability
Non persistent
No backups and restore
Multi-threaded architecture

**ElastiCache for Solutions Architect — Cache Security**
**All caches in ElastiCache:**
- Does not support IAM Authentication
- IAM Policies on ElastiCache are only used for AWS API level security
**Redis AUTH:**
- You can set password/token where you created Redis cluster
- This is extra level section for cache
**Memcached:**
- Supports SAS2-based authentication (advanced)

**Patterns for ElastiCache:**
- Lazy loading: all read data is cached, data can become stale in cache
- Write Through: add or update data in cache when written to database (no stale data)
- Session store: store temporary session data in cache (using TTL feature)
- Quote: there are only 2 hard things in computer science. Cache invalidation and naming things.

**Redis Use Case:**
Gaming leaderboards are computationally complex.
Redis sorted guarantee both uniqueness and element ordering.
Each time a new element is added, it is ranked in real time, then added in correct order.

**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8xwb6qs6mhj96nlzdici.png)**
FTP: 21
SSH: 22
SFTP: 22
HTTP: 80
HTTPS: 443

PostgreSQL: 5432
MySQL: 3306
Oracle RDS: 1521
MSSQL Server: 1433
MariaDB: 3306
Aurora: (5432 if PostgreSQL compatible, 3306 if MySQL compatible)
How To Override CSS Style?
Tags: webdev, css, beginners, coding
Published: 2024-04-21 16:27:47

To override CSS styles, you typically need to apply a more specific or equally specific selector with the desired styles. Here are a few common ways to do this:

1. **Using !important:**
   You can add `!important` to a style to give it higher specificity and priority. However, this should be used sparingly because it can make your CSS harder to manage and maintain.

   ```css
   .my-class {
     color: red !important;
   }
   ```

2. **Increasing specificity:**
   If you have conflicting styles, you can increase the specificity of your selector to override others. For example, adding an additional class or an ID.

   ```css
   .parent .my-class {
     color: red;
   }
   ```

3. **Inline styles:**
   Inline styles always take the highest precedence, so you can add styles directly to the HTML element.

   ```html
   <div style="color: red;">This text is red.</div>
   ```

4. **Using IDs:**
   IDs have higher specificity than classes, so using an ID selector can override styles.

   ```css
   #unique-element {
     color: red;
   }
   ```

5. **Using parent elements:**
   Sometimes you can use a parent element to target a specific child.

   ```css
   .parent .child {
     color: red;
   }
   ```

6. **Using the :not() selector:**
   If you want to target everything except a specific class, you can use the `:not()` selector.

   ```css
   .my-class:not(.special) {
     color: red;
   }
   ```

Remember that the order of CSS rules matters. If two rules have the same specificity, the one that comes last in the stylesheet will take precedence. It's good practice to keep your styles organized and avoid relying too heavily on `!important` to prevent unintended consequences.
A Practical Approach to Quantum-Resistant JWTs
Tags: jwt, quantumresistant, webdev
Published: 2024-04-21 16:21:15

As the field of quantum computing advances, the need for cryptographic systems that can withstand quantum attacks becomes increasingly critical. The `jwt-falcon` library addresses this challenge by integrating the Falcon algorithm, a prominent candidate in the [NIST Post-Quantum Cryptography competition](https://www.nist.gov/news-events/news/2022/07/nist-announces-first-four-quantum-resistant-cryptographic-algorithms), into JSON Web Token (JWT). Falcon is designed to offer security against the potential capabilities of future quantum computers. For detailed information on the Falcon algorithm, visit [Falcon-sign.info](https://falcon-sign.info/). Under the hood, `jwt-falcon` utilizes the [Falcon-crypto](https://www.npmjs.com/package/falcon-crypto) package, a dedicated implementation of the Falcon algorithm for JavaScript environments.

### Getting Started
You can easily integrate `jwt-falcon` into your projects. First, install the library via npm:

`npm install jwt-falcon`
To give you a feel for its usage, here's a simple example:

```
import Falcon from "falcon-crypto";
import { sign, verify, decode } from "jwt-falcon";
import { generateRandomString } from "./utils.js";

const keyPair = await Falcon.keyPair();
const message = { message: generateRandomString() };

// Sign and obtain a JWT
const jwt = await sign(message, keyPair.privateKey);

// Decode and verify the JWT
const decoded = await decode(jwt);
const verified = await verify(jwt, keyPair.publicKey);
// if not `true` the signature is wrong
```

### Why Use jwt-falcon?
The advent of quantum computing poses a significant risk to traditional cryptographic methods. Algorithms like RSA and ECC, which secure much of our digital communication, are particularly vulnerable. `jwt-falcon` provides a proactive measure to protect JWTs against future quantum attacks, ensuring that your security infrastructure remains intact and forward-compatible.

### Contributing
The `jwt-falcon` project is open source, and contributions are welcome. Whether you're a seasoned cryptographer or a web developer looking to dip your toes into security, your input can help refine and expand this library. You can find the project on GitHub at [jwt-falcon](https://github.com/johnb8005/jwt-falcon) and view the npm package at [jwt-falcon](https://www.npmjs.com/package/jwt-falcon?activeTab=readme).
[Hack] picoCTF - Mod 26
Tags: bash, cybersecurity, programming
Published: 2024-04-21 16:12:13

This is a challenge from the [picoCTF picoGym](https://play.picoctf.org/practice/challenge/144?category=2&page=1), the challenge description follows:

```
"Cryptography can be easy, do you know what ROT13 is? 
cvpbPGS{arkg_gvzr_V'yy_gel_2_ebhaqf_bs_ebg13_uJdSftmh}"
```

This is pretty straightforward, we can use a website to decrypt the ROT13 encrypted message.

But in this case, I used a bash script to do this for me. Here's the script:

```bash
# Tring to find a flag using ROT13
# Where $1 is cvpbPGS{arkg_gvzr_V'yy_gel_2_ebhaqf_bs_ebg13_uJdSftmh}

echo "== ROT13 =="
echo ""
output=$(echo "$1" | tr 'N-ZA-Mn-za-m' 'A-Za-z')
echo "${output}"
```

The `tr` command is a substitution command, in this case, we will make the A to be N, B to be O and so on. This is the meaning of ROT13, it will shift each char 13 places:


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

It's bidirectional, so no worries of the ordering.

Running the script, the flag is revealed:

{% spoiler Answer:Flag %}
Flag : picoCTF{next_time_I'll_try_2_rounds_of_rot13_hWqFsgzu}
{% endspoiler %}
Earth is our first mother
Tags: frontendchallenge, devchallenge, css
Published: 2024-04-21 16:04:05

_This is a submission for [Frontend Challenge v24.04.17](https://dev.to/devteam/join-us-for-the-next-frontend-challenge-earth-day-edition-52e4), CSS Art: Earth Day._

## Inspiration
<!-- What are you highlighting today? -->

## Demo 
<!-- Show us your CSS Art! You can directly embed an editor into this post (see the FAQ section of the challenge page) or you can share an image of your project and share a public link to the code. -->

## Journey 
<!-- Tell us about your process, what you learned, anything you are particularly proud of, what you hope to do next, etc. -->

<!-- Team Submissions: Please pick one member to publish the submission and credit teammates by listing their DEV usernames directly in the body of the post. -->

<!-- We encourage you to consider adding a license for your code. -->

<!-- Don't forget to add a cover image to your post (if you want). -->

<!-- Thanks for participating! -->
Css challanges
Tags: frontendchallenge, devchallenge, css
Published: 2024-04-21 16:01:29

_This is a submission for [Frontend Challenge v24.04.17](https://dev.to/devteam/join-us-for-the-next-frontend-challenge-earth-day-edition-52e4), CSS Art: Earth Day._

## Inspiration
<!-- What are you highlighting today? -->

## Demo 
<!-- Show us your CSS Art! You can directly embed an editor into this post (see the FAQ section of the challenge page) or you can share an image of your project and share a public link to the code. -->

## Journey 
<!-- Tell us about your process, what you learned, anything you are particularly proud of, what you hope to do next, etc. -->

<!-- Team Submissions: Please pick one member to publish the submission and credit teammates by listing their DEV usernames directly in the body of the post. -->

<!-- We encourage you to consider adding a license for your code. -->

<!-- Don't forget to add a cover image to your post (if you want). -->

<!-- Thanks for participating! -->
"Navigating Construction Accidents: How Attorneys at LawIsland Ensure Justice Prevails"
Published: 2024-04-21 15:48:05

Article:

In the bustling world of construction, accidents are unfortunately not uncommon. From falls and equipment malfunctions to structural failures, the construction industry presents myriad hazards that can result in serious injuries or even fatalities. When such accidents occur, navigating the legal complexities can be daunting for victims and their families. This is where the expert guidance of Construction Accidents Attorneys at LawIsland becomes invaluable.

**Understanding the Legal Landscape**

Construction accidents often involve a myriad of factors, including negligence, faulty equipment, inadequate safety protocols, or even subcontractor disputes. Successfully litigating these cases requires a deep understanding of both construction regulations and personal injury law. Attorneys at LawIsland specialize in precisely this intersection, leveraging their expertise to ensure that victims receive the compensation they deserve.

**Compassionate Advocacy**

At LawIsland, our attorneys understand the physical, emotional, and financial toll that construction accidents can take on victims and their loved ones. That's why we approach each case with [compassion](https://lawisland.com/) and empathy, providing personalized attention to every client. 
**Proven Track Record**

With years of experience representing construction accident victims, our attorneys at LawIsland have amassed a proven track record of success.. Our dedication to achieving justice has earned us the trust and respect of our clients and peers alike.

**Comprehensive Legal Support**

Navigating the aftermath of a construction accident involves more than just filing a lawsuit. It requires a comprehensive legal strategy tailored to the unique circumstances of each case. Our attorneys at LawIsland possess the knowledge, resources, and determination to pursue every available avenue of compensation for our clients. Whether through negotiation, mediation, or litigation, we tirelessly advocate for our clients' rights.

**Advocates for Change**

Beyond representing individual clients, attorneys at LawIsland are dedicated advocates for systemic change within the construction industry. We work tirelessly to raise awareness of safety issues, push for stronger regulations, and hold negligent parties accountable. By striving for a safer working environment for all construction workers, we aim to prevent future accidents and protect the well-being of workers across the industry.

**Contact LawIsland Today**

If you or a loved one has been injured in a [construction accident](https://lawisland.com/), don't navigate the legal process alone. Contact the Construction Accidents Attorneys at LawIsland today for a free consultation. Let us put our experience, compassion, and dedication to work for you, ensuring that you receive the justice and compensation you rightfully deserve.
AWS Bedrock Update from Claude v2.1 to Claude v3
Tags: aws, ai, anthropic, llm
Published: 2024-04-21 15:33:46

Recently, AWS released Claude v3. It comes with the [Haiku](https://aws.amazon.com/about-aws/whats-new/2024/03/anthropics-claude-3-haiku-model-amazon-bedrock/) and [Sonnet](https://aws.amazon.com/about-aws/whats-new/2024/03/anthropics-claude-3-sonnet-model-amazon-bedrock/) flavors. Both are big improvements over the previous version. We recently updated our [arcBot](https://martinmueller.dev/arcbot-eng) to use Claude v3 Sonnet and are very impressed with the results. Not only are the responses more intelligent, but the speed of the responses is much faster. In the next section I will describe how an update can go as smoothly as it did for us.

## Upgrade

As mentioned above, we upgraded from Claude v2.1 to Claude v3 Sonnet for our gen AI database tool [arcBot](https://martinmueller.dev/arcbot-eng) (Try it out!).

When you do this there is a high risk that your answers will not be as good as before. But we were prepared and the answers are even better now. But how did we do it?

Simply with [Unit Testing](https://martinmueller.dev/aws-bedrock-unit-testing). I wrote a bunch of unit tests during the development with Claude v2.1 and they came in handy for the update to v3. It was basically just a matter of making those unit tests pass.

## Conclusion

Using AWS gen AI offerings like Claude is super fun. It can be challenging to make sure your answers are still as good as before. But with good test coverage, you can make sure that your answers are still as good as before, or even better. With our unit tests in place, we are confident that we can easily upgrade to a future version again, or if we wanted, change the LLM entirely. If you have any questions or thoughts about this, feel free to contact us :)!

## Bonus - AB Picturer

<img src="https://github.com/mmuller88/mmblog/raw/master/content/aws-bedrock-update/ab-picturer.png" alt="drawing" width="400"/>.

Did you notice the cool blog title picture? It is actually one of two randomly selected pictures. I love writing blog posts and choosing nice pictures for them. But often I want to choose THE BEST picture. So to find the best picture I'm using AB Testing. If you are curious about it, have a look at my [AB Picturer Tool](https://martinmueller.dev/ab-picturer) and provide me feedback or even better become an engaged tester :).
Manual Test Case Part 1
Tags: testcase, decisiontable, testing, manualtesting
Published: 2024-04-21 15:27:15

Q1. You are testing a form that allows users to schedule appointments with a doctor. The form has the following fields: first name, last name, email, phone number, and appointment

date/time. Some more inputs:

• If any field is blank, we should display "All fields are required"

• If the email is invalid, we should display "Please enter a valid email"

• If the phone number is invalid, we should display "Please enter a valid phone number"

• If the appointment date/time is not available, it should display "Please choose another date/time"

If all fields are correct and the appointment is available, we should schedule the appointment successfully.

For these requirements write down the correct list of conditions in form of decision table

Ans: The decision table for the doctor appointment as follows


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