Skip to content

Instantly share code, notes, and snippets.

Samuel Wood Otto42

Block or report user

Report or block Otto42

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View demo.php
<?php
/*
Plugin Name: Testing
*/
class Demo {
function do_a_thing() {
echo '<!-- demo -->';
}
}
@Otto42
Otto42 / decode.php
Last active Sep 28, 2016
Decode a file with encoded strings
View decode.php
<?php
// Decodes files that have a bunch of strings with things like "\x6d" and "\155" and such in them.
// Meat of the code from https://stackoverflow.com/questions/13774215/convert-hex-code-into-readable-string-in-php
// run me like so on command line:
// php decode.php < encoded.php > output.php
function decode_code($code)
{
return preg_replace_callback('@\\\(x)?([0-9a-f]{2,3})@',
function ($m) {
if ($m[1]) {
@Otto42
Otto42 / redball.svg
Created Jun 28, 2016
An animated red ball SVG. Move it around with WASD.
View redball.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Otto42
Otto42 / simple-table.php
Created Jan 3, 2016
Simple tables plugin (use [table]...[/table] shortcode around CSV data in rows.
View simple-table.php
<?php
/*
Plugin Name: Simple Table
Plugin URI: http://ottopress.com/wordpress-plugins/simple-table/
Description: Add a [table] shortcode for making tables
Version: 0.1
Author: Otto
Author URI: http://ottopress.com
License: GPLv2
License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
@Otto42
Otto42 / gist:b520710eb40bf95bde12
Created Oct 21, 2015
-- HUMAN RESOURCE MACHINE PROGRAM -- -- 41 Sorting Floor - Basic Bubble Sort --
View gist:b520710eb40bf95bde12
-- HUMAN RESOURCE MACHINE PROGRAM --
-- 41 Sorting Floor - Basic Bubble Sort --
-- Does not achieve any records, but demonstrates the principle of a bubble sort. --
-- Explanation --
-- Each element is copied to the floor until a zero is reached. --
-- CMP is set to the max elements location. --
-- CMP 2 is decremented and each element compared. If the result is not negative, the elements are swapped, using TMP as a temporary holding area. --
-- Once CMP 2 becomes negative, CMP is decreased and the loop repeated. --
@Otto42
Otto42 / gist:b79ff5428993fcff45bb
Last active Nov 2, 2018
disable emojis in wp 4.2
View gist:b79ff5428993fcff45bb
add_action( 'init', 'disable_emoji', 1 );
function disable_emoji() {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
add_filter( 'tiny_mce_plugins', 'disable_tinymce_emoji' );
View keybase.md

Keybase proof

I hereby claim:

  • I am Otto42 on github.
  • I am otto42 (https://keybase.io/otto42) on keybase.
  • I have a public key whose fingerprint is 270B 9CC6 F8C3 4F82 5AAE 92A5 2D65 34DE 7063 B5B2

To claim this, I am signing this object:

@Otto42
Otto42 / metabox.php
Created Jan 13, 2014
Simple meta box plugin
View metabox.php
<?php
/*
Plugin Name: Demo of a Metabox
*/
add_action('add_meta_boxes','my_meta_box_add');
function my_meta_box_add() {
add_meta_box( 'my-meta-box', 'My Meta Box', 'my_meta_box', 'post', 'side');
}
@Otto42
Otto42 / gist:6639477
Created Sep 20, 2013
How to set the color picker and the control in the customizer via JS
View gist:6639477
control = wp.customize.control.instance('header_textcolor');
picker = control.container.find('.color-picker-hex');
control.setting.set('#FFFFFF');
picker.wpColorPicker('color', control.setting() );
@Otto42
Otto42 / time-shortcode.php
Created Sep 13, 2013
Time shortcode used for make p2's
View time-shortcode.php
<?php
/**
* Plugin: Time Shortcode
* Author: Otto
*
* Usage: [time]any-valid-time-string-here[/time]
* Will attempt to parse the time string and create a format that shows it in the viewers local time zone
* Note that times should be complete with year, month, day, and hour and minute.. something strtotime can parse meaningfully
* Conversion happens via Javascript and will depend on the users browser.
**/
You can’t perform that action at this time.