teleren/devto huggingface dataset:
DSA #2
Tags: codenewbie, todayilearned, beginners, 100daysofcode
Published: 2021-02-18 00:14:50

Hi, Guys ...
Let me tell u what I did today towards my goal
if u don't my goal then check this out:https://dev.to/thedharsan/my-power-pack-goal-for-the-next-7-5-months-roadmap-2jai

NOTE: if u want to learn what I am learning I will provide the resource that u can also learn from and continue!!

1.Learned about Array Concepts in Detailed with complex problems

resouce:https://www.geeksforgeeks.org/analysis-algorithms-big-o-analysis/?ref=leftbar-rightbar

 

what I learned:
*Stock buy and sell the problem  
*Trapping rainwater
*Maximum consecutive 1s
*largest even Odd Subarray
*Maximum circular sum subarray
*Majority element
*sliding window
*prefix sum technique
 

These questions mention above solved from naive to the optimized way
you can search in GFG for problems and solutions also.

link for SDE Sheet:https://docs.google.com/document/d/1SM92efk8oDl8nyVw8NHPnbGexTS9W-1gmTEYfEurLWQ/edit
And For SDE sheet Part:

1.find the Majority element (n/2) that appears in the array 
2.find the Majority element (n/3) that appears in the array 

See you tomorrow in post guys✌👍😎!!!
TypeType: generate complex typescript type with ease
Tags: javascript, typescript, types
Published: 2021-02-18 00:12:33

TypeType is designed to generate complex typescript type with ease.

```ts
/* 
  export type MyPick<T, Keys extends keyof T> = { [K in Keys]: T[K] } 
*/
export type function MyPick = (T, Keys extends keyof T) => ^{
    for(K in Keys) {
        return {
            key: K,
            value: T[K]
        }
    }
}

/* type mapped2 = { [K in Keys as `get${K}`]: () => string }*/
type mapped2 = ^{
    for(K in Keys) {
        return {
            key: `get${K}`,
            value: type () => string
        }
    }
}

type function _isNumberString = (text) => ^{
    if(text extends "") {
        return true
    } else if(text extends `${infer digit}${infer rest}`) {
        return ^{
            if(digit extends Digit) {
                return _isNumberString<rest>
            } else {
                return false
            }
        }
    } else {
        return false
    }
}
```

* playground: https://mistlog.github.io/typetype-playground/

* repo: https://github.com/mistlog/typetype
You're probably using the wrong definition of Continuous Integration
Tags: devops, productivity
Published: 2021-02-18 20:43:48

---
title: You're probably using the wrong definition of Continuous Integration
published: true
date: 2021-02-18 00:00:00 UTC
tags: devops, productivity
canonical_url: https://jhall.io/archive/2021/02/18/youre-probably-using-the-wrong-definition-of-continuous-integration/
---

Until recently, I was using the wrong definition of Continuous Integration. You probably are, too.

This is a bit of an embarassing mistake, at least for me, because I’ve heard the proper definition many times. And I talk about, and advocate for, CI, all the time.

If you had asked me, I probably would have said something like “Automatically test your code, before it’s merged.”

