teleren/devto huggingface dataset:
Testing Order Of Operations
Tags: whitebox, testing, frontend, webdev
Published: 2019-11-04 15:28:02

---
title: Testing Order Of Operations
published: true
description: These tests were developed to allow a developer to see that the functions inside code-under-test are firing in a particular order.
tags: White Box, Testing, Front-End, WebDev
series: Front-End Testing Patterns
cover_image: https://thepracticaldev.s3.amazonaws.com/i/i1cdeusnb99wpe5yacwb.png
---

The following code shows a pattern I've been discussing with other developers. The tests were developed to allow a developer to see that the functions inside code-under-test are firing in a particular order.

The code can be found [HERE](https://github.com/bob-fornal/testing-order-of-operations) on GitHub.

## Code Under Test

Here is the code that will be under test. Note the `inOrder` and `outOfOrder` functions. The expectation is that these ***child*** functions, `one`, `two`, `three`, `four`, and `five`, would execute in this order ...

```javascript
const testableCode = {
  one: () => {},
  two: () => {},
  three: () => {},
  four: () => {},
  five: () => {},

  inOrder: () => {
    testableCode.one();
    testableCode.two();
    testableCode.three();
    testableCode.four();
    testableCode.five();
  },
  outOfOrder: () => {
    testableCode.one();
    testableCode.two();
    testableCode.three();
    testableCode.five();
    testableCode.four();
  }
};
```

What we are looking to do is test that the functions to execute the ***child*** functions in a particular order.

## Testing

Here are the tests ...

```javascript
describe('code: order of operations', function() {  
  it('tests specific order', function() {
    // WHITE BOX TESTED
    let order = '';

    spyOn(testableCode, 'one').and.callFake(function() { order += '1,'; });
    spyOn(testableCode, 'two').and.callFake(function() { order += '2,'; });
    spyOn(testableCode, 'three').and.callFake(function() { order += '3,'; });
    spyOn(testableCode, 'four').and.callFake(function() { order += '4,'; });
    spyOn(testableCode, 'five').and.callFake(function() { order += '5'; });

    testableCode.inOrder();

    expect(order).toBe('1,2,3,4,5');
  });

  it('tests out of order', function() {
    // WHITE BOX TESTED
    let order = '';

    spyOn(testableCode, 'one').and.callFake(function() { order += '1,'; });
    spyOn(testableCode, 'two').and.callFake(function() { order += '2,'; });
    spyOn(testableCode, 'three').and.callFake(function() { order += '3,'; });
    spyOn(testableCode, 'four').and.callFake(function() { order += '4,'; });
    spyOn(testableCode, 'five').and.callFake(function() { order += '5'; });

    testableCode.outOfOrder();

    expect(order).not.toBe('1,2,3,4,5');
  });
```

In each of the tests a string is used to track the actual calling order. The first test is testing proper order, the second test verifies that the test will fail if they are not in order.

I chose a string to track the order of execution strictly for its simplicity.

This is a simply WHITE BOX testing pattern that can be used as functionality is abstracted out to maintain consistency.
What to do if you haven't got your Hacktoberfest T-Shirt👕 Email yet
Tags: hacktoberfest, watercooler, prize, opensource
Published: 2019-11-04 15:25:12

I have seen some people confused (including myself) by not receiving the promised Hacktoberfest prize emails. 

It turns out that some people received the email notification but the others not.

#### **What to do if you haven't got your Hacktoberfest T-Shirt Email yet?**

Don't panic - there is a solution, a simple one!

Simply, go to: https://hacktoberfest.digitalocean.com/profile, log in, and you should see the following:

![Hactoberfest prize](https://i.ibb.co/85xjfkL/hacktober-prize.png)

Now, you can copy the unique URL, open it in the browser, and fill in the form to receive your goodies! 🎉🎉🎉


That's it! Hope it helps 😎
create-react-appのTypeScript対応方法について調べた - How create-react-app supports TypeScript
Tags: react, typescript
Published: 2019-11-04 14:59:52

# Summary

* use @babel/preset-typescript through @babel/preset-react-app
* type checking within webpack using ForkTsCheckerWebpackPlugin

# Motivation

1. TypScriptでReactするおすすめの方法はなんだろう
2. ReactのサイトにTypeScriptの使い方って載ってない
3. [create-react-appのドキュメントにはある](https://create-react-app.dev/docs/adding-typescript/#docsNav)
4. どんな設定になっているんだろう?

# Detail

v3.2.0で確認

* [設定方法](https://github.com/facebook/create-react-app/tree/v3.2.0/packages/babel-preset-react-app#usage-with-typescript)
* [@babel/preset-typescriptが有効になる](https://github.com/facebook/create-react-app/blob/v3.2.0/packages/babel-preset-react-app/create.js#L104)
* [webpackの設定はtsconfig.jsonがあればTypeScript用の動作する](https://github.com/facebook/create-react-app/blob/v3.2.0/packages/react-scripts/config/webpack.config.js#L55)
* [型チェックはForkTsCheckerWebpackPluginを使って行われる](https://github.com/facebook/create-react-app/blob/v3.2.0/packages/react-scripts/config/webpack.config.js#L703)

# 感想

確認はしてないが、tscをつかうより@babel/plugin-transform-typescriptを使うほうがトランスパイルするのは早そうに感じる。すべての文法に対応しているかどうかわからない点が気になるといえば気になるが、型チェックのみTypeScriptを使うのはクリーンで良さそう。
babelを利用した場合は型チェックはされないがどうしているか確認したらForkTsCheckerWebpackを利用しているだけだった。ts-loaderを利用する場合もこちらをつかって、型チェックするほうが効率的な気がする。(未確認)
UnityのBuild Report Inspectorでビルドレポートをさくっと確認する
Tags: unity3d
Published: 2019-11-04 14:55:00

---
title: UnityのBuild Report Inspectorでビルドレポートをさくっと確認する
published: true
tags: Unity
date: 20191104T14:55Z
canonical_url: https://qiita.com/shiena/items/c010eb0ec537071a6a26
---
# はじめに

Build Report InspectorとはUnityでビルドした時の情報をインスペクターに表示するエディタ拡張です。
ビルドログを後で確認したりビルドに含まれるアセットを確認したりできます。
類似ツールに[Build Report Tool](https://assetstore.unity.com/packages/tools/utilities/build-report-tool-8162)がありますがこちらはUnity製でPackage Manager/Asset Store/Githubから入手できます。

## 動作環境

Unity2019.2.11f1 (必須環境はUnity2018.1以上)
Build Report Inspector preview - 0.1.0
UIWidgets (動作確認用)

## インストール

Package Managerの`Advanced`から`Show preview packages`をチェック、`All packages`に切り替えて`Build Report Inspector`をインストールします。

![image.png](https://dev-to-uploads.s3.amazonaws.com/i/i1gor6cb0dcvssoicuot.png)

Package Managerを使わない場合はAsset StoreもしくはGithubから導入することができます。

- https://assetstore.unity.com/packages/tools/utilities/build-report-inspector-for-unity-119923
- https://github.com/Unity-Technologies/BuildReportInspector

## 使い方

メニューからウインドウ > Open Last Build Reportを選ぶと`/Assets/BuildReports/`フォルダにビルドレポートがコピーされてインスペクタに表示されます。このファイルはビルドした時に`Library/LastBuild.buildreport`に作成されるので手動でコピーする事もできます。

![image.png](https://dev-to-uploads.s3.amazonaws.com/i/ro88oazynedxazq1lnb6.png)

## BuildSteps

各ビルドステップのログメッセージと処理時間が表示されます。

![image.png](https://dev-to-uploads.s3.amazonaws.com/i/i6kt1s2l55iojfagx8s5.png)

## SourceAssets

ビルドに使われたアセット一覧が表示されます。
ソート方法は以下の3つが用意されています。

* サイズ
* Output Data Files
* Importer Type

![image.png](https://dev-to-uploads.s3.amazonaws.com/i/c005o60vptib9j6xvcyo.png)

## OutputFiles

ビルドで書き込まれたファイル一覧が表示されます。

![image.png](https://dev-to-uploads.s3.amazonaws.com/i/xkz6is5puu2nd75pak9o.png)

## Stripping

Engine Code Strippingをサポートするプラットフォームの場合にビルドに追加されたエンジンモジュールの一覧とその理由が表示されます。

![image.png](https://dev-to-uploads.s3.amazonaws.com/i/ot3i8bcyvwecgelku6vm.png)

# 参考リンク

- [About Build Report Inspector | Build Report Inspector | 0.1.0-preview](https://docs.unity3d.com/Packages/com.unity.build-report-inspector@0.1/manual/index.html)
- [Unity-Technologies/BuildReportInspector: Editor script which implements an inspector for the BuildReport class](https://github.com/Unity-Technologies/BuildReportInspector)
- [Build Report Inspector for Unity - Asset Store](https://assetstore.unity.com/packages/tools/utilities/build-report-inspector-for-unity-119923)
- [Build Report Tool - Asset Store](https://assetstore.unity.com/packages/tools/utilities/build-report-tool-8162)
- [UIWidgets - Asset Store](https://assetstore.unity.com/packages/tools/gui/uiwidgets-146398)
DockerでVimの検証環境を作る方法
Published: 2019-11-04 14:49:06

Vimで設定値やプラグインを手軽に検証するために、一時的な環境を用意する方法についてご紹介します。 今回は Docker を使ったコンテナでの検証環境を準備する方法を紹介します。 前提 検証環境ですから、下記を満たせるこ

つづきは[こちら](https://vim.blue/vim-sandbox-docker-container/)。
[https://vim.blue/vim-sandbox-docker-container/](https://vim.blue/vim-sandbox-docker-container/)
[Vim問題]文字コードを変更してファイルを開き直すコマンドは？
Published: 2019-11-04 14:48:50

この記事では、Vim / neovim でプラグインを使わずに「文字コードを変更してファイルを開き直すコマンド」ためのコマンドについて、ご紹介します。 [解答] :e ++enc=文字コード Vimコマンド1. Wind

つづきは[こちら](https://vim.blue/vim-reopen-encoding-charset/)。
[https://vim.blue/vim-reopen-encoding-charset/](https://vim.blue/vim-reopen-encoding-charset/)
[Vim問題]開いているファイルの文字コードを確認するコマンドは？
Published: 2019-11-04 14:48:34

この記事では、Vim / neovim でプラグインを使わずに「開いているファイルの文字コードを確認する」ためのコマンドについて、ご紹介します。 [解答] :set enc? Vimコマンド1. 文字コードを確認するコマ

つづきは[こちら](https://vim.blue/vim-set-enc-charset/)。
[https://vim.blue/vim-set-enc-charset/](https://vim.blue/vim-set-enc-charset/)
Daily Challenge #107 - Escape the Mines
Tags: challenge
Published: 2019-11-04 14:11:55

---
title: Daily Challenge #107 - Escape the Mines
published: true
series: Daily Challenge
description: Help this miner escape the mines in the dark.
tags: challenge
---

A poor miner is trapped in a mine and you have to help him to get out! The mine is completely dark so you have to tell him where to go.

Implement a method `solve(cave_map, miner, exit)` that has to return the path the miner must take to reach the exit as an array of moves: `['up', 'down', 'right', 'left']`. Those are the only four possible moves as the miner cannot move diagonally. 

`cave_map` is a 2-dimensional array of Boolean values, representing squares. `false` for walls, `true` for open space. It will never be larger than 5 x 5. It is laid out as an array of columns. All columns will always be the same size, though not necessarily the same size as rows (in other words, maps can be rectangular). The map will never contain any loop, so there will always be only one possible path. The map may contain dead-ends though.

`miner` is the position of the miner at the start, as an object made of two zero-based integer properties, `x` and `y`. For example `(0,0)` would be the top-left corner.

`exit` is the position of the exit, in the same format as miner.

Note that the miner can't go outside the map, as it is a tunnel.

Let's take a pretty basic example :
<pre>
cave_map = [[true, false],
    [true, true]];
solve(cave_map, (0,0), (1,1));
// Should return ['right', 'down']</pre>

Challenge maps:
A simple map. (2x2)
`cave_map = [[true, false],
      [true, true]];
miner = (0,0)
exit = (1,0)`

A linear map. (1x4)
`cave_map = [[true], [true], [true], [true]];
miner = (0,0)
exit = (3,0)`

Walk around an obstacle (3x3)
`cave_map = [[true, true, true],
  [false, false, true],
  [true, true, true]];
miner = (0,0)
exit = (2,0)`

Change directions several times (5x5)
`cave_map = [[true, true, false, false, false],
    [false, true, true, false, false],
    [false, false, true, true, false],
    [false, false, false, true, true],
    [false, false, false, false, true]];
miner = (0,0)
exit = (4,4)`

Good luck!
***
_Today's challenge is edited from damned3's [kata](https://www.codewars.com/kata/5326ef17b7320ee2e00001df) on CodeWars. Thank you to [CodeWars](<https://codewars.com/>), who has licensed redistribution of this challenge under the [2-Clause BSD License](<https://opensource.org/licenses/BSD-2-Clause>)!_

_Want to propose a challenge idea for a future post?  Email **yo+challenge@dev.to** with your suggestions!_
Going Multi-Regional in Google Cloud Platform
Tags: googlecloud, programming, serverless, devops
Published: 2019-11-04 13:44:36

---
title: Going Multi-Regional in Google Cloud Platform
published: true
description: Challenges and solutions for going multi-regional within the google cloud platform 
tags: googlecloud,programming,serverless,devops
cover_image: https://miro.medium.com/max/3226/1*uPBllc6jjsttNwkB0dB8fg.png
---

For a successful business, it is important to know who your customers are. Knowing your customers helps to understand your business better, build better versions of your ideas, and can make effective decisions for the successful long run. Everyone knows it right!

When it comes to software infrastructure, it remains important. Knowing your customers greatly improves the performance of your application, makes it more resilient, after all, no one likes to wait for the response :)

Okay getting to the point, if your services are being used by a wide range of audiences across the globe, but your servers are located within a single region, then your users from other parts of the world are going to experience high latency resulting in bad user experience. Several case studies are proving why faster response time is very important for business,
- Why Performance Matters
- Mobile Site Speed Performance,
- Google, Amazon, and many other big software giants confirm several milliseconds(ms) increase in latency can degrade user engagement greatly.


Let's go for an example, [GCP ping](http://gcping.com) is a simple website which makes a ping request to servers located in various regions, and show result ordered by low latency.

[Read more...](https://medium.com/swlh/going-multi-regional-in-google-cloud-platform-18495a833838)
Software engineering interviews AMA
Tags: discuss, career, beginners, ama
Published: 2019-11-04 13:42:39

I've been conducting coding interviews for some time and I will like to help you answer questions you might have about it.

I am not a recruiter, I do the so-called "technical interview" so lets share and hopefully help someone to hit a home run on their next interview.

Some topics I think you might be curious are:
preparation, approach, tools, common pitfalls, etc...

So go on and shoot :smile:

---

## Side note

I am thinking about sparing some time to do mock interviews with some newcomers to the software industry, so if you are interested please let me know and we can check a way to sort it out.
React Hooks Intro Pt. 1: useState (Re-creating a class component)
Tags: javascript, react, tutorial, webdev
Published: 2019-11-04 13:31:59

I'm making a several part series where I demonstrate how to get started using React Hooks by re-creating a class component. I'll also demonstrate some bugs you may encounter with useState. 

Feedback welcome! ✌️

{% youtube fNF2PMB5GW0 %}
Hacktoberfest: complete ✅
Tags: hacktoberfest, opensource, documentation
Published: 2019-11-04 13:31:23

YEAH ! That's it, I finish my first Hacktoberfest 🎉 
Although working with open-source, I have never contributed much. This was the opportunity this month to get started! All right, they're not PRs with big features, they're more like documentation and minor fixes. At least, the documentation will be a little more complete and the projects less buggy 😅

That's all for me, have a good day! 🌤
Automating Your Production Dataflows On Spark - Episode 105
Published: 2019-11-04 13:20:14

<p>As data engineers the health of our pipelines is our highest priority. Unfortunately, there are countless ways that our dataflows can break or degrade that have nothing to do with the business logic or data transformations that we write and maintain. Sean Knapp founded Ascend to address the operational challenges of running a production grade and scalable Spark infrastructure, allowing data engineers to focus on the problems that power their business. In this episode he explains the technical implementation of the Ascend platform, the challenges that he has faced in the process, and how you can use it to simplify your dataflow automation. This is a great conversation to get an understanding of all of the incidental engineering that is necessary to make your data reliable.</p><p><a href='https://www.dataengineeringpodcast.com/ascend-dataflow-automation-episode-105/'>Listen Now!</a></p>
How To Create a Linked List Using Golang
Tags: go, datastructures, howto, code
Published: 2019-11-04 13:19:49

Lately I started to practice my data structures to get a better grasp of programming. Today I chose to tackle the Linked List from scratch using Go. I have not had to write a linked list in forever which made this a great mental exercise.


## Linked List Code Breakdown:
The first step I took was to create a struct. I know this struct needed to hold whatever data to store along with a link to the previous data. Here I set up the struct to hold an integer but this could be anything you want. The second is the link to the previous data and this has to be a pointer to an instance of the struct we just created.

```go
type list struct {
	digi     int
	prevList *list
}
```

I followed that with a `push` method attached to the list type we just created. This will allow us at add new data to the list without rewriting the code. It starts by creating a variable called `current` of the list type we created. `current` will hold the data we need to set as the next node in the list, including the integer passed in and the pointer to the list calling the method. Then the method returns the pointer of the newly created `current` node.

```go
func (l *list) push(num int) *list {
	var current list
	current.digi = num
	current.prevList = l
	return &current
}
```

Since I plan on turning this into a stack challenge, I followed the `push` method with a `pop` method. All this does is remove the most recent addition to the linked list by setting the previous data to the the current.

```go
func (l *list) pop() {
	l.digi = l.prevList.digi
	l.prevList = l.prevList.prevList
}
```

I then follow up with `main()` to execute the methods mentioned above.


## Linked List in Golang:

```go
package main

import "fmt"

type list struct {
	digi     int
	prevList *list
}

// push adds another number to the stack
func (l *list) push(num int) *list {
	var current list
	current.digi = num
	current.prevList = l
	return &current
}

// pop removes the top most member from the stack
func (l *list) pop() {
	l.digi = l.prevList.digi
	l.prevList = l.prevList.prevList
}

func main() {
	var top *list
	// Create parts 0-9 of the stack
	for i := 0; i < 10; i++ {
		top = top.push(i)
	}

	top = top.push(10)
	fmt.Println(*top.prevList.prevList)
	fmt.Println(*top.prevList)
	fmt.Println(*top)
	top.pop()
	fmt.Println(*top)
}
```

Run the code at the [Golang Playground](https://play.golang.org/p/oTTBS6Q27Fc)

If you have any tips on how I can make this linked list more efficient please let me know in the comments. Also feel free to ask any questions!
Angular node-gyp error after updated my mac to Catalina
Tags: nodegyp, angular, npm, catalina
Published: 2019-11-04 13:16:02

After I updated my mac os to Catalina, I realize that my angular projects was not working anymore. npm install was return an error related with node-gyp. I tried to node-gyp rebuild but it was still not working.

I fixed that problem with these codes: 

`rm -rf /Library/Developer/CommandLineTools`
`xcode-select --install`

Source:
https://github.com/nodejs/node-gyp/issues/1861#issuecomment-547679016
The complete guide for Python and Django-Part1 Python
Published: 2019-11-04 12:22:59

Note: In this tutorial, we will be using Python3 instead of Python2. The reason for this choice is that Python2 is slowly getting deprecated from the development world and the developers are developing new libraries strictly for the use with Python3.

Starting with Python3

Content:

1.Installation
2.DataTypes
3.Comparison operators
4.Control flow:
   1.IF ELIF and ELSE statements
   2.WHILE
   3.FOR loop statements
5.Functions
6.Object-Oriented Programming

For more details about this you can read this article as well:-https://codersera.com/blog/python-tutorial-with-django/
💫 [VideoSnippet] Como usar Bootstrap no React
Tags: react, node, bootstrap
Published: 2019-11-04 12:17:22

#react #node #videosnippet

[🤩 Participe da nossa lista de devs 🤩](http://bit.ly/34qy8e3)

No snippet de hoje, você vai aprender como usar o Bootstrap em uma aplicação React!

Espero que gostem!

[![VideoSnippet; Como usar Bootstrap no React](http://i3.ytimg.com/vi/2yLvCSVbBec/maxresdefault.jpg)](https://www.youtube.com/watch?v=2yLvCSVbBec)



[📚 Leitura recomendada "Evolua ou entre em Extinção"](http://bit.ly/35sqiSu)
[➜ Veja as dicas no Instagram](https://www.instagram.com/emersonbrogadev/)
[➜ Assista nosso canal no YouTube](https://www.youtube.com/c/emersonbroga/)
[➜ Curta nossa página no Facebook](https://www.facebook.com/emersonbrogadev/)
[➜ Não perca as atualizações no Twitter](https://www.twitter.com/emersonbrogadev/)
[➜ Veja os repositórios no Github](https://www.github.com/emersonbrogadev/)
My share on Rust 2020
Tags: rust
Published: 2019-11-04 12:14:01

Some weeks ago the rust-lang team made a [blog post](https://blog.rust-lang.org/2019/10/29/A-call-for-blogs-2020.html) asking for opinions on what the priorities for the next year should be. It really amazes me how the team hears everybody and how friendly the community is. 

I have been learning rust for more than a year already, but this year was the first where I tried to write something real and production ready with it. I've gotta say I had a lot of ups and downs with it, but I'm still amazed by the language and its ecosystem. 

The language forced me to revisit some concepts I had forgotten due to working most of my time with garbage collected languages. I've also had to learn some new concepts like the ownership model that rust introduced. I believe I became a better developer after all this, even when working with other languages.

My first weeks using rust were more of a fight against the compiler and its borrow checker. It took sometime until I could finally understand and even predict some code I was writing would or would not compile. The compiler, though very strict, is very friendly. The messages are very intuitive and informative, giving sometimes, even some tips on how to solve the problems it had found.

The general feeling I have with the rust compiler is: if it compiles, it is probably right. I've never had so few bugs when developing an application like I have with rust.

After all this mostly positive experience with rust, one thing let me particularly down about the experience: IDE's. I have tried for sometime IDEA plugin, but I generally don't like to work on the IDEA ecosystem for a long time already. That left me with VSCode. 

Sometimes I think I should uninstall the extension and have only the syntax highlighting due to the problems of the extension:
1. I had to change my configuration to not autosave due to the triggering of the compiler all the time, which was consuming all my CPU very often...
2. It is not the most accurate. I was writing bindings for a C library and very often it could not find the generated code from bindgen, thus showing false errors in my code.
3. The autocomplete is quite poor. It works mostly for the basic types and cannot infer very well the types when you chain `map` calls for example.

And that is just some of the problems I had with the VSCode extension... 

So in my opinion, the focus for the rust team in 2020 should be regarding improving the compiler speed (which I know they're already working on it) and the developer experience with IDEs. I know there's already one [new extension called rust-analyser](https://github.com/rust-analyzer/rust-analyzer), but it is quite unstable at the moment.

I can see the whole rust ecosystem evolving quite fast, more and more developers trying it out and creating some really cool libraries. That leaves me really optimistic for the future of rust and I'm really looking forward to seeing what's gonna come in the next years. :)