Skip to content

Instantly share code, notes, and snippets.

View garraflavatra's full-sized avatar

Romein van Buren garraflavatra

View GitHub Profile
@garraflavatra
garraflavatra / dates.py
Created July 10, 2021 15:00
Get a formatted date in Python. See https://www.w3schools.com/python/gloss_python_date_format_codes.asp for an overview of all formatting codes.
import datetime
x = datetime.datetime.now()
print(x.strftime("%Y-%m-%d %H:%M:%S"))
@garraflavatra
garraflavatra / wp-term-metadata.php
Created July 9, 2021 15:18
Get metadata array of the current term in WordPress.
<?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
@garraflavatra
garraflavatra / wp-query-custom-taxonomy.php
Last active July 9, 2021 15:07
How to query WordPress posts with a custom taxonomy term.
<?php
$posts = get_posts(
array(
'numberposts' => 20,
'post_type' => 'custom_post_type',
'tax_query' => array(
array(
'taxonomy' => 'custom_taxonomy',
'field' => 'slug',
'terms' => array( 'termslug1', 'termslug2' )
@garraflavatra
garraflavatra / button-animation-ripple.js
Last active July 26, 2021 10:00
Material Design Ripple Effect
function createRipple(event) {
const button = event.currentTarget;
const circle = document.createElement("span");
const diameter = Math.max(button.clientWidth, button.clientHeight);
const radius = diameter / 2;
circle.style.width = circle.style.height = `${diameter}px`;
circle.style.left = `${event.clientX - button.offsetLeft - radius}px`;
circle.style.top = `${event.clientY - button.offsetTop - radius}px`;
@garraflavatra
garraflavatra / react-rollup-config.js
Last active July 9, 2021 15:06
Rollup config for React library (no TypeScript)
import babel from "@rollup/plugin-babel";
import external from "rollup-plugin-peer-deps-external";
import del from "rollup-plugin-delete";
import { terser } from "rollup-plugin-terser";
import pkg from "./package.json";
export default {
input: pkg.source,
output: [
{ file: pkg.main, format: "cjs" },
@garraflavatra
garraflavatra / ellipse.pde
Created December 8, 2017 16:58
Ellipse drawing
void setup() {
size(480, 120);
}
void draw() {
if (mousePressed) {
fill(0);
} else {
fill(255);
}