Skip to content

Instantly share code, notes, and snippets.

View allanphilipbarku's full-sized avatar

Allan Philip Barku allanphilipbarku

View GitHub Profile
@allanphilipbarku
allanphilipbarku / vue package version mismatch
Created August 13, 2019 20:41
command to fix vue package version mismatch
npm install vue-template-compiler@2.5.16 --save-dev
@allanphilipbarku
allanphilipbarku / disable_aggregation.md
Created December 20, 2019 00:32 — forked from crittermike/disable_aggregation.md
Disabling CSS/JS aggregation via Drush in Drupal 7 and Drupal 8

Drupal 7

drush vset preprocess_css 0 --yes
drush vset preprocess_js 0 --yes

Drupal 8

@allanphilipbarku
allanphilipbarku / Car.js
Created January 16, 2020 09:33 — forked from r3dm1ke/Car.js
Car class in ES6
class Car {
constructor(make, model) {
this.make = make;
this.model = model;
}
start() {
console.log('vroom');
}
@allanphilipbarku
allanphilipbarku / Car.js
Created January 16, 2020 09:34 — forked from r3dm1ke/Car.js
Car class in ES5
// "class" declaration
function Car(make, model) {
this.make = make;
this.model = model;
}
// the start method
Car.prototype.start = function() {
console.log('vroom');
}
const actions = new Map([
[1, ['processing','IndexPage']],
[2, ['fail','FailPage']],
[3, ['fail','FailPage']],
[4, ['success','SuccessPage']],
[5, ['cancel','CancelPage']],
['default', ['other','Index']]
])
const onButtonClick = (status)=>{
const actions = new Map([
['guest_1', ()=>{/*do sth*/}],
['guest_2', ()=>{/*do sth*/}],
['guest_3', ()=>{/*do sth*/}],
['guest_4', ()=>{/*do sth*/}],
['guest_5', ()=>{/*do sth*/}],
['master_1', ()=>{/*do sth*/}],
['master_2', ()=>{/*do sth*/}],
['master_3', ()=>{/*do sth*/}],
['master_4', ()=>{/*do sth*/}],
const actions = new Map([
[{identity:'guest',status:1},()=>{/*do sth*/}],
[{identity:'guest',status:2},()=>{/*do sth*/}],
//...
])
const onButtonClick = (identity,status)=>{
let action = [...actions].filter(([key,value])=>(key.identity == identity && key.status == status))
action.forEach(([key,value])=>value.call(this))
}
const actions = ()=>{
const functionA = ()=>{/*do sth*/}
const functionB = ()=>{/*do sth*/}
return new Map([
[{identity:'guest',status:1},functionA],
[{identity:'guest',status:2},functionA],
[{identity:'guest',status:3},functionA],
[{identity:'guest',status:4},functionA],
[{identity:'guest',status:5},functionB],
//...
const actions = ()=>{
const functionA = ()=>{/*do sth*/}
const functionB = ()=>{/*do sth*/}
return new Map([
[/^guest_[1-4]$/,functionA],
[/^guest_5$/,functionB],
//...
])
}
const actions = ()=>{
const functionA = ()=>{/*do sth*/}
const functionB = ()=>{/*do sth*/}
const functionC = ()=>{/*send log*/}
return new Map([
[/^guest_[1-4]$/,functionA],
[/^guest_5$/,functionB],
[/^guest_.*$/,functionC],
//...
])