Skip to content

Instantly share code, notes, and snippets.

View Juandresyn's full-sized avatar
🏠
Working from home

Juandres Yepes Narvaez Juandresyn

🏠
Working from home
View GitHub Profile
/*
http://juandresyn.com/reset-css-el-codigo-basico
v3.5 | 20140801
License: none (public domain)
*/
@import url(http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,300,600,700);
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("geolocator",[],t):"object"==typeof exports?exports.geolocator=t():e.geolocator=t()}(this,function(){return function(e){function t(n){if(o[n])return o[n].exports;var r=o[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var o={};return t.m=e,t.c=o,t.i=function(e){return e},t.d=function(e,o,n){t.o(e,o)||Object.defineProperty(e,o,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,"a",o),o},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="dist/",t(t.s=7)}([function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r=O
// As a prototype
/*
* @param property string - The object propperty to group by.
*/
Array.prototype.groupBy = function (property) {
const filtered = this.reduce(function(item, x) {
if (!item[x[property]]) { item[x[property]] = []; }
item[x[property]].push(x);
return item;
function pilesOfBoxes(boxesInPiles) {
boxesInPiles.sort()
let currentHeight = boxesInPiles[boxesInPiles.length - 1];
let totalMoves = 0;
for (i = boxesInPiles.length - 2; i >= 0; i-- ) {
if (boxesInPiles[i] !== currentHeight) {
totalMoves += boxesInPiles.length - (i + 1);
currentHeight = boxesInPiles[i];
}
@Juandresyn
Juandresyn / current-url.liquid
Created May 21, 2019 00:36
Shopify liquid Current Url snippet
{% assign current_url = '' %}
{% case template %}
{% when 'page' %}
{% assign current_url = page.url %}
{% when 'blog' %}
{% assign current_url = blog.url %}
{% when 'article' %}
{% assign current_url = article.url %}
{% when 'collection' %}
@Juandresyn
Juandresyn / imageResize.js
Last active December 3, 2019 14:56
Shopify JavaScript Image resize
const imageService = (img, w, h = w) => {
const imgSplit = img.split('.');
const imgFormat = imgSplit[imgSplit.length - 1];
const imgFirst = img.split(`.${imgFormat}`)[0];
return `${imgFirst}_${w}x${h}.${imgFormat}`;
};
// imageService('https://cdn.shopify.com/s/files/1/0175/8496/t/65/assets/Beckett-Simonon-Oxfords-Durant-Yates-Dean.jpg?1723', 360)
// returns -> "https://cdn.shopify.com/s/files/1/0175/8496/t/65/assets/Beckett-Simonon-Oxfords-Durant-Yates-Dean_360x360.jpg?1723"
@Juandresyn
Juandresyn / objectToArray.js
Created June 12, 2019 19:47
Object to Array
const objectToArray = (obj) => {
const tempArray = [];
Object.keys(obj).forEach((i) => tempArray.push(obj[i]));
return tempArray;
}
@Juandresyn
Juandresyn / date-time.js
Last active December 15, 2023 02:34
js collection of date related functions
const initialDate = '07/29/2019';
export const monthsArray = ['January','February','March','April','May','June','July','August','September','October','November','December'];
export const dayNames = ['Sun', 'Mon', 'Tues', 'Wed', 'Thurs', 'Fri', 'Sat'];
/*
* @param padd Boolean - Add or not a 0 to the beginning of the number.
*/
export const getWeekDate = (padd) => {
const currentDate = new Date(); // get current date
@Juandresyn
Juandresyn / queryparams.js
Last active July 5, 2023 16:57
Get query params
const getUrlParameter = (name) => {
const nameClean = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
const regex = new RegExp('[\\?&]' + nameClean + '=([^&#]*)');
const results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};
const removeUrlParameter = (url, paramKey) => {
const r = new URL(url);
r.searchParams.delete(paramKey);
@Juandresyn
Juandresyn / psyduck.js
Created June 26, 2020 22:40
Trap focus modals
function handleVisibleElements(modal, hide = null) {
let parent = $(modal).parent();
let grandparent = null;
const parentCount = $(modal).parents().length - 1;
const mainTag = $('body main').length ? 'main' : 'body';
const tagToCheck = $(`${mainTag} > article`).length
? 'article'
: '.wrapper';
const hideSiblings = element => {
$(element)