teleren/devto huggingface dataset:
Largest Number At Least Twice of Others
Tags: leetcode, dsa, theabbie
Published: 2022-06-10 01:00:46

You are given an integer array `nums` where the largest integer is **unique**.

Determine whether the largest element in the array is **at least twice** as much as every other number in the array. If it is, return _the **index** of the largest element, or return_ `-1` _otherwise_.

**Example 1:**

**Input:** nums = \[3,6,1,0\]
**Output:** 1
**Explanation:** 6 is the largest integer.
For every other number in the array x, 6 is at least twice as big as x.
The index of value 6 is 1, so we return 1.

**Example 2:**

**Input:** nums = \[1,2,3,4\]
**Output:** -1
**Explanation:** 4 is less than twice the value of 3, so we return -1.

**Example 3:**

**Input:** nums = \[1\]
**Output:** 0
**Explanation:** 1 is trivially at least twice the value as any other number because there are no other numbers.

**Constraints:**

*   `1 <= nums.length <= 50`
*   `0 <= nums[i] <= 100`
*   The largest element in `nums` is unique.

**SOLUTION:**

    class Solution:
        def dominantIndex(self, nums: List[int]) -> int:
            n = len(nums)
            if n < 2:
                return 0
            currmax = float('-inf')
            secmax = float('-inf')
            for num in nums:
                if num > currmax:
                    secmax = currmax
                    currmax = num
                elif num > secmax and num != currmax:
                    secmax = num
            return nums.index(currmax) if currmax >= 2 * secmax else -1
Hugo Partials
Tags: hugo, jamstack, beginners, tutorial
Published: 2022-06-10 00:41:00

