Skip to content

Instantly share code, notes, and snippets.

View klinkov's full-sized avatar

Yuriy Klinkov klinkov

  • London
  • 18:31 (UTC +01:00)
View GitHub Profile
@klinkov
klinkov / protips.js
Created August 1, 2016 17:00 — forked from nolanlawson/protips.js
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
'use strict';
import PushNotification from "react-native-push-notification";
let _pushNotificationToken = null;
const _pushNotificationListeners = [];
function init() {
console.log("PushNotification init");
@klinkov
klinkov / navSaga.js
Created February 2, 2018 18:02 — forked from alexrussell/navSaga.js
Idea of how I have implemented a `goBackTo` saga for react-navigation.
export const goBackTo = function * goBackTo ({ payload: { routeName } }) {
const { nav } = yield select()
let targetIndex
for (let i = nav.index; i > 0; i--) {
if (nav.routes[i].routeName === routeName) {
targetIndex = i + 1
break
}
@klinkov
klinkov / README-Template.md
Created April 13, 2018 18:08 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@klinkov
klinkov / gist:3906133d124962bb8a5e6c797b866cee
Created January 21, 2019 09:49 — forked from shaiguitar/gist:627d52ebc0c03af488477b5d636a8909
Using docker compose to mount current working directory dynamically into the container
# mount volume PWD on host to /app in container.
shai@lappy ~/tmp/example-working-docker-compose-environment-vars [master *] ± % cat docker-compose.yml
version: "3"
services:
some_server:
...
volumes:
- $PWD:/app
function mockServerCall () {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve({
'status': 200,
'content-type': 'application/json',
'data' : {
dataOfInterest: 42
}
})