This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Función de ayuda | |
| show_help() { | |
| echo "Uso: ./convert2webpResize.sh [opciones]" | |
| echo "" | |
| echo "Opciones:" | |
| echo " -h, --help Muestra esta ayuda y sale" | |
| echo " -c, --quality Calidad de la imagen (por defecto: 85)" | |
| echo " -r, --resize Redimensionar la imagen (por ejemplo: 800x600)" | |
| echo " --suffix Agregar sufijo a los archivos convertidos (por defecto: false)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // example includeAndCompactCSS('style-css-file-in.php'); | |
| function includeAndCompactCSS($filePath) { | |
| ob_start(); | |
| //include($filePath); | |
| include get_template_directory() . '/' . $filePath; | |
| $content = ob_get_clean(); | |
| $minifiedCSS = preg_replace( | |
| ['/\n+/', '/\s{2,}/', '/\/\*.*?\*\//', ], | |
| ['',' ',''], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for img in *.jpg; do | |
| cwebp -q 95 "$img" -o "${img%.*}.webp" | |
| done | |
| for img in *.png; do | |
| cwebp -q 95 "$img" -o "${img%.*}.webp" | |
| done | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1. Install ffmpeg: | |
| brew install ffmpeg --with-vpx --with-vorbis --with-libvorbis --with-vpx --with-vorbis --with-theora --with-libogg --with-libvorbis --with-gpl --with-version3 --with-nonfree --with-postproc --with-libaacplus --with-libass --with-libcelt --with-libfaac --with-libfdk-aac --with-libfreetype --with-libmp3lame --with-libopencore-amrnb --with-libopencore-amrwb --with-libopenjpeg --with-openssl --with-libopus --with-libschroedinger --with-libspeex --with-libtheora --with-libvo-aacenc --with-libvorbis --with-libvpx --with-libx264 --with-libxvid | |
| 2. Convert: | |
| ffmpeg -i input-file.mp4 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis output-file.webm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <style> | |
| section.observe { opacity: 0.5; transition: all 0.3s ease; } | |
| section.observe.inportview { opacity: 1; transition: all 1s ease; } | |
| </style> | |
| <script> | |
| (function() { | |
| document.addEventListener("DOMContentLoaded", function() { | |
| const observerOptions = { | |
| root: null, // Use the viewport as the bounding box. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let lastScrollTop = 0; | |
| const $html = document.documentElement; | |
| $html.classList.add('near-top'); | |
| window.addEventListener('scroll', () => { | |
| const currentScrollTop = window.scrollY || document.documentElement.scrollTop; | |
| const windowHeight = window.innerHeight; | |
| const docHeight = Math.max($html.scrollHeight, $html.offsetHeight, $html.clientHeight); | |
| const scrolledPercentage = ((currentScrollTop + windowHeight) / docHeight) * 100; | |
| const remainingScroll = 100 - scrolledPercentage; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'woocommerce_add_to_cart_validation', 'limit_product_quantity_in_cart', 10, 3 ); | |
| function limit_product_quantity_in_cart( $passed, $product_id, $quantity ) { | |
| if ( $quantity > 1 ) { | |
| wc_add_notice( __( 'Only a quantity of one is allowed per product.', 'domain' ), 'error' ); | |
| return false; | |
| } | |
| foreach ( WC()->cart->get_cart() as $cart_item ) { | |
| if ( $cart_item['product_id'] == $product_id || ( isset( $cart_item['variation_id'] ) && $cart_item['variation_id'] == $product_id ) ) { | |
| wc_add_notice( __( 'This product is already in your cart. Only a quantity of one is allowed per product.', 'domain' ), 'error' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // origin: https://gist.github.com/tomhicks/6cb5e827723c4eaef638bf9f7686d2d8 , tomhicks/plink-plonk.js | |
| /* | |
| Copy this into the console of any web page that is interactive and doesn't | |
| do hard reloads. You will hear your DOM changes as different pitches of | |
| audio. | |
| I have found this interesting for debugging, but also fun to hear web pages | |
| render like UIs do in movies. | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let lastScrollTop = 0; | |
| const $html = document.documentElement; | |
| $html.classList.add('near-top'); | |
| window.addEventListener('scroll', () => { | |
| const currentScrollTop = window.scrollY || document.documentElement.scrollTop; | |
| // Determine scroll direction and update classes using ternary expressions | |
| currentScrollTop > lastScrollTop ? | |
| ($html.classList.add('scrolling-down'), $html.classList.remove('scrolling-up')) : | |
| ($html.classList.add('scrolling-up'), $html.classList.remove('scrolling-down')); | |
| // Add or remove class based on scroll position using a ternary expression |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <style> | |
| .video-container { | |
| width: 100%; | |
| max-width: 100vw; /* Adjust as needed */ | |
| margin: auto; | |
| } | |
| </style> | |
| <div class="video-container"> | |
| <video id="myVideo" width="100%" height="auto" muted autoplay muted playsinline loop controls webkit-playsinline > |
NewerOlder