Skip to content

Instantly share code, notes, and snippets.

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

Oleksandr Kovalov okovalov

🏠
Working from home
View GitHub Profile
Pre-reqs
a) install VirtualBox and Vagrant
b) add homestead box (once vagrant is installed) - vagrant box add laravel/homestead
1) create local directory (source code would be placed there)
mkdir ~/prj/Commer/v2/lac2-magento.dev
1.a) cd ~/prj/Commer/v2/lac2-magento.dev/
@okovalov
okovalov / .bash_profile
Created April 13, 2018 17:37 — forked from natelandau/.bash_profile
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@okovalov
okovalov / get_combinations.php
Created October 6, 2018 01:25 — forked from cecilemuller/get_combinations.php
PHP: Get all combinations of multiple arrays (preserves keys)
<?php
function get_combinations($arrays) {
$result = array(array());
foreach ($arrays as $property => $property_values) {
$tmp = array();
foreach ($result as $result_item) {
foreach ($property_values as $property_value) {
$tmp[] = array_merge($result_item, array($property => $property_value));
}
const isOpen = (parenthesisChar, pts) => pts.filter(pt => pt[0] === parenthesisChar).length
const matches = (topOfStack, closed, pts) => pts.filter(pt => pt[0] === topOfStack && pt[1] === closed).length
const getValidCharacters = patterns => patterns.map(p => p.join('')).join('')
const verify = string => {
const charactersArr = string.split('')
const patterns = [
const ceasarCipher = (str, num) => {
const alphabetArr = 'abcdefghijklmnopqrstuvwxyz'.split('')
let myNum = num % alphabetArr.length
const strArr = str.toLowerCase().split('')
let resArr = []
for (let c in strArr) {
const harmlessRansomNote = (search, text) => {
let result = true
const textArr = text.toLowerCase().split(' ')
const searchArr = search.toLowerCase().split(' ')
const hash = {}
for (let idx in textArr) {
const word = textArr[idx]
if (!hash[word]) hash[word] = 0
const fizzBuzz = num => {
for(let i = 1; i <= num; i++) {
if (i % 15 === 0) {
console.log('FizzBuzz')
continue
}
let val = i
if (i % 3 === 0) val = 'Fizz'
const reverseWords = string => {
const wordsArr = string.split(' ')
let result = []
wordsArr.forEach(el => {
result.push(el.split('').reverse().join(''))
})
return result.join(' ')
const reverseArrayInPlace = arr => {
for(let i = 0; i < (arr.length / 2)+1; i++) {
const first = arr.shift()
arr.splice(arr.length - i, 0, first)
}
return arr
}
const getMedian = arr => {
const arrLen = arr.length
if (arrLen % 2 !== 0) {
return arr[Math.floor(arrLen / 2)]
} else {
const m1 = arr[(arrLen / 2) - 1]
const m2 = arr[arrLen / 2]
return (m1 + m2) / 2
}