Skip to content

Instantly share code, notes, and snippets.


Rafael Kendrik rafaelkendrik

View GitHub Profile
rafaelkendrik / vue-router-route-by-href.js
Last active Aug 11, 2020
Get route from vue-router by href
View vue-router-route-by-href.js
// will return the route based on location
console.log( // can be $router.resolve instead
// or
export const ACCOUNT_ID_KEY = 'account-id'
export const ACCOUNTS_KEY = 'accounts'

const get = (key, options = {}) => {
  const value = localStorage.getItem(key)

  return (options.parse)
    ? JSON.parse(value)
    : value
View LoginService.js
import http from '@/http'
export const doLogin = (userInfo) => {
return http().get(`/sanctum/csrf-cookie`).then(() => {
return http().post(`/api/v1/common/login`, {
password: userInfo.password
}).then((response) => {
return response;
rafaelkendrik /
Last active Aug 25, 2020
Shortcode in Javascript using Template Strings

Shortcode in Javascript using Template Strings.

Implementing a similiar Wordpress Shortcode feature in Javascript using Template Strings.

"In a nutshell, a shortcode is a small piece of code, indicated by brackets like [this], that performs a dedicated function on your site."

In Javascript when can implement Shortcodes using Template Strings.

Pretend that we have a template page-template.html that contains a shortcode gallery which will be replaced by the code of AwesomeGallery.



The JSON.stringify() method converts a JavaScript object or value to a JSON string, optionally replacing values if a replacer function is specified or optionally including only the specified properties if a replacer array is specified.

Replacer - as a function

const foo = {
  baz: 'baz',
  bar: 'bar'
rafaelkendrik /
Last active Apr 16, 2020
[EN] Presentation - Rafael Kendrik


My name is Rafael Kendrik, I'm a Brazilian Front-end Web Developer since 2015.

Most of my experience have been dedicated in Single Pages Applications (SPA) development.

I contributed for 2 years in Sices Solar Platform (, developing 2 clients in Vue.js (vuex, vue-router) working in Kolinalabs team.

I also contributed over 1 year in two projects developed in Angular.js.

rafaelkendrik /
Last active Apr 16, 2020
[PT] Apresentação - Rafael Kendrik


Meu nome é Rafael Kendrik, sou desenvolvedor Web Frontend há aproximadamente 5 anos.

Gostaria, por gentileza, de alguns minutos para apresentar um pouco da minha experiência profissional.

A maioria da minha experiência está dedicada em contribuições de desenvolvimento de SPAs.

Durante 2 anos contribui para um projeto de uma empresa Latino Americana chamada Sices Solar ( no desenvolvimento de dois clientes web em Vue.js (+vuex), trabalhando junto à KolinasLabs.

rafaelkendrik / url-update.sql
Created Apr 24, 2019
View url-update.sql
UPDATE wp_options \
SET option_value=replace(option_value, 'url_curr', 'url_new') \
WHERE option_name='home' OR option_name='siteurl';
UPDATE wp_posts \
SET guid=replace(guid, 'url_curr','url_new');
UPDATE wp_posts \
SET post_content=replace(post_content, 'url_curr', 'url_new');
rafaelkendrik / event-loop.js
Last active May 7, 2018
Non-blocking, callback and pomises on Javascript's event loop.
View event-loop.js
/* X example - common non-blocking execution */
const x = 5
console.log('hello X', x)
const plusOneX = (x) => {
setTimeout(() => {
// a bad reassign e.g.:
x = x + 1
rafaelkendrik / n-tree-replace.js
Last active Apr 21, 2020
Walking through a tree, combining reduce and recursion
View n-tree-replace.js
const tree = {
obj1: {
obj2: {
key1: 'key1'
obj3: {
obj4: {
key2: 'key2'