View example.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[cartActions.INCREMENT_CART_ITEM_QTY]({ commit, state }, cartItemId) { | |
let clonedCartItems = {...state.cartItems} | |
clonedCartItems[cartItemId].qty++ | |
let actualCartItems = [] | |
for (let key in clonedCartItems) { | |
let currentCartItem = clonedCartItems[key] | |
actualCartItems.push({ | |
id: currentCartItem.id, | |
product_id: currentCartItem.product_id, | |
qty: currentCartItem.qty |
View question about formatting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static registerCallBack(personName, personPhone) { | |
return axios.post(`${BASE_URL}/api/client/v2/callback_messages`, { | |
name: personName, | |
phone: personPhone | |
}).then(resp => resp.data) | |
.catch(err => { | |
throw err | |
}) | |
} |
View gitconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all | |
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all | |
lg = !"git lg1" | |
[core] | |
editor = vim |
View PipeandReduce.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let statement = "wELCOME | lower | capitalize"; | |
let another = "welcome | upper"; | |
let handlers = { | |
lower : (val) => val.toLowerCase(), | |
upper: (val) => val.toUpperCase(), | |
capitalize: (val) => val.slice(0,1).toUpperCase() + val.slice(1) | |
}; |
View reverse.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let arr1 = [1,2,3,4,5]; | |
let arr2 = [1,2,3,4,5,6,7,8,9,10]; | |
function reverse(arr) | |
{ | |
var len = arr.length; | |
var middle = Math.floor(len / 2); | |
var start = 0; | |
var end = len - 1; | |
View middleware.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let middlewares = [{ | |
handle(requesst , next) | |
{ | |
console.log(`Username is: ${request.name}`); | |
next(request); | |
} | |
}, | |
{ | |
handle(request ,next) | |
{ |
View memoize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function memoize(func) | |
{ | |
let cache = {}; | |
return function(x ,y) | |
{ if(Object.keys(cache).length == 0) | |
{ | |
cache.res = func(x,y ); | |
cache.x = x; |
View promise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
httpGetUser('http://localhost:3000/users') | |
.then(response => | |
{ | |
console.log('First resolve callback'); | |
console.log('~~~~~~~~~~'); | |
var user = JSON.parse(response); | |
user = user.find((user) => user.name == 'Nerhbest'); | |
return user.name; |
View Reduxagain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function todo(state, action) | |
{ | |
switch(action.type) | |
{ | |
case 'ADD_TODO': | |
return { | |
id: action.id, | |
text: action.text, |
View redux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const createStore = (reducer) => | |
{ | |
let state; | |
let listeners = []; | |
const getState = () => state; | |
const dispatch = (action) => | |
{ | |
state = reducer(state , action); |
NewerOlder