Skip to content

Instantly share code, notes, and snippets.

View yayMark's full-sized avatar
💾
Gettin ma tech awn

Mark Hewitt yayMark

💾
Gettin ma tech awn
  • Perth, Western Australia
View GitHub Profile
@yayMark
yayMark / gist:f00d590e0d5a50b080a39a22bab46a4f
Created July 9, 2016 23:48 — forked from corsonr/gist:3d0425deaa80c601d454
WooCommerce: custom variations settings
<?php
// Add Variation Settings
add_action( 'woocommerce_product_after_variable_attributes', 'variation_settings_fields', 10, 3 );
// Save Variation Settings
add_action( 'woocommerce_save_product_variation', 'save_variation_settings_fields', 10, 2 );
/**
* Create new fields for variations
@yayMark
yayMark / wc25.php
Created July 10, 2016 01:01 — forked from corsonr/wc25.php
WooCommerce 2.5+: add new variations settings
<?php
// Add New Variation Settings
add_filter( 'woocommerce_available_variation', 'load_variation_settings_fields' );
/**
* Add custom fields for variations
*
*/
function load_variation_settings_fields( $variations ) {
@yayMark
yayMark / wc25.php
Created July 10, 2016 01:02 — forked from corsonr/wc25.php
WooCommerce 2.5+: display custom variation fields
<div class="woocommerce-variation-custom-text-field">
{{{ data.variation.text_field }}}
</div>
@yayMark
yayMark / gist:47ece2c583dcabaedbfd7e72a26b799a
Created July 14, 2017 05:46
Delete a specific cookie using JavaScript in the URL field of a bookmark
javascript:document.cookie="cookieNameGoesHere=; max-age=-1; path=/;";console.log("Popup cookie removed");
@yayMark
yayMark / animationend.js
Created November 24, 2017 02:23
Applying styling to a button contained within a translucent parent div on a CSS animation end. Applied a stronger background colour instead!
var newsArticles = document.querySelectorAll('.desktop .newspanel .news-article');
for (var i = 0; i < newsArticles.length; i++) {
(function() {
var element = newsArticles[i];
element.addEventListener('animationend', function() {
var style = window.getComputedStyle(element);
var opacity = style.getPropertyValue('opacity');
var selector = '.desktop .btn';
var button = element.querySelector(selector);
if (opacity == 0.9) {
@yayMark
yayMark / beatport.sh
Created December 1, 2017 01:55
In Google Chrome on Mac OS, open an app style window with a site of choice with the profile of choice
#!/bin/bash
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --app=http://mixes.beatport.com/dj/deepspacehouse/43 --profile-directory="Profile 1"
@yayMark
yayMark / epoch_to_date.js
Last active December 3, 2017 00:26
Convert unix epoch to a date time string
var args = process.argv.slice(2);
var epoch = Number(args[0]);
// you can use seconds or milliseconds
var length = args[0].toString().length;
if (length <= 10) {
epoch = epoch * 1000;
}
var myDate = new Date(epoch);
@yayMark
yayMark / bad_encode_to_html_entity.sql
Created December 6, 2017 03:38
WordPress: find and replace badly encoded characters with HTML encoded versions
update wp_posts set post_content = replace(post_content,'“','&ldquo;');
update wp_posts set `post_excerpt` = replace(post_excerpt,'“','&ldquo;');
update wp_postmeta set meta_value = replace(meta_value,'“','&ldquo;');
update wp_posts set post_content = replace(post_content,'’','&rsquo;');
update wp_posts set post_excerpt = replace(post_excerpt,'’','&rsquo;');
update wp_postmeta set meta_value = replace(meta_value,'’','&rsquo;');
update wp_posts set post_content = replace(post_content,'–','&mdash;');
update wp_posts set `post_excerpt` = replace(post_excerpt,'–','&mdash;');
@yayMark
yayMark / apply_style_in_iframe.js
Created December 6, 2017 08:08
jQuery: Apply styling to an element inside and iframe. Will only work if the iframe is on the same domain as the parent.
$("iframe.html5anim").load( function() {
$("iframe.html5anim").contents().find("head")
.append($("<style type='text/css'>#canvas{background-color:red!important;}</style>"));
});
@yayMark
yayMark / iframe_call.js
Created December 6, 2017 09:32
JavaScript: call a function inside an iframe from the parent
document.getElementById("woop").contentWindow.init()