teleren/devto huggingface dataset:
Episode 02 - Best time to buy the stock
Tags: javascript, interview, frontend, interviewquestions
Published: 2023-07-09 05:52:59

In this episode, we are going to explain one of the famous question asked in JavaScript interview. You will be given an array of integers which represents the prices of a stock in each day. Your task is to find the best buying and selling price that will give you maximum profit.

The array will be like [6, 1, 2, 5, 7] and the output will be 6. The lowest price of the stock is on the 2nd day which is 1 and the highest price is on 5th day which is 7. So buying at the price of 1 and selling at 7 will give us the profit of 6.

Now lets explore the way to find this in JavaScript.

```
function findMaximumProfit(prices) {
  const length = prices.length;
  let buyPrice = prices[0];
  let maxProfit = 0;

  for (let i = 1; i < length; i++)  {

    if (buyPrice > prices[i]) {
      buyPrice = prices[i];
    } else {
      maxProfit = prices[i] - buyPrice;
    }    
  }
  return maxProfit;
}

console.log(findMaximumProfit([6, 1, 2, 5, 7])); //6
```

**Code Explanation:**

We will first declare few variables: length to store the length of the variable, declare buyPrice and assign the first price from the array, and maxProfit to 0. We will start the iteration from the first index since we already assigned the 0th value to the variable. In each iteration, we will check if the buyPrice is greater than the current price. If so then, we will modify the value to that price. Otherwise, we will check the profit buy subtracting both values. At the end of the loop we will return the value of maxProfit.

This array returns the profit as 6. We need to buy the stock at the price of 1 and sell at the price of 7. 

There is also another variation of this questions where the interviewer might ask for the buying and selling date instead of the profit. We can solve that also easily, by tweaking this same code.

```
function findBuySellDate(prices) {
  const length = prices.length;
  let buyPrice = prices[0];
  let maxProfit = 0;
  let buyDate = 0;
  let dates = [];

  for (let i = 1; i < length; i++)  {
    if (buyPrice > prices[i]) {
      buyPrice = prices[i];
      buyDate = i;
    } else {
      maxProfit = prices[i] - buyPrice;
      dates = [buyDate, i];
    }    
  }
  return dates;
}

console.log(findBuySellDate([6, 1, 2, 5, 7])); // [1, 4]
```
Running this function with the same code now, will return the indices for the buy and sell.

Check it in our YouTube

