teleren/devto huggingface dataset:
Common Programming Case Types
Tags: javascript, webdev, programming, codenewbie
Published: 2022-12-18 05:07:29

When you are working with computers, especially coding, you have to follow some set of rules to get your ideas working. In some other times, you are on your own to create your flow. However, since this work is a teamwork and chances are that someone else is reading your code, or you are reading someone else's code, there came in some conventions to follow. 

One of the most important conventions to follow is when naming a variable. Everybody who has done coding knows that it is really not that easy to come up with a variable name, but there are conventions to follow when it comes to Case Types. Here is a list of most common Case Types:
- Camel Case
- Kebab Case
- Snake Case
- Pascal Case

Let's see each one of these in a bit more detail.

Note: We are not talking about how meaningful or long (or short) enough your variable needs to be, just simply learning about what different Case Types are.

## Camel Case

This is when the variable name starts with a lowercase character and every subsequent word's first letter is capitalized.

`thisIsAnExampleForACamelCase` 

## Kebab Case

This is one of the easiest one to remember. Every character is lowercase and in between every word, you need to add a dash (`-`).

`this-is-an-example-for-a-kebab-case`

## Snake Case

This one is very similar to Kebab Case. Every character is lowercase and in between every word, you need to add an underscore (`_`).

`this_is_an_example_for_a_snake_case`

## Pascal Case

This one is when first letter of all words are capitalized, including the first letter and there is no space or any other character in between words.

`ThisIsAnExampleForAPascalCase`

## What to use in JavaScript

Again, naming is a convention. However, I'm going to share some examples from [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript#airbnb-javascript-style-guide-) . According to that guide, here are what to use in JavaScript:

- Avoid single letter names like `x` or `q`
- `camelCase` for objects, functions, and instances
- `PascalCase` for constructors or classes
- Do not use trailing or leading underscores like `_firstName`, `lastName_` or `_fullName_`
- Acronyms and initialisms should always be all uppercased, or all lowercased like `HTTPRequest` or `httpRequest`
#45Days of LeetCode - Best time to buy and sell stock II - Day 2
Tags: leetcode, tutorial, python, career
Published: 2022-12-18 05:00:15

Hey dev! In case you don't know, I've started #45daysofleetcode and in these 45 days i'll be writing about two problems every day.

> The problem, how I solved it and a bit of detailed explanation.

I'm sharing this progress with you so that you too can learn a bit of different perspective and have new solutions so hit like to join this journey.

I've chosen the best list of problems from medium to hard. That made lots of developers crack the interview.

Are you excited?

**Today's Problem**

**Name** - Best time to buy and sell stock - 2

**Description** - You are given an integer array prices where prices[i] is the price of a given stock on the ith day.

On each day, you may decide to buy and/or sell the stock. You can only hold at most one share of the stock at any time. However, you can buy it then immediately sell it on the same day.

Find and return the maximum profit you can achieve.

## Example

```
Input: prices = [7,1,5,3,6,4]

Output: 7
Explanation: Buy on day 2 (price = 1) and sell on day 3 (price = 5), profit = 5-1 = 4.
Then buy on day 4 (price = 3) and sell on day 5 (price = 6), profit = 6-3 = 3.
Total profit is 4 + 3 = 7. 

```


## My Approach
Initialize two values -> maxProfits and step.
 Iterate through the array from 0 to list length-1 and step is for jumping because we cannot buy sell twice a day.

If next day price is higher than today's price then -> next day price - today's price = today profit.
 add it to maxProfits, and skip next day and goto another day and so on.

But if next day price is not higher than today's price then do nothing and move on. ref: else condition. step = 1 will do nothing but step = 2 skips a day.

## Code

```
class Solution:

    def maxProfit(self, prices: List[int]) -> int:
        maxProfits = 0
        step = 1
        for i in range(0, len(prices)-1, step):
            if prices[i+1] > prices[i] :
                maxProfits += prices[i+1] - prices[i]
                step = 2
            else :
                step = 1
        return maxProfits
```



Let me know if you've any questions or suggestions!.

