teleren/devto huggingface dataset:
1457. Leetcode solution in Java
Tags: java
Published: 2022-09-14 06:45:43

```

class Solution {
  public int pseudoPalindromicPaths(TreeNode root) {
    dfs(root, 0);
    return ans;
  }

  private int ans = 0;

  private void dfs(TreeNode root, int path) {
    if (root == null)
      return;
    if (root.left == null && root.right == null) {
      path ^= 1 << root.val;
      if ((path & (path - 1)) == 0)
        ++ans;
      return;
    }

    dfs(root.left, path ^ 1 << root.val);
    dfs(root.right, path ^ 1 << root.val);
  }
}
```

#leetcode
#challenge
here is the link for the problem: 
https://leetcode.com/problems/pseudo-palindromic-paths-in-a-binary-tree/submissions/
Head Recursion
Tags: cpp
Published: 2022-09-14 06:18:29

When a recursion doesn’t need to do anything in the calling times, it only needs to do things in the returning time, then it is called a head recursion.
```cpp
void fun(int n){
    if(n>0){
        fun(n-1);
        cout<<n<<endl;
    }
}
```
Same code using a loop:
```cpp
void fun(int n){
    int i=1;
    while(i<=n){
        cout<<i<<endl;
        i++;
    }
}
```
As your can see from here, it is difficult to implement a head recursion using a loop. So, it is better not to write it in loops.
How I can go to the next level?
Published: 2022-09-14 06:12:44

Working as software developers many times we have questions in mind about how I can move to the next level. Or what new skill should I learn so that I can move forward in my career?

If we don't have a clear idea or vision of what to do then we feel stuck while working which became a bottleneck for our success in our career life.

Let's discuss some potential ways of how we can move forward when you get to a certain level in your career when you don't have a clear vision of what to do now.
Library project completed
Tags: javascript, webdev, beginners, codenewbie
Published: 2022-09-14 06:12:38


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dpaovt6w8zfb3jx9vyg1.png)Hello all! I am currently wrapping up the library project from TOP (The Odin Project) boy it was sure a doozy. The first obstacle I ran into was looping through the array that held the books and displaying it on a card/table. I managed to create the table and display it using the DOM but ran into yet another problem, my array kept duplicating each "book".

 After asking for help from some lovely folks it turns out I had to reset the form after each book! After that was settled the next step was pretty simple, which was add a button that brings up the form for the user to input their author, title, number of pages, etc. The next step was when I hit another wall.

> Add a button on each book’s display to remove the book from the library.
You will need to associate your DOM elements with the actual book objects in some way. One easy solution is giving them a data-attribute, that corresponds to the index of the library array.

To be quite honest I had little to no idea how I could implement data-attributes to each book giving them a unique id. Yet again asked another question with as much detail into what I'm trying to achieve (Quick tip asking great questions not only helps you as a programmer/developer it also makes it easier to work with being the other person who is trying to help you. So ask questions but also give great detail!) After asking for help, and turns out It could be solved with just a few lines of slapping an attribute to each book and adding another parameter to my loop and tada! Each book had its own unique id!

The last step was a bit challenging, prototypes were difficult at first but after learning that it is a property on a function that points to an object it became a little clearer as to how to update the read status on the books.

One month later, here we are ! After many headaches and breaks this project is finished. Thank you to everyone that helped and also thank you to the peeps who read my very "professional" blogs. ❤️
On Software Architecture Decisions, Evolution and Engineering - 1
Tags: architecture, softwareengineering, decisions, heuristics
Published: 2022-09-14 16:39:38

---
title: On Software Architecture Decisions, Evolution and Engineering - 1
published: true
date: 2022-09-14 06:00:00 UTC
tags: softwarearchitecture, softwareengineering, decisions, heuristics
canonical_url: https://amanagrawal.blog/2022/09/14/making-architectural-decisions-in-software-engineering/
series: Architecture Series
---

