Skip to content

Instantly share code, notes, and snippets.

@KevinBatdorf
KevinBatdorf / gutenberg-helpers.js
Last active March 22, 2024 20:00
WordPress check Gutenberg editor is ready
import { select, subscribe } from '@wordpress/data'
export function whenEditorIsReady() {
return new Promise((resolve) => {
const unsubscribe = subscribe(() => {
// This will trigger after the initial render blocking, before the window load event
// This seems currently more reliable than using __unstableIsEditorReady
if (select('core/editor').isCleanNewPost() || select('core/block-editor').getBlockCount() > 0) {
unsubscribe()
resolve()
@WesleyAC
WesleyAC / build.sh
Last active April 30, 2024 16:32
Simple rust build and deploy script — https://blog.wesleyac.com/posts/simple-deploy-script
#!/usr/bin/env bash
cd $(dirname $0)
docker run --rm -it -v "$(pwd)":/home/rust/src -v cargo-git:/home/rust/.cargo/git -v cargo-registry:/home/rust/.cargo/registry -v "$(pwd)/target/":/home/rust/src/target ekidd/rust-musl-builder:nightly-2021-01-01 sudo chown -R rust:rust /home/rust/.cargo/git /home/rust/.cargo/registry /home/rust/src/target
docker run --rm -it -v "$(pwd)":/home/rust/src -v cargo-git:/home/rust/.cargo/git -v cargo-registry:/home/rust/.cargo/registry -v "$(pwd)/target/":/home/rust/src/target ekidd/rust-musl-builder:nightly-2021-01-01 cargo build --release
@dbonillaf
dbonillaf / links_bonilista_458.md
Last active March 12, 2020 23:01
Links sobre la enseñanza de programación a niños
@Gerst20051
Gerst20051 / unflatten.php
Last active March 3, 2022 17:26
PHP Unflatten Dot Notation Array
<?
$results = [
'id' => 'abc123',
'address.id' => 'def456',
'address.coordinates.lat' => '12.345',
'address.coordinates.lng' => '67.89',
'address.coordinates.geo.accurate' => true,
];
@simov
simov / README.md
Last active March 28, 2024 03:26
Run `node` scripts using `nvm` and `crontab` without hardcoding the node version

Run node scripts using nvm and crontab without hardcoding the node version

cronjob.env.sh

#!/bin/bash

# NVM needs the ability to modify your current shell session's env vars,
# which is why it's a sourced function
@andyxmas
andyxmas / .lando.yml
Created January 4, 2018 20:43
wordpress lando
name: remadeagency
recipe: wordpress
config:
webroot: .
events:
post-db-import:
# Set PROD_URL and DEV_URL values in .env file
@kurlov
kurlov / mkv embed soft subtitles
Created December 16, 2017 23:41
ffmpeg command to add .srt based subtitles to an .mkv file
ffmpeg -i in.mkv -f srt -i in.srt -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s srt out.mkv
@dmpop
dmpop / unsplash-random.sh
Last active September 18, 2017 21:31
Use random photos from Unsplash as a desktop background on Ubuntu
#!/bin/bash
uuser="unsplash_user_name"
path="path/to/dir"
size=$(xdpyinfo | grep dimensions | awk '{print $2}')
curl "https://source.unsplash.com/user/$uuser/$size" --location --output $path/unsplash-random.jpeg
gsettings set org.gnome.desktop.background picture-uri file://$path/unsplash-random.jpeg
@justinshreve
justinshreve / woocommerce-cancel-unpaid-bookings.php
Created November 2, 2015 16:04
Allows WooCommerce booking orders to be canceled by the cancel unpaid orders cron job.
<?php
/*
* Plugin Name: Cancel Unpaid Bookings
* Author: WooThemes
* Description: Allows booking orders to be canceled by the cancel unpaid orders cron job.
*/
// woocommerce-cancel-unpaid-bookings.php
function woocommerce_cancel_unpaid_booking_orders_from_admin( $return, $order ) {
@janizde
janizde / wpml-term-slug-fiter.php
Last active August 29, 2015 14:17
Filter fixing WPML appending language codes on term slugs
<?php
/**
* Filter fixing term slug for WPML plugin
* always (!) removes -{language code} (including repetitions like "-de-de-de") from the end of the slug before it is saved in the database and after WPML modified the slug.
* Note that this will always happen, even if you typed in the language code yourself in the input.
* The function will not strip combinations of different language codes like "-de-en-de" (this would certainly result in "-de-en").
*
* @author Jannik Portz (@janizde)
* @param string $slug The slug coming from WPML_Term_Translations::pre_term_slug_filter
* @return string The slug without language codes at the end