teleren/devto huggingface dataset:
Create IIS application pool and application via command line
Tags: iis, aspnet
Published: 2019-09-20 08:18:00

Let's say you have an existing IIS site and want to add an application to it. Usually you open up the Internet Information Services (IIS) Manager and do it there using the context menu.

But now assume - and that was in my case - you have multiple servers hosting the same site (behind a load balancer). Depending of the number of servers this is going to take a while, is not really exciting and maybe error prone.

I thought there should be a better solution - and yes, there is one, the command line tool for managing IIS - see https://docs.microsoft.com/en-us/iis/get-started/getting-started-with-iis/getting-started-with-appcmdexe

So I've created a batch file (.bat) which creates an application pool, sets the recycling option, creates an app inside of an existing site and then sets the application pool on the new app:

```
@ECHO OFF

ECHO # CREATE APP POOL
%systemroot%\system32\inetsrv\appcmd add apppool /name:app1 /managedRuntimeVersion:"v4.0" /managedPipelineMode:"Integrated"

ECHO # SET APP POOL RECYCLING
%systemroot%\system32\inetsrv\appcmd clear config -section:system.applicationHost/applicationPools /[name='app1'].recycling.periodicRestart.schedule 
%systemroot%\system32\inetsrv\appcmd set config -section:system.applicationHost/applicationPools /+[name='app1'].recycling.periodicRestart.schedule.[@0,value='03:00:00'] /commit:apphost
%systemroot%\system32\inetsrv\appcmd set config -section:system.applicationHost/applicationPools /[name='app1'].recycling.periodicRestart.time:00:00:00 /commit:apphost

ECHO # CREATE APP
MD D:\@Work\DEV\IIS\example-site\app1
%systemroot%\system32\inetsrv\appcmd add app /site.name:example-site /path:/app1 /physicalPath:D:\@Work\DEV\IIS\example-site\app1

ECHO # SET APP POOL FOR APP
%systemroot%\system32\inetsrv\appcmd set app "example-site/app1" /applicationPool:app1
```

I run it - and checked the result via IIS manager - and as expected everything was setup correctly. Here are the screenshots:

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/v9sxy7rnb58ufal22pu1.png)
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/zfbep69xcnucg1k5gim1.png)
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/77143vxvv28ktyfhispr.png)
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/5ahvz4oe6tenze12ne46.png)
Art of mastering computer programming - Sparkle
Tags: mastery, jankimethod, flashcards, learnprogramming
Published: 2019-09-20 07:17:04

---
title: Art of mastering computer programming - Sparkle
published: true
description: Flashcards to master computer programming - https://sparkle.apricity.co.in
tags: Mastery, Janki Method, Flashcards, Learn Programming
---

Have you ever used flashcards? Sure you did! We’ve all been there and it seems like they are making a comeback. Programmers can remember programming knowledge they don’t use on a day to day basis using spaced repetition.

Sparkle, is a free to use software (web & mobile friendly) that lets you create your flashcards in neatly separated sections. Plus, there are a lot more goodies. Check it out - https://sparkle.apricity.co.in

Sparkle - where you start as a novice and end as a master!
Promise.race for timeouts, fetch and avoiding memory leaks
Tags: javascript
Published: 2019-09-20 07:15:39

Using `Promise.race` is a popular option for getting a cancellation/timeout behaviour for `fetch` calls, when the new `AbortController` is not available for use. However, there are ways to shoot yourself in the foot with this technique. I wrote a post which goes through:

1 How to use `Promise.race` to achieve timeouts for `fetch` calls
2 👾 Buggy implementation
3 ✅A safer implementation using newer features in JavaScript that won't have the problems as that in 2.

