Skip to content

Instantly share code, notes, and snippets.

Avatar

Romein van Buren garraflavatra

View GitHub Profile
View gitlines.sh
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}'
@garraflavatra
garraflavatra / meta.svelte
Last active Jul 13, 2022
Meta tags component for SvelteKit
View meta.svelte
<script lang="ts">
import { page } from '$app/stores';
export let title: string;
export let description: string;
export let image = '/img/social/preview.jpg';
export let path = $page.url.pathname;
export let domain = 'https://www.mysite.com';
export let titleSuffix = 'My site';
@garraflavatra
garraflavatra / get-user-id.cs
Created Sep 26, 2021
ASP.NET Core: get current user's ID
View get-user-id.cs
using Microsoft.AspNetCore.Identity;
string UserID = User.FindFirstValue(ClaimTypes.NameIdentifier);
View button-animation-zoom.scss
.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 / jpeg-tp-jpg.sh
Last active Jul 18, 2021
Rename all *.jpg to *.jpeg or vice-versa. Thanks to https://superuser.com/a/1023909
View jpeg-tp-jpg.sh
find . -type f -name '*.jpeg' -print0 | xargs -0 rename 's/\.jpeg/\.jpg/'
@garraflavatra
garraflavatra / dates.py
Created Jul 10, 2021
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.
View dates.py
import datetime
x = datetime.datetime.now()
print(x.strftime("%Y-%m-%d %H:%M:%S"))
@garraflavatra
garraflavatra / wp-term-metadata.php
Created Jul 9, 2021
Get metadata array of the current term in WordPress.
View wp-term-metadata.php
<?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
@garraflavatra
garraflavatra / wp-query-custom-taxonomy.php
Last active Jul 9, 2021
How to query WordPress posts with a custom taxonomy term.
View wp-query-custom-taxonomy.php
<?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 Jul 26, 2021
Material Design Ripple Effect
View button-animation-ripple.js
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 Jul 9, 2021
Rollup config for React library (no TypeScript)
View react-rollup-config.js
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" },