Skip to content

Instantly share code, notes, and snippets.

View slavafomin's full-sized avatar
✌️
Let's make this World a better place!

Slava slavafomin

✌️
Let's make this World a better place!
View GitHub Profile
@slavafomin
slavafomin / git-submodules.md
Last active February 19, 2025 03:15
Git submodules best practices

Git submodules best practices

Useful commands

— Clone repository with submodules automatically:

git clone --recursive [email protected]:name/repo.git

— Initialize submodules after regular cloning:

@slavafomin
slavafomin / 0-README.md
Last active March 15, 2023 13:35
Angular 2 match other field validator / Password match validator

Angular 2 match other field validator

This custom validator for Angular 4 allows you to have fields that must be equal to some other fields. Such validator is very useful for password confirmation validation, for example.

Besides checking if two values are matching, it also subscribes to changes from other control and re-validates when either of two controls is updated.

Usage

@slavafomin
slavafomin / npm5-vs-yarn.md
Last active May 17, 2018 08:50
npm 5 vs yarn

npm 5 vs yarn

Looks like npm decided to stand up to yarn by releasing npm version 5, which is announced to be 5 times faster than previous version of npm.

I've decided to test it in one of my projects, the results are below:

Performance Benchmark

main.bundle.js:1494 Uncaught TypeError: Object.setPrototypeOf called on null or undefined
at setPrototypeOf (<anonymous>)
at webpackJsonp.../../../../../src/ui-components/src/components/checkbox/checkbox.component.ts.__extends (main.bundle.js:1494)
at checkbox.component.ts:18
at Object.../../../../../src/ui-components/src/components/checkbox/checkbox.component.ts (checkbox.component.ts:19)
at __webpack_require__ (bootstrap e9bc34c43daefa8fa1f1:54)
at Object.../../../../../src/ui-components/src/ui-components.module.ts (ui-components-samples.module.ts:80)
at __webpack_require__ (bootstrap e9bc34c43daefa8fa1f1:54)
at Object.../../../../../src/app/html-outlet.directive.ts (home.component.ts:8)
at __webpack_require__ (bootstrap e9bc34c43daefa8fa1f1:54)
@Component()
export class SomeComponent implements AfterViewInit {
@ViewChild(RouterOutlet)
outlet: RouterOutlet;
ngAfterViewInit (): void {
if (this.outlet.isActivated) {
this.doSomethingWithComponent(this.outlet.component);
$ systemd-resolve --status
Global
DNSSEC NTA: 10.in-addr.arpa
16.172.in-addr.arpa
168.192.in-addr.arpa
17.172.in-addr.arpa
18.172.in-addr.arpa
19.172.in-addr.arpa
20.172.in-addr.arpa
21.172.in-addr.arpa
server {
listen 80 default_server;
root /var/www;
location /health-check {
try_files /health-check.html =404;
}
const numbers = [2, 4, 6, 8, 9, 15];
// Expected result: [4, 16, 64]
// Sorting numbers ascending.
numbers.sort((n1, n2) => n1 > n2);
const firstNumber = numbers[0];
const lastNumber = numbers[numbers.length - 1];
const requests = [
{requestId: 't2', startedAt: 1489744808, ttl: 8},
{requestId: 't3', startedAt: 1489744803, ttl: 3},
{requestId: 't1', startedAt: 1489744806, ttl: 12},
{requestId: 't4', startedAt: 1489744810, ttl: 1}
];
let min = requests[0].startedAt;
@slavafomin
slavafomin / nunjucks-metalsmith.js
Last active November 18, 2017 12:40
Nunjucks integration with Metalsmith
const Metalsmith = require('metalsmith');
const inPlace = require('metalsmith-in-place');
Metalsmith(__dirname)
.source('./src')
.destination('./build')
.use(inPlace({
pattern: '**/*.njk',
engineOptions: {