Skip to content

Instantly share code, notes, and snippets.

View typeofweb's full-sized avatar
🛒
https://yournextstore.com

Michał Miszczyszyn typeofweb

🛒
https://yournextstore.com
View GitHub Profile
const getAllCSSVariableNames = () =>
Array.from(document.styleSheets)
.filter((s) => s.href === null || s.href.startsWith(window.location.origin))
.flatMap((s) => Array.from(s.cssRules))
.filter((r): r is CSSStyleRule => r.type === CSSRule.STYLE_RULE)
.flatMap((r) => (r.selectorText === ":root" ? Array.from(r.style) : []))
.filter((name) => name.startsWith("--"))
.sort();
const getCSSColorVariableNames = () =>
@typeofweb
typeofweb / prezentacja.ts
Created June 22, 2021 19:29
JuniorSenior
import { definitions as Api } from './apitypes';
{
function id1(arg: unknown): unknown {
return arg;
}
function id<Argument>(arg: Argument): Argument {
return arg;
}
// prettier-ignore
const pairs = [
[0x00E5,0x212B],[0x00C5,0x212B],[0x0399,0x1FBE],[0x03B9,0x1FBE],[0x03B2,0x03D0],
[0x03B5,0x03F5],[0x03B8,0x03D1],[0x03B8,0x03F4],[0x03D1,0x03F4],[0x03B9,0x1FBE],
[0x0345,0x03B9],[0x0345,0x1FBE],[0x03BA,0x03F0],[0x00B5,0x03BC],[0x03C0,0x03D6],
[0x03C1,0x03F1],[0x03C2,0x03C3],[0x03C6,0x03D5],[0x03C9,0x2126],[0x0392,0x03D0],
[0x0395,0x03F5],[0x03D1,0x03F4],[0x0398,0x03D1],[0x0398,0x03F4],[0x0345,0x1FBE],
[0x0345,0x0399],[0x0399,0x1FBE],[0x039A,0x03F0],[0x00B5,0x039C],[0x03A0,0x03D6],
[0x03A1,0x03F1],[0x03A3,0x03C2],[0x03A6,0x03D5],[0x03A9,0x2126],[0x0398,0x03F4],
[0x03B8,0x03F4],[0x03B8,0x03D1],[0x0398,0x03D1],[0x0432,0x1C80],[0x0434,0x1C81],
@typeofweb
typeofweb / workerThreads.js
Created April 15, 2021 12:16
Worker Threads node.js Fibonacci
// @ts-check
/**
* @typedef {Object} WorkerData
* @property {number} howMany
*/
const {
Worker, isMainThread, parentPort, workerData
} = require('worker_threads');
import React, { MouseEventHandler } from "react";
import { Modal, ModalHeader, ModalFooter, ModalBody, Button } from "reactstrap";
import YouTube, {
YouTubeProps,
Options as YouTubeOptions,
} from "react-youtube";
import Vimeo from "@u-wave/react-vimeo";
import ReactDOM from "react-dom";
import "./style.css";
import { modalData as ModalData } from "../../interfaces/modalData";
@typeofweb
typeofweb / hapi-cls.ts
Last active May 1, 2020 23:39
Hapi plugin for CLS
// Thanks to https://gist.github.com/quezak/0a9f33d20aa0c13fd86f547f75d9da47
import { Plugin } from '@hapi/hapi';
import {
contextNs,
setContext,
getContext,
updateContext,
USER_CONTEXT_KEY,
} from './hapi-zcontext';
class Singleton {
private constructor() { }
private static instance = new Singleton();
public static getInstance() {
return this.instance;
}
}
function onCopy(e) {
try {
e.clipboardData.setData('Text', 'tekst do skopiowania');
e.preventDefault();
} catch (err) {
console.error(err);
}
}
function onClick() {
@typeofweb
typeofweb / app.js
Last active May 28, 2018 14:24
Przykładowa aplikacja AngularJS oparta o komponenty
angular.module('myApp', []);
@typeofweb
typeofweb / Observer.js
Created May 5, 2016 16:38
Observer pattern - simple implementation
/**
* Observer pattern - simple implementation
* By Michał Miszczyszyn, 2016
*/
class Observer {
constructor() {
this.observers = [];
}