Skip to content

Instantly share code, notes, and snippets.

@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 ) {
@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
*/
@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
@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.
#
@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($) {
@Vestride
Vestride / encoding-video.md
Last active April 24, 2024 09:59
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
INITIALISATION
==============
load wp-config.php
set up default constants
load wp-content/advanced-cache.php if it exists
load wp-content/db.php if it exists
connect to mysql, select db
load object cache (object-cache.php if it exists, or wp-include/cache.php if not)
load wp-content/sunrise.php if it exists (multisite only)
@tomazzaman
tomazzaman / README.md
Last active September 17, 2023 20:59
Gulp workflow for WordPress theme development

Gulp workflow for WordPress theme development

Requirements

In order for Livereload to work, you need a Firefox or Chrome extension as Gulp doesn't inset it automatically. Alternatively, you can also manually put the livereload script in footer.php, just make sure to insert it only on development environment:

<script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script>
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active February 12, 2024 17:18
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@rxaviers
rxaviers / gist:7360908
Last active May 4, 2024 00:48
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue: