Skip to content

Instantly share code, notes, and snippets.

✌️
Let's make this World a better place!

Slava Fomin II slavafomin

✌️
Let's make this World a better place!
Block or report user

Report or block slavafomin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View 2-sass-parent-selector-prefixes.sass
.dc-button {
// common styles
@at-root a#{&} {
// styles for <a> element
}
@at-root button#{&} {
// styles for <button> element
View 1-sass-parent-selector-prefixes.sass
// NOT WORKING! //
.dc-button {
// common styles
a& {
// styles for <a> element
}
View 0-sass-parent-selector-prefixes.css
.dc-button {
/* common styles */
}
a.dc-button {
/* styles for <a> element */
}
button.dc-button {
/* styles for <button> element */
@slavafomin
slavafomin / nginx.conf
Created Jan 22, 2019
How to enable CORS in nginx with origin matching
View nginx.conf
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';
View redirect.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Cache Test Redirect</title>
</head>
<body>
@slavafomin
slavafomin / jest-api.ts
Last active Jan 17, 2019
How to run Jest programmatically in node.js (Jest JavaScript API)
View jest-api.ts
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 Nov 18, 2017
Nunjucks integration with Metalsmith
View nunjucks-metalsmith.js
const Metalsmith = require('metalsmith');
const inPlace = require('metalsmith-in-place');
Metalsmith(__dirname)
.source('./src')
.destination('./build')
.use(inPlace({
pattern: '**/*.njk',
engineOptions: {
View freighthub-cummulative-ttl.js
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;
View freighthub-numbers.js
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];
View https-redirector-nginx.conf
server {
listen 80 default_server;
root /var/www;
location /health-check {
try_files /health-check.html =404;
}
You can’t perform that action at this time.