teleren/devto huggingface dataset:
Minimum Time to Complete Trips
Tags: leetcode, dsa, theabbie
Published: 2022-06-02 16:00:47

You are given an array `time` where `time[i]` denotes the time taken by the `ith` bus to complete **one trip**.

Each bus can make multiple trips **successively**; that is, the next trip can start **immediately after** completing the current trip. Also, each bus operates **independently**; that is, the trips of one bus do not influence the trips of any other bus.

You are also given an integer `totalTrips`, which denotes the number of trips all buses should make **in total**. Return _the **minimum time** required for all buses to complete **at least**_ `totalTrips` _trips_.

**Example 1:**

**Input:** time = \[1,2,3\], totalTrips = 5
**Output:** 3
**Explanation:**
- At time t = 1, the number of trips completed by each bus are \[1,0,0\]. 
  The total number of trips completed is 1 + 0 + 0 = 1.
- At time t = 2, the number of trips completed by each bus are \[2,1,0\]. 
  The total number of trips completed is 2 + 1 + 0 = 3.
- At time t = 3, the number of trips completed by each bus are \[3,1,1\]. 
  The total number of trips completed is 3 + 1 + 1 = 5.
So the minimum time needed for all buses to complete at least 5 trips is 3.

**Example 2:**

**Input:** time = \[2\], totalTrips = 1
**Output:** 2
**Explanation:**
There is only one bus, and it will complete its first trip at t = 2.
So the minimum time needed to complete 1 trip is 2.

**Constraints:**

*   `1 <= time.length <= 105`
*   `1 <= time[i], totalTrips <= 107`

**SOLUTION:**

    class Solution:
        def numTrips(self, time, t):
            trips = 0
            for el in time:
                trips += t // el
            return trips
        
        def minimumTime(self, time: List[int], totalTrips: int) -> int:
            beg = 1
            end = min(time) * totalTrips
            while beg <= end:
                mid = (beg + end) // 2
                currtrips = self.numTrips(time, mid)
                nexttrips = self.numTrips(time, mid + 1)
                if currtrips < totalTrips and nexttrips >= totalTrips:
                    return mid + 1
                elif beg == end:
                    return mid
                elif currtrips < totalTrips:
                    beg = mid
                else:
                    end = mid
Python IDEs - Replit vs VSCode
Tags: python, vscode, opensource, productivity
Published: 2022-06-02 15:43:14

So for the last two years, I've been using Replit for all my Python projects. This is because  you can code on it and host your website at the same time.

But I'd heard a lot about VSCode, so I tried to give it a go.

### 1: Storage
Replit uses Cloud Storage to save all its data, and it has a lot of storage: 500MB per project.
VSCode saves all data on your device.

### 2: Open Source
Anyone who knows what Replit is can view your code on Replit, unless you have Hacker plan (which you have to pay for).
On VSCode, all your code is private unless you use GitHub to make it open source.
GitHub on VSCode is great, as it is easy to use.
GitHub on Replit is also great, but it creates some unnecessary files, like the `__pycache__` folder, the `venv` folder and the `poetry.lock` file.

### 3: Package Installing
On Replit, when you need to import a module, it automatically installs the package without needed to use pip.
On VSCode, you have to use `pip` and manually install the package.

### 4: Hosting
On Replit, when you run code which has a front-end side to it, it automatically hosts it for free.
On VSCode, only people on the device can see the front-end side to the code.

## 5: Which Devices
Replit can run on any device you can log into Replit from.
VSCode will only run on the device you have installed the code on.

### Summary:
| Replit | VSCode |
| ------ | ------ |
| Saves on cloud storage | Saves on your device |
| Public Code | Private code |
| Creates unnecessary files on GitHub | Works perfectly on GitHub |
| Automatic Package Installing | Manual Package Installing |
| Free hosting | No hosting |
| Run on any device | Only run on one device |
Can Open-Source Exist in China? 🎙
Tags: news, opensource, ios, a11y
Published: 2022-06-02 15:36:13

