Router state

   <button type="button" class="btn btn-icon edit" (click)="onEditServerTemplate(element)">
      <clr-icon shape="edit"></clr-icon>
   </button>

Android change text alignment center

Saved from https://stackoverflow.com/questions/432037/how-do-i-center-text-horizontally-and-vertically-in-a-textview
<TextView  
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center"
    android:text="@string/**yourtextstring**"
/>

Android set alignment

Saved from https://stackoverflow.com/questions/24748563/elements-overlapping-on-top-of-each-other-in-relativelayout
<TextView
    android:id="@+id/heading"
    android:text="My First Activity with Relative Layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    />

<Button
    android:id="@+id/button"
    android:text="Save"
    android:layout_width="300px"
    android:layout_height="wrap_content"
    android:layout_below="@id/heading"
    android:layout_margin="20px"
    android:layout_centerHorizontal="true"
    />

Как узнать что сейчас сайт просматриваетмся в проклятом IE

var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");

if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
// Если это Internet Explorer, вернем номер версии
	console.log('🔴 О Боже, это IE ' + parseInt(ua.substring(msie + 5, ua.indexOf(".", msie))));
} else {
	console.log('✅ Этот браузер нормальный и человеческий! Он не каким образом не связаон с IE 👍');
}

Кнопка переключатель или Замена toggle() на jQuery

jQuery(function($){
	$(window).on('load', function () {
//		if $('body').hasClass('home'){
			
			$('a#ThisClicVise').on('click', function(){
			    if (!$(this).hasClass("OnClick")){
					
					$(this).addClass("OnClick");
			// 		console.log('🔵 ');	
					    	event.preventDefault();
					        $(".ThisClickHideIot:not('.TemporaryHide')").each(function(){
					            $(this).css('display','block');
					        });
			       

			     } else {
			       $(this).removeClass("OnClick");
			// 		console.log('🔴 ');
							event.preventDefault();
					        $(".ThisClickHideIot:not('.TemporaryHide')").each(function(){
					            $(this).css('display','none');
					        });
							// И плавный скролл к началу раздела
							$("html, body").animate({ scrollTop: $('#FAQ_IOT').offset().top-50 }, 500);
			    }
			});
//		}
	});

});

Iterate by chunk

General solution for splitting any general iterator by chunks.
import itertools

def grouper(n, iterable):
    it = iter(iterable)
    while True:
       chunk = tuple(itertools.islice(it, n))
       if not chunk:
           return
       yield chunk

sklearn - try different algorithms

https://towardsdatascience.com/data-cleaning-and-feature-engineering-in-python-b4d448366022
import sys
from math import sqrt
from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score
from sklearn.model_selection import GridSearchCV
import numpy as np

from sklearn.linear_model import LinearRegression

'''This train_eval function can be used for any arbitrary scikit-learn algorithm, for both training and evaluation.'''
def train_eval(algorithm, grid_params, X_train, X_test, y_train, y_test):
    '''a set hyperparameters that we want to evaluate against.we pass in {} so we can just use the default hyperparameters on the model'''
    regression_model = GridSearchCV(algorithm, grid_params, cv=5, n_jobs=-1, verbose=1)
    regression_model.fit(X_train, y_train)
    y_pred = regression_model.predict(X_test)
    '''R2: Coefficient of Determination, is a general evaluation of the model showing the percentage of variation in the prediction that can be explained by the features. 
    In general, a higher R² value is better than a lower one.'''
    print("R2: \t", r2_

[Tilix Terminal on Dark Theme] How to force a dark theme just to Tilix Terminal in GTK3 when using a global light theme. #tilix #terminal #b

[Tilix Terminal on Dark Theme] How to force a dark theme just to Tilix Terminal in GTK3 when using a global light theme. #tilix #terminal #bash-scripts #scripts #dark-theme #themes #gtk3
#!/bin/bash

# First, select "Dark" option from Theme Variant setting on Tilix Global Preferences, "Appearance" section
GTK_THEME=Mint-Y-Yltra-Dark:dark tilix

StandardScaler

from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
scaler.fit(X_train) # fit on X_train only, don't fit on X_test. to avoid data leak
X_train[X_train.columns] = scaler.transform(X_train[X_train.columns])
X_train = X_train.join(one_hot)
X_test[X_test.columns] = scaler.transform(X_test[X_test.columns])
X_test = X_test.join(one_hot)

housing_split_cleaned = (X_train, X_test, y_train, y_test)

JS forEach loop

// ES5 for loop

function compressAllBoxes(boxes){
  boxes.forEach(function(item){
    console.log(item);
  });
}

// ES6 for loop

const esSixCompressAllBoxes = boxes => { 
  boxes.forEach( 
    box => console.log(box)
  );
}

esSixCompressAllBoxes([1,2,3,4,5]);

MongoDB ReplicaSet init in StatefulSet

rs.initiate({_id: "MainRepSet", version: 1, members: [
... { _id: 0, host : "pyqod-mongo-0.pyqod-mongo.default.svc.cluster.local:27017" },
... { _id: 1, host : "pyqod-mongo-1.pyqod-mongo.default.svc.cluster.local:27017" },
... { _id: 2, host : "pyqod-mongo-2.pyqod-mongo.default.svc.cluster.local:27017" }
... ]});

JS for loop

Saved from https://repl.it/@niweera/BigO
// JS for loop

const nemoArray = ['nemo'];

function findingNemo(array){
  for (let i = 0; i < array.length; i++){
    if (array[i] === "nemo"){
      console.log("Nemo Found!")
    }
  }
}

findingNemo(nemoArray);

Настройки Sublime Text

{
	"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
	"font_size": 14,
	"ignored_packages":
	[
		"Vintage"
	],
	"theme": "OneDarkMaterial.sublime-theme"
}

Heroku Cheatsheet

---
title: Heroku
category: Devops
layout: 2017/sheet
updated: 2017-10-11
description: |
  A one-page reference to common Heroku-CLI commands.
intro: |
  [Heroku](http://heroku.com/) is a web hosting platform supporting many languages, and this guide is a reference to Heroku's [command-line interface](http://heroku.com/).
---

### `create` - Create an app

```bash
heroku create sushi
```

```bash
git push heroku master
```

### `access` - Collaboration

#### Manage collaborators

```bash
heroku access                     # List
heroku access:add me@xy.com
heroku access:remove me@xy.com
```

#### Transfer to another owner

```bash
heroku apps:transfer new@owner.com
```

### `logs` - Show logs

```bash
heroku logs
heroku logs -t      # --tail (stream)
heroku logs -s app  # --source (only on app logs)
```

### `releases`

```bash
heroku releases
heroku releases:info v25
heroku rollback
```

### `pg` - PostgreSQL

#### Start a database

```bash
heroku addons:add heroku-postgresql
```

####

Настройка окружения для тестирования

Установка утилит mocha, chai
Установка mocha  
` npm i -S mocha `

Установка chai  
` npm i -S chai `

Push Docker image to GCR

gcloud auth configure-docker

# example: `docker tag py-qod gcr.io/kub-py-qod/py-qod:latest`
docker tag [SOURCE_IMAGE] [HOSTNAME]/[PROJECT-ID]/[IMAGE]:[TAG]

# example: `docker push gcr.io/kub-py-qod/py-qod:latest`
docker push [HOSTNAME]/[PROJECT-ID]/[IMAGE]:[TAG]