Skip to content

Instantly share code, notes, and snippets.

@Maxdw
Maxdw / wp.function.multipart.mail.php
Last active November 19, 2015 16:48
WordPress - Sending multipart (text/html and plain/text) email in WordPress programatically.
/**
* Sends a email in both 'text/html' and 'plain/text'.
*
* @param string|array $to
* @param string $subject
* @param string $html
* @param string $text
* @return boolean|string
* @see stackoverflow.com/questions/22507176
*/
@Maxdw
Maxdw / wp.function.get.sidebar.widgets.array.php
Created November 19, 2015 16:48
WordPress - Uses dynamic_sidebar to split widgets into an array allowing more control over widget placement.
/**
* Splits the HTML of each individual widget
* up into chunks of strings accessible by array.
*
* @param string $sidebar_id
* @return array
*/
function get_widgets($sidebar_id) {
$delimiter = '-' . md5(uniqid()) . '-';
$delimiter_cb = function($settings) use($delimiter) {
@Maxdw
Maxdw / localize.swift
Last active April 5, 2023 17:29
genstrings for custom translation function
extension String {
func localizedWith(comment:String) -> String {
return NSLocalizedString(self, tableName: nil, bundle: Bundle.main, value: "", comment: comment)
}
}
@Maxdw
Maxdw / main.yml
Last active April 10, 2018 10:07
ansible protobuf task ubuntu
---
# Install Google Protocol Buffers as PECL extension
# https://github.com/google/protobuf/blob/master/php/README.md
# requires php-pear, php-dev and php7.2-fpm
- pear:
name: pecl/protobuf-3.5.1.1
state: present
- name: Add protobuf extension to fpm and cli php.ini
lineinfile:
package com.github.gist.maxdw;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
class Trim {
/**
* All characters on both the left side and the right side
* of the string that appear in the provided characters string
* argument will be trimmed until a character in string does
<?php
// php mysql-dump-file-splitter.php bigdump.sql
// outputs dump files in ./out/
// php mysql-dump-file-splitter.php bigdump.sql dryrun
// does not output dump files but runs through the process
// options
define('OUTPUT_DIR', __DIR__ . DIRECTORY_SEPARATOR . 'out' . DIRECTORY_SEPARATOR);
$memlimit = '96'/*MB*/ * 1024 * 1024;
$skiptables = explode(',', 'users'); // skips users table