Skip to content

Instantly share code, notes, and snippets.

View tyllo's full-sized avatar
🏠
Working from home

Andrey Pastukhov tyllo

🏠
Working from home
View GitHub Profile
@tyllo
tyllo / async-await-for-cycles.js
Last active August 29, 2017 05:30
Test async-await for cycles
function timeout(time = 1000) {
return new Promise(resolve => setTimeout(resolve, time, time))
}
async function testWhile(count) {
let i = -1
while (++i < count) {
const res = await timeout(i * 1000)
console.log({ res, i })
@tyllo
tyllo / commands.sh
Created March 9, 2017 14:57
Some docker comands
## build image
docker build -t tyllo/$name .
## run image with volume
params='-it -p 8080:8080 -p 8888:8888 -v `cygpath -d $PWD`:"$PWD" -w "$PWD"'
docker run $params --name test tyllo/name bash
## start container id
docker start #name-container
/**
* @param {string} string
* @param {string} prefix
* @return {Generator<string>}
*/
function *permutationGenerator(string, prefix = '') {
if (!string) {
yield prefix;
}
@tyllo
tyllo / task-1.js
Last active March 2, 2017 15:23
Тест
/**
* Convert binary to decimal number
* @param {string} binary
*/
function binaryToDecimal(binary) {
return binary.split('').reverse().reduce((summa, char, i) => {
return char === '0' ? summa : summa + Math.pow(2, i)
}, 0)
}
@tyllo
tyllo / interactors verify_email.rb
Created May 30, 2016 09:02
Simple examle for Ruby on rails
module Register
class VerifyEmail < RegisterBase
def call
context.fail! if context.validation_fail
url = resource_url + '/verification?verification_code='
url += URI.escape(context.verification_code) if context.verification_code
result = make_request(::Utils::Stubs.verify_email, :post, url)
end
@tyllo
tyllo / pagination.js
Created May 30, 2016 08:45
Example Angular derictive
class PaginationDirective {
constructor () {
this.restrict = 'E'
this.replace = true
this.templateUrl = 'common/directives/mb-pagination'
this.scope = {
currentPage: '=',
countPage: '=',
selectPage: '=',
url: '='
@tyllo
tyllo / component-test.js
Created May 30, 2016 08:30
Ember example code for event-popup component
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('event-list-item', 'Integration | Component | event list item', {
integration: true
});
test('it renders', function(assert) {
this.set('model', { meta: {} });
this.set('camera', { id: 'test' });
@tyllo
tyllo / event-test.js
Last active June 24, 2016 13:33
Ember example code for utils
import * as EventUtils from 'frontend/utils/event';
import { module, test } from 'qunit';
const i18n = { locale: 'en', t: trigger => trigger };
module('Unit | Utility | event - generateTitle');
test('it exists', function(assert) {
assert.ok(EventUtils.generateTitle);
});
@tyllo
tyllo / exemple
Created June 16, 2015 14:29
exemple gulp-sourcemaps
var
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
plumber = require('gulp-plumber'),
settings = {
outputStyle: 'compressed',
includePaths: []
};