Skip to content

Instantly share code, notes, and snippets.

Avatar

Jorge Epuñan juanbrujo

View GitHub Profile
@juanbrujo
juanbrujo / fetchRemoteBranches2Local
Last active Nov 4, 2020
Fetch all remote branches to local
View fetchRemoteBranches2Local
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
# https://stackoverflow.com/questions/10312521/how-to-fetch-all-git-branches
@juanbrujo
juanbrujo / netlify.toml
Created Sep 28, 2020
Netlify configuration for routes in a SPA
View netlify.toml
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
@juanbrujo
juanbrujo / select.html
Last active Aug 19, 2020
HTML native select attribute that holds the dropdown with scroll if needed by viewport
View select.html
<!-- test: https://jsbin.com/renixijogu/1/edit?html,css,output -->
<select size="number">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
@juanbrujo
juanbrujo / Mati.vue
Created Oct 15, 2019
How to use Mati (getmati.com) Web SDK in a VueJS project
View Mati.vue
<template>
<div>
<div v-html="MatiButton('CLIENTID')"></div>
</div>
</template>
<script>
View CheckEmptyObject.js
const obj = {}
Object.keys(obj).length === 0 && obj.constructor === Object
@juanbrujo
juanbrujo / checkEmail.vue
Created Aug 29, 2019
Regex to check if email is valid for a Vue.js method.
View checkEmail.vue
checkEmail: function (email) {
// eslint-disable-next-line
const reg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
if (reg.test(email)) return false
return true
}
@juanbrujo
juanbrujo / custom-error-on-specific-route.js
Created Aug 7, 2019
json-server: Custom error (400, 500) when targeting specific route
View custom-error-on-specific-route.js
const jsonServer = require('json-server')
const server = jsonServer.create()
const router = jsonServer.router('mock/db.json')
const middlewares = jsonServer.defaults()
const port = process.env.PORT || 3000
server.use(middlewares)
// send error message when validating code on invest
server.get('/invest_url', (req, res) => {
@juanbrujo
juanbrujo / form-netlify.css
Last active May 6, 2020
JS function to send by AJAX a form data to Netlify Forms
View form-netlify.css
.result {
display: none;
}
.active {
display: block;
}
.inactive {
display: none;
@juanbrujo
juanbrujo / hidden-safari.css
Created Dec 5, 2018
CSS hack targeting Safari Desktop & Mobile
View hidden-safari.css
/**
** test: https://jsbin.com/gacizoyota/1/edit?html,css,output
*/
@media not all and (min-resolution:.001dpcm) {
@media {
/* your code */
}
}
@juanbrujo
juanbrujo / hasStorage.js
Created Nov 14, 2018
Check if browser has webstorage enabled
View hasStorage.js
// check if browser has webstorage enabled
function hasStorage () {
try {
localStorage.setItem('has', 'has')
localStorage.removeItem('has')
return true
} catch (exception) {
return false
}
}
You can’t perform that action at this time.