Skip to content

Instantly share code, notes, and snippets.

View yalovek's full-sized avatar

Vadim Yalovenko yalovek

  • ЮMoney
  • St.Petersburg
View GitHub Profile
@yalovek
yalovek / convertKeyboardKeysLatinToCyrillic.js
Created October 23, 2016 16:49
Convert keyboard keys from latin to cyrillic
/**
* Function for converting keyboard keys from latin to cyrillic
* @param {String} word Word on latin
* @return {String} Word converted to cyrillic
*/
const convertKeyboardKeysLatinToCyrillic = word => {
const keyboardMap = {
'a': 'ф',
'b': 'и',
'c': 'c',
@yalovek
yalovek / iterate-arrays.js
Last active March 30, 2019 04:42
Iterate arrays
(function(cb, ...params) {
const last = params.length - 1;
const count = params[last] - 1;
function iterate(c, values) {
params[c].forEach(function(item) {
if (c === count) {
cb(...values, item);
} else {
iterate(c + 1, [...values, item]);
@yalovek
yalovek / lucky-ticket.js
Last active March 11, 2019 16:57
Lucky ticket
(function(count){
if (count % 2 !== 0) {
throw Error('Must be even number');
}
const result = {};
const length = count / 2;
const sums = Array.from({length: Math.pow(9, length) / 2});
const nums = Array.from({length: 10});
const go = (l, m, n) => {
@yalovek
yalovek / convertKeyboardKeysCyrillicToLatin.js
Created October 24, 2016 19:58
Convert keyboard keys from cyrillic to latin
/**
* Function for converting keyboard keys from cyrillic to latin
* @param {String} word Word on cyrillic
* @return {String} Word converted to latin
*/
const convertKeyboardKeysCyrillicToLatin = word => {
const keyboardMap = {
'ф': 'a',
'и': 'b',
'c': 'c',
@yalovek
yalovek / translitLatinToCyrillic.js
Created October 23, 2016 16:26
Translit latin to cyrillic
/**
* Function for translitirating latin to cyrillic
* @param {String} word Word on latin
* @return {String} Word translitirated to cyrillic
*/
const translitLatinToCyrillic = word => {
const translitMap = {
'a': 'а',
'b': 'б',
'c': 'ц',
@yalovek
yalovek / translitCyrillicToLatin.js
Last active October 23, 2016 16:24
Translit cyrillic to latin
/**
* Function for translitirating cyrillic to latin
* @param {String} word Word on cyrillic
* @return {String} Word translitirated to latin
*/
const translitCyrillicToLatin = word => {
const translitMap = {
'а': 'a',
'б': 'b',
'в': 'v',
@yalovek
yalovek / anagram.js
Last active October 23, 2016 15:24
Function for checking array of words for anagrams
/**
* Function for checking array of words for anagrams
* @param {Array} words Array of words
* @return {Array} Array of arrays with anagram words
*/
const anagram = words => words.reduce((result, word) => {
if (!result[word.length]) {
result[word.length] = [word];
}
else {
@yalovek
yalovek / sum.js
Created October 17, 2016 07:03
Calculating sum of numbers sum(2)(3)(4)
function sum(x) {
const f = y => sum(x + y);
f.valueOf = () => x;
return f;
}
@yalovek
yalovek / install.sh
Last active August 29, 2016 11:23
Installation guide of OSM project for OS X
#!/bin/sh
# Install brew
xcode-select --install
http://xquartz.macosforge.org/landing/
http://support.apple.com/kb/DL1572
@yalovek
yalovek / paint.py
Last active August 29, 2016 11:19
Simple Paint
from turtle import *
import math
class MyTurtle(Turtle):
def rectangle(self,a,b):
self.fd(a)
self.lt(90)
self.fd(b)
self.lt(90)
self.fd(a)
self.lt(90)