⚠ If you are looking for a quick read, this post is anything but. Make sure you’ve grabbed a ☕ or two before you decide to read this! This topic is very important to me, I have strong opinions about this and I’ve been meaning to put my thoughts down for a long time! Real life case studies and examples appear in quoted text with _cheesy_ titles.

In my 15 some odd years of practising software engineering, I have come across two extremes around software architecture and perhaps unsurprisingly so given I cut my teeth in the waterfall era: _Big Design Up Front_ (no code until the design/architecture is nailed down to the last detail) and _No Design Up Front_ (we follow agile so we are just going to get started hacking away at the code until something resembling an architecture emerges _if at all_, and if it works that’s a bonus!). _Move fast and break things_ sort of mindset.

Neither is conducive to the long term health and the value of the system nor to the morale of the teams building them, and MUST be avoided! In the former, you never actually ship anything meaningful and in the latter, you get pwned by your “architecture”! There are some environments where the latter works well enough, start-ups, but here I am talking about my home turf – enterprise software or software systems built at large organisations with often bureaucratic management practices and mis-aligned incentives between engineering and business teams.

My current philosophy is that deliberate and thoughtful architectural decisions that solve real business problems **and** mitigate enough of the real risks, is the RIGHT and the MIDDLE PATH way to go. In this post I want to explore the following questions and demonstrate using examples how we make risk driven architectural decisions in my domain at work and how I as a Principal Engineer facilitate this practice amongst my teams in the hopes that it will resonate with others as well. There is also some helpings of grumpy old man-isms sprinkled here and there:

- What is an architectural decision ?
- How much architectural work should be done upfront ?
- How should architecture evolve?
- Our Architectural Decision Making “Process”
Google action learn more button
Tags: javascript, beginners, googlecloud
Published: 2022-09-14 05:56:24

Now that we are able to fetch data from an RSS feed and show it in the Google Action, how about we add a button to learn more.

A thing to note is that depending on the device, the button might not be rendered.
For instance smart home devices won't show the button, the mobile assistant on the other hand will show them.

For this article i'll be using what we build yesterday, you can find the [article here](https://daily-dev-tips.com/posts/google-action-fetching-data-from-an-rss-feed/).

## Adding a learn more button to Google action

We can actually add the button component as part of our allready existiong card and leverage the RSS data we fetched.

The card can look like this:

```js
conv.add(
  new Card({
    title: jsonData.feed.entry[0].title._cdata,
    text: jsonData.feed.entry[0].content._cdata,
    image: new Image({
      url: 'https://daily-dev-tips.com/images/logo.png',
      alt: 'Daily Dev Tips logo',
    }),
    button: new Link({
      name: 'Read more',
      open: {
        url: jsonData.feed.entry[0].link._attributes.href,
      },
    }),
  })
);
```

Make sure your importing this new `Link` component like this:

```js
const { Link } = require('@assistant/conversation');
```

And if we now test our action on mobile phones for instance we should see the button that will link to the specific article.

Below is a screen recording on my mobile phone showing the full flow.

![Google action learn more button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2t55n28euqlj8s7vnq67.gif)

### Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on [Facebook](https://www.facebook.com/DailyDevTipsBlog) or [Twitter](https://twitter.com/DailyDevTips1)
mapping javascript object values
Published: 2022-09-14 05:55:41

---
title: mapping javascript object values
published: true
description: 
tags: 
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
---

A method that maps only the values of a javascript object, which is a set of key/value pairs, like the map function of an array.

```js
const entriesMap = (object, callbackfn) => {
  const entries = Object.entries(object).map(e => callbackfn(e))
  return Object.fromEntries(entries)
}

const valuesMap = (object, callbackfn) =>
  entriesMap(object, ([k, v]) => [k, callbackfn(v)])

export { entriesMap, valuesMap }
```
Tail Recursion
Tags: cpp, computerscience
Published: 2022-09-14 05:50:21

