Skip to content

Instantly share code, notes, and snippets.

View lvl99's full-sized avatar

Matt Scheurich lvl99

View GitHub Profile
@lvl99
lvl99 / date-iso-string-without-timezone.js
Created November 19, 2019 10:15
Date ISO string without timezone information
const controlDate = new Date();
controlDate.toString();
// -> "Thu Jun 20 2019 11:16:28 GMT+0200 (Central European Summer Time)"
controlDate.toDateString();
// -> "Thu Jun 20 2019"
controlDate.toUTCString();
// -> "Thu, 20 Jun 2019 09:15:28 GMT"
@lvl99
lvl99 / useCallbackRef.test.tsx
Created August 29, 2019 22:58
useCallbackRef - React hook for triggering changes after ref has been received from DOM
import React, { useState, useRef } from "react";
import { render, cleanup } from "react-testing-library";
import useCallbackRef from "./useCallbackRef";
function TestInputRef<T = HTMLInputElement>({
id = "test",
onSet,
onChange
}: {
id?: string;
@lvl99
lvl99 / woocommerce-eu-vat-rates.csv
Last active October 24, 2024 10:39
A CSV table of the VAT rates for EU members. This was made using the table of Standard Rates from this document: https://ec.europa.eu/taxation_customs/sites/taxation/files/resources/documents/taxation/vat/how_vat_works/rates/vat_rates_en.pdf and the VAT abbreviations here: https://en.wikipedia.org/wiki/European_Union_value_added_tax#VAT_rates
Country Code State Code ZIP/Postcode City Rate % Tax Name Priority Compound Shipping Tax Class
AT * * * 20 USt 1 0 1
BE * * * 21 TVA 1 0 1
BG * * * 20 ДДС 1 0 1
CY * * * 19 ΦΠΑ 1 0 1
CZ * * * 21 DPH 1 0 1
DE * * * 19 MwSt 1 0 1
DK * * * 25 moms 1 0 1
EE * * * 20 km 1 0 1
ES * * * 21 IVA 1 0 1
@lvl99
lvl99 / 01-tiled-gallery-carousel-image-args.php
Last active July 26, 2017 11:01
Use Fancybox instead of Jetpack's Carousel to display images in a lightbox
@lvl99
lvl99 / bootstrap.before.php
Created April 29, 2017 15:51
Vanilla Forums: how to support multiple configuration options depending on the server/hostname/etc.
<?php
// Detect any specific server environment config setup to apply
// I use a custom variable where you can set like so in Apache VirtualHost or in .htaccess:
// `SetEnv HTTP_SERVER_ENVIRONMENT "staging"
// Default: development
$server_environment = 'development';
if ( ! empty( $_SERVER['HTTP_SERVER_ENVIRONMENT'] ) ) {
$server_environment = $_SERVER['HTTP_SERVER_ENVIRONMENT'];
}
@lvl99
lvl99 / bootstrap.before.php
Created April 29, 2017 15:49
Vanilla ForumsHow one can support multiple configuration options depending on the server/hostname/etc.
<?php
// Detect any specific server environment config setup to apply
// Default: development
$server_environment = 'development';
if ( ! empty( $_SERVER['HTTP_SERVER_ENVIRONMENT'] ) ) {
$server_environment = $_SERVER['HTTP_SERVER_ENVIRONMENT'];
}
// Load the server environment config
@lvl99
lvl99 / 12-Example-instantiating-Modal-composable-mixin-into-component-class.less
Created April 7, 2017 13:58
Object-oriented inspired composable LESS mixins. View the article on the blog: http://blog.lvl99.com
.modal {
.ui-lvl99-modal(@ns: ‘modal’);
.-modal-init-default({
background: red;
padding: 40px;
});
}
// ... would output the following CSS
.modal {
@lvl99
lvl99 / 11-Example-Modal-composable-mixin-class-(complex).less
Created April 7, 2017 13:57
Object-oriented inspired composable LESS mixins. View the article on the blog: http://blog.lvl99.com
// Modal Mixin Class
// @param @ns Namespaces the custom state classes
.ui-lvl99-modal(@ns: ~"lvl99-modal") {
.ui-lvl99-toggleable(@ns);
// Special mixin to apply any rules to the default class
// If you feel you wouldn’t need to reuse this class definition in other components, you could
// just define it in the main body of the mixin class definition
.-modal-class-default(@rules: {}) {
position: fixed;