Skip to content

Instantly share code, notes, and snippets.

View asvae's full-sized avatar

Yauheni Prakopchyk asvae

View GitHub Profile
@asvae
asvae / convertBYRToBYN.php
Last active February 13, 2017 12:13
Laravel BYR to BYN currency converter command
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class ConvertBYRToBYN extends Command
{
protected $signature = 'convert-byr-to-byn';
@asvae
asvae / array_delete.js
Created May 25, 2017 10:30
array delete function with tests
/**
* Remove item from array via identity check.
*
* @param array
* @param item
* @returns {[*]}
*/
static remove (array: Array, item) {
const result = [...array]
@asvae
asvae / executor.js
Last active May 18, 2023 12:08
Executor pattern
// Class
export default class Executor {
command: Function
wasLastRunFine: Boolean = false
runCount: Number = 0 // Currently active commands count
wasRun: Boolean = false
wasRunFine: Boolean = false
wasRunBad: Boolean = false
@asvae
asvae / countryStore.js
Last active July 3, 2017 15:23
Country store
import CountryRepository from '../classes/Api/CountryRepository.js'
import Country from "../classes/Domain/Entity/Country";
export default {
_isInitialized: false,
_countries: [],
get countries (): Array<Country> {
if (!this._isInitialized) {
this._isInitialized = true
@asvae
asvae / FixUserRoles.php
Created July 12, 2017 13:59
Laravel database fixture example
<?php
namespace Upping\Console\Commands;
use Bican\Roles\Models\Role;
use Illuminate\Console\Command;
use Upping\Models\User;
use Upping\Repositories\UserRepository;
class FixUserRoles extends Command
@asvae
asvae / TimePicker.vue
Created July 17, 2017 19:41
Time picker on vue 2 (stateful computed property example)
<template>
<div>
<vm-clock
v-if="! showMinutes"
type="hours"
v-model="hours"
@input="showMinutes = true"
>
<vm-am-pm-switch v-model="amPm"/>
</vm-clock>
@asvae
asvae / suggest-node-testing.md
Created August 6, 2017 11:09
Suggesting node testing

We suggest to use node.js for api integration tests.

Upsides

  • Code sharing between frontend and testers (Entity (sctructure + bound logic), Factory, Mapper).
  • Filling the test-coverage gap between backend and frontend. Currently this is the most untested and dangerous part.
  • Node is better than php to work with dynamic data structures.
  • Making frontend guys happy as our burden will be lightened.

Downsides

  • Testers should have to learn JS. Though tests don't pose much a difficulty.
@asvae
asvae / 2c2p promise loader
Created September 1, 2017 19:04
2c2p-promise-loader.js
let promise
export async function getMy2c2p () {
promise || (promise = new Promise((resolve, reject) => {
const script = document.createElement('script')
script.src = 'https://demo2.2c2p.com/2C2PFrontEnd/SecurePayment/api/my2c2p.1.6.9.min.js'
script.async = true
script.onload = () => {
resolve(My2c2p)
}
@asvae
asvae / FieldRepository.js
Created September 1, 2017 22:17
FieldRepository.js
import Field from '../Domain/Entity/Field.js'
import FieldMapper from '../Domain/Mapper/FieldMapper.js'
import repoBus from '../../oop-store/repoBus'
import axios from '../../plugins/internal/axios-instance.js'
import MappingHelpers from '../Utility/Static/MappingHelpers.js'
export const FIELD_UPDATED = 'Field updated'
export const FIELD_CREATED = 'Field created'
@asvae
asvae / Hunt for perfect modal.md
Created July 16, 2018 09:16
Hunt for perfect modal

Hunt for perfect modal

#modal #popup #javascript #vuejs 2017-05-08

vue navigation

Hey. Today we will pursue our dream for perfect modal. Being perfect means:

  • Floats above everything else.
  • Is not blocking.
  • Supports nesting of any depth.