If in a recursive function, the recursive call is the last statement of the function, then it is called a Tail Recursion. In returning time, it doesn’t have to perform anything at all.
```cpp
void fun(int n){
    if(n>0){
	    cout<<n<<endl;
        fun(n-1);
    }
}
```
Same code using a loop:
```cpp
void fun(int n){
    while(n>0){
	    cout<<n<<endl;
        n--;
    }
}
```
---
To conclude, the time complexity of both codes is the same. But in recursive calls, as it uses stacks, it is actually taking extra space. So, the space complexity for the loop is O(1), but for the tail recursion, it is O(n). So, it is better to use a loop if it is a tail recursion.
Missing Number - I
Tags: javascript, leetcode
Published: 2022-09-14 05:49:42

```js
var missingNumber = function(nums) {   
    let length =  nums.length;
    let sortedArray = nums.sort((a,b) => a-b);
    for(let i =0; i <=length; i++){

        if(i !== sortedArray[i]){
            return i;
        }
    }
    return undefined;
    
};

```
CSS nth:child selector
Tags: html, css, beginners, webdev
Published: 2022-09-14 05:48:17

Hello guys today i will be showing you the use of nth-child selector in CSS.

* nth-child selector can be used to select any number of elements from a group of same type of element, or with same class, etc.
* Example - Suppose we have 10 paragraphs created with "p" tag and we want to give every second paragraph a background color of black.So, instead of providing separate class names to all the 10 elements we can provide 1 class name to all and use that class name with nth-child to select every second paragraph in that group

## Example 1 - Basic styling 
```css
.paragraph:nth-child(2n){
background-color:black;
color:white;
}
```

* It will give a background color of black and text color of white to every second paragraph in that group having the same class name "paragraph"
* You can also select the "p" tag directly like this
```css
p:nth-child(2n){
background-color:black;
color:white;
}
```
* It's not a recommended approach as there will be other "p" tags in the webpage and it will apply the styling to all the "p" tags.So, better go with the class name approach.

## Example 2 - Using nth-child with Animation

