Skip to content

Instantly share code, notes, and snippets.

View victorwpbastos's full-sized avatar
🏠
Working from home

Victor Bastos victorwpbastos

🏠
Working from home
View GitHub Profile
@victorwpbastos
victorwpbastos / .bash_profile
Last active October 1, 2019 18:30
.bash_profile windows 10
# get current branch in git repo
function parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ ! "${BRANCH}" == "" ]
then
STAT=`parse_git_dirty`
echo " [${BRANCH}${STAT}] "
else
echo " "
fi
@victorwpbastos
victorwpbastos / useErrorHandler.js
Created June 6, 2019 15:23
Vue error handler component
import Vue from 'vue';
import {
VDialog,
VCard,
VCardText,
VToolbar,
VToolbarTitle,
VSpacer,
VIcon,
VExpansionPanel,
@victorwpbastos
victorwpbastos / useLoadingHandler.js
Created June 6, 2019 15:23
Vue loading handler component
import Vue from 'vue';
import { VDialog, VCard, VCardText, VProgressLinear } from 'vuetify/lib';
export default async function useLoadingHandler(fn = () => {}, message = 'Processando requisição...') {
let loadingView = new Vue({
components: { VDialog, VCard, VCardText, VProgressLinear },
data() {
return {
show: false
@victorwpbastos
victorwpbastos / .eslintrc.js
Last active July 26, 2019 19:38
eslint config for vue projects
module.exports = {
root: true,
env: {
node: true
},
parserOptions: {
parser: 'babel-eslint'
},
extends: [
'plugin:vue/recommended',
@victorwpbastos
victorwpbastos / git-prompt.sh
Last active May 24, 2019 18:11
bash prompt (git bash and windows 10)
# get current branch in git repo
function parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ ! "${BRANCH}" == "" ]
then
STAT=`parse_git_dirty`
echo " [${BRANCH}${STAT}] "
else
echo " "
fi
$.ajaxPrefilter((options, originalOptions, jqXHR) => {
let dfd = $.Deferred();
if (options.resolved) {
this.showLogin = false;
return;
}
jqXHR.done(dfd.resolve);
@victorwpbastos
victorwpbastos / fetch-interceptor.js
Last active September 18, 2017 16:21
Fetch interceptor
let _fetch = window.fetch;
window.fetch = (url, options) => {
return new Promise((resolve, reject) => {
let p = _fetch(url, options);
document.dispatchEvent(new CustomEvent('fetchStart', { detail: p }));
p.then(response => {
if (response.ok) {
@victorwpbastos
victorwpbastos / vtable.sublime-snippet
Created December 26, 2016 20:13
Vue Table Snippet
<snippet>
<content><![CDATA[
<table class="table table-bordered">
<thead>
<tr>${SELECTION/([^\s]+)|(?:\s(\w+))/()(?3\n\t\t\t<th class="text-center text-uppercase">$3<\/th>)/g}
</tr>
</thead>
<tbody>
<tr v-for="(item, index) in ${SELECTION/([^\s]+)|(\s\w+)/$1/g}">${SELECTION/([^\s]+)|(\s(\w+))/()(?3\n\t\t\t<td class="text-center">{{ item\.$3 }}<\/td>)/g}
</tr>
@victorwpbastos
victorwpbastos / modal.js
Last active September 23, 2016 21:40
New modal
import $ from 'jquery';
/**
* dp - default parameters
* @type Object
*/
let dp = {
alert: {
header: '',
body: '',
@victorwpbastos
victorwpbastos / paginator.vue
Created July 5, 2016 16:22
Vue Paginator Component
<template>
<div class="columns">
<div class="column col-4">
<select class="form-select" @change="changePerPage" v-model="itemsPerPage" number>
<option v-for="p in perPage" track-by="$index" value="{{p}}">{{p}} REGISTROS POR PÁGINA</option>
</select>
</div>
<div class="column col-4 text-center">
<p style="margin:7px;">PÁGINA {{currentPage}} DE {{totalPages}}</p>
</div>