Skip to content

Instantly share code, notes, and snippets.

View erikyo's full-sized avatar

Erik Golinelli erikyo

View GitHub Profile
@erikyo
erikyo / decimal_floor.scss
Created September 15, 2017 14:58
SASS floor with precision (allow decide how many decimals floor return)
// floor with precision function
@function decimal_floor( $val , $precision: 2 ) {
$n: 1;
@for $d from 1 through $precision {
$n: $n * 10;
}
@return floor($val * $n) / $n;
}
@erikyo
erikyo / strip_unit.scss
Created September 15, 2017 14:58
SASS strip unit from passed value
// strip unit from passed value
@function strip_unit($val) {
@return $val / ($val * 0 + 1);
}
@erikyo
erikyo / Wordpress menu dropdown jquery
Last active November 23, 2017 22:28
Wordpress menu dropdown jquery
/**
* Menu scripts
*/
(function ($, root, window) {
'use strict';
//DROPDOWN MENU
@erikyo
erikyo / StickyPost.php
Last active May 8, 2018 20:56
Include Sticky Post in Page Posts Count
$count_stickies = count(get_option( 'sticky_posts' ));
$ppp = 6;
$offset = ( $count_stickies <= $ppp ) ? ( $ppp - ( $ppp - $count_stickies ) ) : $ppp;
$args = array(
'posts_per_page' => $ppp - $offset
);
$loop = new WP_Query( $args );
@erikyo
erikyo / bundled_products_sku.php
Created January 13, 2018 17:29
WOOCOMMERCE show sku for bundled products
// WOOCOMMERCE show sku for bundled products
add_action( 'woocommerce_bundled_item_details', 'show_bundled_sku', 16 );
function show_bundled_sku( $bundled_item, $product ) {
if ($bundled_item->product->sku) {
printf('<p class="sku"><span class="woocommerce-Sku sku">%s</span></p>',$bundled_item->product->sku) ;
}
}
@erikyo
erikyo / Max_Dissolved_Oxigen.c
Created May 8, 2018 20:25
Max Dissolved Oxigen Saturation over a range of user-specified values for water temperature, barometric pressure, and salinity or specific conductance.
// --------- Max Dissolved Oxigen Saturation ------------//
//
// Equation for the Henry coefficient as a function of temperature and salinity is used to calculate values
// for unit standard atmospheric concentrations (USAC) in freshwater and seawater in equilibrium with air at a total pressure
// of 1 atmosphere. It is estimated that the possible error in the new USAC values is no greater than $\pm 0.1%$ and probably less.
// Tables and equations are presented for obtaining accurate USAC values in the ranges $0^\circ < t < 40^\cir C and 0 < S < 40$.
// Simple procedures are given for calculating standard atmospheric concentrations at pressures different from 1 atm.
//
// Reference https://water.usgs.gov/software/DOTABLES/
// Dissolved oxygen (DO) solubility over a range of user-specified values for
@erikyo
erikyo / fancy-gallery.js
Last active January 24, 2022 03:34
fancybox 3 integration into wordpress Gutenberg gallery block
@erikyo
erikyo / woo_product_accordion.css
Last active February 14, 2022 08:45
WooCommerce sidebar product categories widget animated accordion
ul.product-categories ul {
margin: 0;
padding-left: 32px
}
ul.product-categories li {
line-height: 42px;
margin: 0
}
@erikyo
erikyo / masonry-width-calc.scss
Last active September 28, 2019 14:50
SASS item width calcs for Masonry grid__col-sizer grid__gutter-sizer
$gutter_size: 3%;
$number_of_columns: 3;
$total_gutter_space: ( $number_of_columns - 1 ) * $gutter_size;
.grid__item,
.grid__col-sizer {
width: calc( ( 100% - #{$total_gutter_space} ) / #{$number_of_columns} );
}
.grid__gutter-sizer {
@erikyo
erikyo / wp_square_images.php
Created May 1, 2020 00:37
Force wordpress to generate a square intermediate image resize without hard crop (wp crops image, but i don't need this, I need some extra white space outside)
<?php
add_filter('wp_generate_attachment_metadata', 'custom_crop');
function custom_crop($metadata) {
$square_image_size = 320;
$uploads = wp_upload_dir();
$file = path_join( $uploads['basedir'], $metadata['file'] ); // original image file