{% codepen https://codepen.io/shubhamtiwari909/pen/oNdvLee %}

* You can see all the three span elements have same class name and using nth-child selector all the three span elements have different animation styling and delay.


THANK YOU FOR CHECKING THIS POST

You can contact me on -
Instagram - https://www.instagram.com/supremacism__shubh/
LinkedIn - https://www.linkedin.com/in/shubham-tiwari-b7544b193/
Email - shubhmtiwri00@gmail.com

^^You can help me by some donation at the link below Thank you👇👇 ^^
☕ --> https://www.buymeacoffee.com/waaduheck <--

Also check these posts as well
https://dev.to/shubhamtiwari909/js-push-and-pop-with-arrays-33a2/edit

https://dev.to/shubhamtiwari909/tostring-in-js-27b

https://dev.to/shubhamtiwari909/join-in-javascript-4050

https://dev.to/shubhamtiwari909/going-deep-in-array-sort-js-2n90
CCIE® Data Center V3.0 - Cisco Certified Internetwork Expert Data Center Training
Published: 2022-09-14 05:44:16

The [[CCIE® Data Center certification]](https://www.sprintzeal.com/course/ccie-data-center-v3-cisco-certified-internetwork-expert-data-center-certification-training) is one of the most desirable certifications in the market scenario. Rising demand for cloud computing and virtualization has led to a sudden demand and growth in the CCIE® Data Center. Our CCIE® Data Center certification training validates expert level skills that are required for planning, designing, implementation, and management of complex IT data infrastructure.
Single Number Check
Tags: javascript, leetcode
Published: 2022-09-14 05:36:11

```js
var singleNumber = function(nums) {

   const hash = {};

  for (const el of nums) {
    if (!hash[el]) {
      hash[el] = 1;
    } else {
      delete hash[el]
    }
  }

  return Object.keys(hash)[0];
}
```
Lambda Function in C++
Tags: cpp, computerscience, programming, beginners
Published: 2022-09-14 05:28:47

These three lines of code will help to understand how lambda functions work in c++:
```cpp
int sum = [](int x, int y){return x+y;}(10,20);
// or
auto sumFunc = [](int x, int y){return x+y;};
int sum = sumFunc(10,20);
```
Created macOS with ReactJs
Tags: javascript, react, webdev, programming
Published: 2022-09-14 05:26:01

**Hi Friends, I have created ( MacOS with ReactJs )**

Building projects are always a good idea to learn any programming language.

As I was learning ReactJs, So to utilize my weekends, Last week, I started a project that no one had ever tried with React js. 

I have created macOS with the help of ReactJs. By creating this project I have learned many concepts. In this project, I have covered the following


Login Page 
Docks
New folder
Open Window 
Spotlight
Multiple Folder
Battery Status
Wifi Connection 
Right Click Anywhere
App menu
Status Menu
Control Center 
Updated Date & Time (Local)
Apple Menu
Restart Window
Contacts
Launchpad
Finder
Safari  Browser
Maps


And a lot more you can see in the video I posted here.


I hope you like it. ❤️


If you like my project, please feel free to Drop Your Comments and Share them with your friends to get a better reach.




Project link: [Click Me](https://www.linkedin.com/posts/thegauravsoni_macos-html-css-activity-6975671124210667520-Juk7?utm_source=share&utm_medium=member_desktop)
Augmented Reality is Everyone
Tags: augmentedreality, everyone, creates, nocoding
Published: 2022-09-14 05:19:00

Many essential features are included in PlugXR's cloud-based platform

The PlugXR app allows users to create seamless Augmented Reality apps and experiences and publish them in WebAR or white-labeled Android & iOS apps.

## **Using mobile AR**
With our cloud platform, you can publish advanced AR experiences into your Android and iOS applications, eliminating the need to install Android Studio or XCODE on your computer.

## **Using web AR**
Create a personalized URL or QR code to access your AR experience without downloading an app.

We provide an end-to-end AR solution by supporting all dimensions & verticals of AR tracking


## **Use cases for PlugXR**
PlugXR's market-leading features allow AR applications to be endless
Contributes significantly to all major industry verticals

## **What makes PlugXR different?**
The incredibly low cost and time of development with NO Coding & Dependency make AR a viable option for businesses and individuals on a budget. Increasing client acquisition, retention, and conversion.

## **Video**:
[https://www.youtube.com/watch?v=yIanc3t3PyA&t=220s](https://www.youtube.com/watch?v=yIanc3t3PyA&t=220s)

## **For more information**: [https://bit.ly/3DHwN3H](https://bit.ly/3DHwN3H)
Introducing Signals in React 🚥
Tags: react, javascript, webdev, programming
Published: 2022-09-14 05:09:26

We have all heard/used states in React. It is a way to observe a value and its change to update the UI accordingly without triggering full page refresh. It is very useful but it comes at a cost, State change triggers re-rendering of the component, Which can hit the performance. 

## Preact
[Preact](https://preactjs.com/) is a 3kb alternative library which uses same API as React. But since its smaller, it ships less code to the browser.
Recently, They have announced a new package which is available to install react as well called Signals.
[Docs](https://preactjs.com/guide/v10/signals/)

According to Docs:

> What makes Signals unique is that state changes automatically update components and UI in the most efficient way possible. Automatic state binding and dependency tracking allows Signals to provide excellent ergonomics and productivity while eliminating the most common state management footguns.

What signal does is, It is a object containing a property `.value`, Once defined that signal/object remains the same but its value can change and when it does it notifies this change so that reference to that value can be updated.

Couple of things that make this interesting are,

1. Signals do not trigger re-renders of whole component, instead they just update the value in place.
2. They can be defined globally and imported in other components, So whenever value for specific signal changes, It can update the UI with the value throughout the application.

### To Install Signal in React

```
npm install @preact/signals-react
```
### Simple Use case

```
import {signal} from '@preact/signals-react'

//create a signal
const count = signal(0)

const App = () =>{
 return(
   <>
     <p>{count.value}</p>
   </>
)}
```

[Preact signal Github](https://github.com/preactjs/signals)

So try it and let me know what you guys think. 

Cheers and Happy Coding 🍻👩‍💻
Creating my static site generator
Published: 2022-09-13 22:16:24

Hi everyone,

This week, I created my own SSG (static site generator) called [nan1-ssg](https://github.com/NeilAn99/nan1-ssg) using JavaScript and node.js. My SSG will generate .html files from .txt files as specified by the user.

Some features of nan1-ssg are:

- Generating valid HTML5 files from .txt files and placed in the dist directory
- An index.html file is created which contain relative links to the generated HTML files
- Each HTML file uses a default stylesheet to improve beauty and readability

## Usage

To use my SSG, [node.js](https://nodejs.org/en/download/) is required. After node.js is installed follow these steps to use the tool:

**To use this tool:**

1. Clone or download and extract the repo to a location on your computer.

2. Open a terminal/command window and navigate to the location where the tool is.

3. Run the npm install command:
```
npm install
```

4. Run the npm link command:
```
npm link
```

5. Start using the tool! For example:

```
nan1-ssg [-option]
```

**A list of options:**

|  Option  | Details |
| ---------------| ---------------|
| -v, --version | Will display the name and version of the tool. |
| -h, --help | Will display a help message, showing options and usage. |
| -i <filename>, --input <filename> | Gives the tool a filename to generate HTML files with. The filename can be a file or a directory. |

## Examples

**For a text file:**
```
node main -i hello.txt
```

**For a directory:**
```
node main -i Sherlock-Holmes-Selected-Stories
```

**Files that are nested:**
```
nan1-ssg -i "./Sherlock-Holmes-Selected-Stories/Silver Blaze.txt"
```

**Files containing spaces:**
```
node main -i "file with spaces.txt"
```

Link to repo: [nan1-ssg](https://github.com/NeilAn99/nan1-ssg)

Example of generated static site: https://neilan99.github.io/
Advantage of ReactJS
Tags: javascript, react
Published: 2022-09-14 04:33:20

Today, ReactJS is the highly used open-source JavaScript Library. It helps in creating impressive web apps that require minimal effort and coding. The main objective of ReactJS is to develop User Interfaces (UI) that improves the speed of the apps.

## ADVANTAGES OF REACTJS

- **Easy to Learn and Use**
 
ReactJS is much easier to learn and use. It comes with a good supply of documentation, tutorials, and training resources. Any developer who comes from a JavaScript background can easily understand and start creating web apps using React in a few days. 

- **Creating Dynamic Web Applications Becomes Easier**
 
To create a dynamic web application specifically with HTML strings was tricky because it requires a complex coding, but React JS solved that issue and makes it easier. It provides less coding and gives more functionality. It makes use of the JSX(JavaScript Extension), which is a particular syntax letting HTML quotes and HTML tag syntax to render particular subcomponents. It also supports the building of machine-readable codes.

- **Reusable Components** 

A ReactJS web application is made up of multiple components, and each component has its own logic and controls. These components are responsible for outputting a small, reusable piece of HTML code which can be reused wherever you need them. The reusable code helps to make your apps easier to develop and maintain. These Components can be nested with other components to allow complex applications to be built of simple building blocks. ReactJS uses virtual DOM based mechanism to fill data in HTML DOM. The virtual DOM works fast as it only changes individual DOM elements instead of reloading complete DOM every time.

- **Performance Enhancement**

ReactJS improves performance due to virtual DOM. The DOM is a cross-platform and programming API which deals with HTML, XML or XHTML. Most of the developers faced the problem when the DOM was updated, which slowed down the performance of the application. ReactJS solved this problem by introducing virtual DOM. The React Virtual DOM exists entirely in memory and is a representation of the web browser's DOM. Due to this, when we write a React component, we did not write directly to the DOM. Instead, we are writing virtual components that react will turn into the DOM, leading to smoother and faster performance.

- **The Benefit of Having JavaScript Library**
 
Today, ReactJS is choosing by most of the web developers. It is because it is offering a very rich JavaScript library. The JavaScript library provides more flexibility to the web developers to choose the way they want.