Skip to content

Instantly share code, notes, and snippets.

View juanbrujo's full-sized avatar
:octocat:

Jorge Epuñan juanbrujo

:octocat:
View GitHub Profile
@juanbrujo
juanbrujo / hasStorage.js
Created November 14, 2018 20:54
Check if browser has webstorage enabled
// check if browser has webstorage enabled
function hasStorage () {
try {
localStorage.setItem('has', 'has')
localStorage.removeItem('has')
return true
} catch (exception) {
return false
}
}
@juanbrujo
juanbrujo / bankValidators.js
Created September 27, 2018 13:39
validarNumTarjeta, checkRut, formatearRut 🇨🇱
function validarNumTarjeta(element, show){
exvisa = /^4[0-9]{3,}$/g;
exmaster = /^5[1-9][0-9]{2,}$/g;
examerican = /^3[47][0-9]{2,}$/g;
exdinner= /^3(?:0[0-5]|[68][0-9])[0-9]{1,}$/g;
element.on('input', function(e){
if (/\D/g.test(this.value)){
this.value = this.value.replace(/\D/g, '');
var text = this.value.replace(/\D/g, '').split('');
if(text.length <= 16){
scrollBehavior(to) {
if (to.hash) {
return window.scrollTo({
top: document.querySelector(to.hash).offsetTop - 100,
behavior: 'smooth'
});
} else {
return setTimeout(() => {
window.scrollTo({
top: 0
@juanbrujo
juanbrujo / ElFactorGetOnBrdendevsChile.md
Last active August 29, 2018 14:12
Explicación de la constante ₲

Ya, la explicación de la constante ₲. Pin a esto para futuras referencias y cuando muera que alguien lo lea en mi velorio y en mi lápida que pongan complexGetonbrdCalculus.

En un empleo anterior, parte de mi labor era apoyar el reclutamiento de talentos para incorporarlos en la empresa. Por ello pedí el acceso de empresa a GetOnBrd y me puse a chusmear en los candidatos y en los perfiles que se estaban buscando en otras empresas TI. Hice un scrapper en Node que me trajera los valores (dólares) de todas las ofertas que lo tenían publicada, del mismo perfil que estaba yo buscando (webdev) y saqué un promedio. En ese instante eran $800k y pico así que usé el dólar (como GetOnbrd hace) como moneda oficial y lo dividí por el valor promedio que saqué, y esa es la constante que ven en el código del script finvox.js. Actualicé sólo una vez esa constante ya que me cambié de pega y no tuve más acceso al dashboard y ahora el ₲ sólo fluctúa según el dólar, y expresando el valor promedio de un dev en ese portal. Por e

// https://www.regextester.com/?fam=104295
/\d( ?|-?|\(?|\)?){10,14}/
@juanbrujo
juanbrujo / vue-decodebase64.vue
Created April 4, 2018 16:14
VueJS method to decode Base64 encoded strings
methods: {
decodeBase64: function (string) {
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
var result = ''
var i = 0
do {
var b1 = characters.indexOf(string.charAt(i++))
var b2 = characters.indexOf(string.charAt(i++))
var b3 = characters.indexOf(string.charAt(i++))
var b4 = characters.indexOf(string.charAt(i++))
@juanbrujo
juanbrujo / vue-characters-left.vue
Created February 16, 2018 16:16
VueJS 2 Characters left count && limit
<template>
<div>
<textarea v-model="companyDescription"></textarea>
Add a comment to this line
<p>{{ charactersLeft }}</p>
</div>
</template>
<script>
export default {
const title = document.querySelector('h1.title');
const speed = 0.2;
title.style.transform = 'translateY( calc( var(--scrollparallax) * 1px ) )';
function setScrollParallax() {
title.style.setProperty("--scrollparallax", (document.body.scrollTop || document.documentElement.scrollTop) * speed);
window.requestAnimationFrame( setScrollParallax );
}
window.requestAnimationFrame( setScrollParallax );
@juanbrujo
juanbrujo / parseXML.js
Created September 27, 2017 20:01
Parse XML from RSS feed in vanilla JavaScript
// from: // https://stackoverflow.com/a/17604251/2148418
var parseXml;
if (typeof window.DOMParser != "undefined") {
parseXml = function(xmlStr) {
return ( new window.DOMParser() ).parseFromString(xmlStr, "text/xml");
};
} else if (typeof window.ActiveXObject != "undefined" && new window.ActiveXObject("Microsoft.XMLDOM")) {
@juanbrujo
juanbrujo / getLastRSSFeed.html
Last active March 12, 2020 12:50
Get and display last feed from RSS using JavaScript (jQuery)
<html>
<head></head>
<body>
<div class="noticia">CARGANDO</div>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<script>
$(function(){
var url = 'https://www.domain.co/index.xml';
var news = $('.noticia');