teleren/devto huggingface dataset:
Rearrange Characters to Make Target String
Tags: leetcode, dsa, theabbie
Published: 2022-06-14 21:00:46

You are given two **0-indexed** strings `s` and `target`. You can take some letters from `s` and rearrange them to form new strings.

Return _the **maximum** number of copies of_ `target` _that can be formed by taking letters from_ `s` _and rearranging them._

**Example 1:**

**Input:** s = "ilovecodingonleetcode", target = "code"
**Output:** 2
**Explanation:**
For the first copy of "code", take the letters at indices 4, 5, 6, and 7.
For the second copy of "code", take the letters at indices 17, 18, 19, and 20.
The strings that are formed are "ecod" and "code" which can both be rearranged into "code".
We can make at most two copies of "code", so we return 2.

**Example 2:**

**Input:** s = "abcba", target = "abc"
**Output:** 1
**Explanation:**
We can make one copy of "abc" by taking the letters at indices 0, 1, and 2.
We can make at most one copy of "abc", so we return 1.
Note that while there is an extra 'a' and 'b' at indices 3 and 4, we cannot reuse the letter 'c' at index 2, so we cannot make a second copy of "abc".

**Example 3:**

**Input:** s = "abbaccaddaeea", target = "aaaaa"
**Output:** 1
**Explanation:**
We can make one copy of "aaaaa" by taking the letters at indices 0, 3, 6, 9, and 12.
We can make at most one copy of "aaaaa", so we return 1.

**Constraints:**

*   `1 <= s.length <= 100`
*   `1 <= target.length <= 10`
*   `s` and `target` consist of lowercase English letters.

**SOLUTION:**

    from collections import Counter
    
    class Solution:
        def rearrangeCharacters(self, s: str, target: str) -> int:
            ctrs = Counter(s)
            ctrtarget = Counter(target)
            mcopy = float('inf')
            for c in ctrtarget:
                mcopy = min(mcopy, ctrs[c] // ctrtarget[c])
            return mcopy
NodeJs and React Social Media Application
Published: 2022-06-14 20:57:12

I thought of sharing the link to the respository of this social media application that I'm working on.
A user can share a video,an image or make a text post.
It is powered by NodeJs, React, and MySQL database.
You can help contribute to it.
Link to live project:
[https://merllon-social.web.app/](https://merllon-social.web.app/)
Link to project repository:
[https://github.com/allenarduino/merllon_social](https://github.com/allenarduino/merllon_social)

**Screen shots**

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


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


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


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


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


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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a28ey83xdgm0hqe09uog.png)
Basics of AWS IAM: How to setup a Cloud Trail in your organization?
Tags: aws, cloudtrail, cloud, awsiam
Published: 2022-06-14 20:18:34

In this blog post, I am going to show you how to create a simple CloudTrail in AWS.

**Cloud Trail**: Cloud Trail is a service in AWS that logs in the activity of an event in an account. The logging can be done by anyone user/service/role and it generally logs management and data events. 

Cloud Trail is activated by default and can store the latest 90 days events. If you want to log the trail in an S3 bucket then we need to create a trail.

Except for global services like STS, IAM and Cloud front the cloud trail is regional.

Now let us see a simple way to create a Cloud Trail.

1. Login to you AWS account and search for "Cloud Trail" in the search Tab.



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

2) Click on the 3 bars at the Top left corner and select trails. Then click on the new trail and enter the name of the trail you wish you give. There is an option to select "Enable for all accounts in my organization" use this if you wish you log the events across your organization in a single place. This can be done only if you create this trail in your management account.



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

3) I have chosen to untick both the log file SSE KMS Encryption and log file validation. Click Next.



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

4) I have left everything as default as I only want to log Management events. 



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

5) Verify all the details mentioned in the next step and click create trail. 



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

Give a few minutes for the cloud trail to collect logs on the activity done inside the AWS account. 

6) Click on the S3 bucket to see the cloud trail logs that are generated in the account.



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

7) Over time logs get created in the S3 bucket and you can see the contents when you open them. Below is an example of the same.


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

