Skip to content

Instantly share code, notes, and snippets.

View xenohunter's full-sized avatar
🤖

Phil Filippak xenohunter

🤖
View GitHub Profile
@xenohunter
xenohunter / ComponentPropsPair.tsx
Created June 1, 2023 19:15
Type checking of a component-props pair in TypeScript
import React from "react";
import WrapperComponent from "./WrapperComponent";
import SomeOtherComponent from "./SomeOtherComponent";
const ComponentPropsPair = () = {
return (
<>
<div>...</div>
<WrapperComponent
// You want type check to work for `contentComponent` and `contentProps`
@xenohunter
xenohunter / terminal.js
Last active May 5, 2022 12:29
Terminal emulator (circa 2014 CE)
var terminal;
function init() {
var elem = $('#terminal');
if (!elem.size()) {
console.log('Error! Something is wrong!');
return false;
} else if (elem.data('busy')) {
@xenohunter
xenohunter / concat.typed.arrays.js
Created August 16, 2017 13:33
Concatenate several TypedArray objects of one type
function concatTypedArrays(...args) {
if (!args.length) {
throw new Error('Nothing to concatenate!');
}
const Constructor = args[0].constructor;
args.forEach((arr) => {
if (!(arr instanceof Constructor)) {