Skip to content

Instantly share code, notes, and snippets.

View OlegLustenko's full-sized avatar

Oleg Lustenko OlegLustenko

View GitHub Profile
@OlegLustenko
OlegLustenko / add.js
Created March 14, 2016 09:13
Adding big numbers JavaScript (from codewars.com)
function add (a, b) {
let res = '', c = 0
a = a.split('')
b = b.split('')
while (a.length || b.length || c) {
c += ~~a.pop() + ~~b.pop()
res = c % 10 + res
c = c > 9
}
return res
@OlegLustenko
OlegLustenko / x-www-form-urlencode.js
Created March 14, 2016 09:14
HTTP POST x-www-form-urlencode Lodash-practise
Задача: build_key_value
Flatten the given hash. This is how HTTP libraries pack data when POST requests are made using x-www-form-urlencoded.
Example: {"x[0]":"1","x[1]":"2","x[2]":"3"} == solution({"x":["1","2","3"]})
var _ = require('lodash')
module.exports = solution = (s, p) => {
var r = {};
_.forEach(s, (v, k) => {
function deepCompare(o1, o2) {
let compare = x => {
if(x == null) return x;
return Object.keys(x).sort()
.reduce((a,b)=>{
if( Array.isArray(x[b]) ) {
a[b] = x[b].map(side=>JSON.stringify(compare(side)))
} else if( typeof x[b] == 'object' && x[b] != null ) {
// Place your settings in this file to overwrite the default settings
{
"window.zoomLevel": 1,
"editor.tabSize": 2,
"eslint.enable": true,
"eslint.options": {
"rules": {
"semi": 2,
"comma-dangle": 2, // disallow or enforce trailing commas
"no-cond-assign": 2, // disallow assignment in conditional expressions
'use strict';
const NODE_ENV = process.env.NODE_ENV || 'pokestars';
const webpack = require('webpack');
const fs = require('fs');
const path = require('path');
let homeWork = fs.readdirSync(path.join(__dirname, 'home_work'))
.reduce((a, lesson) => {
a[lesson] = fs.readdirSync(path.join(__dirname + '/home_work', lesson))
@OlegLustenko
OlegLustenko / Ws.js
Created November 14, 2016 12:18
WebStorm settings
let asd = 'hi'
@OlegLustenko
OlegLustenko / cloudSettings
Created December 2, 2016 21:31
Visual Studio Code Sync Settings GIST
{"lastUpload":"2016-12-02T21:31:24.262Z"}
// Place your settings in this file to overwrite the default settings
{
"extensions.autoUpdate": true,
"flow.enabled": true,
"window.zoomLevel": 1,
"files.associations": {
"*.css": "scss"
},
// "editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,