teleren/devto huggingface dataset:
The Difference Between HTML DOM Properties: innerHTML, innerText, and textContent
Tags: javascript, beginners, html
Published: 2024-02-08 05:12:36

When you’re starting out learning JavaScript it can be challenging to understand the differences between innerHTML vs innerText vs textContent. While all three are DOM properties that allow you to set or return the content of HTML elements, they each have different use cases.  Let’s start by breaking down the major differences between the three in the chart below.

#Key Differences

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

_Source: [W3 Schools definitions](https://www.w3schools.com/jsref/prop_node_innertext.asp)_

#Example

Let’s go through an example that further illustrates the difference between the three properties.

Here's our starting HTML:

```
<p> Paragraph demonstrating the <span style="color:purple">difference</span> between       innerHTML, innerText, and textContent.</p>
```

As well as what it looks like rendered in the browser: 

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

Here's the JavaScript where we're applying innerHTML, innerText, and textContent to our paragraph element:

```
const paragraphText = document.querySelector("p");

//innerHTML//
function innerHTMLTest() {
    console.log("innerHTML:" + paragraphText.innerHTML);
}
innerHTMLTest();


//innerText//
function innerTextTest() {
    console.log("innerText:" + paragraphText.innerText);
}
innerTextTest();


//textContent//
function textContentTest() {
    console.log("innerContent:" + paragraphText.textContent);

textContentTest();
```

What appears in the console:


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


#When to Use Each Property

###innerHTML

innerHTML is great to use when you’re looking to see or replace the HTML content inside of an element. It can be especially helpful if you’re looking to quickly and easily replace a large amount of HTML or empty an HTML element (eg. empty a div tag using div.innerHTML = “”).

To continue our example from above, you could use innerHTML to completely swap the text in our paragraph with an unordered list:

```
const paragraphText = document.querySelector(‘p’);

paragraphText.innerHTML = “
<ul> 
    <li>List item one</li> 
    <li>List item two></li> 
    <li>List item three></li>
</ul>”;
```

###innerText

innerText is used when you want to see or replace the text inside an element or node, but **you don’t care about additional formatting like spacing**. This is the property that I end up using the most often when I’m trying to replace any text within an HTML element since I’m often not running into a lot of additional styling or spacing within the text.

###textContent

textContent is used when you want to see or replace the text inside an element or node, **including any styling**.
Deploy Spring Boot on Cloud run ?
Tags: cloud, spring
Published: 2024-02-08 04:41:44

Spring boot is an excellent framework and it is well suited for Cloud Run. The startup time of Spring boot application can be well managed and it can run with very little resources. 

Check out this [guide to deploying spring boot apps on cloud run](https://www.frontendeng.dev/blog/31-step-by-step-guide-to-deploy-spring-boot-app-on-google-cloud-run). 

**Resources:**

Cloud Run documentation for Java applications: https://cloud.google.com/run/docs/tips/java
Spring Boot on Cloud Run example: https://spring-gcp.saturnism.me/getting-started/helloworld/cloud-run
Quickstart: Deploy a Java service to Cloud Run: https://cloud.google.com/run/docs/quickstarts/build-and-deploy/deploy-java-service
How I Optimized Huys Kitchen's Website by Serving Images with Exact Size
Tags: performance, web, html, webdev
Published: 2024-02-08 04:26:58

In the world of web development, optimizing website performance is a key factor for user satisfaction. Recently, I took on the challenge of enhancing the performance of [Huys Kitchen's website](https://www.huyskitchen.com.au/) by focusing on image optimization. This blog post details the tools I used, the steps taken, and the remarkable results achieved.

**Tools Utilized:**

1. **PageSpeed Index:**
   To gauge the website's performance and identify areas for improvement, I employed the [PageSpeed Index](https://pagespeed.web.dev/). This tool provided valuable insights and a performance report that served as a benchmark for the optimization process.

2. **ImageMagick CLI Tool:**
   For image resizing, I turned to the powerful [ImageMagick CLI tool](https://www.imagemagick.org/script/index.php). This versatile tool allows for efficient manipulation of images, making it an ideal choice for our optimization efforts.

**Performance Assessment Before Optimization:**

Before diving into the optimization process, I conducted a thorough performance analysis using PageSpeed Index. The initial report can be viewed [here](https://pagespeed.web.dev/analysis/https-www-huyskitchen-com-au/dfkizz69ko?form_factor=mobile). This served as a baseline to measure the impact of the changes made.

**Optimization Steps:**

The primary focus of the optimization was on resizing images to match the exact dimensions they were rendered on the page. To accomplish this, I utilized the ImageMagick CLI tool to efficiently resize and serve images tailored to their display requirements.

**Performance Assessment After Optimization:**

The results post-optimization were nothing short of impressive. The updated performance report can be accessed [here](https://pagespeed.web.dev/analysis/https-www-huyskitchen-com-au/ridynt0021?form_factor=mobile). Witnessing the improvements firsthand, it became evident that serving images with exact dimensions significantly enhanced the website's load time and overall user experience.

**Conclusion:**

Optimizing a website involves a combination of strategic choices and the right tools. In the case of Huys Kitchen, focusing on image optimization using the ImageMagick CLI tool proved to be a game-changer. The journey from the initial performance analysis to implementing changes and witnessing the positive impact on load times emphasizes the importance of meticulous optimization in delivering a seamless online experience.

update

This is the performance report I got after minifying the javascript and css files (report)[https://pagespeed.web.dev/analysis/https-www-huyskitchen-com-au/zgvki2mqrr?form_factor=desktop]
New Adventure
Tags: webdev
Published: 2024-02-08 04:15:30

**Same work, bored everyday**
That's always my first thought when I go to work in the morning. Waking up, going to work with a wonderful team who put up with my silly antics. Letting me jump and help other departments, or expanding my network as I walk the quiet halls of the airport.

Time flies, and my heart wants something new. So by jumping off my high tower of worry, I decided to join WebDev Bootcamp. I've been full of fear to take the risk, but as I sit in my cubical and  I sit and wondered. 
_Why am I still doing the same thing over and over?_
_I love learning new things, and the world of coding looks like it's so much fun to learn_
So that's what I'm going to do, it will take a lot out of me but it's an adventure I'm willing to take.
Any advise would be helpful.
> “Take your risks now. As you grow older, you become more fearful and less flexible. And I mean that literally. I hurt my knee this week on the treadmill, and it wasn’t even on.” —Amy Poehler
Beyond the Chair: Kevin Molldrem Dentist's Commitment to Community Wellness
Tags: beginners
Published: 2024-02-08 04:09:00

[Kevin Molldrem Dentist](https://medium.com/@kevinmolldremdentist/latest-story-of-kevin-molldrem-dentist-molldrem-family-dentistry-best-dental-clinic-eden-deb906f0e38f) is not just a name associated with dental expertise; it's a commitment to community wellness. Explore how Kevin Molldrem goes beyond the dental chair, actively engaging in initiatives that promote oral health education and awareness.In this content piece, learn how Kevin Molldrem Dentist is contributing to the greater good, making a positive impact beyond the confines of his dental practice. His dedication to community wellness has not only solidified his position as the top-rated dentist but also as a community leader with a genuine interest in the health and happiness of those he serves.
https://medium.com/@kevinmolldremdentist/latest-story-of-kevin-molldrem-dentist-molldrem-family-dentistry-best-dental-clinic-eden-deb906f0e38f
Avoid Fakers in Unit Tests
Tags: programming, testing, softwaredevelopment
Published: 2024-02-08 04:03:02

---
title: Avoid Fakers in Unit Tests
description: In your unit and integration tests, avoid using tools that automatically generate test input data
tags: programming, testing, softwaredevelopment
canonical_url: https://davidadamojr.com/avoid-fakers-in-unit-tests/
---
In your unit and integration tests, avoid using tools that automatically generate test input data. Unless you are [fuzz testing](https://en.wikipedia.org/wiki/Fuzzing) or your goal is to create [property-based tests](https://github.com/STAR-RG/practical_testing_book/blob/master/testgeneration/propertybased.ipynb), these test data generators (a.k.a. fakers) are likely to do more harm than good in the long run because:

1. Your tests will become much slower than they should be. The computational cost of randomization and data generation adds up much quicker than you might think. Slow tests are productivity poison.
    
2. By using fakers in your tests, you increase the likelihood of flakiness due to randomized data. Your future self will have a tough time figuring out why a specific test failed. Tests should be repeatable and deterministic, with input values that stay the same each time you execute them.
    
It is often better to explicitly specify your test inputs. If you have to use a faker in your tests, make sure it always generates the same test inputs each time your tests are executed. You can do this by configuring your faker with a random seed.
How to recover stolen cryptocurrency using Pro Wizard Gilbert Recovery
Published: 2024-02-08 04:00:12

Thanks to Pro Wizard Gilbert Recovery, my challenging times have come to an end. In mid-November 2023, I ventured into cryptocurrency trading after being introduced by "Miss Gabriela," whom I believed to be a legitimate finance manager. She showcased a LinkedIn profile with over 5000+ connections and an Instagram account with 500k+ followers, instilling trust in the company. Two weeks into our discussions, she persuaded me to set up a Metamask wallet and fund it with $29k USDT, emphasizing the use of USDT to prevent fund depreciation in my investment portfolio. Believing every word she said, I invested, and she explained that the $29k was just the beginning, advocating for larger trades. Despite my suggestion to wait for the first trade's completion, she insisted on taking on more significant trades in pairs, promising higher profits. Before the larger trade, I emphasized that these were my retirement funds, expecting returns upon completion. However, things didn't go as planned. The agreed-upon 4-week trading period passed, and no funds appeared in my wallet linked to the trading website. Upon bringing this to Gabriela's attention, she advised filing a complaint with Care support, revealing that my account had gone negative with imposed fees of over $90k in taxes and charges. Refusing to pay, I sought help from Pro Wizard Gilbert Recovery after learning about their ability to TRACK & RECOVER lost investments. Contacting Pro Wizard Gilbert Recovery and providing them with transaction details, they initiated a 5-day recovery process, fulfilling their promise as my funds returned to my wallet. If you're struggling to find a trustworthy hacker, look no further; your solution is here. Reach out to the team of experts in Pro Wizard Gilbert Recovery.

INFORMATION OF PRO WIZARD GILBERT RECOVERY:
Email: prowizardgilbertrecovery(@)engineer .com 
Telegram: @Pro_Wizard_Gilbert_Recovery
Backend challenge #1 - Beginner level (Simple Api)
Tags: backend, programming, beginners, backenddevelopment
Published: 2024-02-08 03:53:34

If you want to start your journey in the backend development world, welcome to this series that I decide to call **Backend challenges** where we will look at some interestings projects related to the backend development.

We will start from 0 until we become a backend developer. All of this series will be based on making projects, I will share the characteristics and goal of the project, and you will have to choose the tools and language to make the project.

This include database, frameworks, programming language, etc.

So let's get started with the first project:

## Single Endpoint Api (No DB connections)

### Project description
Build an api with just one endpoint that allows the user to do the next:

- Get an array of resources
- Create an element for that resource
- Updating an element of the list of resources
- Deleting an element of the list of resources

### Requirements

- Do the 4 basic actions (Create, Read, Update and Delete)
- The data should be stored in an array

Example of some endpoint for the project
```
<site>.com/<endpoint>

# Example
localhost/dogs/get
localhost/dogs/post
localhost/dogs/put
localhost/dogs/delete
``` 

### Not needed but recommended

This is the list of things that you can do for the project, but they are just recommended things that can be omited.

- Just use one name for the four request for example instead of
```
localhost/dogs/get
localhost/dogs/post
localhost/dogs/put
localhost/dogs/delete
```
use
```
localhost/dogs/ # Reacting according with the method passed
```
AWS AppSync: The Game-Changing Access Method For Environment Variables
Tags: aws, appsync, lambda, serverless
Published: 2024-02-08 03:26:18

Excitingggggg news! AWS has just rolled out support for environment variables in AppSync. Let's delve into incorporating this feature in our SAM & Serverless Framework.

## Solution

**Step1:** When defining AppSync, we can now add environment variables similarly to how it's done during Lambda creation. In the properties section, include EnvironmentVariables and add key-value pairs as needed.

```
Resources:
  UserAppsync:
    Type: "AWS::AppSync::GraphQLApi"
    Properties:
      Name: "user-int-appsync"
      AuthenticationType: "AWS_IAM"
      EnvironmentVariables:
        USERTABLENAME: "user-int-table"
```
**Step2:** Having defined the environment in the YAML file, let's access it in our resolver file. Once environment variables are specified, they are passed for both request and response within the ctx (context) of the function parameter

```
//accessing the environment variable(NEW METHOD)
const tableName = ctx.env.USERTABLENAME
```
Accessing it is demonstrated below Inside the Resolver:
```
/**
 * @param {*} ctx - Context
 * @retuns {Object} - Request object
 */

export function request(ctx) {
  //accessing the environment variable(NEW METHOD)
  const tableName = ctx.env.USERTABLENAME
  return {
    operation: 'BatchGetItem',
    tables: {
      [tableName]: { keys },
    },
  };
}

/**
 * @param {*} ctx - Context
 * @retuns {Object} - Response object
 */
export function response(ctx) {
  return {};
}
```

As discussed, the environment is now passed within the ctx of both request and response. This enhancement simplifies the process of passing and accessing environment variables with the latest updates.
A Quick Guide to Clamping Numbers in JavaScript
Tags: programming, typescript, coding, javascript
Published: 2024-02-08 15:39:32

---
title: A Quick Guide to Clamping Numbers in JavaScript
published: true
date: 2024-02-08 02:32:12 UTC
tags: programming,typescript,coding,javascript
canonical_url: https://www.omarileon.me/blog/javascript-clamp
---

![](https://cdn-images-1.medium.com/max/1024/0*FCHT63t_rFys4Fvx)

In JavaScript, there’s “Math.min()”, “Math.max()”, but unfortunately no Math.clamp(). There’s but it’s currently in the draft stages. This is fine — it’s very easy to implement clamp, and in this article, I’ll talk through doing just that.

### A Quick Way

You can use the following function to clamp a number between a minimum and maximum value:

```
function clamp(num: number, lower: number, upper: number) {
    return Math.min(Math.max(num, lower), upper);
}
```

Why does this work? Let’s think it through. At first, our number is any valid JavaScript number, anything in the range **-Number.MAX\_VALUE <= num <= Number.MAX\_VALUE**

Then we have:

```
Math.max(num, lower);
```

So now our range gets updated to whatever the larger value is out of “lower” and “num”. Our range is now: **lower <= num <= Number.MAX\_VALUE.**

I’m sure you can see where this is going — let’s break our code up:

```
const lowerBound = Math.max(num, lower);
const result = Math.min(num, upper);
```

Just like before but reversed. Our result is the lower of num or upper, so we can update our range to: **lower <= num <= upper.**

And just like that, our number is clamped! If it’s lower than the lower bound, we pick the lower bound. If it’s higher than the upper bound, we pick the upper bound. Otherwise, we pick the number.

### Lodash

Lodash is a JavaScript utility library. You can install it with one of these commands:

```
npm i lodash 
pnpm add lodash 
yarn add lodash
```

And it works exactly the same as our function:

```
import { clamp } from 'lodash'; 
clamp(number, lower, upper);
```

Short and simple! If you’re not familiar with Lodash, it can be quite handy if you’re looking for any functions not native to JavaScript. Check it out .

### Conclusion

So there’s two ways of getting the clamp math function into your JavaScript code. Which one should you use? Personally, I think since it’s such a small function, you should probably just implement this one yourself if you need it. If you’re already using Lodash though, then you may as well use their built-in function. Thanks for reading! If you liked this article, why not follow me on [Twitter](https://twitter.com/marile0n)?

_Originally published at_ [_https://www.omarileon.me_](https://www.omarileon.me/blog/javascript-clamp)_._
Authorization and Authentication in Django
Tags: webdev, django, security, python
Published: 2024-02-08 02:27:07

## Introduction:
Django, the high-performance web framework for Python, offers a comprehensive suite of tools for handling user authentication and authorization. In this post, we'll embark on a journey through the intricacies of Django's security features, exploring how they ensure robust user management and access control in web applications.

## Authentication: Verifying User Identity
**User Models:**
Django's authentication system begins with a robust User model. We'll dissect the default User model, examining its components and understanding how it can be customized to meet specific project requirements.

## Authentication Views and Forms:
Building a secure login, registration, and logout system is made easy with Django's built-in authentication views and forms. We'll explore how to leverage these components, tailoring them to create a seamless and secure user authentication process.

Social Authentication:
Integrating third-party authentication providers is a game-changer. We'll walk through the process of implementing social authentication, allowing users to log in using their Google, Facebook, or GitHub accounts.

Authorization: Controlling User Access
Groups and Permissions:
Django's authorization system revolves around groups and permissions. We'll dive into the world of permissions, showing you how to create custom permissions, assign them to groups, and manage user access based on roles.

## Decorators and Mixins:
Controlling access to views is essential for application security. Django provides decorators and mixins for precisely this purpose. We'll guide you through their usage, ensuring your views are only accessible to users with the right permissions.

## Object-Level Permissions:
For fine-grained control, Django enables object-level permissions. We'll explore how to implement and manage permissions at the individual object level within your application's models.

## Advanced Security Measures

**Two-Factor Authentication (2FA):
**Enhance your application's security by implementing two-factor authentication. We'll showcase popular packages and guide you through the process of integrating 2FA for an additional layer of user account protection.

## Security Headers and Best Practices:
Protecting your application against common web vulnerabilities is crucial. We'll discuss the implementation of security headers like Content Security Policy (CSP) and HTTP Strict Transport Security (HSTS), ensuring a robust defense against potential threats.

## Conclusion: Elevating Your Django Application's Security
By the end of this post, you'll have a thorough understanding of Django's authentication and authorization capabilities. Whether you're a Django enthusiast or just starting, these features will empower you to build secure, user-friendly web applications. Join the discussion on the Dev Community and stay tuned for more insights into Django development!
Event listener triggering outside of target element in mobile resolution (HTML)
Tags: beginners
Published: 2024-02-08 02:21:30

I found what seems to be a bug, unless I'm missing something. And I was wondering if anyone here found something similar happening to them and what the fix could be. Also I really need to rule out that there's something I'm not seeing here and that it effectively is a bug. I had this happen on a project I was working on and I got to the point of creating a React project completely from scratch just to see if I could replicate it and of course I could. Then went on an made a simple .html file with a div and the error happened as well. I'm losing my mind here.

`</head>
<body>
    <div style="width: 300px; height: 300px; border: 1px solid green" onclick="alert('hi')"></div>
</body>`

Alert pops up when clicking slightly outside of its container :(

I'm expecting alert only to pop up only when clicking on the area inside the green borders.
Checkmate Roofing and Construction
Tags: roofing, carpentry, painting, chimney
Published: 2024-02-08 01:55:28

Introducing Checkmate Roofing and Construction, your trusted local neighbor and affordable roofing contractor! With over 20 years of roofing expertise under our ownership, we take pride in delivering top-notch residential and commercial roofing solutions. Beyond roofing, our skilled team offers carpentry, residential painting, and chimney repair services. Committed to quality craftsmanship and customer satisfaction, we're your go-to partner for reliable and comprehensive construction needs. Choose Checkmate for excellence in every project—we're not just contractors; we're your community roofing specialists.


[Checkmate Roofing and Construction
](https://www.checkmateroofing.com/)
1916 Pike Pl Suite 12, Seattle, WA 98101

425-985-9909

[Get Directions
](https://www.google.com/maps?cid=3876795480900756441
)

Find Us Online

[twitter](https://twitter.com/checkmateroof
)
[foursquare](https://foursquare.com/checkmat2892761
)
[facebook](https://www.facebook.com/checkmateroofing
)
[instagram](https://www.instagram.com/checkmateroofing/
)
[pinterest](https://www.pinterest.com/checkmateroofing/
)
[linkedin](https://www.linkedin.com/company/checkmate-roofing-and-construction
)
[yelp](https://www.yelp.com/biz/checkmate-roofing-and-construction-seattle
)
[google](https://www.google.com/search?q=checkmate+roofing+and+construction+98101
)
[youtube](https://www.youtube.com/channel/UC3-8RDefzhn6o8E5YhzcI1A
)

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

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