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
// NOT WORKING! //
.dc-button {
// common styles
a& {
// styles for <a> element
}
.dc-button {
/* common styles */
}
a.dc-button {
/* styles for <a> element */
}
button.dc-button {
/* styles for <button> element */
@slavafomin
slavafomin / nginx.conf
Created January 22, 2019 17:35
How to enable CORS in nginx with origin matching
server {
listen 80 default_server;
root /var/www;
location / {
set $cors '';
set $cors_allowed_methods 'OPTIONS, HEAD, GET';
if ($http_origin ~ '^https?://(www\.)?example.com$') {
set $cors 'origin_matched';
@slavafomin
slavafomin / redirect.html
Created January 18, 2019 16:12
HTTP Cache Test
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Cache Test Redirect</title>
</head>
<body>
@slavafomin
slavafomin / jest-api.ts
Last active February 26, 2020 11:01
How to run Jest programmatically in node.js (Jest JavaScript API)
import {runCLI} from 'jest-cli';
import ProjectConfig = jest.ProjectConfig;
const projectRootPath = '/path/to/project/root';
// Add any Jest configuration options here
const jestConfig: ProjectConfig = {
roots: ['./dist/tests'],
testRegex: '\\.spec\\.js$'
@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: {
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;
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];
server {
listen 80 default_server;
root /var/www;
location /health-check {
try_files /health-check.html =404;
}
$ 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