Skip to content

Instantly share code, notes, and snippets.

const server = http2.createSecureServer(options);
const commonCSS = fs.readFileSync('common.css');
server.on('stream', (stream, headers) => {
console.log(`${headers[':method']} ${headers[':path']}`);
const parsedUrl = url.parse(headers[':path']);
let pathname = `.${parsedUrl.pathname}`;
const ext = path.parse(pathname).ext;
if (headers[':path'] === '/index.html') {
stream.pushStream({ ':path': 'common.css' },
const http2 = require('http2');
const fs = require('fs');
const url = require('url');
const path = require('path');
const options = {
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
};
const mimeType = {
'.ico': 'image/x-icon',
@bendc
bendc / personal-raf-boilerplate.js
Last active January 21, 2018 17:19
requestAnimationFrame boilerplate code
"use strict";
// animation utils
// ===============
const trackTime = timing => {
const now = performance.now();
if (!timing.startTime) timing.startTime = now;
const elapsed = now - timing.startTime;
@bendc
bendc / raf-boilerplate.js
Created August 28, 2017 13:52
rAF tutorial: boilerplate code
"use strict";
// animation utils
// ===============
const trackTime = id => {
const [entry] = performance.getEntriesByName(id);
if (!entry) {
performance.mark(id);
@akella
akella / setup.md
Last active February 21, 2023 22:59
Мой сетап

То что я использую в работе и стримах

Софт для разработки

@nodkz
nodkz / .babelrc.js
Last active November 28, 2024 00:45
Babel 7.0 with .babelrc.js DEPRECATED! This config was created when babel 7 was in beta
/* eslint-disable prefer-template */
const path = require('path');
const aliases = require('./aliases');
// ///////////////////////////////////////////////////////////////
// ////////////////// PLUGINS ////////////////////////////////
// ///////////////////////////////////////////////////////////////
const commonPlugins = [
@bars3s
bars3s / nginx.conf
Last active December 2, 2022 21:04
nginx image resizer with size parameters in query string
# Example: test.com/images/cats.jpeg?w=100&h=100
location ~* ^/images/(.+\.(?:jpe?g|png|gif))$ {
set $image_name $1;
set $demins "${arg_w}x${arg_h}";
set $check_str "${demins}";
# check that original size file exists
if ( -f $request_filename ) {
set $check_str "${check_str}F1";
@WebReflection
WebReflection / benchmark-dom-classes.js
Last active November 13, 2021 20:52
Classes VS DOM Events Handling Benchmark
// Players
class ClickCounter {
constructor() { this.clicks = 0; }
onclick(e) { this.clicks += (e.type === 'click') ? 1 : -1; }
}
class Handler extends ClickCounter {
constructor(currentTarget) {
super();
currentTarget.addEventListener('click', this);
@adamgiese
adamgiese / nth-child-quantity-mixins.scss
Last active April 19, 2023 11:22
Advanced nth-child mixins
@mixin valid-quantity($quantity) {
@if type-of($quantity) != 'number' {
@error 'The "quantity" parameter must be a number!';
}
@if not(unitless($quantity)) {
@error 'The "quantity" parameter must not have a unit!';
}
@if $quantity < 0 {
@error 'The "quantity" parameter must be at least 0!';
}