Skip to content

Instantly share code, notes, and snippets.

View sotaan's full-sized avatar

David Mamane sotaan

  • Paris, France
View GitHub Profile
@sotaan
sotaan / VuexComputed.js
Last active June 30, 2018 00:00
this Vue plugin will create a new computed property with getter/setter binded to a Vuex state property and a mutation
// bind a computed property getter&setter to Vuex state&mutation
// install it with `Vue.use(VuexComputed)` after `Vue.use(Vuex, ...)` line
const VuexComputed = {
install (Vue) {
/**
* computed property factory
* @param {String} statePropName state property name in Vuex store
* @param {String} mutationType name of mutation updating state property
* @param {Number} [debounce=false] wait time argument passed to lodash debounce function
* @return {Object} the new computed property to inject
@sotaan
sotaan / storage.js
Created October 6, 2016 13:45
proxy & cookie storage experiments (use https://github.com/franciscop/cookies.js)
cookies({ token: '42' , guestHash: 'sdjskdljskdjlkjsdUHYIUYHKJH', accountType: 'BUYER'})
var encapsulatedData = val => ({ value: val, lastAccess: new Date()})
var target = { 'token': null , 'guestHash': null, 'accountType': null }
//var authorizedKeys = Object.keys(target)
for (key in target) {
//we encapsulate the data with Date of its last access
target[key] = encapsulatedData(cookies(key))
}
var handler = {
@sotaan
sotaan / api_config.js
Last active October 6, 2016 13:06
generate URL of any RESTfull API Endpoint
/**
* Components used to build the final URL
* @type {Object}
*/
const urlComponents = {
url: "http://myapi.mycompany.com/",
prefix: "api",
cart_uri: "/carts",
cart_active_uri: "/active",
cart_clean_uri: "/clean",
@sotaan
sotaan / command output
Last active October 5, 2016 12:16
wdio error with webdriverajax
$ wdio
=======================================================================================
Selenium 2.0/webdriver protocol bindings implementation with helper commands in nodejs.
For a complete list of commands, visit http://webdriver.io/docs.html.
=======================================================================================
[16:02:56]: COMMAND POST "/wd/hub/session"
[16:02:56]: DATA {"desiredCapabilities":{"browserName":"chrome","version":"","javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"platform":"ANY","loggingPrefs":{"browser":"ALL","driver":"ALL"},"requestOrigins":{"url":"http://webdriver.io","version":"3.4.0","name":"webdriverio"}}}