Skip to content

Instantly share code, notes, and snippets.

View caseInsensitiveProxy.test.ts
import { caseInsensitiveProxy } from '../caseInsensitiveProxy';
describe('caseInsensitiveProxy', () => {
it('set and get', () => {
const proxy = caseInsensitiveProxy<Record<string, unknown>>();
proxy.someValue = 1;
expect(proxy.someValue).toBe(1);
expect(proxy.SomeValUE).toBe(1);
expect(proxy.somevalue).toBe(1);
View gist:109f8a5f6635496b2526166d19ace8fe
import * as React from 'react';
export const MemoryUsage = () => {
const [percent, setPercent] = React.useState<string | number>('-');
const color = (() => {
if (typeof percent === 'string') {
return 'white';
}
if (percent < 50) {
View RangesManager.test.ts
import { RangesManager } from '../RangesManager';
/*
About test cases:
There are three equivalence classes with respect to any range.
Using the range from 5 to 10 as an example (or [5; 10])
- to the left of the range: [-∞; 4]
- the range itself: [5; 10]
- to the right of the range: [11; ∞]
View yaMetrika подсчёт процентов начиная с версии.js
var browsers = [
['Google Chrome', 57],
['Chrome Mobile', 57],
['Яндекс.Браузер', 18],
['Mobile Safari', 11],
['Firefox', 50],
['Opera', 44],
['Samsung Internet', 7],
['MSIE', 9999],
['Edge', 17],
View html
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Form demo</title>
</head>
<body>
<form class="form" method="POST">