Skip to content

Instantly share code, notes, and snippets.

@LuisPaGarcia
LuisPaGarcia / isValidDeepLink.js
Last active February 27, 2024 22:52
isValidDeepLink
@LuisPaGarcia
LuisPaGarcia / remove_yt_modal.js
Created November 3, 2023 20:51
remove yt modal
document.querySelector('body > tp-yt-iron-overlay-backdrop').remove();
document.querySelector('body > ytd-app > ytd-popup-container').remove();
@LuisPaGarcia
LuisPaGarcia / path-to-slug.js
Created September 13, 2023 22:40
path to slug
function replaceSlashesWithDashes(path) {
// Remove the leading and trailing slashes if they exist
const trimmedPath = path.replace(/^\/|\/$/g, '');
// Replace all remaining slashes with dashes
return trimmedPath.replace(/\//g, '-');
}
import\s+(\w+)\s+from\s+'kepler\/lib\/components\/(?!\\1';)$
function sortTableByColumn(tableId, columnIdx) {
const table = document.getElementById(tableId);
const tbody = table.querySelector('tbody');
const rows = Array.from(tbody.getElementsByTagName('tr'));
rows.sort((rowA, rowB) => {
const cellA = rowA.getElementsByTagName('td')[columnIdx];
const cellB = rowB.getElementsByTagName('td')[columnIdx];
// Handle empty cells
@LuisPaGarcia
LuisPaGarcia / script.sh
Created May 24, 2023 16:33
Sort by LOC
#!/bin/bash
# Function to count lines of code in a file
count_lines_of_code() {
local file=$1
local lines=$(wc -l < "$file")
echo "$lines"
}
# Function to sort files based on lines of code
/* Map function to iterate over questions and add the `asertion` any */
function mapAgeGenderQuestionsAddAny(question) {
question.assertion = "any";
return question;
}
/* Reducer function to alter the props of the age_and_gender{_2} pages */
function reducerAgeAndGenderQuestion(questionProps) {
var tooltipValue = "You’ll miss out on certain plan types if you don’t submit your birth date and gender! If you only want to see Medicare Advantage, you can hit “Continue” to skip this question.";
var questions = questionProps.questions.map(mapAgeGenderQuestionsAddAny);
questionProps.tooltipHeadline = tooltipValue;
function startTimer(duration) {
var timer = duration, minutes, seconds;
var intervalId = setInterval(function () {
minutes = parseInt(timer / 60, 10);
seconds = parseInt(timer % 60, 10);
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
console.log(minutes + ":" + seconds);
var init = {a: 123, b: 456, c: { d: false}};
var output = {};
for([key, output[key]] of Object.entries(init));
console.log(output);
@LuisPaGarcia
LuisPaGarcia / scrollTo.js
Created October 30, 2020 21:50
A scrollto function enhanced for IE and
/**
* A scrollto function enhanced
* @param {string} element The query selector of the destiny element
* @param {number} space Space between top and element on scroll (optional)
* @param {bool} notSmooth Define if the scroll speed must be smooth or auto (Default: Smooth)
*/
function scrollToNative(element, space = 0, behaviorScroll = 'smooth') {
const tabsCta = document.querySelector(element).offsetTop
const top = tabsCta + space
const behavior = ['auto', 'smooth'].includes(behaviorScroll)