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 / validaMatricula.js
Created October 17, 2014 16:39
Validador de Matricula
var _ = require('underscore');
module.exports = function(matricula) {
var arrNumerosSoma = {
DV_1: [2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 1, 2, 3, 4, 0, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
DV_2: [1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 1, 2, 3, 0, 0, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
},
somatoria = {
DV_1: [],
DV_2: []
@victorwpbastos
victorwpbastos / sticky-footer.css
Last active August 29, 2015 14:17
Sticky footer
@victorwpbastos
victorwpbastos / layout.css
Last active November 9, 2015 19:14
Layout 3 Rows
html, body {
padding: 0;
margin: 0;
height: 100%;
}
.wrapper {
display: table;
width: 100%;
height: 100%;
@victorwpbastos
victorwpbastos / webpack-readdir.js
Last active November 12, 2015 03:00
Read all files in a dir with webpack
var _ = require('underscore');
var paths = require.context('./models', true, /.js$/);
var models = [];
_(paths.keys()).each(function(path) {
var name = /.\/(.*).js/.exec(path)[1];
models[name] = paths(path);
});
var model = new models['a']({id: 123});
@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>
@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 / 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 / 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) {
$.ajaxPrefilter((options, originalOptions, jqXHR) => {
let dfd = $.Deferred();
if (options.resolved) {
this.showLogin = false;
return;
}
jqXHR.done(dfd.resolve);
@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