Skip to content

Instantly share code, notes, and snippets.

@aderaaij
aderaaij / yoast
Last active April 3, 2024 20:11
Wordpress - Move yoast seo boxes to bottom of post/page
// Move Yoast to bottom
function yoasttobottom() {
return 'low';
}
add_filter( 'wpseo_metabox_prio', 'yoasttobottom');
@aderaaij
aderaaij / acf-future-posts.php
Last active February 8, 2024 14:29
Advanced Custom Fields datepicker: Show only events with a date of today or in the future. Extra comments from Pasnon @ ACF Forums: f you needed to, you could also play with the comparison date, which is the first array in meta_query, currently set to date("Y-m-d") which is today; if you were to make it date("Y-m-d", strtotime("-1 day")) you cou…
<?php
/*
* Display posts only from today and in the future:
* http://old.support.advancedcustomfields.com/discussion/6000/how-to-sort-posts-by-acf-date-and-display-only-future-posts
* by Pasnon
*/
$date_args = array(
'post_type' => 'events',
@aderaaij
aderaaij / getComputedTranslateXY.ts
Last active February 12, 2023 15:19
Get the computed Translate X and Y values of a given DOM element. Based on https://stackoverflow.com/questions/21912684/how-to-get-value-of-translatex-and-translatey
function getTranslate(item: HTMLElement): number | number[] | undefined {
const transArr = [];
if (!window.getComputedStyle) {
return;
}
const style = window.getComputedStyle(item);
const transform = style.transform || style.webkitTransform;
let mat = transform.match(/^matrix3d\((.+)\)$/);
if (mat) {
return parseFloat(mat[1].split(', ')[13]);
@aderaaij
aderaaij / GLSL-Noise.md
Created October 4, 2022 21:45 — forked from patriciogonzalezvivo/GLSL-Noise.md
GLSL Noise Algorithms

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
	return mix(rand(fl), rand(fl + 1.0), fc);
}
@aderaaij
aderaaij / custom-feed.php
Last active June 29, 2020 15:34
Custom feed used to import WooCommerce product variations into other stores, etc. In this particular example each WooCommerce variation is queried as a single product).
<?php
/**
* Template Name: custom woocommerce feed
* Description: Custom feed for importing woocommerce products in other stores
* Author: Arden de Raaij
*
* @package WordPress
*
*
*/
@aderaaij
aderaaij / offset.js
Created November 29, 2015 18:17
Basic offset function, replacing jQuery's offset.
function offset(elt) {
var rect = elt.getBoundingClientRect(), bodyElt = document.body;
return {
top: rect.top + bodyElt .scrollTop,
left: rect.left + bodyElt .scrollLeft
}
}
//use:
@aderaaij
aderaaij / webpack.config.js
Created February 1, 2018 17:20
A minimal webpack config for vuejs
const webpack = require('webpack');
const path = require('path');
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './build'),
filename: 'bundle.js',
},
module: {
@aderaaij
aderaaij / es6-spread-operator.js
Last active July 25, 2018 09:27
The spread operator can expand(spread) any iterable like an array or a string.
const avengers = ['Thor', 'The Hulk', 'Captain America'];
let guardians = ['Star Lord', 'Gamorra', 'Drax', 'Rocket', 'Groot'];
// Spread out arrays in a new array and put a new value in between them
const heroes = [...avengers, 'Loki', ...guardians];
// Adding new stuff to an array just got easier too
guardians = [...guardians, 'Mantis', 'Yondu', 'Nebula'];
// Or simply making a TRUE copy of an array
const avengersCopy = [...avengers];
@aderaaij
aderaaij / ramda.js
Last active January 29, 2018 08:00
/*
* Using the library ramda, what is the result of the following code?
* R.reduce((acc,x) => R.compose(R.flip(R.prepend)(acc), R.sum,R.map(R.add(1)))([x,...acc]), [0])([13, 28]);
* Explain each of the steps the best you can.
*/
const R = require('ramda');
// Reduce function iterating over [13, 28]
// starting point: [0]
const test = R.reduce(
@aderaaij
aderaaij / browser-sync-start-directory
Last active December 22, 2017 17:58
Start a browsersync server in underlaying directory https://browsersync.io/docs/command-line
browser-sync start -s --directory "/"
browser-sync start -s --directory "/" --files "**/*.html"