In this episode of **DevNews**, our hosts speak with [Zeyi Yang](https://twitter.com/ZeyiYang), reporter at the MIT Technology Review about a recent piece he wrote titled, ["How censoring China’s open-source coders might backfire."](https://www.technologyreview.com/2022/05/30/1052879/censoring-china-open-source-backfire/).

The show also covers Salesforce employees calling for an end of the company working with the National Rifle Association as well as the accessibility features coming to the Apple ecosystem.

Enjoy a great episode!

## Listen on Apple Podcasts

{% embed https://podcasts.apple.com/us/podcast/s8-e8-can-open-source-exist-in-china-apple-unveils/id1525581923?i=1000564942739 %}

## Listen on Spotify

{% embed https://open.spotify.com/episode/7MMcbdRV2CGNq9ZTpFvHPE?si=F1bwhGfSTCK-qXHdcgaaXg %}

### **[Or listen right here on DEV](https://dev.to/devnews/s8e8-can-open-source-exist-in-china-apple-unveils-new-accessibility-features-salesforce-employees-vs-the-nra-and-more) 🎉**

***

**If you like this episode, definitely subscribe to the show!**

Happy coding news!
useEffect() makes life easier
Tags: javascript, webdev, react
Published: 2022-06-02 15:35:05

`import {useEffect} from 'react';`

While building web applications in React, we often come across tasks where we want some activity or data to be displayed when the page loads automatically. For example, I have been building web applications for a while now where it greets the user with their name and puts some important data on the page after sign in successfully. In order to this, useEffect() helps a lot. useEffect() is called when a page loads and executes code within that code block.
Why is standardized data so important in embedded systems?
Tags: microservices, opensource, devjournal, luos
Published: 2022-06-02 15:32:05

Luos is designed to have software and hardware containers. Discover our article to discover why it is essential to standardize data in embedded systems.

⏩ https://www.luos.io/blog/why-is-standardized-data-so-important-in-embedded-systems

Our community of experts on Luos and community members will be happy to exchange about projects and embedded systems, so don’t hesitate to join us on Discord!
Flower Planting With No Adjacent
Tags: leetcode, dsa, theabbie
Published: 2022-06-02 15:30:40

You have `n` gardens, labeled from `1` to `n`, and an array `paths` where `paths[i] = [xi, yi]` describes a bidirectional path between garden `xi` to garden `yi`. In each garden, you want to plant one of 4 types of flowers.

All gardens have **at most 3** paths coming into or leaving it.

Your task is to choose a flower type for each garden such that, for any two gardens connected by a path, they have different types of flowers.

Return _**any** such a choice as an array_ `answer`_, where_ `answer[i]` _is the type of flower planted in the_ `(i+1)th` _garden. The flower types are denoted_ `1`_,_ `2`_,_ `3`_, or_ `4`_. It is guaranteed an answer exists._

**Example 1:**

**Input:** n = 3, paths = \[\[1,2\],\[2,3\],\[3,1\]\]
**Output:** \[1,2,3\]
**Explanation:**
Gardens 1 and 2 have different types.
Gardens 2 and 3 have different types.
Gardens 3 and 1 have different types.
Hence, \[1,2,3\] is a valid answer. Other valid answers include \[1,2,4\], \[1,4,2\], and \[3,2,1\].

**Example 2:**

**Input:** n = 4, paths = \[\[1,2\],\[3,4\]\]
**Output:** \[1,2,1,2\]

**Example 3:**

**Input:** n = 4, paths = \[\[1,2\],\[2,3\],\[3,4\],\[4,1\],\[1,3\],\[2,4\]\]
**Output:** \[1,2,3,4\]

**Constraints:**

*   `1 <= n <= 104`
*   `0 <= paths.length <= 2 * 104`
*   `paths[i].length == 2`
*   `1 <= xi, yi <= n`
*   `xi != yi`
*   Every garden has **at most 3** paths coming into or leaving it.

**SOLUTION:**

    class Solution:
        def gardenNoAdj(self, n: int, paths: List[List[int]]) -> List[int]:
            types = [1] * n
            graph = {}
            for a, b in paths:
                graph[a - 1] = graph.get(a - 1, []) + [b - 1]
                graph[b - 1] = graph.get(b - 1, []) + [a - 1]
            visited = set()
            stack = list(range(n))
            while len(stack) > 0:
                curr = stack.pop()
                visited.add(curr)
                colors = set()
                for j in graph.get(curr, []):
                    colors.add(types[j])
                    if j not in visited:
                        stack.append(j)
                if types[curr] in colors:
                    for i in range(1, n + 1):
                        if i not in colors:
                            types[curr] = i
                            break
            return types
Building PowerShell module on Azure DevOps pipeline - step by step guide
Tags: devops, powershell, video, cicd
Published: 2022-06-02 15:04:41

{% youtube RZzmdF1iI7E %}

The World talks constantly about DevOps, CI/CI pipelines, automation - which great, but where to actually start? Especially when you've been writing PowerShell which is often used as automation language, but not actually as programming language?

In this video I'll show you how to create a build pipeline for PowerShell module, from scratch. We will start from creating a project, creating new Git repository, pushing code to repository to finally create a pipeline which takes care of building the module, versioning it and finally publishing. And I'll be writing all these steps in front of you.

If you've been writing PowerShell for some time and would like to get step closer to the DevOps world - this is great video for you! If on the other hand you've been using Azure Pipelines for other languages and need to quickly pick how to build PowerShell module, then later part of video might be useful, or even just just open repo git below, and just look at the yml file in there.

### Repo with all the files I've been writing and using during the video###
https://dev.azure.com/kprocyszyn/_git/About-PowerShell

### Video where I go in more detail about using ModuleBuilder ###
https://youtu.be/lKO_LPMfV1Y

### How to create PowerShell module and manifest ###
https://youtu.be/xPQq0ui8j78
Koko Eating Bananas
Tags: leetcode, dsa, theabbie
Published: 2022-06-02 15:00:42

Koko loves to eat bananas. There are `n` piles of bananas, the `ith` pile has `piles[i]` bananas. The guards have gone and will come back in `h` hours.

Koko can decide her bananas-per-hour eating speed of `k`. Each hour, she chooses some pile of bananas and eats `k` bananas from that pile. If the pile has less than `k` bananas, she eats all of them instead and will not eat any more bananas during this hour.

Koko likes to eat slowly but still wants to finish eating all the bananas before the guards return.

Return _the minimum integer_ `k` _such that she can eat all the bananas within_ `h` _hours_.

**Example 1:**

**Input:** piles = \[3,6,7,11\], h = 8
**Output:** 4

**Example 2:**

**Input:** piles = \[30,11,23,4,20\], h = 5
**Output:** 30

**Example 3:**

**Input:** piles = \[30,11,23,4,20\], h = 6
**Output:** 23

**Constraints:**

*   `1 <= piles.length <= 104`
*   `piles.length <= h <= 109`
*   `1 <= piles[i] <= 109`

**SOLUTION:**

    import math
    
    class Solution:
        def getTime(self, piles, k):
            if k == 0:
                return float('inf')
            currh = 0
            for el in piles:
                currh += math.ceil(el / k)
            return currh
        
        def minEatingSpeed(self, piles: List[int], h: int) -> int:
            beg = 1
            end = max(piles)
            while beg < end:
                mid = (beg + end) // 2
                currh = self.getTime(piles, mid)
                currnexth = self.getTime(piles, mid + 1)
                if currh > h and currnexth <= h:
                    return mid + 1
                if currh > h:
                    beg = mid + 1
                else:
                    end = mid
            return 1
Rails live reloading assets
Tags: ruby, rails, tutorial, webdev
Published: 2022-06-02 14:58:12

Recently I've been trying to learn more about the Rails assets pipeline. The standard documentation is very well written and has tons of tips and best practices but there's something I was still missing: **live reloading the assets**, in particular the css/scss assets.

Working with React this is the pretty standard behaviour: you update a file and you can instantly see the changes on the browser.

The Rails documentation does not explain how to obtain this behaviour and, honestly, I've never managed to make the live compilation work, so I've been killing the server, running `bundle exec rails assets:precompile` and restarting the server the whole time, until now.

Luckily, a few days ago I discovered an handy gem that solves this issue in a very simple way: [rails_live_reload](https://github.com/railsjazz/rails_live_reload).

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

## Install the rails_live_reload
Adds this gem in the `development` group, or whatever group you need, in you Gemfile
```
group :development do
  gem 'rails_live_reload'
  ...
end
```
and un `bundle install`.

## Tweak the development settings
Open the `config/environments/development.rb` file and add these lines:
```
config.assets.compile = true
config.assets.digest = false
```
the `assets.compile` option enables the live compilation through Sprockets, as stated in [the official documentation](https://guides.rubyonrails.org/asset_pipeline.html#live-compilation) while the `assets.digest` turns off the generation of digest strings for the assets names. To be honest I'm not sure why the latter is required **but if it is omitted both the live reloading and the live compilation won't work**.

## Run the css watch
We need to open a terminal window and spawn the process that watches for changes in the the css/scss files.
If you are using the `dartsass-rails` gem you can run:
```
bundle exec rails dartsass:watch
```
while if you are using `cssbunding-rails` or any other solutions you probably want to run:
```
yarn build:css --watch
```

**keep this terminal running, do not kill it.**

## The Rails server
Finally, open a new terminal and run the Rails server to enjoy the live reloading assets 😎.

Feel free to write any suggestion or question in the comments. I would be really happy if someone could explain to me, and everyone who will read this tutorial, why the `config.assets.digest = false` is required to make the auto compilation/reloading work 🤯
Bond Dev and Company.
Tags: beginners, programming, codenewbie, devjournal
Published: 2022-06-02 14:43:02

So, for me, when I accept a new career challenge, or opportunity, I usually like to have everyone know what it is that I aim for in the new company. THIS, for me, is the most essential thing to do, due to previous let-downs and wanting to NEVER go through that again.
This means, let the company know what you expect from them, what you NEED from them and what is required to have your new experience a good one.
In other words, have them know that you wish to learn this new technology or tool that the company uses, have them know that you will need to set a meeting with the manager or tech lead in order to progress through your new job tasks or get rid of any new questions that you may have. 

Another thing that you MUST make sure you understand, is how fast will they want results. IF the answer is IMMEDIATE, than there is something wrong, if you're not being hired as a Senior or high-level engineering job that will focus on high-tier projects. Otherwise, this is a clown move from the company. NO OTHER professional should be required to provide immediate results. especially if you're not Senior level. If you're not Senior level yet, than you MUST have supervision on your code and constant update schedules in order to get you up to speed the company requires from you.
Number of 1 Bits
Tags: leetcode, dsa, theabbie
Published: 2022-06-02 14:30:42

Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the [Hamming weight](http://en.wikipedia.org/wiki/Hamming_weight)).

**Note:**

*   Note that in some languages, such as Java, there is no unsigned integer type. In this case, the input will be given as a signed integer type. It should not affect your implementation, as the integer's internal binary representation is the same, whether it is signed or unsigned.
*   In Java, the compiler represents the signed integers using [2's complement notation](https://en.wikipedia.org/wiki/Two%27s_complement). Therefore, in **Example 3**, the input represents the signed integer. `-3`.

**Example 1:**

**Input:** n = 00000000000000000000000000001011
**Output:** 3
**Explanation:** The input binary string **00000000000000000000000000001011** has a total of three '1' bits.

**Example 2:**

**Input:** n = 00000000000000000000000010000000
**Output:** 1
**Explanation:** The input binary string **00000000000000000000000010000000** has a total of one '1' bit.

**Example 3:**

**Input:** n = 11111111111111111111111111111101
**Output:** 31
**Explanation:** The input binary string **11111111111111111111111111111101** has a total of thirty one '1' bits.

**Constraints:**

*   The input must be a **binary string** of length `32`.

**Follow up:** If this function is called many times, how would you optimize it?**SOLUTION:**

    class Solution:
        def hammingWeight(self, n: int) -> int:
            if n == 0:
                return 0
            return (n & 1) + self.hammingWeight(n >> 1)
3 Activities to Make You a Better Bug Hunter
Tags: security, bugbounty, productivity
Published: 2022-06-02 14:27:39

**That are not actually about hunting for bugs.**

You can do tons of things to become good at bug hunting: participating in CTFs, reading write-ups and looking for bugs being some excellent strategies!

However, **we usually neglect to mention the "other stuff"**. The activities that aren't directly about security at all! Think about it. A professional sports player usually doesn't only play their own sport. They go to the gym and build fitness. You can do the same for bounty hunting!

Here are three activities that have helped me become a better bounty hunter:

## 👨‍💻 Coding

It's all about **thinking about code**.

In writing code, architecting systems, and debugging your own mistakes, you gain insight into what thoughts go into designing a system. This insight is tremendously helpful when you're looking for bugs.

Plus, you can build tools that **automate** some of **your hacking**!

## 📚 Reading

(Web3) security is a very **diverse field**.

You will only get a superficial understanding if you never do your research and dive down that rabbit hole. Read about **how compilers work, game theory, economics, systems thinking, formal methods, traditional security, etc.**

Go down those rabbit holes! It will pay off tenfold.

## 🥗 Health

The picture of a hacker dude that stays up all night, chugs countless energy drinks, and never goes out is **wrong!**

Sleep, food, exercise, etc., all the boring stuff your mom made (or makes :p) you do. These are critical to your brain functioning and, therefore, your bounty hunting performance!

**Take good care of yourself!**
Music for programming
Tags: music, programming, productivity, html
Published: 2022-06-02 14:21:06

If you are a person that needs a focus music I have a list of website for you.


https://coderadio.freecodecamp.org/

https://musicforprogramming.net/latest/ (I think  is the best UI ever)

https://radio.x-team.com/ (I like it because It has a chat integrated)

the last, it's interesting because with that you don't have to go to _youtube and search lofi_ again. 

https://www.lofi.cafe/
How do I flag when a coworker has bad security practices?
Tags: discuss, anonymous, career
Published: 2022-06-02 14:11:00

_This is an anonymous post sent in by a member who does not want their name disclosed. Please be thoughtful with your responses, as these are usually tough posts to write. Email sloan@dev.to if you'd like to leave an anonymous comment or if you want to ask your own anonymous question._ 

***


How do I flag a coworker who doesn’t have good security practices to management in a way that doesn’t get them fired? I’ve mentioned this to them directly before and I still see them putting our security at risk on a regular basis (poor logging practices, insecure storage, etc). It's wild to me that they don't see the way they handle security as an issue, but they're a more senior team member than me, and I don't know how to go about it without reaping my own consequences.
Pascal's Triangle
Tags: leetcode, dsa, theabbie
Published: 2022-06-02 14:00:47

Given an integer `numRows`, return the first numRows of **Pascal's triangle**.

In **Pascal's triangle**, each number is the sum of the two numbers directly above it as shown:

![](https://upload.wikimedia.org/wikipedia/commons/0/0d/PascalTriangleAnimated2.gif)

**Example 1:**

**Input:** numRows = 5
**Output:** \[\[1\],\[1,1\],\[1,2,1\],\[1,3,3,1\],\[1,4,6,4,1\]\]

**Example 2:**

**Input:** numRows = 1
**Output:** \[\[1\]\]

**Constraints:**

*   `1 <= numRows <= 30`

**SOLUTION:**

    class Solution:
        def generate(self, numRows: int) -> List[List[int]]:
            tri = []
            curr = [1]
            n = 1
            for i in range(numRows):
                tri.append(curr)
                curr = [0] + curr
                n += 1
                for i in range(n - 1):
                    curr[i] = curr[i] + curr[i + 1]
            return tri