If you want full list of solutions, [here's the list.](https://github.com/Anas-Dew/dsa-coding-solutions) Make sure you star the repository.

Follow to join this #45daysofleetcode
Bye!
Help with a react component
Tags: javascript, react, marquee
Published: 2022-12-18 04:49:50

I am trying to write a vanilla marquee onto a picture using react-Bootstrap.  I have written the js, which works great outside react.  I need help getting the typed script over to the image.
Here is the js file:
    

> import React, { Component, useEffect, useState } from 'react'

import Sadeyes from './sadeyes.jpg'

const SadeyesText = () =>{

  const bannerText = new Array("our world is changing", "so is therapy");
  const iSpeed = 100; // time delay of print out
  const iNewLine = 500; // time delay at line breaks
  const iIndex = 0; // start printing array at this position
  const iArrLength = bannerText[0].length; // the length of the text array

  const iScrollAt = 20; // start scrolling up at this many lines

  const iTextPos = 0; // initialise text position
  const sContents = ""; // initialise contents variable
  let iRow; // initialise current row
  
  const typewriter = (props) => {
  sContents = " ";
  iRow = Math.max(0, iIndex - iScrollAt);
  var destination = document.getElementById("typedtext");

  while (iRow < iIndex) {
    sContents += bannerText[iRow++] + "<br />";
  }
  test = sContents + bannerText[iIndex].substring(0, iTextPos);
  destination.innerHTML = test
  console.log(test[test.length - 1])
  if (iTextPos++ == iArrLength) {
    iTextPos = 0;
    iIndex++;
    if (iIndex != bannerText.length) {
      iArrLength = bannerText[iIndex].length;
      setTimeout("typewriter()", iNewLine);
    }
  } else {
    setTimeout("typewriter()", iSpeed);
  }
}

useEffect(() => {
  window.typewriter()

return () => {
  window.removetypewriter()
}, [])
}


  export default SadeyesText

> 

Here is the picture:
    

> import React from "react";
import "bootstrap/dist/css/bootstrap.css";
import { Container } from 'react-bootstrap'
import Image from "react-bootstrap/Image";
import sadeyes from './sadeyes.jpg'
import './sadeyestext.component'

import './home.styles.scss'

export default function Sadeyes () {
return (
	<div>
        <Container>
        <figure className="position-relative">
        <Image
		src={sadeyes} alt="sadeyes"  />
        <figcaption>
            {}
        </figcaption>
        </figure>
        </Container>
	</div>
);
}
>

Thanks for your help
Custom Selenium Framework using Java || Configuration Management(Properties File Reader) || Part 2
Tags: webdev, beginners, programming, tutorial
Published: 2022-12-18 04:05:44




In this video, We are starting our Selenium Framework using Java, We are going to create own custom Selenium Framework from scratch with our 5 Step process.

✅ 5 Step process to Create Selenium Automation Framework
1. Build Management
2. Configuration Management ✅
3. Add Logs for Framework.
4. Reporting to Framework.
5. Page Object Model, Test, Utils

✅ Download Notes in PDF - https://sdet.live/2TJn

✅  Download Source Code - https://github.com/apitestingco/selen...

{% embed https://youtu.be/3TFu2cthzh4 %}

✅  What is Selenium?
Selenium is the biggest open source automation testing suite that has been making testing seamless. It is widely used for testing among the bigwigs like Google, Netflix, Fitbit, etc. to the emerging startups such as likewise.

What is Configuration Management 
Configuration Management (CM) is a systems engineering process for establishing and maintaining consistency of a product’s performance, functional, and physical attributes with its requirements, design, and operational information throughout its life.

Properties class in Java
The properties object contains key and value pair both as a string. The java.util.Properties class is the subclass of Hashtable.

It can be used to get property value based on the property key. The Properties class provides methods to get data from the properties file and store data into the properties file. Moreover, it can be used to get the properties of a system.

FileReader reader=new FileReader("db.properties");  
      
    Properties p=new Properties();  
    p.load(reader);  
      
    System.out.println(p.getProperty("user"));  
    System.out.println(p.getProperty("password"));  



✅  What is Selenium Framework?
Selenium Framework is a code structure that helps to make code maintenance easy

✅ API Testing - 
https://www.learnapitesting.com


✅ Cypress Tutorial with LIVE Projects -
http://cypresstutorial.com


✅ 30 Days of API Testing Challenge - https://apitesting.co/30days


✅ 30 Days of Automation Testing Challenge - https://go.scrolltest.com/automation


✅ 30 Days of Rest Assured(with Framework) - https://go.scrolltest.com/30days-rest...
{% embed https://youtu.be/3TFu2cthzh4 %}
This week’s newsletter is out! (17-12-2022) - Ensuring the Enable Maximiser Doesn’t Destroy the Multiverse
Tags: javascript, tech, webdev
Published: 2022-12-18 03:26:27

---
title: This week’s newsletter is out! (17-12-2022) - Ensuring the Enable Maximiser Doesn’t Destroy the Multiverse
published: true
description: Another week of great javascript, tech and web development links.
tags: javascript, tech, webdev, discuss
---

Ensuring the Enable Maximiser Doesn’t Destroy the Multiverse

https://markjgsmith.substack.com/p/mark-smiths-newsletter-17-12-2022

Would love to hear any comments and feedback you have.

[@markjgsmith](https://twitter.com/markjgsmith)
Moving to Astro and StaticCMS
Published: 2022-12-18 15:49:53

---
title: Moving to Astro and StaticCMS
published: true
date: 2022-12-18 03:05:23 UTC
tags: 
canonical_url: https://alex.party/posts/2022-12-18-moving-to-astro-and-staticcms/
---

Hey Y’all,

So I spent this past thursday feverishly working on moving my blog from Gridsome and Netlify CMS over to [Astro](https://astro.build/) and [StaticCMS](https://staticjscms.netlify.app/) and let me tell you what: It has been extremely rewarding.

## Gridsome and Netlify-CMS are Dead, Long Live Astro and StaticCMS

I am not one to try and constantly change out how things work. I try to find a system I like and stick with it (mostly out of laziness). At work lately we’ve been experimenting with some other systems outside of my normal routine, and Astro has been a big hit with both people at work, and many other people I know. I converted my (extremely simple) blog from gridsome over to astro in a couple of hours. It was really impressive.

Now, there has been a small amount of movement over the last 2 years at the gridsome project, and I hope they will eventually get things working in vue 3, but honestly, I’m tired of waiting. I also gave nuxt v3 a shot, and…. well… rss support was non existent, everything fel like it was in a state of “we will do that eventually” and I also feel like the end result SSG was a lot bigger than i wanted it to be (javascript wise).

Astro seemed like a good compromise by allowing me to copy over my styles and vue components and vue pages, and what I found was that it is so much better than a compromise. It’s enjoyable. It’s delightful. I was dubious at first about the `.astro` components needed to be used as pages and how they have serverside javascript in… frontmatter tags? But when I started using them, it just clicked. It was so easy.

I also had been using netlify-cms as my backend and apparently the 2 people who had been maintaining it at netlify [are no longer working there](https://github.com/netlify/netlify-cms/discussions/6503) which really kinda kills it. There have been a lot of small bugs here and there for a while, and knowing that no one is going to fix them is frustrating.

However, StaticCMS is a fork that has been made, and HOPEFULLY, it will be maintained for a while. I’m using it currently. It also has some new and different bugs, but I am sure those will get ironed out.

## Alex.Party Going Forward

All of that being said I am super looking forward to being able to add some features more easily to this here ding dang site.

Y’all be good.
Default vs named module export in Javascript
Tags: javascript, node, webdev, beginners
Published: 2022-12-18 01:16:17

## Introduction

In JavaScript, we can use the <code>export</code> keyword to make certain variables, functions, and classes available to other parts of our codebase or to other modules. We can then use the import keyword to access those exports in another file.

There are two ways to use the export keyword: <code>named exports</code> and <code>default exports</code>.

## Named Exports
Named exports allow us to export multiple variables, functions, or classes with a specific name. We can use the export keyword followed by the variable, function, or class that we want to export. Here is an example of a file with named exports:

```javascript
export const add = (a, b) => a + b;
export const subtract = (a, b) => a - b;
export const multiply = (a, b) => a * b;
export const divide = (a, b) => a / b;
```

We can then import these named exports into another file by using the import keyword and specifying the names of the exports that we want to import. Here is an example of how we can import the named exports from the above file:

```javascript
import { add, subtract, multiply, divide } from './math';

console.log(add(1, 2)); // 3
console.log(subtract(1, 2)); // -1
console.log(multiply(2, 3)); // 6
console.log(divide(6, 2)); // 3
```

We can also use the * symbol to import all of the named exports from a module, like this:

```javascript
import * as math from './math';

console.log(math.add(1, 2)); // 3
console.log(math.subtract(1, 2)); // -1
console.log(math.multiply(2, 3)); // 6
console.log(math.divide(6, 2)); // 3
```

## Default Exports

In addition to named exports, we can also use default exports in JavaScript. Default exports allow us to export a single variable, function, or class as the default export of a module. We can use the export default keyword followed by the variable, function, or class that we want to export as the default. Here is an example of a file with a default export:

```javascript
export default const add = (a, b) => a + b;
```

We can import the default export from another file by using the import keyword and specifying a name for the default export. Here is an example of how we can import the default export from the above file:

```javascript
import add from './math';

console.log(add(1, 2)); // 3
```

It's important to note that we can only have one default export per module. However, we can have multiple named exports in the same module.

## Choosing Between Named Exports and Default Exports

When deciding whether to use named exports or a default export, it's important to consider the context in which the exports will be used. If you only need to export a single variable, function, or class, then using a default export might make the most sense. On the other hand, if you need to export multiple variables, functions, or classes, then named exports might be the better choice.
Quick, Draw!
Tags: ai, discuss
Published: 2022-12-18 01:15:42

Hey all! Just found probably my all-time favorite AI use, made by Google. It's called [QuickDraw](https://quickdraw.withgoogle.com/), and it gives you six prompts for doodling. Try it at your own risk - I've found it's pretty addicting! 🤣

Have any of you found any cool AI uses recently? I've heard a bunch about ChatGPT recently, but I haven't heard much about anything else.
TIL: @MappedSuperclass vs. @Inheritance (JPA)
Tags: java, jpa, spring, database
Published: 2022-12-18 00:38:30

Today i needed to learn the difference between _MappedSuperclass_ and _Inheritance_ especially for use in my personal project.

## What do i needed in my project
There was two tables, _Person_ and _Role_. The _Person_ table it's a super table, so there was more tables that inherits properties and methods from it, does not have the need for a table _Person_ in the database, so Person does not use the _Entity_ annotation.

But, i need to use the _OneToMany_ and _ManyToOne_ annotation between Person and Role tables, but how Person does not use _Entity_, the _OneToMany_ annotation was not possible in Role (Yes, i also learned this).

## So, the difference between the annotations and my use for each it.

I searched in the _StackOverflow_ and haved founded these links:
[JPA: Implementing Model Hierarchy - @MappedSuperclass vs. @Inheritance](https://stackoverflow.com/questions/9667703/jpa-implementing-model-hierarchy-mappedsuperclass-vs-inheritance)

[@MappedSuperclass and @OneToMany](https://stackoverflow.com/questions/4769546/mappedsuperclass-and-onetomany)

What do i have learned from that:

- **MappedSuperclass**: Will only be used to inherits props and methods and will not create a table in the database for it.

- **Inheritance**: With the use of the prop (_strategy = InheritanceType.TABLE_PER_CLASS_) and the _Entity_ annotation, will inherits the props and methods, and also, create a table for it in the database.

if there is some misunderstood in my text, let me know so i can change it.

Thanks for reading and i hope i helped.
Update xml file via Terminal or bash script
Tags: xml, webdev, bash
Published: 2022-12-18 00:38:21


## Introduction

There are several ways you can update an XML file using the terminal or a bash script. Here are a few options:

## sed
Use sed: sed is a command-line tool that can be used to search and replace text in a file. You can use it to update an XML file by specifying the search pattern and the replacement text. For example:

```bash
sed -i 's/<old-text>/<new-text>/g' file.xml
```

This will search for all instances of <code>old-text</code> in file.xml and replace them with <code>new-text</code>.


## awk
Use awk: awk is a programming language designed for text processing. You can use it to update an XML file by specifying the search pattern and the replacement text. For example:

```bash
awk '/<old-text>/{sub("<old-text>","<new-text>")}1' file.xml > newfile.xml
```
This will search for all instances of <code>old-text</code> in file.xml and replace them with <code>new-text</code>, and write the updated content to a new file called newfile.xml.

## xmlstarlet
Use xmlstarlet: xmlstarlet is a command-line tool for working with XML files. You can use it to update an XML file by specifying the element you want to update and the new value. For example:

```bash
xmlstarlet ed -L -u '/root/element/@attribute' -v 'new value' file.xml
```
This will update the attribute of the element element under the root element in <code>file.xml</code> with the value new value.

<b>Note:</b> These are just a few examples of how you can update an XML file using the terminal or a bash script. There are many other tools and techniques you can use, depending on your specific needs.

## Combination of sed and xmlstarlet 

To update an XML file from a bash script, you can use a combination of the sed command and the xmlstarlet utility. Here is an example of how this can be done:

First, make sure that the sed and xmlstarlet utilities are installed on your system.

Create a bash script and open it in a text editor.

Use the sed command to find and replace a specific string in the XML file. For example, the following command will replace the string "old_string" with "new_string" in the file "input.xml":

```bash
sed 's/old_string/new_string/g' input.xml > output.xml
```

Use the xmlstarlet utility to update specific elements or attributes in the XML file. For example, the following command will update the value of the <code>name</code> attribute in the <code>item</code> element to <code>new_name</code>:

```bash
xmlstarlet ed -u '/items/item/@name' -v 'new_name' input.xml > output.xml
```

Save and close the bash script.

Run the bash script to update the XML file.

Keep in mind that this is just a basic example, and you can use a combination of sed and xmlstarlet commands to update the XML file in more complex ways. You can also use other utilities such as awk or perl to manipulate the XML file in your bash script.

Checkout original post {% embed https://www.bojanjagetic.com/post/xml-update-via-shell %}
Code with ️love ️, Share Your Knowledge, Have Fun with Coding 😉
Tags: startup, codewithlove
Published: 2022-12-18 00:07:17

👋Hello everyone👋

It’s great to have you here, together we will have a great journey around the internet ✌️ and we will learn new things in coding, designing and developing 😉. I want you all to support us we have just started our journey 🌏 and we need your support.
Custom email domain with Cloudflare and Gmail
Published: 2023-04-19 18:40:35

---
title: Custom email domain with Cloudflare and Gmail
published: true
date: 2022-12-18 00:00:00 UTC
tags: 
canonical_url: https://tinygame.dev/posts/Custom-email-domain-with-Cloudflare-and-Gmail/
---

## Setup to receive emails

1. In your Cloudflare dashboard, go to Websites > your website > Email.
2. Click `Add records and enable` and Cloudflare will automatically set up the MX and TXT records as needed. We will make some modifications to them soon.
3. Add a destination address where emails should be forwarded to. I tend to use [Gmail's address variation](https://support.google.com/a/users/answer/9282734) and use something like `username+mydomain@gmail.com`. This will forward emails to `username@gmail.com` as expected. You'll need to verify this email before Cloudflare accepts it.
4. Add a new custom address like `hello@mydomain.com` with the `Send to an email` action and the preferred destination.

This is enough to start receiving emails. If you'd like to send emails from the custom domain as well, continue with the following section.

## Setup to send emails

1. Add a new DNS TXT record with name `_dmarc` and content `v=DMARC1; p=none; rua=mailto:hello@mydomain.com`. This tells email servers what to do when senders can't be verified and the report will be sent to the specified address.
2. Cloudflare should have added another TXT record where the content value contains `v=spf1 ...`. Edit this record to enable Gmail to send emails on our behalf. The content should look like this: `v=spf1 a mx include:_spf.google.com include:_spf.mx.cloudflare.net ~all`.
3. In your Google account, under Security, create a new App Password for the Mail app. Save the generated password to use in a later step.
4. In your Gmail settings, under `Accounts and import`, add another email address to the `Send email as` section. Pick your name, untick `Treat as an alias`, and use the custom domain email address in both email and reply-to address fields.
5. In the next window, set SMTP server to `smtp.gmail.com`, leave port unchanged, add your gmail username (e.g. `username` from `username@gmail.com`), and the app password from earlier.

When composing an email from Gmail after this point, you should have the option to pick your custom domain address as a sender.

**Note**: your original `username@gmail.com` will be visible in the email header, in case this is important to you.

More detailed info on this topic on [Jay Caines-Gooby's blog](https://jay.gooby.org/2022/05/06/use-a-basic-gmail-account-to-send-mail-as-with-a-domain-that-uses-cloudflare-email-routing).