Skip to content

Instantly share code, notes, and snippets.

View vvscode's full-sized avatar
⌨️
Here is Rhodes, jump here!

Vasiliy Vanchuk vvscode

⌨️
Here is Rhodes, jump here!
View GitHub Profile
@vvscode
vvscode / loadable.ts
Created February 8, 2019 10:34
handle-api-call-state-nicely
export function createDefaultLoadable() {
loading: false,
success: false,
error: null,
}
export function onLoadableLoad(loadable) {
return {
...loadable,
loading: true,
success: false,
@vvscode
vvscode / Loadable.d.ts
Created February 8, 2019 10:33
handle-api-call-state-nicely
export interface Loadable {
loading: boolean;
success: boolean;
error: any;
}
@vvscode
vvscode / News.d.ts
Created February 8, 2019 10:32
handle-api-call-state-nicely
export interface News {
loading: boolean;
entities: string[];
}
@vvscode
vvscode / package.json
Last active February 3, 2019 10:15
Websocket shell (node.js)
{
"name": "ws-proxy",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
const {
getChange
} = require('./getChange');
const assert = require('assert');
const TESTS = [{
dealDetails: [1, 1],
change: [0, 0, 0, 0, 0, 0]
},
{
const {
buildSquareStr
} = require('./buildSquareStr');
const assert = require('assert');
const SQUARES = {
1: `■`,
3: [`□□□`, `□■□`, `□□□`].join('\n'),
5: [`■■■■■`, `■□□□■`, `■□■□■`, `■□□□■`, `■■■■■`].join('\n'),
7: ['□□□□□□□', '□■■■■■□', '□■□□□■□', '□■□■□■□', '□■□□□■□', '□■■■■■□', '□□□□□□□'].join('\n'),

@kangax's ES6 quiz, explained

@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).

Here we go with the explanations:

Question 1:
(function(x, f = () => x) {
@vvscode
vvscode / godmode.js
Created September 4, 2016 17:29
God Mode in JavaScript
// что возвращает эта функция?
(function fun(Infinity, length, __proto__)
{
return [,,~0.[0|0]][fun.__proto__.length && Infinity, -~String(this).length >> __proto__] << (0. === .0) + Infinity;
}).apply(typeof fun, [,,2]);
// рассмотрим массив с аргументами:
// "0" in [,,2] => false
// "1" in [,,2] => false
@vvscode
vvscode / am-snippet.js
Created March 31, 2016 06:43
Amazing Hiring parsing helper
// In global NS to make debug more easier
var PAGES_DELAY = 3000;
var profiles = [];
function step1() {
console.log(`Process page: ${window.location}`);
$('a[href*="/profile"]').toArray().forEach((a) => profiles.push(a.getAttribute('href')));
console.log(profiles.length, $('a[href*="/profile"]').length);
if(!$('a.page-link.next').length) {
return;
@vvscode
vvscode / vasiliy_elevator.js
Created March 15, 2016 18:47
Задача про лифт
var DIRECTION_DOWN = -1
var DIRECTION_NONE = 0
var DIRECTION_UP = 1
function HardwareElevator(){};
HardwareElevator.prototype = {
moveUp:function(){console.log('moving up');},
moveDown:function(){console.log('moving down');},
stopAndOpenDoors:function(){console.log('stopping and opening doors');},
getCurrentFloor:function(){console.log('getting current floor');},