Skip to content

Instantly share code, notes, and snippets.

View pjohanneson's full-sized avatar
💭
Scribblin'

Patrick Johanneson pjohanneson

💭
Scribblin'
View GitHub Profile
@ipbastola
ipbastola / clean-up-boot-partition-ubuntu.md
Last active April 3, 2024 06:54
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@conatus
conatus / ello.md
Last active April 13, 2023 19:32
Ello API

Ello API

This is a basic exploration of the Ello API. Completely unofficial, your mileage my vary, don't smash their servers as they are likely very busy.

Methods return HTML for their representation where appropriate which is a nice little pattern. Everything returns application/json.

Like this:

{
 "id": ,
@markjaquith
markjaquith / gist:6225805
Last active February 21, 2024 23:56
WordPress multi-tenant directory structure sharing core files for opcode awesomeness, fast deployments, and low disk usage. With inspiration from @weskoop. "=>" indicates a symlink.
sites
|__ ms.dev
| |__ content
| |__ index.php
| |__ wp => ../../wordpress/stable
| |__ wp-config.php
|__ one.dev
| |__ content
| |__ index.php
| |__ wp => ../../wordpress/stable
@markjaquith
markjaquith / wp-config.php
Created August 12, 2013 20:19
`wp-config.php` file to sit above a pristine WordPress directory, whereby the site can symlink their WP directory to a common one, and this file will make sure their `wp-config.php` is the one that gets called. Untested in production. Just an idea right now.
<?php
$path = str_replace( $_SERVER['DOCUMENT_ROOT'], '', dirname( $_SERVER['SCRIPT_FILENAME'] ) );
$path_parts = explode( '/', $path );
while ( count( $path_parts ) > 0 ) {
$path = $_SERVER['DOCUMENT_ROOT'] . implode( '/', $path_parts ) . '/wp-config.php';
if ( file_exists( $path ) ) {
include( $path );
break;
} else {
array_pop( $path_parts );
@annalinneajohansson
annalinneajohansson / plugin-settings.php
Last active February 23, 2023 04:42
A base for a WordPress plugin settings page, using the Settings API #add_options_page #add_action #admin_init #register_setting #add_settings_section
<?php
# http://kovshenin.com/2012/the-wordpress-settings-api/
# http://codex.wordpress.org/Settings_API
add_action( 'admin_menu', 'my_admin_menu' );
function my_admin_menu() {
add_options_page( __('My Plugin Options', 'textdomain' ), __('My Plugin Options', 'textdomain' ), 'manage_options', 'my-plugin', 'my_options_page' );
}
add_action( 'admin_init', 'my_admin_init' );
@justinph
justinph / validate_gravatar.php
Created March 19, 2013 16:49
In wordpress, a better way to check if an author has a gravatar or not. Sometimes you might want to check to see if a gravatar exists and not display any image if there isn't one. Uses the wordpress HTTP and caching apis. A better version of this: http://codex.wordpress.org/Using_Gravatars#Checking_for_the_Existence_of_a_Gravatar
/**
* Utility function to check if a gravatar exists for a given email or id
* @param int|string|object $id_or_email A user ID, email address, or comment object
* @return bool if the gravatar exists or not
*/
function validate_gravatar($id_or_email) {
//id or email code borrowed from wp-includes/pluggable.php
$email = '';
@bitfade
bitfade / gist:4555047
Last active January 21, 2022 03:06
WordPress - Remove empty p tags for custom shortcodes
<?php
add_filter("the_content", "the_content_filter");
function the_content_filter($content) {
// array of custom shortcodes requiring the fix
$block = join("|",array("col","shortcode2","shortcode3"));
// opening tag
@dbernar1
dbernar1 / gist:4133966
Created November 23, 2012 04:09
Setting some options through enabling a theme. In this case, comments and pingbacks are disabled by default in posts/pages, and timezone is Winnipeg.
add_action( 'after_switch_theme', 'dbfds_disable_comments' );
function dbfds_disable_comments( $theme_name ) {
update_option( 'default_comment_status', 'closed' );
update_option( 'default_ping_status', 'closed' );
update_option( 'timezone_string', 'America/Winnipeg' );
}
@jkudish
jkudish / tribe-settings-example.php
Created March 27, 2012 20:28
Tribe Settings Example
<?php
add_action('tribe_settings_do_tabs', 'tribe_add_general_tab');
function tribe_general_setting_tabs() {
$generalTab = array(
'priority' => 10,
'fields' => array(
'upsell-heading' => array(
'type' => 'heading',
'label' => __('Additional Functionality', 'tribe-events-calendar'),
'conditional' => ( !defined('TRIBE_HIDE_UPSELL') || !TRIBE_HIDE_UPSELL ),