{% embed https://youtu.be/j9V7nSYU-cY %}
Collect system disk drive information using Rust.
Tags: programming, rust, package, neyaznafiz
Published: 2023-07-09 05:49:47

## system_diskinfo
A package for collect information about disk drive means SSD/HDD etc of a windows operating system.

You will be able to collect disk information from any device with just a function call. you will be able to collect the `disk name`, `disk model`, `disk size` and `disk serial number` information of a windows system with this package.

**Install Package**
```
cargo add system_diskinfo
```

**Add Dependencies**
```
system_diskinfo = "0.1.4"
```

### **Modules**
- `driveName`
- `driveSize`
- `driveModel`
- `driveSerialNumber`

### **Functions**
- `drive_name()` for collect the name of system disk drive.
- `drive_size()` for collect the total capacity of disk drive.
- `drive_model()` for collect the model of system disk drive.
- `drive_serial_number()` for collect the serial number of system disk drive.

### **Guideline**
First of all add this package to your `dependencies` in `cargo.toml` file, then open a file where you want to use and add the package in the top of the file like `use system_diskinfo`, after that, to get the correct output use it like this: 
- First write the package name. ( `system_diskinfo` )
- Add double clone. ( `::` )
- Write module name using camel case. ( `driveName` )
- Add double clone. ( `::` )
- Call the function using snake case. ( `drive_name` )

### **Example**
We are printing here the total capacity information about the disk drive of a windows system.

*cargo.toml*
```
[dependencies]
system_diskinfo = "0.1.4"
```

*main.rs*
```
use system_diskinfo;

fn main() {
  let size = system_diskinfo::driveSize::drive_size();
  println!("Disk Drive Size: {}",  size);
}
```

Open your terminal with the correct path of your project and run `cargo run` command
```
--- Output ---

Disk Drive Size: 512105932800 
```

##### Best Regards. Enjoy.
Have a lot of idea recently
Published: 2023-07-09 05:24:42

Yap, I have a lot of game idea like The Room (survival in your room), or Neko Switch (you have ability to switch to cat).
I feel like I can make them in a week but ... x.x historically, I can't.
And I need fix bugs in my old project
Need to build molecular simulation
Need to complete my Zomtopia
Waaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
I don't feel overwhelming, I just feel empty, motivation is all I need. Or just turn on machine mode and make them out of thin air =.= (cost me taste of life thou)
Waaaaaaaaaaaaaaaaaa
I am game developer, not game coder!!!!
...
Oh nice, I feel the machine mode already turn on =.=
Recode ET.Firebase
Published: 2023-07-09 05:17:23

I am remaking the section in ETEngine that integrate the user with Firebase, while also adding some flexible UI to it. x.x Quite don't like doing this but this is an critical feature in some of my project. I will probably remove the user authentication, just want to make the game feature clean for the users.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nt0oge8qaxinpbmyugv3.png)
#4 SOLID - Interface Segregation Principle | Swift | iOS Development
Tags: ios, interview, softwareengineering, swift
Published: 2023-07-09 05:07:20

In the following example we have defined a `PrinterProtocol` which we can use to create multiple type of printers.

We have added every methods in one protocol. So, even if we want to create a simple printer we will have to implement every function in the protocol. We can provide default implimention for the protocols but still it's violates the ISP because the `SimplePrinter` could call the default implementation as well. That is not expected behaviour. A `SimplePrinter` doesn't have to call `receiveFax()` method.

```swift
protocol PrinterProtocol {
    func printDocument()
    func scanDocument()
    func sendFax()
    func receiveFax()
}

extension PrinterProtocol {
    func receiveFax() {
        print("Default: Receiving fax...")
    }
}

class SimplePrinter: PrinterProtocol {
    func printDocument() {
        print("Printing document...")
    }
    
    func scanDocument() {
        print("Scanning document...")
    }
    
    func sendFax() {
        print("Sending fax...")
    }
    
    func receiveFax() {
        print("Receiving fax...")
    }
}
```
Let's check how we can implement as per ISP 🚀

- Clients should not be forced to depend on interfaces they don't use.
- Larger, general-purpose interfaces should be segregated into smaller, more specific interfaces that are tailored to the needs of individual clients.
- The goal is to avoid the situation where a client is required to implement methods that are irrelevant to its use case.
- This promotes modularity, maintainability, flexibility, and testability in software systems.


```swift

protocol Printer {
    func printDocument()
}

protocol Scanner {
    func scanDocument()
}

protocol FaxMachine {
    func sendFax()
    func receiveFax()
}

class AllInOnePrinter: Printer, Scanner, FaxMachine {
    func printDocument() {
        print("Printing document...")
    }
    
    func scanDocument() {
        print("Scanning document...")
    }
    
    func sendFax() {
        print("Sending fax...")
    }
    
    func receiveFax() {
        print("Receiving fax...")
    }
}

class SimplePrinter: Printer {
    func printDocument() {
        print("Printing document...")
    }
}

```
SecureCred
Tags: opensource, android, security, github
Published: 2023-07-09 05:05:44


We started an open source project called **SecureCred**.

SecureCred is an open source project that **_provides a secure solution for both developers and regular users who need a reliable place to store their passwords_**. Whether you have multiple accounts across various platforms or you're a developer with numerous project-related accounts, SecureCred has got your back! No more hassle when handing over credentials to clients during project deployment. Say goodbye to storing passwords in insecure places like sticky notes or your browser. SecureCred is here to save the day!🔒🔑

GitHub:https://github.com/VC-AndroidDevelopers/SecureCred

Figma:https://www.figma.com/file/I10VRUqyXnNIwdVxrLTSjT/SecureCred-UI?type=design&node-id=0%3A1&t=KTDOzil79B8ap1Ed-1

RoadMap:https://www.figma.com/file/cbBqyQ3ttub55I10TOQrDq/SecureCred-Project-GTD-weekly?type=design&node-id=0%3A1&t=eME1KhumCnrIxsCp-1
2 of the best Coins That Utilize Decentralization at its best
Published: 2023-07-09 03:34:47

Decentralization is an integral element of cryptocurrency, intended to eliminate the need for intermediaries such as banks or governments and enable peer-to-peer exchange of digital assets thereby improving transparency, security and efficiency. By eliminating middlemen decentralization empowers individuals by giving them control of their own funds and transactions.

[Stellar (XLM)](https://simplemoneyinvesting.com/stellar-lumens-xlm-price-prediction-2025-2030-2040/) is an impressive cryptocurrency known for its commitment to decentralization and inclusivity. Offering fast and cost-effective cross-border transactions, Stellar makes itself the go-to choice for individuals and businesses alike. Furthermore, Stellar's decentralized network enables the issuance and transfer of digital assets such as tokens representing fiat currencies, commodities, or even real estate assets.

[XYO ](https://simplemoneyinvesting.com/xyo-price-prediction/)is an innovative blockchain-based platform that uses decentralization to revolutionize location verification and data sharing. Utilizing its network of connected devices known as sentinels, XYO ensures the accuracy and integrity of location-based data. Through trustless interactions enabled by blockchain technology, users can validate location data without depending on centralized systems for verification or validation purposes.
61 berufliches Vorwärtskommen: Die nächsten Schritte.
Tags: deutsch, career, motivation, discuss
Published: 2023-07-09 03:31:00

Moin Moin,

Ich war die letzten Wochen damit beschäftigt, über unseren bisherigen Austausch zu reflektieren, und dies in meine Pläne für ein Unternehmen einzubinden. Entsprechend habe ich mir etwas überlegt. Dies bedarf allerdings einiges an Vorarbeit. Ich denke jedoch, dass wir, die hier den Austausch gemeinsam führen, weitere Probleme identifizieren und auch gemeinsam lösen können. Was genau ich mir vorstelle und wie, erwähne ich nicht ausdrücklich, das sollte an meinen Handlungen in nächsten Monaten und Jahren deutlich werden. Falls nicht, dann muss ich mich dahingehend verbessern :-)

Der Austausch soll wieder regelmäßig stattfinden.

Also, willkommen zurück :-)
Tidbits: TailwindCSS and Next.js
Tags: beginners, devjournal
Published: 2023-07-09 02:49:30

This short journal entry sums up the stuff I've been doing the past week in my spare time. I've been going through a couple of [Dr Sahand Ghavidel](https://www.udemy.com/user/sahand-ghavidel/) video course entitled "Mastering Tailwind CSS 3.0 Build Two Dynamic Projects" where he shows how to use Tailwind to partially clone a couple of pages from Tesla and Instagram.

I then proceeded to learn from [Brad Traversy](https://www.udemy.com/courses/search/?src=ukw&q=brad+traversy) from his video course called "Tailwind CSS From Scratch - Learn by Building Projects" where he goes through 5 mini-projects and several projects.

I then started looking into Next.js and read some of the documentation and then decided to just jump in and create a repo so that I can actually start trying it's many exciting new features. Once the repo is set up, I will apply what I've learned from Tailwind to test different layouts, pages and components.

I've created a bunch of repos from this week's learnings at: [https://github.com/jenad88](https://github.com/jenad88)
Blogroll: the list of blogs that I like to read
Tags: programming, productivity, writing, computerscience
Published: 2023-07-09 02:44:10

I'm a person that likes to read a lot of things, and I have a lot of blogs that I like to read. I'll list here some of them:

## Summary

- [Personal blogs](#personal-blogs)
- [Company blogs](#company-blogs)
- [Self-improvement](#self-improvement)
- [Computer science](#computer-science)
- [Newsletters](#newsletters)
- [RSS Feeds](#rss-feeds)

## Personal blogs

- [Joel Hooks](https://joelhooks.com/)
- [Gwern Branwen](https://www.gwern.net/)
- [Drew DeVault](https://drewdevault.com/)
- [Eli Bendersky](https://eli.thegreenplace.net/)
- [Eliot Peper](https://www.eliotpeper.com/)
- [Julian Shapiro](https://www.julian.com/blog)
- [Nikita Voloboev](https://wiki.nikitavoloboev.xyz/)
- [Tom MacWright](https://macwright.com/)
- [Paul Graham](http://www.paulgraham.com/articles.html)
- [Seth Godin](https://seths.blog/)
- [Derek Sivers](https://sivers.org/blog)
- [David Perell](https://www.perell.com/blog)
- [Ben Kuhn](https://www.benkuhn.net/)
- [Alexey Guzey](https://guzey.com/)
- [Hillel Wayne](https://www.hillelwayne.com/)

## Company blogs

- [Stripe](https://stripe.com/blog)
- [Airbnb](https://medium.com/airbnb-engineering)
- [Uber](https://eng.uber.com/)
- [Netflix](https://netflixtechblog.com/)
- [Spotify](https://engineering.atspotify.com/)
- [Dropbox](https://dropbox.tech/)
- [Google](https://developers.googleblog.com/)
- [Facebook](https://engineering.fb.com/)
- [Twitter](https://blog.twitter.com/engineering/en_us.html)
- [Microsoft](https://devblogs.microsoft.com/)
- [Amazon](https://developer.amazon.com/blogs)

## Self-improvement

- [Farnam Street](https://fs.blog/)
- [James Clear](https://jamesclear.com/articles)
- [Mark Manson](https://markmanson.net/articles)
- [Minding your way](https://mindingourway.com/)
- [Ness Labs](https://nesslabs.com/blog)
- [Nat Eliason](https://www.nateliason.com/blog)
- [Scott Young](https://www.scotthyoung.com/blog/)

## Computer science

- [Julia Evans](https://jvns.ca/)
- [TK Kinoshita](https://www.iamtk.co/)
- [Dan Abramov](https://overreacted.io/)

## Newsletters

- [Hacker Newsletter](https://hackernewslettr.com/)
- [Hacker News Digest](https://hndigest.com/)
- [The Overflow](https://stackoverflow.blog/newsletter/)
- [The Changelog](https://changelog.com/newsletters)
- [ByteByteGo](https://blog.bytebytego.com/)
- [Latent Space](https://www.latent.space/)
- [The Palindrome](https://thepalindrome.org/)

## RSS Feeds

A way to group all these blogs in one place is to use a RSS reader. I use [Feedly](https://feedly.com/) to read all my RSS feeds.
If you want to get the OPML that I use to view these blogs, you can get it [here](https://gist.github.com/noghartt/53e05e6bccb41e9fd69e24fa36ec65ce).
Get API Map Key
Published: 2023-07-09 02:23:22


[Youtube](https://youtube.com/playlist?list=PL6Q9UqV2Sf1i34MsUP_1WuigH3-TLck9H)

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

https://developers.google.com/maps/documentation/android-sdk/overview

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


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


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


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


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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d8ke4jacy24hva997i66.png)
Is the AI Hype Over? OpenAI's ChatGPT Code Interpreter Takes Center Stage
Tags: ai, discuss, news
Published: 2023-07-09 02:07:06

_Greetings, friends! Ready to have your minds blown? Let's dive headfirst into the thrilling world of AI and explore OpenAI's ChatGPT's game-changing feature: the code interpreter. Buckle up!_


![mind blown](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2euqvpxav0aoshmmd0t1.gif)



In the whirlwind of AI advancements, OpenAI's ChatGPT has added a novel feature to its arsenal: a code interpreter. This innovation allows ChatGPT to write, execute, and test its own code, marking a new level of automation.

Unveiled to 20 million paying users, this feature promises to revolutionize how we interact with code. It's akin to having a skilled software developer at your beck and call. Data analysts, in particular, can use it to upload files and solve complex math problems efficiently.

Imagine needing to perform a data analysis task. Instead of spending time writing and debugging code, you could describe the task to ChatGPT, and it would handle the rest. This transforms the work of data analysts, freeing them from tedious coding tasks.

Yet, this promising feature has sparked debate. Could an AI model that writes, executes, and tests its own code lead to unchecked automation and job displacement? Could it result in software so complex that even its creators can't fully control it?

These concerns are valid but must be weighed against potential benefits. Yes, the code interpreter could take over certain tasks. But it could also free humans to tackle more creative, complex, and fulfilling work.

In the end, our perception of ChatGPT's code interpreter feature hinges largely on our perspective. It's a tool, and its impact depends on how we use it. As we navigate the AI landscape, balancing innovation with ethical standards and human-centric values is crucial.

_LMK what you think in the comments section_

![cheers](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rqt0bz913eywp7nykc1c.jpeg)
Composition vs props in React
Tags: react, props, composition
Published: 2023-07-10 06:33:13

---
title: Composition vs props in React
published: true
date: 2023-07-08 15:27:08 UTC
tags: react, props, composition
canonical_url: https://krzysztofzuraw.com/blog/2023/compositon-props-react/
---

I recently was adding support for dynamic data (meaning loaded from API) to the design system component. I started as usual - add new props indicating that for example, the `Combobox` component is `loading` or that it has its input value changed so I can hook into that and ask API. I added them to `Combobox` directly so I have more or less those props on the component level:

```tsx
<Combobox loading={true} onInputValueChanged={callAPI} />
```

At first look, it seems like this component is ok - it has all props it needs to work. But can I do better? What about having a new component for this case? So I will have:

```tsx
<Combobox /> // static data

<DynamicCombobox loading={true} onInputValueChanged={callAPI} /> // dynamic data
```

Why it is better? I think mainly because it follows React principle of composition. I can have a base combobox that shares functionality between static and dynamic. Another pro is that in the second case, it is harder to make the impossible state possible. What does it mean? If static `Combobox` does not have a `loading` prop I can't mess with it and set it to `true` when there is no call to API.

There is one more question: how do I share common parts between `Combobox` and `DynamicSelect`? I think there are at least 2 options:

- `BaseCombobox` component - it will have all common parts of combobox: input, list of items to select, etc.
- common functions, CSS classes - it is more granular as you compose your component from small pieces rather than full component
Terminal arcade!
Published: 2023-07-08 23:10:05

I made this program #1 because it would be great practice #2 codecademy said i had to do it #3 making an arcade would be a fun idea.

throughout this each game has the board printed after each turn and each function will help with the functionality of the program.

[here is the project](https://github.com/reynolds22/portfolio-proj1.py-ZR.git)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4kk4ng33j0ybiaku9oiq.png)
I am working on a context-aware storage/knowledge base platform called The Drive AI.
Tags: productivity, webdev, discuss, ai
Published: 2023-07-08 23:09:07

I recently launched an MVP of a context-aware storage/knowledge base platform called [The Drive AI](https://thedrive.ai). The crux of the app is to let you build your knowledge base by either uploading, importing or syncing your files across existing storage systems. 

After you build your knowledge base, you can easily search over them, ask ChatGPT-like questions, and get answers from your knowledge base. Additionally, you can write new content with sources drawn from your knowledge base. 

We also want to integrate a team chat feature, so that your team would have storage and communication in a single place. I would love to hear your feedback. :)
"Hello World!"
Tags: beginners, html, blog, programming
Published: 2023-07-08 21:40:36

Hey There! My name is Kristion Kim. I got accepted into the University of Oregon Coding Boot Camp and will begin to learn all the languages and steps to have a full-stack programming portfolio to help me further my interest in programming. My love for coding began my senior year in high school when I signed up to be a part of Computer Science. My introduction to the class was close to home, I found myself in a dark room with individuals who had their faces lit up only by the 1080p monitors they were glued to. The teacher was down to earth yet knowledgeable in his craft in programming and RuneScape. His teaching style wasn't filled with lectures or packets of information which I would have to figure out myself, while simultaneously pretending to know the information already just to fill that I was in the right spot. No, it was filled with demonstrations, as well as a quick analysis of what the code he just developed using Python meant and did. It was a quick and simple introduction to what we had to create and he would send us on our adventures into the coding space while lending a hand from the dark corner he resided in, no doubly on Twitter. While the work was demanding in a sense, I had more free time on my hands to complete it and move on to the next project, because homework was never done at home it was done when my teachers would go on a spiel about the basics of what we were learning to the kids who dreaded the idea of school. Coding was so satisfying to me that I found myself bringing my laptop to the airport with me to spend my downtime completing my CS assignments and going on the course to create an empty terminal to write my code to see what I could create. I understand this is a spiel of my own so I will give an overview of myself and end it there. I'm 19 years old and was supposed to study Biomedical Science at OSU but circumstances had me journey down another pathway. During my track on this new avenue I found that I would spend most of my time thinking about who I'll become and how I would do it, it shared thoughts with when I'd hop on Overwatch next so it became demanding for an unemployed individual. However, I came across an ad on social media called Free Coding which I explored for a little and found sketchy. But, because I gave social media the idea that I was into coding it shared with me the boot camp at OU which I am now enrolled in. At first, I thought I would do it to spend my free time but it gave me the idea that if I give this everything that I got both in class and out of it I could dive into a developer career which I am thrilled about because it gives me the sense of something to accomplish. So there it is a little bit of how it began, where I am at, and where I want to be. I hope this blog finds people who are also beginning a stage in programming so we can discuss topics with each other, or just discuss our interests and eventually become associates. Thank you and wish me luck!