Skip to content

Instantly share code, notes, and snippets.

View lkraav's full-sized avatar
🎯
Focusing

Leho Kraav lkraav

🎯
Focusing
View GitHub Profile
@danielbitzer
danielbitzer / file.php
Last active May 18, 2023 15:31
AutomateWoo - Action function to change subscription next payment date
<?php
/**
* AutomateWoo action function to extend a subscription by 3 months.
*
* A note will be added to the subscription.
*
* Ensures that the dates near the end of the month are logically handled and do not shift to the start of the following month.
*
* Custom action function docs: https://automatewoo.com/docs/actions/custom-functions/
*
@danielbitzer
danielbitzer / functions.php
Last active January 22, 2023 21:39
AutomateWoo - Async custom trigger example
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Register AutomateWoo triggers.
add_filter( 'automatewoo/triggers', function ( $triggers ) {
// Include the file containing the trigger class
require_once 'my-custom-order-paid-trigger.php';
import { CSSResult, LitElement } from "lit-element";
/**
* Takes a node, CSSResult and appends it
*/
export const applyStyle = (node: HTMLElement, style: CSSResult) => {
if ("adoptedStyleSheets" in document && node.shadowRoot) {
const shadowRoot: any = node.shadowRoot;
const sheets = shadowRoot.adoptedStyleSheets;
shadowRoot.adoptedStyleSheets = [...sheets, style.styleSheet];
@hamidzr
hamidzr / sof-audio-setup-carbonx1.sh
Last active June 2, 2023 01:43
Lenovo Carbon X1 Gen 7 - Audio and microphone fix - https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_7) might be all you need.
#!/bin/bash
# README You probablyl don't need this script anymore. Please read the comments below to catch up.
## Description
# Lenovo Carbon X1 Gen 7 - Audio and microphone fix - kernel 5.3+ required.
# The script has only been tested for Arch and OpenSuse,
# Original thread: https://forums.lenovo.com/t5/Ubuntu/Guide-X1-Carbon-7th-Generation-Ubuntu-compatability/td-p/4489823
# Prereq: Install Linux 5.3 or newer
@westonruter
westonruter / basic-site-caching.php
Last active December 16, 2020 07:15
⚠️ This plugin is obsolete as of PWA v0.6.0. See https://github.com/GoogleChromeLabs/pwa-wp/pull/338
<?php
/**
* Plugin Name: Basic Site Caching
*
* @package Basic_Site_Caching
* @author Weston Ruter, Google
* @license GPL-2.0-or-later
* @copyright 2019 Google Inc.
*
* @wordpress-plugin
@knuch
knuch / functions.php
Created July 24, 2019 08:32
Gutenberg override core block
<?php
// https://developer.wordpress.org/reference/hooks/render_block/
add_filter( 'render_block', 'foo_core_gallery_filter', 10, 3);
function foo_core_gallery_filter( $block_content, $block ) {
// use blockName to only affect the desired block
if( "core/calendar" !== $block['blockName'] ) {
<?php
$form_id = 3;
add_filter( 'gform_form_post_get_meta_' . $form_id, 'add_repeater_field' );
function add_repeater_field( $form ) {
$field_id = 1000;
$fields = [
GF_Fields::create(
[
'type' => 'text',
@lizthegrey
lizthegrey / attributes.rb
Last active February 24, 2024 14:11
Hardening SSH with 2fa
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'
@tomjn
tomjn / tomjn_http2_push.php
Created January 25, 2019 23:43
A naive and incomplete, but functional approach to http2 push
<?php
/**
* Plugin name: HTTP2 Push scripts
* Author: Tom J Nowell
*/
function tomjn_get_dep_url( /*\WP_Dependency*/ $dep ) {
global $wp_version;
$relative = str_replace( site_url(), '', $dep->src );
$ver = $dep->ver;
@lukecav
lukecav / Commands
Last active January 9, 2024 06:48
Speed up wp db export using WP-CLI
# Export site database using wp db export
wp db export /wp-content/wordpress-dump.sql --all-tablespaces --single-transaction --quick --lock-tables=false
# Gzip compress the recent database export
gzip wordpress-dump.sql
# Export sites database using wp db export and gzip compress
wp db export --all-tablespaces --single-transaction --quick --lock-tables=false - | gzip -9 - > wordpress-dump.sql.gz