Skip to content

Instantly share code, notes, and snippets.

View amikitevich's full-sized avatar

Alexey Mikitevich amikitevich

View GitHub Profile
/**
* service that emulates http
*/
@Injectable()
export class TodoService {
readonly todos = [
{id: 1, text: 'todo1', categoryId: 1},
{id: 2, text: 'todo2', categoryId: 2},
{id: 3, text: 'todo3', categoryId: 1},
@amikitevich
amikitevich / gist:79bb73572965cc3c515773d0d15310bd
Created December 17, 2017 21:43
XHR get by Promise and async
function bredListRequest(resolve, reject) {
const r = new XMLHttpRequest();
r.open('GET', 'https://api.github.com', true);
r.onerror = (e) => reject(e, 'error');
r.onload = () => resolve(r.responseText);
r.send();
}
@amikitevich
amikitevich / gist:6e7d26d8b91485d07bf9c243a5a4e8f0
Created September 11, 2018 10:06
Check and compare ios version with provided
const getIosVersion = () => {
return [11, 3, 0];
if (isIos()) {
const v = navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);
return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || '0', 10)];
}
};
/**
* iosVersionToCheck is : string like '11' or '11.0' or (11.1.0), number like 10 or 11 or 9
function sleep(delay) {
var start = new Date().getTime();
while (new Date().getTime() < start + delay);
}
@amikitevich
amikitevich / InPortal.js
Last active May 3, 2020 03:02
Wrapper around React's portal
import { Component } from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
const modalRoot = document.getElementById('modal-root');
// Let's create a Modal component that is an abstraction around
// the portal API.
class InPortal extends Component {
constructor(props) {
@amikitevich
amikitevich / jsconfig.json
Created May 6, 2020 21:53
simple jsconfig for react project written in js
{
"compilerOptions": {
"jsx": "react",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"target": "es2015",
"module": "esnext",