Skip to content

Instantly share code, notes, and snippets.

Thorsten Ott tott

View GitHub Profile
View gist:7125b5cfa1bd48d8da0e9ad89256c802
polybar config
[module/date]
type = custom/script
exec = ~/scripts/popup-calendar.sh
interval = 5
click-left = ~/scripts/popup-calendar.sh --popup
format-background = ${colors.alt-background}
format-foreground = ${colors.alt-foreground}
label = %output:25%
@tott
tott / read-backlight.py
Created Nov 22, 2018
Read backlight for x230 / x330 taobao FHD mod
View read-backlight.py
#!/usr/bin/env python
import sys
import array
import usb.core
import usb.util
import os
path = "/tmp/backlight-value"
# decimal vendor and product values
@tott
tott / gist:a10bebe067d517455e423eb32f7d1d3d
Created Oct 16, 2018
Sending multipart mail with wp_mail (untested)
View gist:a10bebe067d517455e423eb32f7d1d3d
<?php
$to = "receipt@domain.com";
$subject = "My Multipart test";
$message = "I am the plain text message";
$boundary = uniqid(rand(), true);
$header = "MIME-Version: 1.0\n"
@tott
tott / options-monitor.sh
Last active Jul 10, 2018
WordPress options table size Nagios monitor
View options-monitor.sh
#!/bin/bash
OPTIND=1
verbose=0
dbuser=""
dbpasswd=""
while getopts "vh?U:P:H:" opt; do
case "$opt" in
@tott
tott / minions-post-pusher.php
Last active Aug 6, 2017
WP-Minions ( https://github.com/tott/WP-Minions/tree/alter-job-data ) for multisite syndication to one site.
View minions-post-pusher.php
<?php
/**
* Plugin Name: WP Minions Post Pusher
* Description: Pushes all published posts to one blog using wp-minions
* Version: 1.0
* Author: Thorsten ott
* Author URI: http://thorsten-ott.de/
* License: GPLv2 or later
*/
View gist:2fb5a32786542c3b423faf007b085d74
#!/bin/bash
# ./curl-urls.sh numprocessses http://urltograp urlpattern
# ./curl-urls.sh 3 http://www.domain.com domain.com
numprocessses=$1
baseurl=$2
urlpattern=$3
function forky() {
local num_par_procs
if [[ -z $1 ]] ; then
@tott
tott / gist:a7638cb9b602425b3c87
Last active Aug 29, 2015
workaround disabling xmlrpc from within wordpress mu-plugins file
View gist:a7638cb9b602425b3c87
/**
* Disable xmlrpc
*/
if ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) {
include_once(ABSPATH . WPINC . '/class-IXR.php');
class blocking_xmlrpc_server {
function serve_request() {
$response = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this site.' ) ) );
die( $response->getXml() );
@tott
tott / gist:0cc78e7dcad18024d1c8
Created Jul 1, 2014
Create a full list of sites with domain mapping with wp-cli
View gist:0cc78e7dcad18024d1c8
for i in `wp site list | cut -f 2 | grep -v url`; do wp --url=$i eval 'global $wpdb, $blog_id; $blogname=get_option("blogname"); $blogurl=home_url(); $domains=$wpdb->get_results( "SELECT * FROM {$wpdb->dmtable} WHERE blog_id = $blog_id;" ); foreach( $domains as $data ) { echo $blog_id.",".$blogname.",".$blogurl.",".$data->domain.",".$data->active."\n"; }'; done
@tott
tott / maybe-flush-rewrite-rules.php
Created Mar 14, 2014
Flush rewrite rules when it's necessary. This could be put in an init hook or the like and ensures that the rewrite rules option is only rewritten when the generated rules don't match up with the option.
View maybe-flush-rewrite-rules.php
function maybe_flush_rules() {
global $wp_rewrite;
$rewrite_rules = get_option( 'rewrite_rules' );
foreach( $rewrite_rules as $rule => $rewrite ) {
$rewrite_rules_array[$rule]['rewrite'] = $rewrite;
}
$maybe_missing = $wp_rewrite->rewrite_rules();
$missing_rules = false;
$rewrite_rules_array = array_reverse( $rewrite_rules_array, true );
foreach( $maybe_missing as $rule => $rewrite ) {
@tott
tott / harvest-bugger.php
Created Feb 3, 2014
For all those people who forget to run their harvest timer. Here's a little script that will bug you when you do. Runs on OSX.
View harvest-bugger.php
<?php
/**
* Helper script that can be run in cron to bug you when you forgot to run a harvest timer.
* install terminal-notifier via:
* sudo gem install terminal-notifier
* Make sure to adjust your credentials.
* Schedule via crontab -e to run weekdays 9-5
* <star>/10 09-17 * * 1-5 php <path-to-script>
* replace <star> with *
*/
You can’t perform that action at this time.