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> | |
/* | |
Original idea | |
https://stackoverflow.com/a/13184714/ | |
*/ | |
.anchor{ | |
display: block; | |
position: relative; | |
top: -120px; /* this value can be updated */ | |
visibility: hidden; |
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
<script> | |
// use the `anchor` parameter to change the hash | |
var newHash = "<?php echo $_GET['anchor']; ?>"; | |
window.location.hash = newHash; | |
</script> |
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
// Reverse purchase in Google Analytics with Enhanced Ecommerce | |
// Source: https://support.google.com/analytics/answer/1037443?hl=en | |
var items = [ | |
{ | |
id: 573, // original ID | |
price: "57000.00", // original price | |
quantity: "-2500" // negative quantity | |
}, |
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
// run a loop | |
// that jumps on the next iteration only after an external condition is met | |
// -> a poller checks on the condition every 100 ms and the iteration goes on only if certain conditions are met | |
// inspiration -> | |
// https://medium.com/@eric.stermer/setinterval-simply-put-is-a-timed-loop-652eb54bd5f8 | |
// the `products` variable is defined elsewhere |
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
// createdObj is an object created by the script | |
// setup that should run after the script has been executed | |
var setup = function(){ | |
console.log('the script is on the page and did execute'); | |
console.log(typeof createdObj, 'does it exist?'); // -> function | |
}; | |
// attach the script to the page | |
var script = document.createElement("script"); |
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
// If you need to have a different appearance on hover in iOS | |
// you have to simulate it by toggling a class on touchstart/touchend | |
// and then style the element accordingly | |
// source: https://stackoverflow.com/a/2891155/ | |
$('.hovered-element').on('touchstart touchend', function () { | |
$(this).toggleClass('touch-hover'); | |
}); |
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 | |
// Enqueue child theme styles (typically in functions.php) | |
function update_child_theme_styles() { | |
// Force CSS changes to go live | |
wp_enqueue_style( '--child-theme-name--', | |
get_stylesheet_directory_uri() . '/style.css', | |
array(), | |
filemtime( get_stylesheet_directory() . '/style.css' )); | |
} |
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
import UIKit | |
import XCPlayground | |
import PlaygroundSupport | |
public class SimpleLine: UIView { | |
public init() { | |
super.init(frame: CGRect(x: 0, y: 0, width: 480, height: 320)) | |
backgroundColor = UIColor.white | |
} |
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
import UIKit | |
import XCPlayground | |
import PlaygroundSupport | |
public class SimpleLine: UIView { | |
public init() { | |
super.init(frame: CGRect(x: 0, y: 0, width: 480, height: 320)) | |
backgroundColor = UIColor.white | |
} |
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
import UIKit | |
import XCPlayground | |
import PlaygroundSupport | |
public class SimpleLine: UIView { | |
public init() { | |
super.init(frame: CGRect(x: 0, y: 0, width: 480, height: 320)) | |
backgroundColor = UIColor.white | |
} |