Skip to content

Instantly share code, notes, and snippets.

@ninnypants
ninnypants / change-featured-img-text.php
Created March 2, 2012 07:19
Change featured image text
@ninnypants
ninnypants / proxy.php
Created March 13, 2012 23:35
Proxy that adjusts links
<?php
session_start();
function build_url($args = array()){
$defaults = array(
'scheme' => 'http',
'host' => '',
'path' => '',
'query' => '',
'user' => '',
@ninnypants
ninnypants / gist:5170883
Created March 15, 2013 15:54
Download latest WordPress unzip and add keys
<?php
$fp = fopen('wordpress.zip', 'w');
$ch = curl_init('http://wordpress.org/latest.zip');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
curl_close($ch);
exec('unzip wordpress.zip');
exec('cp -R wordpress/* .');
exec('rm wordpress.zip');
@ninnypants
ninnypants / remove-empty-p.php
Last active January 3, 2023 01:11
Remove empty p tags from WordPress posts
<?php
add_filter( 'the_content', 'remove_empty_p', 20, 1 );
function remove_empty_p( $content ){
// clean up p tags around block elements
$content = preg_replace( array(
'#<p>\s*<(div|aside|section|article|header|footer)#',
'#</(div|aside|section|article|header|footer)>\s*</p>#',
'#</(div|aside|section|article|header|footer)>\s*<br ?/?>#',
'#<(div|aside|section|article|header|footer)(.*?)>\s*</p>#',
'#<p>\s*</(div|aside|section|article|header|footer)#',
@ninnypants
ninnypants / gist-oembed.php
Created February 28, 2013 05:51
Quick WordPress plugin to add gists to oEmbed
<?php
/*
Plugin Name: Gist oEmbed
Plugin URI: http://ninnypants.com
Description: Embed gists into posts
Version: 1.0
Author: ninnypants
Author URI: http://ninnypants.com
License: GPL2
@ninnypants
ninnypants / keymap.c
Created April 17, 2019 16:10
QMK macro to send and open a new zoom meeting with /zoom in slack. Built using Alfred mapped to cmd+space but may work with spotlight.
bool process_record_user( uint16_t keycode, keyrecord_t *record ) {
switch ( keycode ) {
case SLACK_ZOOM:
if ( record->event.pressed ) {
SEND_STRING( SS_DOWN( X_LGUI ) SS_TAP( X_SPACE ) SS_UP( X_LGUI ) );
_delay_ms( 250 );
SEND_STRING( SS_TAP( X_Z ) SS_TAP( X_O ) SS_TAP( X_O ) SS_TAP( X_M ) SS_TAP( X_ENTER ) );
_delay_ms( 5000 );
SEND_STRING( SS_DOWN( X_LGUI ) SS_TAP( X_SPACE ) SS_UP( X_LGUI ) );
_delay_ms( 250 );
M104 S0 ;extruder heater off
M140 S0 ;heated bed heater off (if you have it)
G91 ;relative positioning
G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure
G1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more
G28 X0 ;move X to endstop out of the way
G28 Y210; move bed out for easier access
M84 ;steppers off
G90 ;absolute positioning
@ninnypants
ninnypants / display-site-ids.php
Created February 28, 2013 04:38
Show ID column in multisite Sites list table
<?php
/*
Plugin Name: Show Multisite IDs
Plugin URI: http://ninnypants.com
Description: Adds table column to show site ID
Version: 1.0
Author: ninnypants
Author URI: http://ninnypants.com
License: GPL2
@ninnypants
ninnypants / single-page-walker.php
Created June 5, 2012 01:56
Nav walker for single page WordPress sites
<?php
class Single_Page_Walker extends Walker_Nav_Menu{
function start_el(&$output, $item, $depth, $args) {
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$classes[] = 'menu-item-' . $item->ID;
@ninnypants
ninnypants / easing.js
Created July 8, 2012 17:31
jQuery easing easeInOutExpo
jQuery.extend(jQuery.easing,{easeInOutExpo:function(e,f,a,h,g){if(f==0){return a}if(f==g){return a+h}if((f/=g/2)<1){return h/2*Math.pow(2,10*(f-1))+a}return h/2*(-Math.pow(2,-10*--f)+2)+a}});