Skip to content

Instantly share code, notes, and snippets.

@mikaelz
mikaelz / functions.php
Last active January 26, 2022 11:03
WooCommerce auto-update cart when quantity changed, relates with https://gist.github.com/mikaelz/418a337dace188ba95b476ce65abfe0c
/**
* Auto update cart after quantity change
*
* @return string
**/
add_action( 'woocommerce_after_cart', 'custom_after_cart' );
function custom_after_cart() {
echo '<script>
jQuery(document).ready(function($) {
@magicoli
magicoli / copy-from-time-machine.sh
Last active April 18, 2023 19:31 — forked from vjt/copy-from-time-machine.sh
Copy data from a Time Machine volume mounted on a Linux box.
#!/bin/bash
#
# Copy data from a Time Machine volume mounted on a Linux box.
#
# Usage: copy-from-time-machine.sh <source> <target>
#
# source: the source directory inside a time machine backup
# target: the target directory in which to copy the reconstructed
# directory trees. Created if it does not exists.
#
@Chaz6
Chaz6 / update-weechat-ssl-letsencrypt.bash
Last active August 22, 2022 11:35
Script to update weechat relay ssl certificate using LetsEncrypt
#!/bin/bash
/usr/bin/certbot renew
if /usr/bin/test $(find /etc/letsencrypt/live/weechat.example.com/cert.pem -mmin -60)
then
/bin/cat /etc/letsencrypt/live/weechat.example.com/cert.pem /etc/letsencrypt/live/weechat.example.com/privkey.pem > /home/user/.weechat/ssl/weechat.example.com_ssl.pem
/bin/cat /etc/letsencrypt/live/weechat.example.com/fullchain.pem > /home/user/.weechat/ssl/weechat.example.com_fullchain.pem
/usr/bin/su -c 'echo "*/relay sslcertkey" > /home/user/.weechat/weechat_fifo_*' user
fi
@soulflyman
soulflyman / fixAssetLoading.html
Created February 28, 2017 10:37
The fixAssetLoading.js from @edave64 modified for the use in your "about" field in your soup.io profile
<script type="text/javascript">
/**
* Replaces assets that fail to load with working alternatives.
*
* Licence: Public domain
*/
/**
* @param {Element} ele
*/
@psorensen
psorensen / tinymce-add-formats.md
Last active August 23, 2019 06:24
Wordpress/TinyMCE - Add elements to formats dropdown

Adding Elements to the TinyMCE Format Dropdown

On a recent migration project, one of the requirements was to add a few blockquote styles to the TinyMCE dropdown list to match the editorial process of the old CMS. Wordpress provides a filter to add a secondary or tetriary dropdown, but if you only have a couple additional elements, it seems like bad UX to seperate it from the original dropdown.

Going off a tip from Chancey Mathews, I realized that Wordpress does not send a argument for block_formats when initializing TinyMCE, thus relying on the defaults. By adding this argument to the tiny_mce_before_init filter, we can add in our extra elements*:

* Note: since we're overriding the defaults, we need to include the original elements (p, h1-h6..etc)

function mce_formats( $init ) {