Skip to content

Instantly share code, notes, and snippets.

Boris Okunskiy inca

Block or report user

Report or block inca

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@inca
inca / HEXRAY_PRIVACY_POLICY.md
Created Jul 29, 2019
HexRay Laser Puzzle Privacy Policy
View HEXRAY_PRIVACY_POLICY.md

Privacy Policy

HexRay Laser Puzzle game is a Freemium app (Service) provided by Boris Okunskiy (Author) at no cost and is intended for use as is. It is designed for general audience, including children younger than 13 years old.

This page is used to inform the users of Service regarding our policies with the collection, use, and disclosure of Personal Information if anyone decided to use our Service.

If you choose to use our Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that we collect is used for providing and improving the Service. We will not use or share your information with anyone except as described in this Privacy Policy.

Information Collection and Use

@inca
inca / generate-combinations.js
Last active Jun 17, 2019
Generate Combinations Without Repetition
View generate-combinations.js
function* generateCombinations(array) {
if (array.length == 0) {
return;
}
const head = array[0];
const tail = array.slice(1);
yield [head];
for (const comb of generateCombinations(tail)) {
yield comb;
yield [head].concat(comb);
View promise-reduce.es6
const tasks = [
doThis,
doThat
];
function doAllTasks() {
return tasks.reduce((flow, task) => flow.then(() => task()),
Promise.resolve());
}
View promise-all.es6
function doBunchOfStuff() {
return Promise.all([
doThis(),
doThat()
])
.then([ thisResult, thatResult] => {
/* ... */
});
}
View promise-sequence.es6
function doSomeWork() {
return Promise.resolve()
.then(() => doSomething())
.then(() => doSomethingElse());
}
function doSomething() {
return new Promise(resolve => { /* ... */ });
}
View promise-to-callback.es6
function (done) {
doStuff()
.then(result => done(null, result), done);
}
View callback-to-promise.es6
// Most trivial one: promisified setTimeout
function timeout(delay) {
return new Promise(resolve => setTimeout(resolve, delay));
}
// Promisified request
import request from 'request';
function req(...args) {
return new Promise(resolve => {
@inca
inca / STYLEGUIDE.md
Last active Jul 19, 2016
Stylesheets Styleguide
View STYLEGUIDE.md

Minimal conventions for composing stylesheets — our response to CSS frameworks 🤓

Conventions

Good classnames:

  • .myComponent
  • .myComponent-subComponent
  • .myComponent--modifier
@inca
inca / README.md
Last active Nov 15, 2018
Koa 2 Router
View README.md

Simple DIY router for Koa 2

Why? Because koa-route is too verbose and accepts middleware functions with weird signatures (e.g. async (ctx, param1, param2, next)) which prevent robust middleware composition. And koa-router has .use method that behaves not as Express users would expect.

This gist is not a library material (at least not yet), b/c it doesn't account for all possible use-cases for routers, since people tend to use them completely differently. Instead, it provides you with ~100sloc router which you can use and further adapt to your specific needs.

Dependencies

npm i --save koa@2 path-to-regexp methods koa-mount@next
@inca
inca / README.md
Last active Aug 29, 2015
Browserify + Transforms + Symlinks
View README.md

Browserify + Transforms + Symlinks

This document briefly describes how I tend to build static front-end apps with Browserify. Specifically, it addresses the "Avoiding ../../../../../" issue described in Browserify Handbook while also preserving the ability to use Browserify transforms.

The Heartbeat Problem

Requiring own modules using relative paths can quickly become pretty annoying:

var Users = require('../../../repository/users')
You can’t perform that action at this time.