Skip to content

Instantly share code, notes, and snippets.

View asvae's full-sized avatar

Yauheni Prakopchyk asvae

View GitHub Profile
@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 / 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 / compare_laravel_and_doctrine_migrations.md
Last active November 13, 2020 18:43
Compare laravel and doctrine migrations

Let’s compare Laravel and Doctrine migrations

Laravel vs Doctrine

This article is targeted on Laravel beginners. No skills required whatsoever. Article is a tad opinionated, so take it with a grain of salt. Also, details are omitted for the sake of brevity.

In this article I will do the actual comparison as well as give several hints to get started.

If you’ve never heard of Doctrine, it is database abstraction layer. Sorta like Eloquent, but different type: Laravel is active record (AR), while Doctrine is object relational mapper (ORM).

Laravel migrations (docs)

@asvae
asvae / inject-provide-store-example.md
Last active October 11, 2019 10:50
Inject-provide store example

Plugin (store-plugin.ts)

import { CheckOutStore } from '../services/store'

export const checkOutStoreInjectKey = Symbol('checkOutStore')

export const StorePlugin = {
  install (Vue: any): void {
    Vue.mixin({
      inject: {
@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.
import DomHelpers from './Utility/DomHelpers.js'
// ...
methods: {
click (event) {
DomHelpers.isChild(this.$el, event.target) || this.hide()
},
}
<div class="click-target-modal">
<div class="click-target-modal__content"
v-if="isDisplayed"
>
<slot></slot>
</div>
</div>
// ...
methods: {
show () {
this.isDisplayed = true
this.$emit('input', true)
this.listen(true)
},
hide () {
this.isDisplayed = false
this.$emit('input', false)
<div class="document-event-modal">
<div class="document-event-modal__content"
@click.stop
v-if="isDisplayed"
>
<slot></slot>
</div>
</div>
.full-screen-overlay-modal {
&__background {
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
&__content {