Skip to content

Instantly share code, notes, and snippets.

View diego-betto's full-sized avatar

Diego Betto diego-betto

View GitHub Profile
@diego-betto
diego-betto / css-select-options-colors.html
Created October 3, 2024 08:20
CSS: select with placeholder gray, options and selected values black
<style>
select {
color: #747474;
&:has(option:checked:not(:disabled)) {
color: #2c2c2c;
}
}
option {
@diego-betto
diego-betto / generate-changelog-md.sh
Last active March 20, 2024 10:15
Bash script to generate a CHANGELOG.md file based on git tags
#!/bin/bash
shopt -s lastpipe
footerTags=()
echo "# Changelog
This document maintains a list of released versions and changes done in respective versions.
" > ./CHANGELOG.md
@diego-betto
diego-betto / video-ios.html
Created September 17, 2020 12:39
Video with autoplay, loop and iOS support
<video autoplay loop muted playsinline class="video-background ">
<source src="to/the/video.mp4" type="video/mp4">
</video>
@diego-betto
diego-betto / image-start-end-alpha.js
Last active December 13, 2017 10:15
Detects the beginning and end of an image along its center
function getRealImageYStartEnd($imageId){
var img = document.getElementById($imageId);
var canvas = document.createElement('canvas');
canvas.width = img.width;
canvas.height = img.height;
canvas.getContext('2d').drawImage(img, 0, 0, img.width, img.height);
var context = canvas.getContext('2d');
var middle = Math.floor(img.width/2);
var startImage = 0;
@diego-betto
diego-betto / jquery-footer.functions.php
Created October 20, 2017 13:20
Wordpres: move jQuery to the footer
@diego-betto
diego-betto / disable-default-embeds.functions.php
Last active October 20, 2017 13:17
Disable default Wordpress embeds in frontend
<?php
// in functions.php
if (!is_admin()){
remove_action( 'rest_api_init', 'wp_oembed_register_route' );
add_filter( 'embed_oembed_discover', '__return_false' );
remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
remove_action( 'wp_head', 'wp_oembed_add_host_js' );
@diego-betto
diego-betto / iubenda-check-consent.js
Created October 11, 2017 09:26
Iubenda, check consent given in javascript
@diego-betto
diego-betto / custom-navbar-breakpoint.bootstrap.css
Created September 26, 2017 14:33
Change Bootstrap 3 navbar collapse point
@media (max-width: 1200px) {
.navbar-header {
float: none;
}
.navbar-left,.navbar-right {
float: none !important;
}
.navbar-toggle {
display: block;
}
@diego-betto
diego-betto / no-scroll-input-focus.css
Last active May 20, 2021 17:24
Tablet & Mobile: Avoid scroll on input focus
html,body{
-webkit-overflow-scrolling : touch !important;
overflow: auto !important;
height: 100% !important;
}
@diego-betto
diego-betto / DOM-Ready.js
Created September 7, 2017 16:53 — forked from franzese/DOM-Ready.js
Vanilla JavaScript Document Ready
Document.prototype.ready = function(callback) {
if(callback && typeof callback === 'function') {
document.addEventListener("DOMContentLoaded", function() {
if(document.readyState === "interactive" || document.readyState === "complete") {
return callback();
}
});
}
};