---
canonical_url: https://cloudcannon.com/community/learn/hugo-beginner-tutorial/hugo-partials/
series: Hugo Beginner Tutorial
--- 
By [Mike Neumegen](https://cloudcannon.com)

Brought to you by [CloudCannon](https://cloudcannon.com/hugo-cms/), the Git-based CMS for Hugo.

{% embed https://www.youtube.com/watch?v=EGwLmE7hfSE %}

The idea behind a partial is simple: it’s a file that can be included into a layout to reduce repetition or simply hide some complexity. You’ll add a nav bar to your site with a partial. While you could add this logic directly to your `baseof.html`, sometimes it’s nice to split a layout up into smaller partials so you don’t need to deal with a 2000-line file.

Your first partial
------------------

Create a `partials` directory in your `layouts` directory so the final path will be `/layouts/partials/`. Inside create `nav.html` with the following contents:

```html
    <nav>
      <ul>
        <li><a href="/">Home</a></li>
        <li><a href="/about/">About</a></li>
      </ul>
    </nav>
```

That’s the navigation taken care of. Now it’s time to include it in your layout. Open `/layouts/_default/baseof.html` and add the following below `<body>`:

```html
    {{ partial "nav.html" }}
```

In Go, your single quotes are no good for strings; only double quotes designate a string.

Render your page, and there you have it.

Your second partial
-------------------

Let’s try another scenario to demonstrate the power of partials. We will simplify `baseof.html` even further by moving the contents of `<head>` to a partial. Create `/layouts/partials/meta.html` with the following content:

```html
    <meta charset="utf-8">
    <title>{{ print .Page.Title }}</title>
    {{ $style := resources.Get "sass/main.scss" | resources.ToCSS | resources.Minify }}
    <link rel="stylesheet" href="{{ $style.Permalink }}">
```

In this partial, we have variables that need the context of the current page. Lucky for you, passing the context of the current page can be done with a single character.

Open up `/layouts/_default/baseof.html` and replace the contents of `<head>` with the following:

```html
    {{ partial "meta.html" . }}
```

That little `.` at the end is passing the context of the current page, which allows the partial to print out the current page’s title. You’ll see this come up a lot in your Hugo sites, just you wait.

What’s next?
------------

In the next lesson we’ll go through the basics of Hugo templating and see how we can manipulate and iterate over data.
Quando não utilizar o spread operator
Tags: javascript, todayilearned, braziliandevs
Published: 2022-06-10 00:35:16

Hoje aprendi um problema que nunca tive (ainda bem por que claramente eu passaria horas para descobrir o que estava acontecendo), e também como solucionar esse problema.

## O problema

Quando utilizamos spread operator para clonar um objeto no javascript, ele até que funciona para os dados na primeira estrutura do objeto.

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

Porem se tivermos algum dado dentro de um objeto ele vai manter a referencia na memoria a mesma, então nesse caso o `objectCloned.job.title` e o `object.job.title` vão apontar para o mesmo endereço de memoria, significando que, caso eu altere um o outro vai ser alterado junto.

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

Nessa imagem dá para ver que só alterei o valor no objeto clonado mas essa mudança refletiu nos meus dois objetos

## A solução

Descobri duas soluções para esse problema uma mais antiga que não é uma boa pratica é usar o `JSON.stringify` e `JSON.parse` para garantir a criação de um novo objeto

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

Dessa forma da para ver que funciona e não temos mais esse compartilhamento de valores.

A segunda solução e mais recomendada é bem recente, é essa funçao de [structuredClone](https://developer.mozilla.org/en-US/docs/Web/API/structuredClone) inclusive no editor online de javascript que fiz os testes ele não conhecia essa função mas no final ele rodou ela sem problema e ficou assim 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i4ycez9lfdv4l59jix8x.png)
How to change App ID/Package Name for Android app built with React Native
Tags: reactnative, android, webdev, mobile
Published: 2022-06-10 00:25:24

When uploading a bundled version of your Android app to Google Play Console, you might need to change your Package Name / Application ID to satisfy Google Play Console rules.

If you are getting an error like the following (or something similar)

```
You need to use a different package name because "com.***.***.***" already exists in Google Play
```

Then try out the following steps.

# Change Package Name / Application ID in Android app built with React Native.

- In VSCode go to the Search

![Search](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0pwndjkox2goqtckk5h2.png)

- Enter your current Package Name / Application ID in the search text input.

NOTE: If you don't know what's your current Package Name / Application ID, you can find it within the `android/app/build.gradle` file, in the `applicationId` field. In my case, the current Package Name / Application ID is `com.papitas`.

- Enter the path to your `android` directory in the `files to include` text input.

_In my case my `android` directory lives under `projectrootdir/apps/mobile/android` yours could be different_,

![Files to include](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qh8wz5m666hxqwvc7rib.png)

This will display all the instances of the string `com.papitas`.

- Use the "Replace" text input to replace your current Package Name / Application ID for the new one.

![Replace old package name for new one](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8nnjdg0q5renbn45gxka.png)
 
That's it!
Car Use Time Recording System With Flask
Published: 2022-06-10 00:09:44


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/du11ymuv4bky7bxw1ljp.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/70l480vjg783immm224i.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hmcn9mogpf6lpm619mom.png)
car recording system And there is also a gps tracker in case of picking up students.

Repo:
https://github.com/watchakorn-18k/CarRegistration-Online

Dependencies:
- python 3.8+
- flask
- sqlite

Version History:
0.5

[✅ add car gps tracking
[✅ add view map for car gps tracking
0.4

[✅ add pagination in page show details use car
[✅ add pagination split page excel sheet
0.3

PHASE 1
[✅] edit signature user use car
[✅] show signature driver
[✅] add signature driver to excel
[✅] add page select-car
PHASE 2
[✅] add sqlite3 column license_ID
[✅] add input license_ID
[✅] add license_ID to excel
[✅] download to excel spilt with license_ID
PHASE 3
[✅] add system login
[✅] add system register
[✅] manager session
[✅] optimize session login
[✅] customize ui icon
[✅] split session for admin
PHASE 4
[✅] add system edit profile name and password
0.2

PHASE 1
[✅] edit bug delete car
[✅] Add number order sort
[✅] edit bug value mileage total car
PHASE 2
[✅] split code Download Report To Excel because of code too long
[✅] split code crop image because of it's not about this master code.
[✅] edit add image to table excel
0.1

Initial Release
Check If It Is a Good Array
Tags: leetcode, dsa, theabbie
Published: 2022-06-10 00:00:43

Given an array `nums` of positive integers. Your task is to select some subset of `nums`, multiply each element by an integer and add all these numbers. The array is said to be **good** if you can obtain a sum of `1` from the array by any possible subset and multiplicand.

Return `True` if the array is **good** otherwise return `False`.

**Example 1:**

**Input:** nums = \[12,5,7,23\]
**Output:** true
**Explanation:** Pick numbers 5 and 7.
5\*3 + 7\*(-2) = 1

**Example 2:**

**Input:** nums = \[29,6,10\]
**Output:** true
**Explanation:** Pick numbers 29, 6 and 10.
29\*1 + 6\*(-3) + 10\*(-1) = 1

**Example 3:**

**Input:** nums = \[3,6\]
**Output:** false

**Constraints:**

*   `1 <= nums.length <= 10^5`
*   `1 <= nums[i] <= 10^9`

**SOLUTION:**

    class Solution:
        def gcd(self, a, b):
            while b:
                a, b = b, a % b
            return a
        
        def isGoodArray(self, nums: List[int]) -> bool:
            n = len(nums)
            curr = nums[0]
            for i in range(1, n):
                curr = self.gcd(curr, nums[i])
                if curr == 1:
                    return True
            return curr == 1
    
    # class Solution:
    #     def gcd(self, a, b):
    #         while b:
    #             a, b = b, a % b
    #         return a
        
    #     def isGoodArray(self, nums: List[int]) -> bool:
    #         n = len(nums)
    #         paths = [([i], nums[i]) for i in range(n)]
    #         i = 0
    #         while i < len(paths):
    #             curr, currgcd = paths[i]
    #             if currgcd == 1:
    #                 return True
    #             for j in range(curr[-1] + 1, n):
    #                 paths.append((curr + [j], self.gcd(currgcd, nums[j])))
    #             i += 1
    #         return False
Dual Boot Grub-Customizer
Published: 2022-06-09 23:54:23

It took me a while to figure this out. I always had Windows Boot Manager on my grub menu, but when I added a theme. It disappeared.

To fix this:

In the terminal

sudo os-prober #if it detects it then run

update-grub

if update-grub isn't found. Just install it

sudo pacman -S update-grub
yay -S update-grub

I got a warning that os-prober won't detect it when I ran the command.
I would go to 

/etc/default/grub (this is a file) you need to edit it

GRUB_DISABLE_OS_PROBER=false

just uncomment it and save.

Try again.

It should work now.
How's your relationship with StackOverflow?
Tags: discuss
Published: 2022-06-09 23:50:44

Every time I discover a new technology, I like to make a silly small project with it. This time, I created [Discovr](https://discovr-ashen.vercel.app/) or, how I described it: "Just an excuse to learn SolidJS". The Tech Stack was TypeScript, SolidJS, Vite, Vitest and Testing Library. To sum up: I wanted to learn new things.

While dropping characters into VSCode, I, of course, ran into issues. My gut feeling was google it and open the first SO or Doc entry, and so I did and... No answers. In the end I got over the problem the hard way: reading source code and muddling through, something I don't do too often.

Everything went well. But at some point I considered leaving the project aside and coming back once there was a tutorial, answer or doc entry for my problem (which goes against the initial purpose of exploring new technologies). At the end, I got myself thinking if I was too used to having answers handed on a silver platter instead of digging for answers.

What do you guys think? Is StackOverflow-dependency a thing? Does using it too much affect learning? What's your opinion about tutorials and "ready-to-use" answers? Personally, I feel like they surely help a lot in the beginning, but as you start digging deeper into something, it won't suffice anymore
The 2 Things You Ask Your Team When You Pass $1B w/ Hippo’s VP of Engineering
Tags: podcast, leadership, devops, productivity
Published: 2022-06-09 23:25:12

When you think of a billion-dollar tech company, you probably imagine rooms full of monitors with dashboards and non-stop data streams.

Well, after talking to Hippo - a certified unicorn and newly minted giant in the insurance industry - we realized this couldn’t be further from the truth.

Mike Gordon, VP of Engineering at [Hippo](https://www.hippo.com/), sat down with [Dev Interrupted](https://devinterrupted.com/podcasts/) to chat about what it’s actually like to run the dev teams powering a company that just passed a $1 billion valuation.

His insights about what actually matters to him were amazing for how simple, focused and – brilliant – they are.

A great conversation on what’s important to a company re-writing the rules of insurance, Mike Gordon is by far one of the most thoughtful-yet-pragmatic minds we’ve had on yet.

{% spotify spotify:episode:0ZnCZR6HtwZUUhpaPenhz4 %}
## Episode Highlights Include:
* (1:56) From West Point to VP of Engineering
* (5:22) Best thing about metrics is "Retiring dumb stuff"
* (14:32) Reducing 'extreme face time'
* (19:23) Burnup charts vs Burndown charts
* (23:56) The two most important questions
* (35:24) Mike's four 'Golden Metrics'

## Engineering Insights before anyone else....
_The Weekly Interruption is a newsletter designed for engineering leaders, by engineering leaders. We get it. You're busy. So are we. That's why our newsletter is light, informative and oftentimes irreverent. No BS or fluff. Each week we deliver actionable advice to help make you - whether you're a CTO, VP of Engineering, team lead or IC  - a better leader._

_It's also the best way to stay up-to-date on all things Dev Interrupted - from our podcast, to trending articles, [Interact](https://devinterrupted.com/event/interact/) & our community [Discord](https://discord.com/invite/devinterrupted)._

***[Get interrupted.](https://devinterrupted.com/subscribe/)***

![Dev Interrupted](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v5bjf41umkcrfauggf9m.png)
Day 570 : The Night
Tags: hiphop, code, coding, lifelongdev
Published: 2022-06-09 23:11:20

_liner notes_:
- Professional : Thursday is meetings day. So many meetings haha. I was able to publish the new version of Web Components that I updated this week. Then I verified that the application using them still worked. Word. Also interacted with some folks in the community channel.

- Personal : Tried to play around with the new technology some more. I tried a couple of demos and couldn't get them to really work. Then I loaded the project from the library's repo onto my local machine, ran it, but still couldn't get it to work. Not sure if I can use it for future projects. Went through some tracks for the radio show. Ended the night watching the first episode of "Ms Marvel" on Disney+.

![A river flowing through a forest in Oregon, United States with a fallen tree across the river](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uvowlqf8wyhx9daxin6m.jpg)

Going to go through more tracks for the radio show and start putting together the playlist. Maybe work on my next side project.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube bho9pAQXj9Q %}
FastAPI: The High-Performance Python Framework for Building APIs
Tags: python, fastapi, api, performance
Published: 2022-12-26 14:37:20


---
title: FastAPI: The High-Performance Python Framework for Building APIs
published: true
date: 2022-06-09 23:04:44 UTC
tags: python,fastapi,api,performance
canonical_url: https://blog.jjdiaz.dev/fastapi-the-high-performance-python-framework-for-building-apis
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gu4bebxhglb3sw5nkvhn.png
---
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints. One of the key features of FastAPI is its automatic OpenAPI validation and documentation, which allows you to automatically generate interactive documentation for your API using Swagger UI. FastAPI is built on top of Starlette, which is a lightweight ASGI framework, and is designed to be easy to use and to scale.

To get started with FastAPI, you will need to install the FastAPI package using `pip`. You can then create a new FastAPI application by defining a Python function that takes in an `FastAPI` object and uses it to define your API endpoints.

Here is an example of a simple FastAPI application:

```
from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def read_root():
    return {"Hello": "World"}

```

This example defines a single endpoint at the root path (`/`) that returns a JSON object containing the message "Hello World".

To run this application, you can use the `uvicorn` ASGI server, which is automatically installed with FastAPI. Simply run the following command:

```
uvicorn main:app --reload

```

This will start the server and you should be able to access the endpoint at `http://localhost:8000/`.

FastAPI also includes support for dependency injection, which allows you to easily manage the dependencies of your application and make them available to your API functions. This can be particularly useful for managing database connections or other resources that you need to use in multiple places in your application.

I hope this gives you a good overview of FastAPI and how to get started with it.

Enjoy!
Hiring - Senior DevOps Eng
Tags: devops, job, hiring, career
Published: 2022-06-09 22:51:03

[Shop-Ware](http://www.shop-ware.com) is seeking a Senior DevOps Engineer to add to our team. 

We are Series-A funded and growing quickly. We're looking for someone who will grow with us over the next several years. 

Fully-remote - US-based only please. $140-165K/year plus equity and benefits.

For more info, please contact Nicole at Nicole.Jeans@shop-ware.com.
Lead Engineers (FE & FS)
Tags: job, career, hiring, ruby
Published: 2022-06-09 22:48:12

[Shop-Ware](http://www.shop-ware.com) is a series-a software company delivering saas solutions to automotive repair shops across the globe. We are rapidly growing and seeking an additional **Lead Front-end Engineer** (React) as well as a **Lead Fullstack Engineer** (Ruby on Rails) to join our growing dev team (company size is 100). 

We are also seeking a **Senior DevOps Engineer** and a **Principal Backend Developer** for our Platform team. 

Comp range is based on experience and location. Depending on role the range is $160-225K. 

Fully remote - US-based candidates only plz.

If you're interested in learning more, please contact nicole at nicole.jeans@shop-ware.com
GitLab Moves to AlmaLinux as Supported Platform
Tags: gitlab, almalinux, linux, opensource
Published: 2022-06-09 22:40:08

[GitLab](https://about.gitlab.com/) has switched from CentOS 8 to AlmaLinux as a supported platform. CentOS itself reached end of life (EOL) on December 31, 2021, and enterprise users in multiple industries are looking at alternatives.

GitLab provides a DevOps platform that empowers organizations to maximize the overall return on software development by delivering software faster and efficiently, while strengthening security and compliance. GitLab has an estimated 30 million+ registered users (both Paid and Free) from startups to global enterprises.

“With CentOS going EOL, we needed to choose a build platform to replace our Centos8 build machines. Omnibus GitLab is a way to package different services and tools required to run GitLab, so that most users can install it without laborious configuration. We needed a ‘boring’ solution, and AlmaLinux was asked for by our users,” said DJ Mountney, Engineering Manager, Distribution Build at GitLab.

AlmaLinux is a community owned and governed, forever-free enterprise grade Linux distribution that provides a robust production platform. AlmaLinux is 1:1 binary compatible with RHEL. The release of AlmaLinux 8.5 was within 48 hours of the Red Hat Enterprise Linux (RHEL) 8.5 release, cementing AlmaLinux’s position as a CentOS alternative and delivering on its promise of timely releases for the community. Recently, AlmaLinux has also recently surpassed 1 Million Docker pulls, released a build for the PowerPC architecture and is working on additional architecture support for s390x as well as the next major version release.

“AlmaLinux is very excited to be the stage to GitLab’s rockstar, a product which means so much to and is trusted by millions of developers across the world,“ said Jack Aboutboul, community manager for AlmaLinux. “It’s been very validating for us to see widespread developer adoption and GitLab makes us especially proud since it empowers developers to do their best work every single day. They are true friends of the Open Source community, and we are glad that our ‘boring’ solution will help give rise to the next exciting thing.”

GitLab Resources for Using AlmaLinux

* [Install self-managed GitLab for AlmaLinux](https://about.gitlab.com/install/#almalinux-8) - You can download, install and maintain your own GitLab instance using AlmaLinux
* [GitLab installation minimum requirements](https://docs.gitlab.com/ee/install/requirements.html)
Paracetamol.test.js🧪| #1: Testea este código JavaScript
Tags: javascript, testing, jest, webdev
Published: 2022-06-09 22:38:56

## **<center>Testea el siguiente código JavaScript</center>**
#### <center>**Dificultad:** <mark>Básico</mark></center>

```js
const restar = (x, y) => {
  return x - y;
};

test("5 - 5 es 0", () => {
  const res = restar(5, 5);
  expect(res).toBe(0);
});
```

A. `❌ FAIL tests, 5 - 5 es 0`
B. `✅ PASS tests, 5 - 5 es 0`

Respuesta en el primer comentario.

---
Subsets
Tags: leetcode, dsa, theabbie
Published: 2022-06-09 22:30:39

Given an integer array `nums` of **unique** elements, return _all possible subsets (the power set)_.

The solution set **must not** contain duplicate subsets. Return the solution in **any order**.

**Example 1:**

**Input:** nums = \[1,2,3\]
**Output:** \[\[\],\[1\],\[2\],\[1,2\],\[3\],\[1,3\],\[2,3\],\[1,2,3\]\]

**Example 2:**

**Input:** nums = \[0\]
**Output:** \[\[\],\[0\]\]

**Constraints:**

*   `1 <= nums.length <= 10`
*   `-10 <= nums[i] <= 10`
*   All the numbers of `nums` are **unique**.

**SOLUTION:**

    class Solution:
        def subsets(self, nums: List[int]) -> List[List[int]]:
            n = len(nums)
            subsets = []
            for mask in range(1 << n):
                subset = []
                for i in range(n):
                    if mask & 1 << i:
                        subset.append(nums[i])
                subsets.append(subset)
            return subsets