Skip to content

Instantly share code, notes, and snippets.

View amikitevich's full-sized avatar

Alexey Mikitevich amikitevich

View GitHub Profile
@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",
@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) {
function sleep(delay) {
var start = new Date().getTime();
while (new Date().getTime() < start + delay);
}
@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
@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();
}
/**
* 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 / cloudSettings
Last active June 27, 2020 10:14
Visual Studio Code Sync Settings Gist
{"lastUpload":"2020-06-27T10:14:49.762Z","extensionVersion":"v3.4.3"}
@amikitevich
amikitevich / 0_reuse_code.js
Created February 10, 2016 22:00
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@amikitevich
amikitevich / gist:febed1444cb85259a693
Created January 25, 2016 00:02
Число с ведущими нулями
<?php
$str = '1';
echo sprintf("%04d", $str);
// Выводит "0001"
?>
@amikitevich
amikitevich / gist:7bf031cd5f2cd7f4dbe7
Created January 24, 2016 23:58
Залогировать евенты
app/Mage.php should look like:
public static function dispatchEvent($name, array $data = array())
{
// log event name
Mage::log($name, null, 'events.log', true);
Varien_Profiler::start('DISPATCH EVENT:'.$name);
$result = self::app()->dispatchEvent($name, $data);
#$result = self::registry('events')->dispatch($name, $data);