Interestingly, the simplest definition of continuous integration says nothing about testing—automatic or otherwise. Quoting [Martin Fowler](https://www.martinfowler.com/articles/continuousIntegration.html):

> Continuous Integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily - leading to multiple integrations per day.

This means that even with a fully-automated unit, integration, API, and end-to-end test quite with 100% coverage, you’re not doing CI if you have a long-lived feature branch. Or if multiple developers contribute to the same branch.

It also has the surprising implication that you could theoretically have continuous integration _with no automated tests_. This is a thought experiment [I’ve played with before](https://jhall.io/posts/cd-without-ci).

To be fair, the very next line from Fowler says “Each integration is verified by an automated build (including test) to detect integration errors as quickly as possible,” so please don’t go telling him (or anyone) that I think we shouldn’t be doing automated tests!

* * *

If you found this content interesting, I expanded on a lot of this in yesterday’s session of my free remote course “Ship better code faster”. You can watch the replay here: [https://www.crowdcast.io/e/j7a4lakq/3](https://www.crowdcast.io/e/j7a4lakq/3)
Unit Testing Basics - Go
Tags: go, unittest
Published: 2021-05-02 10:40:25

---
title: Unit Testing Basics - Go
published: true
date: 2021-02-18 00:00:00 UTC
tags: golang, unittest
canonical_url: https://tech.serhatteker.com/post/2021-02/unit-testing-basics-go/
---

Go has a *built-in* testing command `go test` and a package `testing` which gives a minimal but complete testing flow.

## Function to Test

Below there is an example method we want to test in the `main` package. We defined an exported function called `Sum` which takes two integers and adds them together.

```go
// main.go
package main

import "fmt"

func Sum(x, y int) int {
	return x + y
}

func main() {
	sum := Sum(13, 29)
	fmt.Println("Sum is", sum)
}
```

## Test

In Go we write our tests in a **separate** file. The test file can be in a different package —and folder or in the same one —main. Here's our unit test for `main.go`:

```go
// main_test.go
package main

import "testing"

func TestSum(t *testing.T) {
	sum := Sum(13, 29)
	if sum != 42 {
		t.Errorf("Sum not correct: got %d, want %d", sum, 42)
	}
}
```

Main rules of Golang testing:

* The first and only parameter needs to be `t *testing.T`
* It begins with `Test` followed by a word starting with a capital letter: `TestSum`
* Calls `t.Error` or `t.Fail` to show a failure
* Tests **must** be saved in a file named `*_test.go` such as: `sum_test.go`

## Run Tests

To run test(s), simply write:

```bash
$ go test
PASS
ok      github.com/serhatteker/unit-testing-basics  0.001s
```

This picks up any files matching `*_test.go`.

In order to get `verbose` output use `-v` flag:

```bash
$ go test -v
=== RUN   TestSum
--- PASS: TestSum (0.00s)
PASS
ok      github.com/serhatteker/unit-testing-basics  0.001s
```
## Table Driven Test

The concept of **table driven test** is a set —slice array, of test input (got) values and output (wanted) value:

```go
// main_test.go
package main

import "testing"

func TestSum(t *testing.T) {
	tables := []struct {
		x int
		y int
		s int
	}{
		{13, 29, 42},
		{0, 9, 9},
		{1, 2, 3},
		{5, -2, 3},
	}

	for _, table := range tables {
		sum := Sum(table.x, table.y)
		if sum != table.s {
			t.Errorf("Sum of (%d+%d) not correct, got: %d, want: %d.", table.x, table.y, sum, table.s)
		}
	}
}
```

## Coverage

The go test tool has *built-in* **code coverage**. To try it with above example type:

```bash
$ go test -cover
PASS
coverage: 33.3% of statements
ok      github.com/serhatteker/unit-testing-basics  0.001s
```

### Html Coverage Report

If you use the below two commands you generate `coverage.html` report that
visualises which parts of your program covered and not covered by the tests:

```bash
$ go test -cover -coverprofile=coverage.out
$ go tool cover -html=coverage.out -o coverage.html
```

The generated report will be like:

![unit testing basics golang](https://tech.serhatteker.com/img/content/2021/unit-testing-basics-golang.png)




All done!
Gamedev.js Survey: State of the HTML5 Game Development in 2021
Tags: gamedev, survey, javascript, webmonetization
Published: 2021-02-18 18:30:34

---
title: Gamedev.js Survey: State of the HTML5 Game Development in 2021
published: true
date: 2021-02-18 00:00:00 UTC
tags: gamedev, survey, javascript, webmonetization
canonical_url: https://enclavegames.com/blog/gamedevjs-survey-2021/
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v86zu7ochonzq07oze7v.png
---

We’re conducting a [Survey](https://gamedevjs.com/survey/) as part of the [Gamedev.js](https://gamedevjs.com/) initiative to learn about the **current state of the HTML5 Game Development in 2021** - where the developers work, what tools do they use, how much do they earn, and much more.

The survey is open for a month - from today, Thursday February 18th, till March 18th 2021. The results will be announced a week after, on March 25th. I do hope we’ll get as many answers as possible, to have a good overview of our niche. Please spread it in your communities!

We’re happy to be supported by the [Grant for the Web](https://grantfortheweb.org/) program, and offer **$600 in prizes** for sixteen lucky participants: half of it in cash (6 x $50 each), and the other in [Coil](https://coil.com/?ref=end3r) membership plans (10 x 6-month plan for $5 a month each). This is optional - the survey is anonymous, but if you leave your email address, you will be eligible to win one of the prizes listed above.

Visit [the landing page](https://gamedevjs.com/survey/) to learn more, or [go directly here](https://forms.gle/UJGoDr21yW91oKy5A) to fill the form - thanks!
Deploy to Kubernetes in less than 5 minutes!
Tags: kubernetes, aks, github, devops
Published: 2021-02-17 23:42:40

Deploying your applications to __Kubernetes__ is not easy. Unless until now!

Let me show you how you can __deploy to AKS in less than 5 minutes__ and without even writing your Kubernetes deployment files and you CICD scripts.

Let's get into it.

### Intro

Today I want to show you how easy it could be to deploy to Kubernetes, thanks to the power AKS (_Azure Kubernetes Service_) and _GitHub_.

Using the __AKS Deployment center__, you don't need to write the Kubernetes YAML manifest files. Actually you don't even need to create your CICD workflows!

___All you need is a Dockerfile___ for your application, and 5 minutes of your time.

### Video

They say an image is worth 100 words... _or something like that_...

So I made a video for you, because this is much better shown then told... So you can see by yourself how incredibly easy and automated the whole experience is.

{% youtube B0bIiG_JLZc %}

([Link to the video: https://youtu.be/B0bIiG_JLZc](https://youtu.be/B0bIiG_JLZc))

### Conclusions

Alright, that's it for today. That was really quick and easy, right?

Let me know in the comment section below what you think about the AKS deployment center. Of course it is not suitable for all the scenarios, especially the more complex ones, but I think it's a hell of a tool to use especially when you are getting started with Kubernetes.
O que é Spring?
Tags: java, spring, webdev, programming
Published: 2021-02-17 23:33:08

Ao buscar definições sobre Spring encontramos, na maioria das vezes, que ele é um framework, uma tecnologia backend ou um universo de tecnologias para backend utilizando a linguagem Java. Mas, que universo é esse? O que é, de fato, Spring?

Spring não é apenas um framework, mas uma iniciativa open source baseada em Java, mas que também tem espaço para a linguagem Kotlin, que reúne um conjunto de projetos com finalidades específicas. Alguns dos projetos, ou módulos, mais conhecidos são:

- **Spring boot:** importa e configura de forma automática todas as dependências adicionadas ao projeto.
- **Spring Framework:** configura o projeto para rodar na web.
- **Spring Data:** responsável pela implementação dos repositórios (camada de persistência de dados).
- **Spring Security:** permite a adição de autenticação na aplicação.

Percebe-se que os projetos são organizados como módulos e essa **modularidade** implica na **independência** de cada um deles. Logo, se você precisa de um sistema web simples, por exemplo, utilize o Spring Framework e para novas necessidades adicione o módulo que melhor combina com a solução do problema que precisa resolver.

Em poucas palavras, percebemos que o Spring fornece um **modelo de configuração mais simples**, que cuida da infraestrutura que nada mais é do que partes da aplicação que são importantes para o seu funcionamento, mas que, em sua maioria, não estão diretamente ligadas às regras de negócio. Sendo assim, trabalhar com o Spring é um modo **simples**, **inovador** e **confiável** de desenvolver aplicações em Java ou Kotlin.  

__________________________________________________________

#### Referências

[Spring.io: Documentações] (https://spring.io/) 
[Devmedia: Spring Framework] (https://www.devmedia.com.br/introducao-ao-spring-framework/26212) 
[Hipsters Ponto Tech: O que é Spring Framework?](https://hipsters.tech/o-que-e-spring-framework/)
[Vitor A K Moschetti: Explicando o Universo do Spring] (https://medium.com/@vitormoschetti/o-que-%C3%A9-o-spring-c672be3477b8)
MongoDB Marvels - Slicing Data by Dates - Series #14
Tags: database, mongodb, javascript, node
Published: 2021-02-17 23:24:13


## Intro
Let's look at a simple query first as we prep ourselves for more thorough queries in this Series:

Query for how many user actions per hour block.
This will report which hour blocks the site is busiest.
```js
  mgArr(dbEnum.nlpdb, collEnum.users_actions,
    {
      $addFields: {
        hourUtc: {
          $hour: { date: "$_id" }
        },
        hourPst: {
          $hour: { date: "$_id", timezone: "-08:00" },
        },
      },
    },
    groupByKey("hourPst"),
    sortDesc("count"),
  )
```

## Notes

The server timestamp is in UTC Time (Coordinated Universal Time).

The db query code also converts the timezone from UTC to PST.
(In another post we'll extract the user's timezone from their device.)

The query has 3 stages:

The $addFields stage adds two computed fields to our resultset, "hourUtc" and "hourPst". (Just to show an example of how to get dates without and with an offset)

The Group stage will pivot on the hour component of the date, for the PST timezone.

Sort Descending, so we see the busiest hours at the top.

We will get back 24 records (24 hours in each day), so we don't need to Paginate.


The output:
```js
/*
 { count: 610, hourPst: 15 },
  { count: 58, hourPst: 20 },
  { count: 55, hourPst: 21 },
  { count: 51, hourPst: 23 },
  { count: 49, hourPst: 14 },
  { count: 41, hourPst: 10 },
  { count: 38, hourPst: 13 },
  { count: 34, hourPst: 22 },
  { count: 33, hourPst: 18 },
  { count: 32, hourPst: 16 },
  { count: 27, hourPst: 17 },
  { count: 24, hourPst: 11 },
  { count: 23, hourPst: 0 },
  { count: 17, hourPst: 19 },
  { count: 17, hourPst: 1 },
  { count: 15, hourPst: 12 },
  { count: 9, hourPst: 3 },
  { count: 5, hourPst: 2 },
  { count: 5, hourPst: 8 },
  { count: 3, hourPst: 6 }
*/
```

## Notes
Looks like 3:00:00 to 3:59:59 PM is very busy for some reason. :)

Though this is an example query, you can see how you can get meaningful and sometimes surprising insights into your data by carving it up into timeseries dimensions.



## What's Next

We'll cover more power with dates and time series in this Series of Articles.

As always, if you have an questions or input, let me know.
Introduction to Timezones in Rails
Tags: timezones, ruby, rails
Published: 2021-02-17 23:21:02

---
title: Introduction to Timezones in Rails
published: true
description: What are timezones and how to use them sensibly in Rails
tags: timezones, ruby, rails
---

One day I'll do the perfect presentation about timezones.

For now, I did a talk at RoRoSyd in December 2020. This is called "Introduction to Timezones" and discusses what a time zone is, how Rails handles them and how to use them in a way that makes sense.

{% youtube FfUay3iBSOc %}
Day 311 : The Process
Tags: hiphop, code, coding, lifelongdev
Published: 2021-02-17 22:32:31

_liner notes_:
- Professional : Had a meeting heavy day. Sat in on a few talk prep sessions. Met someone about a tutorial and maybe implementing something new. Had a company-wide meeting. Only thing I really did was go over my presentation slides for tomorrow. So I added a "copy code" button to my slides to make it easier to get the code snippets. Got it working yesterday, but come to find out that it won't work if you use it in an iframe. To fix it, I had to add an allow="clipboard-read; clipboard-write" in the iframe tag. Super happy I got it working. Fixed some things I missed when I created the code. Put together some notes on things I wanted cover on each slide. Trying to prepare as much as possible for tomorrow. I ran through the process of creating and publishing a Web Component and got it working on the first try. Awesome.

- Personal : Last night, went through a bunch of tracks for the radio show. Also added a section to my admin section. Took the time to go over the database documentation to see if there are any new things and best practices to get the most out of it. Forgot to watch "Dinosaurs" haha.

![View from a beach in Ta‘ū, American Samoa with a jungle on the left, the ocean on the right, and some green mountains in the distance ahead.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/483nrqo00gte7xh8zz22.jpg)

Tonight, I'm going to go through more tracks for this week's radio show. Add a section to the admin dashboard for my side project. I'll probably call it early since I have a lot to do tomorrow. I may go over my slides again before going to sleep. Might watch "Dinosaurs" to help wind down.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube dq2jy-4lyF8 %}
100 Bytes Of Wisdom: Day 4
Tags: career, journey, advice
Published: 2021-02-17 22:16:56

---
title: 100 Bytes Of Wisdom: Day 4
published: true
description: Bytes of Wisdom is a new project by Sam Jarman that brings together snippets of advice for software engineers
tags: career, journey, advice
//cover_image: https://direct_url_to_image.jpg
---

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u49zkv9voxzmw1jaognd.png)


Developers like to solve problems in code, but more often than not, the biggest problems for developers are their own flaws. The best developers recognise these or seek feedback on them. They then reflect on them and work to fix them.

Heads up: As with any terse bit of advice, there will be exceptions of course, and subtleties and nuance that can't possibly be captured in a Byte of Wisdom. This has been what I've experienced, I'd love to hear yours in the comments too!

You can catch up with all the other bytes at http://bytesofwisdom.com/
GameDevHQ Intensive Training Week 01 / Week 08 [Day 3]
Tags: unity3d, gamedev, mobile
Published: 2021-02-17 22:11:21

Day 3 was a more slow day.  

Took it easy in the morning since I was able to complete all of the tasks of week 1, check on my project before the check in meeting.

During the check in I got really good reminders to apply on my script and to always have in mind when creating scripts.

Few of those were to always try to create managers for each action, depending on the script. 

Example:
On my spawn manager script I had the pooling pattern to reuse the enemy and not to destroy them. So in this case the SpawnManager is only responsibility is to Spawn so this mean that i need to put the object pooling pattern on its own script 

Another one, that makes total sense, was if any Manager is always going to be alive on the game / scene then if it needs any game object reference then it is best practice to add the game object reference using the inspector and not GameObject.Find().

So I took those tips and applied them today.

Next up is to write down how i want to approach the project since my aim is to make it a mobile game😊.

I promise I will add more GIF, Clips and Photos for the post; getting used to in writing this type of blogs 😆

Lets see what tomorrow brings

Day 3 Done

To be continued……...
Function Call and Apply Methods
Tags: javascript, node, webdev, tutorial
Published: 2021-02-17 22:05:24

<a href="https://www.sitepoint.com/?ref=osagiebello&utm_source=osagiebello" target="_BLANK" rel="nofollow"><img src="https://static.tapfiliate.com/5d4a604a4bdb3.png?a=53828-915cee&s=1267410-90e49c" border="0"></a>

---
### *call()* Method
The `call()` method accepts an object and optionally argument list.

See the syntax below:

```
object.method.call(obj1[, arg1, ...argN])
```

#### *call()* method with a parameter object
The `call()` method is used on an object. The parameter passed to the function is also an object.

See the examples below:

Without `call()` method.

```js
const person = {
  firstName: "Osagie",
  lastName: "Bello",
  fullName() {
    return `Hello ${this.lastName} ${this.firstName}!`;
  }
};

console.log(person.fullName()); // Hello Bello Osagie!
```
---

<a href="https://www.datacamp.com?tap_a=82040-4385c0&tap_s=1301289-aaa316" target="_BLANK" rel="nofollow"><img src="https://static.tapfiliate.com/5f922766d7ec0196634518.png?a=82040-4385c0&s=1301289-aaa316" border="0"></a>

---

With `call()` method.

```js
const person = {
  fullName() {
    return `Hello ${this.lastName} ${this.firstName}!`;
};

const person1 = {
  firstName: "Osagie",
  lastName: "Bello"
};

const person2 = {
  firstName: "Richard",
  lastName: "Jury"
};

console.log(person.fullName.call(person1)); Hello Bello Osagie!
console.log(person.fullName.call(person2));  // Hello Richard Jury!
```
#### *call()* method with arguments
The `call()` method is used on an object with arguments also passed to the function.

```js
const person = {
  fullName(country, city) {
    return `${this.firstName} ${this.lastName}, ${country} ${city}`;
  }
};

const person1 = {
  firstName: "Osagie",
  lastName: "Bello"
};

const person2 = {
  firstName: "Richard",
  lastName: "Jury"
};

console.log(person.fullName.call(person1, "Nigeria", "Lagos"));  
// Osagie Bello, Nigeria Lagos
console.log(person.fullName.call(person2, "UK", "Oxford"));  
// Richard Jury, UK Oxford
```

### *apply()* Method
The `apply()` method accepts an object and optionally array instead of an argument list.

See the syntax below:

```
object.method.apply(obj1[, array])
```

#### *apply()* method with arguments array
Not only an object be passed to the apply method, but it also accepts an array.

```js
const person = {
  fullName(country, city) {
    return `${this.firstName} ${this.lastName}, ${country} ${city}`;
  }
};

const person1 = {
  firstName: "Osagie",
  lastName: "Bello"
};

const person2 = {
  firstName: "Richard",
  lastName: "Jury"
};

console.log(person.fullName.call(person1, "Nigeria", "Lagos"));  
// Osagie Bello, Nigeria Lagos

console.log(person.fullName.apply(person2, ["UK", "Oxford"]));  
// Richard Jury, UK Oxford
```

**Happy coding!!!**

---
[![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1613663170784/C2mi59lDa.png)](https://www.buymeacoffee.com/techstackmedia)

---

[![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1613662919601/H9jem8Bjb.png)](https://skillshare.eqcm.net/c/2680282/300216/4650)