Skip to content

Instantly share code, notes, and snippets.

Allow a popup type element to be closed on body click. Also plays nice on iOS.
```
jQuery(document).on('click touchstart',function(e){
$miniCart = jQuery('.mini-cart');
if(!$miniCart.is(e.target) && $miniCart.has(e.target).length === 0)
$miniCart.hide();
});
```
## Creating a web server
1. Within Google Cloud Platform, open the left menu and select **Compute Engine > VM instances**
2. Select **Create instance** from the top menu
3. Create the server depending on what specification you need and check the boxes to **Allow HTTP/HTTPS traffic** so that it can be viewed in a browser, then select **Save** when done.
4. (optional) SSH into the server and install the LAMP/LEMP stack depending on your requirements.
## Creating a database server
1. Within Google Cloud Platform, open the left menu and select **SQL**
2. Select **Create instance** from the top menu
3. Select **MySQL** (unless you have a need to use PostgreSQL)
```
add_filter( 'woocommerce_variation_is_active', 'grey_out_variations_when_out_of_stock', 10, 2 );
function grey_out_variations_when_out_of_stock( $grey_out, $variation ) {
if ( ! $variation->is_in_stock() )
return false;
return true;
}
```
add_filter( 'woocommerce_dropdown_variation_attribute_options_args', 'my_wc_filter_dropdown_args', 10 );
function my_wc_filter_dropdown_args( $args ) {
$product_id = method_exists( $product, 'get_id' ) ? $product->get_id() : $product->id;
if( has_term( array('clothing','traningsklader'), 'product_cat', $product_id ) ){
$variation_tax = get_taxonomy( 'attribute' );
$args['show_option_none'] = 'Choose ' . strtolower(wc_attribute_label($args['attribute'],$product));
}
return $args;
Locate site config file
```
apachectl -S | grep "port 443" | grep "SITE NAME"
```
View it
```
cat /etc/apache2/sites-enabled/[SITE_DOMAIN_NAME].conf
```
## OSX
```
sudo killall -HUP mDNSResponder
```
https://coderwall.com/p/hkgamw/creating-full-width-100-container-inside-fixed-width-container
```
.row-full{
width: 100vw;
position: relative;
margin-left: -50vw;
height: 100px;
margin-top: 100px;
left: 50%;
}
Source http://sandbox.onlinephpfunctions.com/code/ac3217c37d8d1ba600d5190dbf7b323cb6cb1f32
```
<?php
/**
* Example: linear_partition([9,2,6,3,8,5,8,1,7,3,4], 3) => [[9,2,6,3],[8,5,8],[1,7,3,4]]
* @param array $seq
* @param int $k
* @return array
```
du -sh * | sort -hr | head -n10
```
```php
/**
* Custom fields in Woocommerce product
*/
function vads_create_custom_fields() {
global $post;
$pictograms = (array) get_post_meta( $post->ID, '_pictograms', true );
?><p class='form-field _pictograms'>
<label for='_pictograms'><?php _e( 'Pictograms', 'woocommerce' ); ?></label>
<select name='_pictograms[]' class='wc-enhanced-select' multiple='multiple' style='width: 80%;'>