Skip to content

Instantly share code, notes, and snippets.

View mysql-dump-file-splitter.php
<?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
View Trim.java
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
@Maxdw
Maxdw / main.yml
Last active Apr 10, 2018
ansible protobuf task ubuntu
View main.yml
---
# 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:
@Maxdw
Maxdw / localize.swift
Last active Jul 2, 2020
genstrings for custom translation function
View localize.swift
extension String {
func localizedWith(comment:String) -> String {
return NSLocalizedString(self, tableName: nil, bundle: Bundle.main, value: "", comment: comment)
}
}
@Maxdw
Maxdw / wp.function.get.sidebar.widgets.array.php
Created Nov 19, 2015
WordPress - Uses dynamic_sidebar to split widgets into an array allowing more control over widget placement.
View wp.function.get.sidebar.widgets.array.php
/**
* 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 / wp.function.multipart.mail.php
Last active Nov 19, 2015
WordPress - Sending multipart (text/html and plain/text) email in WordPress programatically.
View wp.function.multipart.mail.php
/**
* 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
*/