teleren/devto huggingface dataset:
414. Third Maximum Number
Tags: java, leetcode, array
Published: 2023-01-03 17:23:43

Given an integer array nums, return the third distinct maximum number in this array. If the third maximum does not exist, return the maximum number.

 

**Example 1:**

**Input:** nums = [3,2,1]
**Output:** 1
**Explanation:**
The first distinct maximum is 3.
The second distinct maximum is 2.
The third distinct maximum is 1.

**Example 2**:

**Input:** nums = [1,2]
**Output:** 2
**Explanation:**
The first distinct maximum is 2.
The second distinct maximum is 1.
The third distinct maximum does not exist, so the maximum (2) is returned instead.

**Example 3:**

**Input:** nums = [2,2,3,1]
**Output:** 1
**Explanation:**
The first distinct maximum is 3.
The second distinct maximum is 2 (both 2's are counted together since they have the same value).
The third distinct maximum is 1.
 

**Constraints:**

1 <= nums.length <= 104
-231 <= nums[i] <= 231 - 1

**_Solution:_**

```
public class Solution {
    public int thirdMax(int[] nums) {
        long m1 = Long.MIN_VALUE;
        long m2 = Long.MIN_VALUE;
        long m3 = Long.MIN_VALUE;
        for (int num : nums) {
            if (num == m1 || num == m2 || num == m3) {
                continue;
            }
            if (num > m1) {
                m3 = m2;
                m2 = m1;
                m1 = num;
            } else if (num > m2) {
                m3 = m2;
                m2 = num;
            } else if (num > m3) {
                m3 = num;
            }
        }
        return (int) (m3 != Long.MIN_VALUE ? m3 : m1);
    }
}

```
Website vs. Application vs. Web App
Published: 2023-01-03 18:13:48

---
title: Website vs. Application vs. Web App
published: true
date: 2023-01-03 17:11:11 UTC
tags: 
canonical_url: https://alex.party/posts/2023-01-03-website-vs-application-vs-web-app/
---

[Jen Simmons](https://front-end.social/@jensimmons/109621383745874459) recently posted an interesting question about website thinking for 2023, and I waded into the conversation and realized I have strong opinions as a mediocre white guy in tech. So I’m gonna go into my headspace about these topics.

### Websites, Applications, and Web Apps Are Both All the Same and Separate

When we talk about these 3 concepts, you can have a multitude of combinations of how they work together. There is no clear cut separation of these, only many shades or flavor combinations that come out of it. In general you cannot have one without the other in some way shape or form but many times, It’s based on WHO is interacting at any given time that informs the definition.

That was wordy. Let me explain.

### What is a “Website”?

A website is just html, js, and css. That’s it. From my distinct perspective specifically, a website is used to present information, and you will generally care about speed, SEO, and proper social meta data for sharing and what not. Many times, this is a landing page, Maybe a blog, product listings… etc. That is a website.

### What is an “Application”?

An application is anytime you want to track state across page loads. or maybe even computer systems. A website can be the “face” of an application. An online store can be an application. Generally speaking, if you can update data in some meaningful way, it’s an application. Applications may or may not care about social sharing. Applications may or maynot need you logged in. Heck, a WordPress site is both a “Website” and an “Application” depending on if you are logged in or not. Or what you are trying to do.

### What is a “Web App”?

This is where things get…. real weird. Generally speaking I would say if I open a website and expect the information to stay updated without me refreshing the page, it’s a web app. If you need to figure out how to manage state in the browser without doing a full page reload…. it’s probably a web app.

### So How is This Weird?

Well, You can have all 3 things be true about any given site. A static website marketing page has a little chat bubble that pops-up that allows you to ask questions.

The marketing site is 100% a website.

The chat bubble? A web app.

All of this stuff is sent from an application.

### Conclusion

My general rule of thumb is: Everything is a website. Treat it like a website, until you know it NEEDS to be a web app.

_\*Written from a web app_
Day 2: Chrome Extension for Voice-Activated Web
Tags: 100daysofcode, opensource, webdev, challenge
Published: 2023-01-03 17:00:00

Picovoice’s [Porcupine Wake Word](https://picovoice.ai/platform/porcupine/) engine, plus WebAssembly, now allows web browsers to run wake words using on-device voice AI - within web browsers.

A dedicated wake word engine is the only feasible way to achieve always-listening behaviour since it’s impractical—and a privacy nightmare—to continuously have a hot mic open to a cloud API. Without a phrase to trigger the application (i.e. trigger word), it’s not possible to offer an end-to-end hands-free experience as voice assistants Alexa or Siri does. 

Proof-of-concept [Chrome extension](https://chrome.google.com/webstore/detail/voice-ai-search-extension/jcabocjijfbdpakkppainoflododlead) that is powered by [Porcupine Wake Word SDK for Web](https://picovoice.ai/docs/api/porcupine-web/) offers multiple wake word options to trigger Google search. 

The Chrome voice extension is [open source and available on GitHub](https://github.com/Picovoice/browser-extension). Although the extension is Chrome-only, the web SDK supports all modern web browsers including Safari, Firefox and Edge. It has additional packages for [Angular](https://picovoice.ai/docs/api/porcupine-angular/), [React](https://picovoice.ai/docs/api/porcupine-react/), and [Vue](https://picovoice.ai/docs/api/porcupine-vue/).
One App 5 Frameworks - Chapter 1: React
Tags: react, redux, javascript, webdev
Published: 2023-01-03 16:52:14

With over 15,000,000 downloads on npm, React is one of the most popular frameworks out there. It was a no brainer to not have it included in the series. 

_Please note: I already have experience working with Angular, so I've tried to formulate these points from an angular developer's POV._

## Programming paradigm

React uses a functional programming paradigm, which is different from the object-oriented programming paradigm that I used in Angular.

---

## ✨Hooks✨

React hooks are functions that allow you to add state and side 
effects to functional components in React. This concept took the longest time for me to understand. 

But The ability to make custom hooks and the wide variety of community-developed hooks helped me understand the importance of using them. Hooks are my favorite feature in React.

---

## Redux / React router: 

One more thing that I realized while developing with react is how lightweight it is when compared to Angular. You don't get a lot of built-in features. Which reduces the bundle size and also gives customizability to the developer.

I used Redux for state management. But the freedom of choice is given to the developer here, a few alternatives that I considered are the built-in context APIs and Pullstate.

---

## Application
Checkout the application [here](https://github-repo-finder-react.netlify.app/).
101 nodemon + Node.js
Published: 2023-01-03 16:51:15




`# Install nodemon
npm install nodemon

# Install nodemon globally on your machine
npm install -g nodemon

# Install nodemon on your project as dev-dependency
npm install nodemon --save-dev`

then in file package.json

add it 
`"scripts": {
        "start":"nodemon index.js"
    }`

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

then in index.js 

add this



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p603uxc0i0riuret8njm.png)
`console.log("heloo");
`
then in cmd add this  `npm start`

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b2ma2bbtdhgab68rwd95.png)
Building an app using 5 JavaScript Frameworks - Introduction
Tags: webdev, javascript, tutorial, beginners
Published: 2023-01-03 16:39:44

> The last thing the world needs is another Javascript Framework - Jeff Delaney

## Intro
I started my professional Software Engineering journey in 2020 and have been working on Angular since then. I wanted to try out the other frameworks and wanted to document the learning along the way.
What better way to learn something than by building something with it? So let's build the same application on all 5 Frameworks and perform a comparison
I'm going to rank these frameworks along the way on a few parameters.

- Learning Curve
- Community
- Ease of Use
- Developer Experience

## The Application

I wanted the application to have a certain set of features to replicate real-world application development. We'll be building a single-page application that lists the repositories for a GitHub user. This application will have

- Routing
- Data Store
- API Interaction

I'll be using Typescript, ESLint, and prettier as a standard for code hygiene and Bootstrap for styling

## The Frameworks
Choosing the frameworks was one of the less complex part in this entire journey. I wanted to make sure I cover almost all the variants in the front-end category and did not want to miss some of the latest and greatest meta-frameworks for SSR. After a few minutes of research I ended up with this list.

- [React](https://dev.to/killswitchh/one-app-5-frameworks-chapter-1-react-4kjh) 
- [Vue](https://dev.to/killswitchh/one-app-5-frameworks-chapter-2-vue-31bi)
- [Angular](https://dev.to/killswitchh/one-app-5-frameworks-chapter-3-angular-2he8)
- [Svelte](https://dev.to/killswitchh/one-app-5-frameworks-chapter-4-svelte-5gh4)
- [Qwik](https://dev.to/killswitchh/one-app-5-frameworks-chapter-5-qwik-24oe)

## Conclusion
You can checkout the apps [here](https://github-repositories-multiframework.netlify.app/).

The choice of what framework to use is completely dependent on the problem you are trying to solve. Each framework has its own sets of pros and cons that may aid or hinder the solution you would like to build for your specific problem.

I'd also like to include this cool guide to frameworks in 2023 by @t3dotgg
![cool guide to frameworks in 2023](https://pbs.twimg.com/media/FmJ0ipcaYAccFPi?format=jpg&name=4096x4096)
JavaScript Array Methods: A Comprehensive Guide
Tags: webdev, javascript, programming, tutorial
Published: 2023-01-03 16:35:22

## Top JavaScript Array Methods with Real-World Examples

**JavaScript arrays methods** are a very powerful for organizing and manipulating data natively.

While there are many articles and examples available online for working with arrays in JavaScript, these examples often only cover arrays of strings or numbers. In reality, a more common scenario is working with arrays of objects, especially when making API calls.
Therefore, it can be useful to have a list of the most useful array methods and examples specifically for working with arrays of objects.

Today, I would like to share some of the most useful array methods that I have found helpful when working with arrays of objects.

## Get an array of objects with a key “status” equal to “active” from an array of objects in JavaScript

```

let listUser = [
  { id: 1, name: 'Alice', status: 'active' },
  { id: 2, name: 'Bob', status: 'inactive' },
  { id: 3, name: 'Charlie', status: 'active' },
  { id: 4, name: 'Dave', status: 'active' }
];

let activeUsers = listUser.filter(object => object.status === 'active');

console.log(activeUsers); 

// [{ id: 1, name: 'Alice', status: 'active' }, { id: 3, name: 'Charlie', status: 'active' }, { id: 4, name: 'Dave', status: 'active' }]

```

The **filter()** method creates a new array with all elements that pass the test function provided. In this case, the test function checks if the status property of the object is equal to 'active'. If it is, the object is included in the new array. If it is not, it is not included.

## Find an object with a specific ‘id’ in an array using JavaScript

```
let listUser = [
  { id: 1, name: 'Alice' },
  { id: 2, name: 'Bob' },
  { id: 3, name: 'Charlie' },
  { id: 4, name: 'Dave' }
];

let result = listUser.find(object => object.id === 3);

console.log(result); 
// { id: 3, name: 'Charlie' }
```

The **find()** method returns the value of the first element in the array that satisfies the provided testing function. In this case, the testing function checks if the id property of the object is equal to 3. If it is, the object is returned. If it is not, undefined is returned.

If you like, you can check out the full article with more examples on Medium 👇

{% medium https://medium.com/notonlycss/javascript-array-methods-a-comprehensive-guide-46de07fa4b6e %}

_If you are not able to read the article, in the comments is present the friend link ;)_
Moonly weekly progress update #30
Tags: javascript, nf, blockchain, saas
Published: 2023-01-03 16:32:29


## Moonly weekly progress update #30

![](https://cdn-images-1.medium.com/max/3200/1*CY8pGpF94XfX83RQQV_ssQ.png)

Happy New Year to everyone, God bless you all!
I hope you had a nice New Year’s Eve, with your loved ones and in the circle of your family.
I wish you lots of health, happiness, and love!

**Weekly devs progress:**

* Write a script to simplify the new tx parser testing

* Finished pagination in monitor table (not deployed)

* Fixed meta tags

* Fixed titles in images

* Finished skeleton UI for NFT cards

* Investigating parser improvement

* Fixing the metadata-scraper issue

* Researched options to decrease the Big Database disk space consumption

* Resolved deployment problems on moonlydev

* Researched the possibility to compress data in the Big DB

* Design the flow of the holder verification feature

* Design DB schema for verification settings in Bot DB

* Wrote API on moonly-API for trait list of collection

* Wrote resolvers in Moonly-bot for discord roles and traits

* Added validation on frontend forms to not accept input without https:// protocol

* Integrated Discord role API

* Modified trait API and integrated it into the front-end

* Integrated verification setting API

* Modified different logic to display these data correctly

**Staking (Locking):**

* Finished Stake Creation

* Implemented Collection Update Functionality

* Added admin functions in the admin area

* Fixed metadata storage issue, it’s showing up well in the wallet

* Investigated wallet issues and improved anchor program code flow

* Implemented Collection Owner Validation in Smart Contract

**Portfolio Tracker:**

* Cleaned up and restructured the token-tracker package

* Started scraping Token Transactions IDs on scale

* Deployed live-feed-worker and tokens metadata scrapers on production

* Investigated tokens metadata scrapers operation

* Designed workflow for the on-demand Transaction Logs

* Reviewed & merged fixes to identify more transactions types

* Merged serving token metadata from the uploads folder

* Reviewed and merged the separation of the token tracker API into the token tracker

**Upcoming NFT projects to mint:**

[https://moon.ly/nft/degen-legends](https://moon.ly/nft/degen-legends)

[https://moon.ly/nft/bullyz-crew](https://moon.ly/nft/bullyz-crew)

[https://moon.ly/nft/nitro-badge](https://moon.ly/nft/nitro-badge)

**Minted projects worth mentioning:**

[https://moon.ly/nft/immortals](https://moon.ly/nft/immortals)

[https://moon.ly/nft/helions](https://moon.ly/nft/helions)

[https://moon.ly/nft/alpha-pharaohs](https://moon.ly/nft/alpha-pharaohs)

[https://moon.ly/nft/retrogoons](https://moon.ly/nft/retrogoons)

[https://moon.ly/nft/degen-fat-cats](https://moon.ly/nft/degen-fat-cats)
💥Luos surpasses 11 000 members on Discord
Tags: community, opensource, microservices, luos
Published: 2023-01-03 16:31:51

💥 Woo-hoo! We opened a new community last year for embedded and edge developers and have passed the 11 000 member mark!

Thanks to all of you maintainers, contributors, communicators and members for being part of this great project!
API Magic: Unlocking the Power of Data and Functionality
Tags: javascript, api, softwareengineering
Published: 2023-01-03 23:35:51

---
title: API Magic: Unlocking the Power of Data and Functionality
published: true
date: 2023-01-03 16:26:09 UTC
tags: JavaScript,API,SoftwareEngineering
canonical_url: https://techdevblog.io/api-magic-unlocking-the-power-of-data-and-functionality/
---

 ![API Magic: Unlocking the Power of Data and Functionality](https://techdevblog.io/content/images/2023/01/image_2-3.png)

An API, or Application Programming Interface, is a set of rules that specifies how two software programs should interact with each other. APIs allow different software programs to communicate with each other, sharing data and functionality.

In JavaScript, you can use APIs by making HTTP requests to a server and receiving a response. This response can be in the form of data (such as a JSON object) or functionality (such as a JavaScript function).

One well-known and free to use API is the OpenWeatherMap API, which allows you to access current weather data for any location. Here's an example of how you can use this API in JavaScript:

First, you'll need to sign up for a free API key at the OpenWeatherMap website.

Once you have your API key, you can make a request to the OpenWeatherMap API using the `fetch()` function in JavaScript. For example:

```
fetch('https://api.openweathermap.org/data/2.5/weather?q=New+York&appid=YOUR_API_KEY')
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

```

This will make a request to the OpenWeatherMap API, asking for the current weather in New York. The API will respond with a JSON object containing the weather data, which you can access by calling `response.json()`.

Once you have the weather data, you can use it in your JavaScript code. For example, you might want to display the current temperature on your webpage:

```
fetch('https://api.openweathermap.org/data/2.5/weather?q=New+York&appid=YOUR_API_KEY')
  .then(response => response.json())
  .then(data => {
    const temperature = data.main.temp;
    document.getElementById('temperature').innerHTML = temperature;
  });
```

This will update the element with the ID "temperature" to display the current temperature in New York.

I hope this helps! Let me know if you have any questions.
Recursion
Tags: javascript, programming, tutorial, beginners
Published: 2023-01-03 16:16:32

**<u>How to Think About Recursion</u>**

**Recursion is when a function calls itself in a return statement**

This may be confusing at first - "won't this make an infinite loop?" you might ask. The key in recursive functions is that every time they call themselves, they change their parameters slightly so that an included if statement can check for an end state and properly stop the function from continuing

for example:

`function recur(count){
if(count === 0){
  return;
}
console.log(count);
return recur(count - 1);
}`

The above function would print the numbers from count down to 1 to the console; note that it would not print "0" because when count eventually becomes 0, the if statement will simply return. If we wanted to print 0 as well, we'd need another console.log within the return statement.

**Another looping mechanism for your repertoire**

The best way I have found to think of recursion is that it's simply another way to do loops. It has all the pieces of, say, a for loop, just in a different order. For instance, if we wanted to print the above function using a for loop it would look like this:

`function forLoop(count){
   for(let i = count; i > 0; i--){
     console.log(i);
   }
}`

Let's break this down:

the first part of the for loop, "let i = count", sets up how many iterations we will go through based what argument is passed to the function. No "i" variable is needed in the recursive function, but the argument passed to "count" still serves the same purpose.

The second part of the for loop, "i < 0", indicates the stop statement for the loop; the loop will continue iterating so long as i is greater than 0. The same functionality is served by the if statement at the top of the recursive function; once count = 0, the loop is ended by a return statement.

The third part of the for loop, "i--", is what changes the variable that is tested for in order to stop the function once it has gone through all the iterations we want it to, and to prevent it from becoming an infinite loop. The same purpose is covered by the return statement at the end of the recursive function: "return recur(count - 1);". 

So if we think about this, if count = 5, then the first time we go through the recursive function it will console.log count (5), then it will return itself with count - 1 as the argument, so it will essentially return "recur(4)". It will do this until the if statement's condition is met (i.e. it runs "recur(0)"), at which point it will hit the return statement and stop iterating.

In summary, a recursive function has all of the pieces of a for loop, just in different locations. 

I hope this helps your understanding of recursion!
create a reservasion section
Tags: help, webdev, react
Published: 2023-01-03 16:11:28

Hello everyone 
im learning react right now i was building a section for a project which is reservation section but i get stuck and need some hint or guidance on how to organize the components and when i click and submit it should take me to another section  This is how it should be 

![screen shot of the project](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cpv0ld52ixpucsr47jfa.png)
![screen shot of the project](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1bp8jijizlbmpr2zw21l.png
)


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

and there is several other pages as well 
i couldnt find any tutorial or article regarding this
Create a Windows 11 in React.js
Tags: react, redux, typescript
Published: 2023-01-03 15:54:08

I always thought that what if that we could make online windows on the web? however, at that time I wasn't able to make it done!

So this summer, I decide to make it and be the first one, coded that independently by myself,

but then I realize another team did that 🥲
I'll share the link below to check [it](https://win11.blueedge.me/) out, back to story it was a little disappointing, but I figure that I could start developing my new one, and whenever I got stuck I could get help from the existing one, and also learn new things.

and the reason I didn't publish that by this time is the revolution is taking place in Iran.

## The technologies I used are:

- ReactJs 🎓
- TypeScript 💙
- Redux 💖
- Styled Components 💇‍♂️
- framer-motion 💪

## Check it Online

I know, you can't wait for taking look at it, so here you go. make sure you're using Desktop.

[Wins-11 Online](https://wins-11.vercel.app/)


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

## Github page

and make sure you like the repo if you like it.

[Github Repo](https://github.com/vito-mohagheghian/wins-11)

> also there's a document on the GitHub page.

## Short description 

the general things are the same as windows, but details are working at them so don't worry about that.

and the funny 😂 thing about this was that by the time I finished coding when Microsoft updates some UI, so there must be some changes.

## But it's not over!


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

I plan to make real-world widows where you're able to create accounts, upload files, make folders install apps from the store, and be somehow a VPN or something like that, in which you're like using a virtual machine.

## Conclusion

I really appreciate reading this dumb post to the end. 🙏
hope you enjoy and inspire you for making everything web apps you want 🤞. 


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