Skip to content

Instantly share code, notes, and snippets.

View corocoto's full-sized avatar
👨‍💻
creates something cool

Artem Gusev corocoto

👨‍💻
creates something cool
View GitHub Profile
//correct test for https://ru.hexlet.io/courses/js-advanced-testing/lessons/files/exercise_unit task
import os from 'os';
import path from 'path';
import { promises as fs } from 'fs';
import getFunction from '../functions.js';
const prettifyHTMLFile = getFunction();
// BEGIN (write your solution here)
@corocoto
corocoto / download_canvas.js
Created December 9, 2020 17:04
download canvas image
const canvas = document.querySelector('canvas');
const downloadLink = document.querySelector('.download-link');
downloadLink.addEventListener('click', (e) => e.target.href = canvas.toDataURL());
@corocoto
corocoto / wsl_close.ps1
Created October 10, 2020 08:40
close wsl process
wsl.exe --shutdown
@corocoto
corocoto / flow-maybe-type.js
Created July 31, 2020 12:00
Flow | Maybe type defining
/**
* `Maybe` type allows us to type annotate a potentially `null` or `undefined` value.
* They have the type `T|void|null` for some type `T`, meaning it is either type `T` or it is `undefined` or `null`.
*/
var message: ?string = null; //here I’m saying that message is either a `string`, or it’s `null` or `undefined`
/**
* You can also use maybe to indicate that an object property will be either of some type `T` or `undefined`.
*
* By putting the `?` next to the property name for `middleInitial`, you can indicate that this field is optional.
@corocoto
corocoto / flow-generic.js
Created July 31, 2020 11:53
Flow | Generic
type GenericObject<T> = { key: T };
var numberT: GenericObject<number> = { key: 123 };
var stringT: GenericObject<string> = { key: "Preethi" };
var arrayT: GenericObject<Array<number>> = { key: [1, 2, 3] }
@corocoto
corocoto / flow-type-alias.js
Created July 31, 2020 11:51
Flow | Type Alias
type PaymentMethod = {
id: number,
name: string,
limit: number,
};
var myPaypal: PaymentMethod = {
id: 123456,
name: 'Preethi Paypal',
limit: 10000,
@corocoto
corocoto / flow-var.js
Created July 31, 2020 11:08
Flow | variables defining
var isFetching: boolean = false;
var luckyNumber: number = 10;
var notSoLuckyNumber: number = NaN;
var myName: string = 'Artem';
var dataNull: null = null;
@corocoto
corocoto / App.jsx
Last active July 31, 2020 08:32
Loading SVG image as Component in Create React App project
import { ReactComponent as Logo } from './logo.svg';
function App() {
return (
<div>
<Logo title="logo"/>
</div>
);
}
/* Tip: The imported SVG React Component accepts a title prop along with other props that a svg element accepts.
@corocoto
corocoto / cra.bash
Created July 29, 2020 05:58
Use NPM as package manager for installing dependencies instead of using Yarn (for project that build using create-react-app)
npx create-react-app my-app --use-npm
@corocoto
corocoto / index.html
Created July 14, 2020 17:53
debouncer example
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>