This blog post was originally published on https://www.ganeshboggarapu.com/how-to-setup-a-cloud-trail/
NPM command aliases
Tags: webdev, node, opensource, ubuntu
Published: 2022-06-14 20:04:17

Start using **npm aliases** for the main commands of the **node** package manager, as well as popular frameworks like: Laravel Mix, VueJS, NuxtJS, ReactJS, NextJS. New version of **npm aliases** released with new `npm audit` aliases and documentation improvements like command notes and manual installation guide.

See how easy it is to work with npm now: instead of `npm install` just use `ni`, instead of `npm install --save-dev` just use `nid`, instead of global installation command `npm install -g` just use `nig`.

Build project with your favorite framework easily - replace `npm run build` with `nrb` and lote more.

## v1.0.1 release notes
Ubuntu 22.04 LTS Jammy Jellyfish release. **Slava Ukraini!**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bxhdjolqtu45bhy31wdb.png) 
### Features
- npm audit #10
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x99n7hx4ii2aaishw01w.png)

### Docs
- Add manual installation in docs #12
- Add npm dependency version #13
- Add alias notes #16
- Add telegram to author contacts #14
Basic Built-in Python Functions To Know As A Beginner
Tags: beginners, python, programming
Published: 2022-06-14 19:53:32

In python, getting familiar with built-in functions helps a lot while programming. They help in breaking big tasks into smaller chunks and increase code’s clarity. Also, big programs are broken down into smaller units thus making it easier to read, understand and debug if the need arises. In this tutorial, we’ll be taking a look at some built-in functions in python programming.[To continue reading](https://oyedeletioluwani.hashnode.dev/basic-built-in-python-functions-to-know-as-a-beginner)
What's a senior dev anyway?
Tags: career, watercooler, discuss
Published: 2022-06-14 19:37:13

Needless to say, there are many different opinions on what a senior dev is or does.

According to some people on [StackExchange](https://softwareengineering.stackexchange.com/questions/25564/when-should-you-call-yourself-a-senior-developer) a senior developer can:

- handle the entire software development life cycle, end to end
- lead others, or others look to him/her for guidance
- can self manage projects

I think this is a reasonable answer but sure enuogh people added more: 
- I would disagree with the second bullet point
- at 22-23 you should not be a senior devloper. (Why exactly?)
- Accountability
- you have had at least one project fail under your leadership
- etc

So what are the key things defining a senior dev in your opinion?
Or, if you prefer the via negativa, what is a "junior" missing to be a senior?
Sender With Largest Word Count
Tags: leetcode, dsa, theabbie
Published: 2022-06-14 19:30:40

You have a chat log of `n` messages. You are given two string arrays `messages` and `senders` where `messages[i]` is a **message** sent by `senders[i]`.

A **message** is list of **words** that are separated by a single space with no leading or trailing spaces. The **word count** of a sender is the total number of **words** sent by the sender. Note that a sender may send more than one message.

Return _the sender with the **largest** word count_. If there is more than one sender with the largest word count, return _the one with the **lexicographically largest** name_.

**Note:**

*   Uppercase letters come before lowercase letters in lexicographical order.
*   `"Alice"` and `"alice"` are distinct.

**Example 1:**

**Input:** messages = \["Hello userTwooo","Hi userThree","Wonderful day Alice","Nice day userThree"\], senders = \["Alice","userTwo","userThree","Alice"\]
**Output:** "Alice"
**Explanation:** Alice sends a total of 2 + 3 = 5 words.
userTwo sends a total of 2 words.
userThree sends a total of 3 words.
Since Alice has the largest word count, we return "Alice".

**Example 2:**

**Input:** messages = \["How is leetcode for everyone","Leetcode is useful for practice"\], senders = \["Bob","Charlie"\]
**Output:** "Charlie"
**Explanation:** Bob sends a total of 5 words.
Charlie sends a total of 5 words.
Since there is a tie for the largest word count, we return the sender with the lexicographically larger name, Charlie.

**Constraints:**

*   `n == messages.length == senders.length`
*   `1 <= n <= 104`
*   `1 <= messages[i].length <= 100`
*   `1 <= senders[i].length <= 10`
*   `messages[i]` consists of uppercase and lowercase English letters and `' '`.
*   All the words in `messages[i]` are separated by **a single space**.
*   `messages[i]` does not have leading or trailing spaces.
*   `senders[i]` consists of uppercase and lowercase English letters only.

**SOLUTION:**

    from collections import Counter
    
    class Solution:
        def largestWordCount(self, messages: List[str], senders: List[str]) -> str:
            n = len(senders)
            ctr = Counter()
            for i in range(n):
                ctr[senders[i]] += len(messages[i].split())
            return max(senders, key = lambda sender: (ctr[sender], sender))
One-Click Sign In with Next Auth
Tags: nextjs, nextauth
Published: 2022-06-14 19:23:55

In the frontend it's as simple as...

```ts
import { signIn } from "next-auth/react";

<button
  onClick={() => signIn("google", { callbackUrl: "/account" })}
>
  Sign in
</Button>
```

And your `api/auth/[...nextauth].ts` route stays the same, no extra configuration needed:

```ts
const options = {
  providers: [
    GoogleProvider({
      clientId: process.env.GOOGLE_OAUTH_CLIENT_ID,
      clientSecret: process.env.GOOGLE_OAUTH_CLIENT_SECRET,
    }),
  ],
  adapter: PrismaAdapter(prisma),
  secret: process.env.SECRET,
};

const authHandler: NextApiHandler = (req, res) => NextAuth(req, res, options);

export default authHandler;
```
CSS Variables with Global & Local Scope
Tags: css, beginners, programming, tutorial
Published: 2022-06-14 19:23:37

Hello everyone! 
It's been a long long time since I've posted anything. I am working as a Front-end Developer and suddenly, I realized that I have forgotten many **CSS** basics. So, I started learning it once again.

This blog is about **CSS Variables**.

Here I learned the usage of _CSS variables_ and how you can use them in your project. 

First of all, a CSS variable name must start with two dashes `--` and it is _case sensitive_. 
For example:

```
--blue: #1e90ff;
--red: rgb(255,0,0);
```

## Global & Local Scope

### Declaring Global CSS Variable

CSS Variables can have a **global scope** and a **local scope**. When you declare a CSS variable in a _global scope_, it can be accessed throughout the entire document. 

To create a variable with global scope, we need to declare it inside the `:root` selector. The `:root` selector matches the document's root element. We declare a global CSS variable as follows:

```js
root: {
    --blue: #1e90ff;
    --red: rgb(255, 0, 0);
    --white: #ffffff;
}
```

### Using CSS Variable in Local Scope

To create a variable with local scope, we need to declare it inside the selector that is going to use it.

The `var()` function is used to insert the value of a CSS variable. The syntax of the `var()` function is as follows: 

```js
var(name, value);
```
To use the above declared _global variables_ inside another selector we need to write it in the following way:

```js
body {
    background-color: var(--blue);
    color: var(--white);
}

button {
    background-color: var(--white);
    color: var(--red);
    border: 1px solid var(--red);
}
```
### Usefulness of CSS Variables

1. CSS variables have access to the DOM, so we can create it with both global and local scope.
2. It can be changed with JavaScript.
3. It can be changed based on media queries.
4. The best way to use CSS variables is to change the color properties of your design. You can declare some variables and use them over and over again instead of copy-pasting the same colors.

I used CSS Variables in a FreeCodeCamp Learning project to change the colors of my design and it came out like this:


![City Skyline Day](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e8k5mqutwgcswho5jwcm.png)


![City Skyline Night](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3lpc2xqdjqb6gtmuhx1p.png)

You can have a look at the code by accessing this repo:
https://github.com/SwarnaliRoy94/FreeCodeCamp-CSS-Projects/tree/main/CSSVariablesSkyline

I hope you have learned something new reading this blog. Thank you so much for your valuable time. Feel free to ask me anything in the discussion section.

Happy Coding! Happy Learning!!
Paracetamol.js💊| #141: Explica este código JavaScript
Tags: javascript, spanish, programming, webdev
Published: 2022-06-14 19:23:08

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

```js
const arr = ["a", "b", "c"];
console.log(Array.isArray(arr));
console.log(typeof arr);
```

A. `true`, `function`
B. `true`, `array`
C. `true`, `object`
D. `false`, `array`

Respuesta en el primer comentario.

---
Computer science degree is it worth it?
Tags: computerscience, career, programming
Published: 2022-06-14 19:18:11

In this article, I am going to talk about the worth of a Computer Science degree for a programming career. My expectation after finishing school. I will share my worries after finishing my first year of studies. It will be useful for people who:
- Finished school and thinking if they should study at university.
- Currently studying.
- Failed studies and are thinking to continue until graduation.

**Expectations**
After finishing school I was planning to finish university and have great work with a huge salary. I was full of hope that university will learn me everything, that I need to become a great developer. In reality, I was a kid with huge expectations.

**First impressions**
I started my studies in 2015. Met nice people with who I keep in contact even today. During the first year, I had a lot of different math, C/C++,  first steps in the programming world, etc. At the start, everything was looking fun and interesting. Later I was asking myself, how I will use this knowledge in work?

**Worries**
I was thinking the educational program will include one popular main programming language like Python, C#, PHP, JS, and Java. In my second year of studies, I was learning all mentioned technologies above (Without Python) additionally with CSS, and HTML. Looking at this solution now, I understand how bad this idea is. Sticking to one programming language is better, in this, there is more time to learn, practice the main concepts, and spend more time on projects. Also, I do not understand why universities do not include Git in university programs as a must-have. These are only my ideas on how to improve 
the educational system in universities. I am sure there are more solutions, that can improve universities/colleges.

**After graduation**
It was really hard to find the first work. Everyone in the university was talking it will be easy, but the reality is different. I was improving my technical and soft skills. I have finished a 6-month full-stack developer course at CodeAcademy. The course included a guide on how to improve your LinkedIn profile. In Lithuania, LinkedIn is useless for web developers, maybe I was unlucky. After asking my friends, the situation was the same as mine. Even after watching tutorials on how to improve my profile, nothing changed. If this topic is interesting for reading do not forget to follow me to an upcoming new article about HR and my personal, and professional improvements.

**Conclusion**
If You like studying, the university is for You. Do not expect anything for professional growth. There are many free resources available. YouTube is full of high-quality content, use it. I spent a perfect time and made nice connections. For my personal growth, it was a great experience, but not for my professional skills.

I am available on social media:
[Twitter](https://twitter.com/Oscar_Sherelis)
[LinkedIn](https://www.linkedin.com/in/oscar-sherelis)
[Instagram](https://www.instagram.com/oscar_sherelis)

If You want to support me:
https://www.buymeacoffee.com/oscarWeb
New Free Developer Security Tool of 2022!
Tags: java, python, beginners, javascript
Published: 2022-06-14 19:01:15

**Meet CodeSec by Contrast**
Secure Code with the fastest and most accurate scanner in the market. Get Immediate & actionable result. Up and running in less than 5 minutes for free!

**CodeSec makes developer security efficient and accurate by delivering the following capabilities right to the developer’s laptop, through a simple command line interface (CLI):**

- **CodeSec – SCA:** Secure vulnerable libraries in your open-source software (OSS) with lighting speed, accuracy, and actionable remediation guidance to ship code faster and create a standardized Software Bill of Materials (SBOM) to manage supply chain risk with ease. Additionally, you can secure your Github pipeline with Contrast GitHub Actions for free. [Click Here](https://github.com/marketplace/actions/contrast-security-sca) to learn more. **Supports:** Java, JavaScript, Python, Ruby, GO, PHP, and .NET

- **CodeSec – Scan:** Optimize code security for applications with fast, industry-leading (SAST) scans and actionable remediation guidance, in a simple command line interface. Additionally, you can secure your Github pipeline with Contrast GitHub Actions for free. [Click Here](https://github.com/marketplace/actions/contrast-scan-analyze)  to learn more. **Supports:** Java, JavaScript, Angular, React, JQuery, and .NET


- **CodeSec – Serverless:** Take advantage of a new ground-breaking application security tool for serverless environments in AWS Lambda functions that detects cloud-native vulnerabilities quickly and accurately while providing actionable remediation guidance. **Supports:** Java, and Python

**[Start Now For Free](https://www.contrastsecurity.com/developer/codesec/)**
4Sum
Tags: leetcode, dsa, theabbie
Published: 2022-06-14 19:00:46

Given an array `nums` of `n` integers, return _an array of all the **unique** quadruplets_ `[nums[a], nums[b], nums[c], nums[d]]` such that:

*   `0 <= a, b, c, d < n`
*   `a`, `b`, `c`, and `d` are **distinct**.
*   `nums[a] + nums[b] + nums[c] + nums[d] == target`

You may return the answer in **any order**.

**Example 1:**

**Input:** nums = \[1,0,-1,0,-2,2\], target = 0
**Output:** \[\[-2,-1,1,2\],\[-2,0,0,2\],\[-1,0,0,1\]\]

**Example 2:**

**Input:** nums = \[2,2,2,2,2\], target = 8
**Output:** \[\[2,2,2,2\]\]

**Constraints:**

*   `1 <= nums.length <= 200`
*   `-109 <= nums[i] <= 109`
*   `-109 <= target <= 109`

**SOLUTION:**

    class Solution:
        def fourSum(self, nums: List[int], target: int) -> List[List[int]]:
            n = len(nums)
            nums.sort()
            res = set()
            for i in range(n):
                a = nums[i]
                for j in range(i + 1, n - 2):
                    b = nums[j]
                    start = j + 1
                    end = n - 1
                    while start < end:
                        c = nums[start]
                        d = nums[end]
                        total = b + c + d
                        if total == target - a:
                            res.add(tuple([a, b, c, d]))
                            start += 1
                            end -= 1
                        elif total > target - a:
                            end -= 1
                        else:
                            start += 1
            return list(res)
How to set or get default timezone in PHP
Tags: php, programming, webdev, beginners
Published: 2022-06-14 18:46:05

In this tutorial, we will explain how to set or get a default timezone in PHP. This will help you to change the default timezone for all date and time in PHP

Using php built-in function **date_default_timezone_set()** and **date_default_timezone_get()** we can set and get default timezone respectively.

You can check detail article at: [https://tagstack.org/article/how-to-set-or-get-default-timezone-in-php](https://tagstack.org/article/how-to-set-or-get-default-timezone-in-php)
Island Perimeter
Tags: leetcode, dsa, theabbie
Published: 2022-06-14 18:30:41

You are given `row x col` `grid` representing a map where `grid[i][j] = 1` represents land and `grid[i][j] = 0` represents water.

Grid cells are connected **horizontally/vertically** (not diagonally). The `grid` is completely surrounded by water, and there is exactly one island (i.e., one or more connected land cells).

The island doesn't have "lakes", meaning the water inside isn't connected to the water around the island. One cell is a square with side length 1. The grid is rectangular, width and height don't exceed 100. Determine the perimeter of the island.

**Example 1:**

![](https://assets.leetcode.com/uploads/2018/10/12/island.png)

**Input:** grid = \[\[0,1,0,0\],\[1,1,1,0\],\[0,1,0,0\],\[1,1,0,0\]\]
**Output:** 16
**Explanation:** The perimeter is the 16 yellow stripes in the image above.

**Example 2:**

**Input:** grid = \[\[1\]\]
**Output:** 4

**Example 3:**

**Input:** grid = \[\[1,0\]\]
**Output:** 4

**Constraints:**

*   `row == grid.length`
*   `col == grid[i].length`
*   `1 <= row, col <= 100`
*   `grid[i][j]` is `0` or `1`.
*   There is exactly one island in `grid`.

**SOLUTION:**

    class Solution:
        def isEmpty(self, grid, i, j, m, n):
            if i < 0 or j < 0 or i >= m or  j >= n:
                return True
            if grid[i][j] == 1:
                return False
            return True
        
        def islandPerimeter(self, grid: List[List[int]]) -> int:
            m = len(grid)
            n = len(grid[0])
            perimeter = 0
            for i in range(m):
                for j in range(n):
                    if grid[i][j] == 1:
                        for x, y in [(i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1)]:
                            if self.isEmpty(grid, x, y, m, n):
                                perimeter += 1
            return perimeter