Skip to content

Instantly share code, notes, and snippets.

View rafaelkendrik's full-sized avatar

Rafael Kendrik rafaelkendrik

View GitHub Profile
@rafaelkendrik
rafaelkendrik / event-loop.js
Last active May 7, 2018 11:43
Non-blocking, callback and pomises on Javascript's event loop.
/* 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 / ranges.js
Last active December 6, 2018 17:39
Creating an array of results through a range: traditional mutation vs functional way.
const playDice = sides => 1 + Math.floor(Math.random() * sides)
const playSixSidedDice = () => playDice(6)
// Pushing to Results (Traditional For)
const playSixSidedDices = rollTimes => {
let results = []
for(let i = 0; i < rollTimes; i++) {
results.push(playSixSidedDice())
}
return results
@rafaelkendrik
rafaelkendrik / url-update.sql
Created April 24, 2019 18:31
wordpress-url-update
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 / json-stringify.md
Last active April 15, 2020 22:15
JSON.stringify

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-pt.md
Last active April 16, 2020 18:04
[PT] Apresentação - Rafael Kendrik

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 / presentation-en.md
Last active April 16, 2020 20:32
[EN] Presentation - Rafael Kendrik

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 / n-tree-replace.js
Last active April 21, 2020 07:27
Walking through a tree, combining reduce and recursion
const tree = {
obj1: {
obj2: {
key1: 'key1'
},
obj3: {
obj4: {
key2: 'key2'
}
}
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;
});
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
@rafaelkendrik
rafaelkendrik / vue-router-route-by-href.js
Last active August 11, 2020 00:32
Get route from vue-router by href
// will return the route based on location
console.log(
VueRouter.prototype.resolve.call( // can be $router.resolve instead
this.$router,
'/my-path'
)
)
// or