Skip to content

Instantly share code, notes, and snippets.

View acarabott's full-sized avatar

Arthur Carabott acarabott

View GitHub Profile
@acarabott
acarabott / wp_mce_metabox_save.php
Created June 13, 2011 11:44
Wordpress custom metabox with TinyMCE saving formatting properly
add_action( 'add_meta_boxes', 'add_metaname_box');
add_action( 'save_post', 'metaname_save');
function add_metaname_box() {
@acarabott
acarabott / gist:1022656
Created June 13, 2011 11:47
Removing non-validating links from Wordpress header
remove_action( 'wp_head', 'rsd_link' ); // Display the link to the Really Simple Discovery service endpoint, EditURI link
remove_action( 'wp_head', 'index_rel_link' ); // index link
(from http://wpengineer.com/1438/wordpress-header/ )
@acarabott
acarabott / C.sublime-build
Created September 27, 2012 11:52
C Build (and run) System for Sublime Text 2 (OS X)
{
"cmd" : ["gcc ${file} -o ${file_base_name}.out && ./${file_base_name}.out"],
"path" : "/usr/bin:/usr/local/bin",
"shell" : true
}
@acarabott
acarabott / gist:4139266
Created November 24, 2012 11:25
Fixing 'Too many authentication failures' SSH error
This is usually caused by using multiple different ssh keys for a server without turning on IdentitiesOnly.
To get access to your account, get your host to run ssh-add -D to clear the identities. Once you are logged back in, add this to your ~/.ssh/config file:
IdentitiesOnly yes
via: http://superuser.com/questions/187779/too-many-authentication-failures-for-username
@acarabott
acarabott / gist:4531195
Created January 14, 2013 16:18
Add page-slug to body class of wordpress pages
<?php
// Add to functions.php
// Add page-slug to body
function add_body_class( $classes )
{
global $post;
if ( isset( $post ) ) {
if (substr($post->post_type, 0, 4) == 'page') {
$classes[] = $post->post_type . '-' . $post->post_name;
@acarabott
acarabott / gist:4635408
Created January 25, 2013 15:47
Wordpress - Add default menu_order to custom post type, optional terms
<?php
// Add to functions.php
// Make sure your custom post type has 'page-attributes' in its supports array
// Adjust the 'typeN's to your custom post types
// the first type
add_filter( 'wp_insert_post_data', 'set_menu_order', 10, 2 );
function set_menu_order( $data, $postarr ) {
global $post;
$pt = $data['post_type'];
@acarabott
acarabott / injectMultiple.js
Created June 18, 2013 23:37
Inject multiple scripts on Chrome Extension pageAction
function createSrcCall(tabId, src, callback) {
return function () {
if (callback !== undefined) {
chrome.tabs.executeScript(tabId, {file: src}, callback);
} else {
chrome.tabs.executeScript(tabId, {file: src});
}
};
}
@acarabott
acarabott / config.rb
Last active December 19, 2015 13:59
Capistrano SSH agent forwarding for shared hosts where authentication fails when accessing repos (not complete config.rb)
default_run_options[:pty] = true # Must be set for the password prompt from git to work
# Tell Capistrano to use agent forwarding with this command. uses your local keys instead of keys installed on the server.
ssh_options[:forward_agent] = true
ssh_options[:keys] = %w('~/.ssh/id_rsa.pub')
# shared hosts e.g. hostgator prevent filfefs with high (>5) group privileges from being run (rightfully)
set :group_writable, false
# You will probably have to update any submodules that are have an SSH remote to use https e.g.
@acarabott
acarabott / responsive_embed.css
Created October 13, 2013 12:50
Make embed codes responsive
.embed-wrap {
position: relative;
padding-top: 25px; /* IE6 workaround*/
height: 0;
object, embed, iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
@acarabott
acarabott / functions.php
Created December 16, 2013 23:41
Wordpress remove content image dimensions without regexp
function remove_img_dimensions($html) {
$dom = new DOMDocument;
$dom->loadHTML($html);
$imgs = $dom->getElementsByTagName('img');
foreach ($imgs as $img) {
$img->removeAttribute('width');
$img->removeAttribute('height');
}