Skip to content

Instantly share code, notes, and snippets.

Jorge Epuñan juanbrujo

Block or report user

Report or block juanbrujo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View regex-cellphone-mx
// https://www.regextester.com/?fam=104295
/\d( ?|-?|\(?|\)?){10,14}/
@juanbrujo
juanbrujo / vue-decodebase64.vue
Created Apr 4, 2018
VueJS method to decode Base64 encoded strings
View vue-decodebase64.vue
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 Feb 16, 2018
VueJS 2 Characters left count && limit
View vue-characters-left.vue
<template>
<div>
<textarea v-model="companyDescription"></textarea>
Add a comment to this line
<p>{{ charactersLeft }}</p>
</div>
</template>
<script>
export default {
View cheap-parallax.js
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 Sep 27, 2017
Parse XML from RSS feed in vanilla JavaScript
View parseXML.js
// 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 Nov 11, 2019
Get and display last feed from RSS using JavaScript (jQuery)
View getLastRSSFeed.html
<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');
@juanbrujo
juanbrujo / jQuery.addClass2Menu.js
Created Mar 20, 2017
addClass2Menu: Add class to menu if certain height is reached
View jQuery.addClass2Menu.js
/**
* Add class to menu if certain height is reached
*/
function addClass2Menu(container, classname, height){
$(window).on('load scroll', function(){
var scroll = $(window).scrollTop();
if( scroll >= height) {
container.addClass(classname);
} else {
container.removeClass(classname);
@juanbrujo
juanbrujo / comunas-regiones.json
Last active Feb 12, 2020 — forked from sergiohidalgo/comunas-regiones-chile.json
Comunas y regiones de chile JSON
View comunas-regiones.json
{
"regiones": [{
"region": "Arica y Parinacota",
"comunas": ["Arica", "Camarones", "Putre", "General Lagos"]
},
{
"region": "Tarapacá",
"comunas": ["Iquique", "Alto Hospicio", "Pozo Almonte", "Camiña", "Colchane", "Huara", "Pica"]
},
{
@juanbrujo
juanbrujo / Pluralyze.js
Last active Mar 14, 2017
Pluralyze: check count to return singular / plural noun
View Pluralyze.js
function Pluralyze(count, noun) {
var suffix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 's';
return count + ' ' + noun + (count !== 1 ? suffix : '');
};
// USE:
// Pluralyze(0, 'layer'); => 0 layers
// Pluralyze(1, 'layer'); => 1 layer
// Pluralyze(10, 'sandwich', 'es); => 10 sandwiches
View YoutubeSearchBookmarklet.js
javascript:(function(){
var youtube = 'https://www.youtube.com/results?search_query=';
var query = prompt('video query');
if(query != '') {
document.location.href = youtube + query;
}
})();
You can’t perform that action at this time.