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
We couldn’t find that file to show.
# Hacer stash de todos los archivos, nuevos o modificados
git stash save --include-untracked "nombre del stash"
# Hacer stash de todos los archivos, nuevos o modificados MAS corto
git stash -u
# Retomar los cambios del ultimo stash guardado
git stash pop
# Hacer un hard reset de una branch
/* 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);