Skip to content

Instantly share code, notes, and snippets.

View garraflavatra's full-sized avatar

Romein van Buren garraflavatra

View GitHub Profile
@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);
}
@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 / 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 / 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 / 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 / jpeg-tp-jpg.sh
Last active July 18, 2021 07:15
Rename all *.jpg to *.jpeg or vice-versa. Thanks to https://superuser.com/a/1023909
find . -type f -name '*.jpeg' -print0 | xargs -0 rename 's/\.jpeg/\.jpg/'
.button {
// border: 2px solid currentColor;
// border-radius: 3rem;
// color: #ff0;
// font-family: roboto;
// font-size: 4rem;
// font-weight: 100;
overflow: hidden;
// padding: 1rem 2rem;
position: relative;
@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 / get-user-id.cs
Created September 26, 2021 11:26
ASP.NET Core: get current user's ID
using Microsoft.AspNetCore.Identity;
string UserID = User.FindFirstValue(ClaimTypes.NameIdentifier);
@garraflavatra
garraflavatra / gitlines.sh
Created December 29, 2021 10:19
Git: how many lines did a user change? Modified https://gist.github.com/Xeoncross/4020489#gistcomment-3989215
git log --shortstat --author "Romein van Buren" \
| egrep "file[s] changed" \
| sed 's/changed, \([0-9]\+ deletions\)/changed, 0 insertions(+), \1/g' \
| awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed:", files, "- lines inserted:", inserted, "- lines deleted:", deleted}'