Skip to content

Instantly share code, notes, and snippets.

Avatar

Rafael Kendrik rafaelkendrik

View GitHub Profile
@rafaelkendrik
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(
VueRouter.prototype.resolve.call( // can be $router.resolve instead
this.$router,
'/my-path'
)
)
// or
View promisify-localstorage.md
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`, {
email: userInfo.email,
password: userInfo.password
}).then((response) => {
return response;
});
@rafaelkendrik
rafaelkendrik / javascript-template-string-shortcodes.md
Last active Aug 25, 2020
Shortcode in Javascript using Template Strings
View javascript-template-string-shortcodes.md

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.

View json-stringify.md

JSON.stringify()

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
rafaelkendrik / presentation-en.md
Last active Apr 16, 2020
[EN] Presentation - Rafael Kendrik
View presentation-en.md

Hi,

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 (https://plataformasicessolar.com.br), 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
rafaelkendrik / presentation-pt.md
Last active Apr 16, 2020
[PT] Apresentação - Rafael Kendrik
View presentation-pt.md

Olá!

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 (https://plataformasicessolar.com.br) no desenvolvimento de dois clientes web em Vue.js (+vuex), trabalhando junto à KolinasLabs.

@rafaelkendrik
rafaelkendrik / url-update.sql
Created Apr 24, 2019
wordpress-url-update
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
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
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'
}
}