[https://kgrz.io/avoiding-memory-leaks-timing-out-fetch.html](https://kgrz.io/avoiding-memory-leaks-timing-out-fetch.html)
Fun with Array.reduce(): get a nested object by name
Tags: javascript, array, reduce
Published: 2019-09-20 07:06:46

Say you have an object in the global scope such as
```
var level0 = {level1:{level2:{level3:'holy grail'}}};
```

that you want to access the last level of, and you are given its name as a string: 
```
var nestedName = 'level0.level1.level2.level3';
```
There are, of course, many ways to get the value of the level3, and one way is to use Array.reduce():
```

var getNestedValueByName = name=>name.split('.').reduce((acc, next)=>acc[next], window);

console.log(getNestedValueByName(nestedName));
// holy grail
```
Also works for arrays, only have to use indices instead of names:
```
var a = [['first', 'second'],['third', 'fourth']];

console.log(getNestedValueByName('a.1.0'));
// third
```
How to style helperText in the TextField material-ui component
Tags: react, materialui
Published: 2019-09-20 07:06:21

Add custom styles to the “material-ui” component may be a challenge sometimes.  

For example, I need to add additional custom styles to the “TextField” component.

<img align="center" src="https://thepracticaldev.s3.amazonaws.com/i/e6t3o4d9uefgeam1najm.png" alt="helperText">

I tried different solutions and spent a lot of time to find the most simple one.  

In the end, I found that it is a possible just pass “FormHelperTextProps” property with “className” key.

{% gist https://gist.github.com/OleksandrSachuk/88c4177bdc577207b56aa124f8dab8d4 %}

Hope, this solution saves you time!
Expressのmorganと他のロガーを連携する
Tags: node, express
Published: 2019-09-20 06:48:00

---
title: Expressのmorganと他のロガーを連携する
published: true
tags: Node.js, Express
date: 20190920T06:48Z
canonical_url: https://qiita.com/shiena/items/a8b6c117d83cac87910b
---
# はじめに

Node.jsのWebフレームワークExpressは`express-generator`を使うとアプリケーションの雛形を作成してくれます。
この雛形はHTTPリクエストロガーのmorganが含まれていますが、メッセージフォーマットくらいしかカスタマイズできません。
そこで他のロガーと連携してみました。ここではwinstonを使ってみます。

# 連携方法

GitHubのページでは以下のように`stream`プロパティでファイルに出力しています。

[expressjs/morgan # write logs to a file](https://github.com/expressjs/morgan#write-logs-to-a-file)

```js
// create a write stream (in append mode)
var accessLogStream = fs.createWriteStream(__dirname + '/access.log', {flags: 'a'})

// setup the logger
app.use(morgan('combined', {stream: accessLogStream}))
```

この`stream`プロパティがどのように使われているのか追跡すると以下のように`write`関数を呼び出しています。

[morgan / index.js#L130](https://github.com/expressjs/morgan/blob/871726c3f0941fe80494ba510decd735f1659206/index.js#L130)

```js
stream.write(line + '\n')
```

つまり、次のような形で他のロガーと連携できるはずです。

```js
app.use(require('morgan')({
    stream: {
        write: function(message) {
            // ここでmessageをログ出力すればよい！
        }
    }})
);
```

# winstonと連携する

winstonのカスタムロガーと連携する場合は以下のようなコードになります。

```js
// winstonでカスタムロガー作成
var winston = require('winston');
winston.emitErrs = true;

var logger = new winston.Logger({
    level: 'info',
    transports: [
        new (winston.transports.Console)({
            level: 'silly',
            handleExceptions: true,
            json: false,
            colorize: true
        }),
        new (winston.transports.File)({
            handleExceptions: true,
            json: false,
            colorize: false,
            filename: './logs/all-logs.log'
        })
    ]
});

// 連携用のwrite関数
logger.stream = {
    write: function (message) {
        logger.info(message);
    }
};

// morganと連携
app.use(require('morgan')({stream: logger.stream}));

// アプリログはlogger.info()などで出力する
```

# 参考

[stackoverflow # Node.js - logging / Use morgan and winston](http://stackoverflow.com/questions/27906551/node-js-logging-use-morgan-and-winston)
Handle async actions by the RxJS and Redux-observable
Tags: react, rxjs, reduxobservable
Published: 2019-09-20 06:34:59

---
title: Handle async actions by the RxJS and Redux-observable
published: true
description: 
tags: #react, #rxjs, #redux-observable
---

## Table Of Contents
* [Code example](#code-example)
* [RxJS operators](#RxJS-operators)

### Code example <a name="code-example"></a>

RxJS and Redux-observable are very useful to handle async actions.
I would like to show an example usage RxJS and Redux-observable in the react app.

{% gist https://gist.github.com/OleksandrSachuk/6b1d1490276074525724dcf14c7058b0 %}


First of all, we wait for some action in the ofType.

### RxJS operators <a name="RxJS-operators"></a>
Later we use switchMap operator.

I prefer to use switchMap which returns an ‘inner’ Observable and stops emitting items from the earlier-emitted inner Observable and begins emitting items from the new one.

For instance, if async action calls several times ‘switchMap’ cancel a subscription to the previous async action call and wait for the result of the latest one.

Inside “switchMap” you can get access to the action payload if it provided.

As mentioned previously “switchMap” returns an inner Observable, for instance, promise.

From the inner observable you create a separate pipe to handle async action result.

First of all, I would like to pay attention to the “startWith” operator to set pending action from the start.

For the success, handling I prefer to use “flatMap” which in general mining like a then in promises and catchError for the error handling.

Please, pay attention that all operators (startWith, flatMap and catchError) are inside “inner” Observable for handling async promise.

This is a very simple and easy way of reading to handle async actions.
And the latest thing, don’t forget to add an epic to the “combineEpics” from redux-observable.
Will Data Science Ever Rule the World?
Tags: career, sql, database, datascience
Published: 2019-09-20 06:29:01

What might be the future employments for data science? As of late, there has been an increasing demand in data science innovations over the world. This will without a doubt change the manner in which individuals live and exchange the market. The utilization of data science tools is progressively utilized in various innovation for doing several everyday decisions in professional lives. It encourages individuals to drive the business easily by recognizing waste and clear spots searching for the help of different various data science tools.
read more:- http://bit.ly/2lHUcj5
Challenges Software Developers Face Today
Published: 2019-09-20 05:57:37

The Creative Minds behind the computer programmes are software developers. They develop complex softwares to perform the specific task in devices.

But it’s not that easy to develop software for any software developer, especially for beginners. Initially, they might face a lot of challenges while developing any software.

Software development is a dynamic industry today and building a high-quality product is the goal of every organization which creates challenges on every step for software developers. Thus they are struggling to be on top of new technologies for their profession.

Technical Challenge

Technical challenges are what you face normally while associating the core coding of software development. Some major challenges are:-

Not Understanding The Project:

Users may have their own opinion to build software but it creates difficulties for a developer as they barely get to interact with them directly.
The same problem occurs when you work on the unestablished project because every development project required a test and pre-production. Sometimes you get some complex project and it’s hard to cope up and work on each and every part of the project, single-handedly. In some cases, you might have to work on code written by another developer. This situation can cause problems for new developers.

Planning a project:

Planning a code is one of the important parts of software development. For building a good product you need proper planning. Because sometimes you might not get expected output after executing the code.

If you are a beginner so here are some tips to avoid such scenarios-

Always start with putting your ideas on paper rather than carrying them around in your head. It will help you to focus on what you are about to code.
Once you figure out the idea, start addressing the problems which your product will resolve.
As you get the problems, now think about the solutions for those problems.
Debugging:

When a software failed to execute properly. A developer debugs the software to identify and analyze the bug to resolve. It is considered as the most complex part because errors need to be resolved at all stages of debugging.

Usually, New programmers found these bugs ( App is crashing or some button is not working or not clickable ) from QA.
But some bugs are not easy to debug. This can lead to lost development time and endless frustration for new developers.

But bugs are common in programming, even best-written code can have them and they can be fixed.

Reproducing is a great idea to understand the errors and it will give you a good idea on how to resolve them. The tester who found the issue can help you to reproduce it.

For more details Click here:-https://codersera.com/blog/challenges-software-developers-face-today/
NeoVim and LanguageClient for Elixir
Tags: vim, elixir, editors
Published: 2019-09-20 05:15:33

---
title: NeoVim and LanguageClient for Elixir
published: true
tags: Vim,Elixir,editors
canonical_url: https://www.rockyourcode.com/neovim-and-languageclient-for-elixir
---

Yesterday I installed **[LanguageClient-neovim][languageclient]** for NeoVim.

This tool adds [Language Server Protocol support](https://github.com/Microsoft/language-server-protocol) for NeoVim (or Vim8).

It helps with autocompletion, code formatting, code definitions, and offers other features as well.

## LanguageClient-neovim Installation

With `minpac`:

```vimscript
call minpac#add('autozimu/LanguageClient-neovim',
          {'rev': 'next',
           'do': '!bash install.sh'})
```

In Neovim, run the following command afterwards:

```bash
:UpdateRemotePlugins
```

### elixir-ls Installation

You have to install a language server for each language you want to support and then configure the plugin.

For **Elixir**, you can check my previous blog post on [Developing with Elixir in Vim](https://www.rockyourcode.com/developing-with-elixir-in-vim#elixir-language-server).

```bash
$ git clone git@github.com:elixir-lsp/elixir-ls.git
$ cd elixir-ls
$ mix deps.get
$ mix compile
$ MIX_ENV=prod mix elixir_ls.release
```

This creates a folder with an executable, i.e., `release/language_server.sh`.

(For Windows, use `.bat`.)

### Configuration

This has to go into your `.vimrc`:

```vimscript
set hidden

let g:LanguageClient_serverCommands = {
\ 'elixir': ['~/<path-to-your-language-server-executable.sh-or-bat>],
\ }

nnoremap <F5> :call LanguageClient_contextMenu()<CR>
" Or map each action separately
nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
```

### Further Reading

- [autozimu/LanguageClient-neovim][languageclient]
- [JakeBecker/elixir-ls](https://github.com/JakeBecker/elixir-ls)
- [Developing with Elixir in Vim][elixirvimdev]

[languageclient]: https://github.com/autozimu/LanguageClient-neovim
[elixirvimdev]: https://www.rockyourcode.com/developing-with-elixir-in-vim
Make switch statements super type safe with the never type
Tags: typescript
Published: 2019-09-20 03:51:39

---
title: Make switch statements super type safe with the never type
published: true
description: How the never type in TypeScript can be used in a switch statement over a union type to warn us when a type in the union hasn't been handled
tags: typescript
---

![Stop sign](https://www.carlrippon.com/wp-content/uploads/2019/09/broken-danger-daylight-1411397-1024x683.jpg "Photo by Wendelin Jacober from Pexels")

## The problem

The following code is a simple reducer for a counter component. It contains a `switch` statement over a union type which is pretty type safe:

{% gist https://gist.github.com/carlrip/5033765ec41cefa08a2cedf4f272f6c7 %}

How can we make this even more type safe? What if we get a new requirement for the counter to be reset? That would mean that a new action is added to the `Actions` type. When we add the new action, how can we get the TypeScript compiler to remind us that a new branch in the `switch` statement needs to be implemented?

## The solution

What if we could tell the TypeScript compiler that the `default` branch in the `switch` statement should never be reached? Well we can do just that with the `never` type!

Let's examine what the type of `action` would be in the `default` branch:

{% gist https://gist.github.com/carlrip/ccfc18368813e815715d5f1a4ca90b5a %}


![action is never](https://www.carlrippon.com/wp-content/uploads/2019/09/default-never-1.png)

It is of type `never`!

So, if we create a dummy function that took in a parameter of type `never` that is called in the `default` `switch` branch, maybe the TypeScript compiler would error if it reached there ...

{% gist https://gist.github.com/carlrip/91364da38272965b0c8edef47f9843dd %}

Let's add a `Reset` action and give this a try:

{% gist https://gist.github.com/carlrip/d749c7dac6307560a9473998a64bbe2a %}


![reset not handled warning](https://www.carlrippon.com/wp-content/uploads/2019/09/default-never2.png)

The TypeScript compiler errors as we hoped. Neat!

## Wrap up

Calling a dummy function that has a parameter of type `never` is neat way to get the TypeScript compiler to warn us if an area of our program is reached that shouldn't be. It's a nice touch in a `switch` statement over a union type so that we are reminded to implement an additional branch if the union type is ever changed.

Marius Schulz has a [great post](https://mariusschulz.com/blog/the-never-type-in-typescript) on the `never` type if you want to learn more about it.

*Originally published at [https://www.carlrippon.com/make-switch-statements-super-type-safe-with-the-never-type](https://www.carlrippon.com/make-switch-statements-super-type-safe-with-the-never-type) on Sept 20, 2019.*
Learn Machine Learning Zero to Hero!
Tags: machinelearning, tutorial
Published: 2019-09-20 02:58:24

Intro to Machine Learning: Machine Learning represents a new paradigm in programming, where instead of programming explicit rules in a language such as Java or C++, you build a system which is trained on data to infer the rules itself. But what does ML actually look like? In part one of Learn Machine Learning Zero to Hero, AI Advocate Laurence Moroney (lmoroney@) walks through a basic Hello World example of building an ML model, introducing ideas which we'll apply in later episodes to a more interesting problem: computer vision.

Try this code out for yourself in the Hello World of Machine Learning: https://goo.gle/2Zp2ZF3

Basic Computer Vision with ML: In part two of Learn Machine Learning Zero to Hero, AI Advocate Laurence Moroney (lmoroney@) walks through basic computer vision with Machine Learning by teaching a computer how to see and recognize different objects.

Beyond Hello World, a Computer Vision Example: https://goo.gle/34cHkDk

Introducing convolutional neural networks: In part three of Learn Machine Learning Zero to Hero, AI Advocate Laurence Moroney (lmoroney@) discusses convolutional Neural Networks and why they are so powerful in Computer vision scenarios. A convolution is a filter that passes over an image, processes it, and extracts features that show a commonality in the image. In this video you'll see how they work, by processing an image to see if you can extract features from it!

Codelab: Introduction to Convolutions → http://bit.ly/2lGoC5f

Build an image classifier: In part four of Learn Machine Learning Zero to Hero, AI Advocate Laurence Moroney (lmoroney@) discusses the build of an image classifier for rock, paper, and scissors. In episode one, we showed a scenario of rock, paper, and scissors; and discussed how difficult it might be to write code to detect and classify these. As the episodes have progressed into Machine Learning, we’ve learned how to build neural networks from detecting patterns in raw pixels, to classifying them, to detecting features using convolutions. In this episode, we have put all the information from the first three parts of the series into one.

Colab notebook: http://bit.ly/2lXXdw5

Rock, paper, scissors dataset: http://bit.ly/2kbV92O

{% youtube yIR_bMInPGo %}
#TeachingKotlin - Kotlin for Android Java developers
Tags: kotlin, android, java
Published: 2019-09-20 03:01:28

---
published: true
tags: kotlin, android, java
canonical_url: https://msfjarvis.dev/posts/teaching-kotlin-kotlin-for-android-java-developers/
---

Anybody familiar with my work knows that I am a fan of the [Kotlin](https://kotlinlang.org/ "Kotlin") programming language, especially it's interoperability with Java with respect to Android. I'll admit, I've not been a fan since day one. The abundant lambdas worried me and everything being that much shorter to implement was confusing to a person whose first real programming task was in the Java programming language.  
  
As I leaped over the initial hurdle of hesitation and really got into Kotlin, I was mindblown. Everything is so much better! Being able to break away from Java's explicit verbosity into letting the language do things for you is a bit daunting at first but over time you'll come to appreciate the time you save and in turn how many potential problems you can avoid by simply not having to do everything yourself. [Can't have bugs if you don't write code](https://github.com/kelseyhightower/nocode) :p

As I've gotten more and more into the Kotlin ecosystem and community and converted developers into adopting Kotlin, into taking that first step, I've realised most of them have a common set of concerns and often a lack of knowledge about what Kotlin actually brings to the table and what are the drawbacks of using a "new" language over an established behemoth like Java.

Hence I've decided to publish a series of posts outlining exactly that -- What to expect when moving to Kotlin from Java, the benefits and the common pitfalls as well as current limitations that may or may not hinder said move. The first post of the series will go up on the upcoming Monday evening, and all following ones will be published at around the same time every week. I'd like to keep this up for as long as possible and so I'm not declaring this as a `n`-part series right off the bat. We'll figure it out as we go :)
What's your favourite side-project?
Tags: discuss, showdev
Published: 2019-09-20 02:26:29

You know, that one thing you made for just your own use but is pretty cool.

I'll start: I was pretty annoyed at having to manually update my résumé every month or so. With things like download numbers, it gets outdated pretty fast. 

Enter DynamicLaTeX. Auto-updates stuff every day and deployed to Heroku. Pretty nifty, imo.

{% github aadibajpai/DynamicLaTeX %}

What's something you made to automate the boring stuff?