teleren/devto huggingface dataset:
Find Smallest Letter Greater Than Target
Published: 2022-12-06 15:01:41

[Find Smallest Letter Greater Than Target](https://leetcode.com/problems/find-smallest-letter-greater-than-target/description/)

```js
/**
 * @param {character[]} letters
 * @param {character} target
 * @return {character}
 */
var nextGreatestLetter = function(letters, target) {
    let left = 0; // sets left index
  let right = letters.length; // sets max right index

  while (left < right) {
    let mid = Math.floor((left + right) / 2);

    if (target < letters[mid]) {
      // letters[mid] is greater than our target so we set our
      // right index to the mid index
      right = mid;
    } else {
      // if letters[mid] > target then we set left index to mid + 1
      left = mid + 1;
    }
  }
  // edge case when we knw that left pointer has reached at the end of list means smallest character not available
  if(left === letters.length){
    return letters[0]
  }
  return letters[left];
};

```
AZ-400: Analyze metrics
Published: 2022-12-06 14:58:18

[Return to Exam Guide](https://dev.to/aidutcher/azure-devops-az-400-study-guide-exam-guide-outline-17dm)

- Inspect distributed tracing by using Application Insights
- Inspect application performance indicators
- Inspect infrastructure performance indicators, including CPU, memory, disk, and network
- Identify and monitor metrics by using Application Insight
- Interrogate logs using basic Kusto Query Language (KQL) queries
Setup GraphQL And Firebase Functions API
Tags: node, graphql, firebasefunctions
Published: 2022-12-06 14:57:26

To create a GraphQL Node.js and Firebase functions API with TypeScript and Yarn to post and get blog posts for users, follow these steps:

Install the necessary dependencies using Yarn. This includes the GraphQL and Firebase dependencies, as well as TypeScript and any other necessary libraries:
```bash
yarn add graphql apollo-server-express firebase-admin @types/graphql @types/firebase-admin
```
Create a new file called server.ts and import the necessary libraries:
```bash
import { ApolloServer } from 'apollo-server-express';
import { FirebaseAdmin, Firestore } from 'firebase-admin';
import { buildFederatedSchema } from '@apollo/federation';
```
Initialize the Firebase app and connect to the Firestore database:
```bash
const firebaseApp = FirebaseAdmin.initializeApp({
  credential: FirebaseAdmin.credential.cert(serviceAccount),
  databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
});
const firestore = firebaseApp.firestore();
```

Define the GraphQL schema for the blog post type, including fields for the title, content, and author:
```bash
const typeDefs = gql`
  type BlogPost {
    id: ID!
    title: String!
    content: String!
    author: String!
  }

  type Query {
    blogPosts: [BlogPost]
  }

  type Mutation {
    createBlogPost(title: String!, content: String!, author: String!): BlogPost
  }
`;
```
Implement the resolvers for the GraphQL queries and mutations. These will be used to fetch and store data in the Firestore database:
```bash
const resolvers = {
  Query: {
    blogPosts: async () => {
      const blogPostSnapshot = await firestore.collection('blog_posts').get();
      return blogPostSnapshot.docs.map((doc) => doc.data());
    }
  },
  Mutation: {
    createBlogPost: async (parent, args) => {
      const { title, content, author } = args;
      const blogPost = {
        title,
        content,
        author
      };
      const blogPostRef = await firestore.collection('blog_posts').add(blogPost);
      return {
        ...blogPost,
        id: blogPostRef.id
      };
    }
  }
};
```
Create the Apollo server and pass in the schema and resolvers. Also, enable the GraphQL Playground for testing:
```bash
const server = new ApolloServer({
  schema: buildFederatedSchema([{ typeDefs, resolvers }]),
  playground: true
});
```
Create the Firebase function that will handle requests to the GraphQL API. This function will be triggered when a user makes a request to the API endpoint:
```bash
exports.graphql = functions.https.onRequest(server);
```
Test the API using the GraphQL Playground. You should be able to create and fetch blog posts using the provided queries and mutations.
With these steps, we have created a minimal GraphQL API with firebase functions and Nodejs. Next we will add more functionalities to the API

Watch out for the next Article in the series.
AZ-400: Configure monitoring for a DevOps environment
Published: 2022-12-06 14:55:25

[Return to Exam Guide](https://dev.to/aidutcher/azure-devops-az-400-study-guide-exam-guide-outline-17dm)

- Configure and integrate monitoring by using Azure Monitor
- Configure and integrate with monitoring tools, such as Azure Monitor and Application Insights
- Manage access control to the monitoring platform
- Configure alerts for pipeline events
AZ-400: Automate security and compliance scanning
Published: 2022-12-06 14:51:49

[Return to Exam Guide](https://dev.to/aidutcher/azure-devops-az-400-study-guide-exam-guide-outline-17dm)

- Automate analysis of source code by using GitHub code scanning, GitHub secrets scanning, pipeline-based scans, and SonarQube
- Automate security scanning, including container scanning and OWASP ZAP
- Automate analysis of licensing, vulnerabilities, and versioning of open-source components by using WhiteSource Bolt and GitHub Dependency Scanning
How to read file and return as array of string or number as generic type
Tags: typescript
Published: 2022-12-06 14:49:05

Actually we can write 2 functions: `readFileAsArrayOfNumber` and `readFileAsArrayOfString`, but I'm too lazy to do that.

Here the solution to read a file and convert it into array of generic type (string or number).

```ts
function readFile<T>(filePath: string): T[] {
  const contents = fs.readFileSync(filePath, 'utf-8')
  return contents.split(/\r?\n/).map(line => {
    const parsedNumber = parseInt(line, 10)
    if (!isNaN(parsedNumber)) {
      return parsedNumber as T
    }

    return line as T
  })
}
```

Usage `readFile<string>(filePath)` or `readFile<number>(filePath)`
AZ-400: Design and implement a strategy for managing sensitive information in automation
Published: 2022-12-06 14:48:36

[Return to Exam Guide](https://dev.to/aidutcher/azure-devops-az-400-study-guide-exam-guide-outline-17dm)

- Implement and manage service connections
- Implement and manage personal access tokens
- Implement and manage secrets, keys, and certificates by using Azure Key Vault, GitHub secrets, and Azure Pipelines secrets
- Design and implement a strategy for managing sensitive files during deployment
- Design pipelines to prevent leakage of sensitive information
AZ-400: Maintain pipelines
Published: 2022-12-06 14:45:20

[Return to Exam Guide](https://dev.to/aidutcher/azure-devops-az-400-study-guide-exam-guide-outline-17dm)

- Monitor pipeline health, including failure rate, duration, and flaky tests
- Optimize pipelines for cost, time, performance, and reliability
- Analyze pipeline load to determine agent configuration and capacity
- Design and implement a retention strategy for pipeline artifacts and dependencies
AZ-400: Design and implement infrastructure as code (IaC)
Published: 2022-12-06 14:42:55

[Return to Exam Guide](https://dev.to/aidutcher/azure-devops-az-400-study-guide-exam-guide-outline-17dm)

- Recommend a configuration management technology for application infrastructure
- Implement a configuration management strategy for application infrastructure, including IaC
- Define an IaC strategy, including source control and automation of testing and deployment
- Design and implement desired state configuration for environments, including Azure Automation State Configuration, Azure Resource Manager, Bicep, and Azure Policy guest configuration
AZ-400: Design and implement deployments
Published: 2022-12-06 14:38:34

[Return to Exam Guide](https://dev.to/aidutcher/azure-devops-az-400-study-guide-exam-guide-outline-17dm)

- Design a deployment strategy, including blue/green, canary, ring, progressive exposure, feature flags, and A/B testing
- Design a pipeline to ensure reliable order of dependency deployments
- Plan for minimizing downtime during deployments by using VIP swap, load balancer, and rolling deployments
- Design a hotfix path plan for responding to high-priority code fixes
Implement load balancing for deployment, including Azure Traffic Manager and the Web Apps feature of Azure App Service
Browser Testing With Laravel Dusk
Tags: php, automationtesting, laravel, laravelframework
Published: 2022-12-10 00:41:44

---
title: Browser Testing With Laravel Dusk
published: true
date: 2022-12-06 14:35:15 UTC
tags: php,automationtesting,laravel,laravelframework
canonical_url: https://blog.devgenius.io/browser-testing-with-laravel-dusk-aeef2e8b30f8
---

[![](https://cdn-images-1.medium.com/max/688/1*Ogde7GbJZPgN8vegGjkWfA.png)](https://blog.devgenius.io/browser-testing-with-laravel-dusk-aeef2e8b30f8?source=rss-17217f29618a------2)

Laravel creates an admin panel from scratch — Part 17

[Continue reading on Dev Genius »](https://blog.devgenius.io/browser-testing-with-laravel-dusk-aeef2e8b30f8?source=rss-17217f29618a------2)
Advent of Code 2022 Day 6
Tags: adventofcode, rust
Published: 2022-12-06 14:34:52

---
title: "Advent of Code 2022 Day 6"
published: true
description: "Advent of Code 2022 Day 6: Tuning Trouble"
tags: 
- "adventofcode"
- "rust"
series: "Advent of Code 2022"
canonical_url: "https://nickymeuleman.netlify.app/garden/aoc2022-day06"
---

## Day 6: Tuning Trouble

https://adventofcode.com/2022/day/6

> TL;DR: [my solution in Rust](https://github.com/NickyMeuleman/scrapyard/blob/main/advent_of_code/2022/src/day_06.rs)

Today we get a communication device from an elf.

A stream of characters get sent to the device.
Your input is the stream it receives.

An example input looks like this:

```txt
mjqjpqmgbljsphdztnvjfqwrcgsmlb
```

## Part 1

The start of a **packet-marker** is the first sequence of **4** characters that are all different.

The question asks to find how many characters had to be checked when we detect the first marker.

I looped over sliding windows of size 4.
For each window, I check if all characters in it are unique.

To check if all characters in a window are unique,
I loop through the window and check if the character at that point exists in the window so far.

```rust
window
    .iter()
    .enumerate()
    .all(|(idx, c)| !window[..idx].contains(c))
```

> I could have also checked for uniqueness differently:
If [a set](https://en.wikipedia.org/wiki/Set_(abstract_data_type)) of a window has the same length as the window itself, all items in that window are unique.

> ```rust
window.iter().collect::<HashSet<char>>().len() == window.len()
```

The first window that passes that check is the first marker.

The index of that window is the beginning of that 4 character marker.

Add 4 to that index to find how many characters have been received up to that point.

```rust
pub fn part_1() -> usize {
    let input = std::fs::read_to_string("src/day06.txt").unwrap();

    input.as_bytes()
        .windows(4)
        .position(|window| {
            window
                .iter()
                .enumerate()
                .all(|(idx, c)| !window[..idx].contains(c))
        })
        .unwrap()
        + 4
}
```

## Part 2

The start of a **message** is the first sequence of **14** characters that are all different.

The question asks to find how many characters had to be checked when we detect the first message.

This code is identical to part1, but that constant of 4 is now 14.

```rust
pub fn part_2() -> usize {
    let input = std::fs::read_to_string("src/day06.txt").unwrap();

    input.as_bytes()
        .windows(14)
        .position(|window| {
            window
                .iter()
                .enumerate()
                .all(|(idx, c)| !window[..idx].contains(c))
        })
        .unwrap()
        + 14
}
```
AZ-400: Design and implement pipelines
Published: 2022-12-06 14:34:45

[Return to Exam Guide](https://dev.to/aidutcher/azure-devops-az-400-study-guide-exam-guide-outline-17dm)

- Select a deployment automation solution, including GitHub Actions and Azure Pipelines
- Design and implement an agent infrastructure, including cost, tool selection, licenses, connectivity, and maintainability
- Develop and implement pipeline trigger rules
- Develop pipelines, including classic and YAML
- Design and implement a strategy for job execution order, including parallelism and multi-stage
- Develop complex pipeline scenarios, such as conatinerized agents and hybrid
- Configure and manage self-hosted agents, including virtual machine (VM) templates and containerization
- Create reusable pipeline elements, including YAML templates, task groups, variables, and variable groups
- Design and implement checks and approvals by using YAML environments
Top 7 Featured DEV Posts from the Past Week
Tags: top7
Published: 2022-12-06 14:33:46

---
title: Top 7 Featured DEV Posts from the Past Week
published: true
description: A round up of the most-read and most-loved contributions from the community this past week
tags: icymi 
cover_image: https://thepracticaldev.s3.amazonaws.com/i/sfwcvweirpf2qka2lg2b.png
---

_Every Tuesday we round up the previous week's top posts based on traffic, engagement, and a hint of editorial curation. The typical week starts on Monday and ends on Sunday, but don't worry, we take into account posts that are published later in the week._ 

## Writing a Technical Blog

In this article, @abbeyperini offers up a succinct, helpful guide to writing a technical blog post. Keep these tips in mind next time you're looking to craft a post!

{% embed https://dev.to/abbeyperini/writing-a-technical-blog-79o %}


## Native Typing for JavaScript

Is native typing headed for JS? @christopherkade has been keeping eyes on TC39 and recent moves on the Type Annotations proposal signal that it is. So, what's this mean for the future of JavaScript and TypeScript? 

{% embed https://dev.to/christopherkade/goodbye-typescript-hello-native-typing-for-javascript-3ee1 %}


## Make your GitHub Profile Shine

Learn how to make your GitHub profile stand out and why it's important to do so thanks to @shubhicodes' fantastic guidance here.

{% embed https://dev.to/shubhicodes/why-your-github-profile-should-stand-out-20p3 %}


## Technical Storytelling at Its Finest

"There is unrealized potential for making stories about code more expressive and edifying." @robole makes a solid case for improving technical documentation, offering up plenty of examples with commentary to get the creative wheels turning.  

{% embed https://dev.to/robole/want-to-create-attractive-interactive-docs-use-these-amazing-documentation-tools-and-examples-562l %}


## Fine-Grained Reactive Performance

With @modderme123 as our guide, we'll explore some of the different algorithmic approaches to fine-grained reactivity, learn about Milo's library Reactively, and benchmark three libraries to compare performance.

{% embed https://dev.to/modderme123/super-charging-fine-grained-reactive-performance-47ph %}


## Web Font Optimization

In this article, @alex_barashkov shares advanced techniques to make your site faster and create better UX by using web fonts.

{% embed https://dev.to/alex_barashkov/advanced-web-font-optimization-techniques-2n1f %}


## Dear Tech Recruiter...

Got another message from a clueless tech recruiter? Frustrated with receiving message after message, @eevajonnapanula crafted a response to call out to these folks the many ways they're getting it wrong and how they might improve. 

{% embed https://dev.to/eevajonnapanula/hey-tech-recruiter-here-are-some-tips-from-a-developer-4hl8 %}


_That's it for our weekly Top 7 for this Tuesday! Keep an eye on dev.to this week for daily content and discussions...and be sure to keep an eye on this series in the future. You might just be in it!_
AZ-400: Design and implement a package management strategy
Published: 2022-12-06 14:30:45

[Return to Exam Guide](https://dev.to/aidutcher/azure-devops-az-400-study-guide-exam-guide-outline-17dm)

- Design a package management implementation that uses Azure Artifacts, GitHub Packages, NuGet, and npm
- Design and implement package feeds, including upstream sources
- Design and implement a dependency versioning strategy for code assets and packages, including semantic versioning and date-based
- Design and implement a versioning strategy for pipeline artifacts
Dart'ta const ve final ifadeleri arasındaki fark nedir?
Tags: flutter, dart, const, final
Published: 2022-12-06 14:28:33

Dart'ta “const” ve “final” anahtar kelimeleri arasındaki fark nedir?

Fark, belleğin nasıl tahsis edildiği ile ilgilidir.
const değişkenleri derleme zamanında(compile time) değerlendirilirken final değişkenler çalışma zamanında(runtime) değerlendirilir.

const değişkenleri sabit bir değerle başlatılmalıdır, oysa final değişkenler çalışma zamanında belirlenen bir değerle başlatılabilir.

const değişkenlerin değeri ilan edilir edilmez belirlenir. Başlatıldıktan sonra değerini kullanmasanız bile bellekte yer kaplamaya devam eder. final değişkenleri ise tembel(lazily) olarak değerlendirilir, yani değerleri ilk kez erişilene kadar belirlenmez.

Const değişkenlerin birkaç ilginç özelliği ve kısıtlaması vardır:

Derleme zamanında hesaplanabilen verilerden oluşturulmaları gerekir. Bir const nesnesinin çalışma zamanında hesaplamanız gereken hiçbir şeye erişimi yoktur. 1 + 2 geçerli bir const ifadesidir, ancak new DateTime.now() değildir.

Bir const listeniz varsa, içindeki her şey de const olmalıdır.


Flutter'da const ve final'ı nasıl kullanabileceğinize dair bir örnek:
```
const int maxAttempts = 3;  // Compile-time constant
final random = Random();  // Runtime constant

void main() {
 // maxAttempts süresine kadar oturum açma girişimi
  for (int i = 0; i < maxAttempts; i++) {
    // 1 ile 10 arasında rastgele bir sayı üret
    final password = random.nextInt(10) + 1;
    if (attemptLogin(password)) {
      break;
    }
  }
}

```

Bu örnekte maxAttempts, const anahtar sözcüğü kullanılarak bildirilen bir derleme zamanı sabitidir. Değeri derleme zamanında belirlenir ve çalışma zamanında değiştirilemez.


Öte yandan, random, final anahtar sözcüğü kullanılarak bildirilen bir çalışma zamanı sabitidir. İlk defa erişilene kadar değeri belirlenmez ve başlatıldıktan sonra değiştirilemez.

Genel olarak, derleme zamanında bilinen değerler için const, çalışma zamanında belirlenen değerler için final kullanmalısınız. Bu, derleyicinin kodunuzu optimize etmesine ve çalışma zamanında gereksiz hesaplamalardan kaçınmasına olanak tanır.

Kaynaklar
[geeksforgeeks](https://www.geeksforgeeks.org/dart-const-and-final-keyword/#:~:text=The%20only%20difference%20between%20final,considered%20frozen%20and%20completely%20immutable.)
[openai](https://chat.openai.com/chat)
[flutteragency](https://flutteragency.com/difference-between-the-const-and-final-keywords/)
AZ-400: Design and implement pipeline automation
Published: 2022-12-06 14:28:05

[Return to Exam Guide](https://dev.to/aidutcher/azure-devops-az-400-study-guide-exam-guide-outline-17dm)

- Integrate pipelines with external tools, including dependency scanning, security scanning, and code coverage
- Design and implement quality and release gates, including security and governance
- Design integration of automated tests into a pipeline
- Design and implement a comprehensive testing strategy
- Implement orchestration of tools, such as GitHub Actions and Azure Pipelines
Hyperiondev bootcamp - Day 2
Tags: webdev, codenewbie, beginners
Published: 2022-12-06 14:24:43

**Welcome to day 2**

Overnight I got my first two code reviews back and all was signed off as correct. Also overnight came a "progress" email. This one was a little passive aggressive in it's tone but I guess they're trying to make sure everyone is getting used to putting in the hours as in all reality this is a self-motivated course.

Task 3 - Intro variables
Getting used to variable types in JS. Learning how to type cast them, smoosh them together and do basic maths operations.

Task 3 - Intro to control structures.
If, else & if-else statements. Getting into a bit of control within programs. Nothing groundbreaking but a nice, slow, brick upon brick build of basic programming.

Lecture 2 - Based on Task 2 work.
So here is one of the "issues" with the bootcamp so far. The lectures are running one a day this week, this is great for those having zero experience with code but there are many in the lectures who are romping ahead and then asking questions related to where they are in the work which aren't related to the lecture. This is tending to make the lectures over-run and I imagine putting a bit of stress on those not pushing so far on. I feel that if they released the course work a couple of weeks at a time, this would; 

a. help to prevent this as much.
 
b. keep people used to working consistently rather than starting all guns blazing and then dropping off as the going gets tough and they are way ahead of the live lectures.

So onwards and upwards. Overall feel of quality of the learning and course resources is okay, I've seen much slicker and more pleasing methods of teaching JS. However the way we are running things is a great into to being more self-reliant and opposed to doing all our work on a web based IDE which is all set up to make our life easy.
Meme Tuesday! 🤨
Tags: discuss, watercooler, jokes
Published: 2022-12-06 14:23:34

For the second time in three weeks, we are celebrating Meme Monday on a Tuesday. If the topic were more serious, I'd take more precautions against scheduling conflicts. But here we are.

Today's cover image comes from [last week's thread](https://dev.to/ben/meme-monday-537h).

DEV is an inclusive space! Humor in poor taste will be downvoted by mods.
Recursive Functions in Python
Tags: beginners, python, programming, tutorial
Published: 2022-12-06 14:23:19

A basic example of a recursive function in python. The function outputs the factorial of `num` and ignores additional arguments. If additional arguments are provided, the function returns `"ACCEPTING ONLY 1 ARGUMENT"`.

The function calls itself over and over until the condition `num == 1` is met. Using recursive functions when dealing with repeatable operations is very useful.

```Python
def factorial(num, *args):
    if len(args) == 0:
        if num == 1:
            return 1
        return num * factorial(num - 1)
    return "ACCEPTING ONLY 1 ARGUMENT"
```

> 
GitHub: https://github.com/Sunil16666/example-code-python/blob/main/Recursive-Factorial-with-ErrorCatching/main.py
>