Skip to content

Instantly share code, notes, and snippets.

@rohmann
rohmann / goodbye-skype.sh
Last active March 18, 2017 20:25
Cleanup cmd+tab and the dock by launching apps in the background. You can still open their main windows with Alfred/Spotlight.
# Go away
defaults write "$(mdfind kMDItemCFBundleIdentifier = 'com.skype.skype')/Contents/Info.plist" "LSUIElement" -string "1" && killall Skype
# Come back
defaults write "$(mdfind kMDItemCFBundleIdentifier = 'com.skype.skype')/Contents/Info.plist" "LSUIElement" -string "0" && killall Skype
# If you get any requests to use the keychain, they should go away the next time you restart your mac. You may be asked to sign into Skype again.
@rohmann
rohmann / wp-debug.php
Last active August 29, 2015 14:01
Debugging for live WordPress environments.
define('WP_DEBUG', true);
if (WP_DEBUG) {
/**
* Log errors to wp-content/debug.log
* Don't forget to delete this when you're finished,
* as it may be publicly accessible.
*/
define('WP_DEBUG_LOG', true);
@rohmann
rohmann / anchor.js
Created April 3, 2014 22:07
Target an a tag normally used for anchor navigation. Provide an offset element, and it can do an animated scroll and compensate for fixed headers
jQuery(function($){
$('section a').click(function(e){
e.preventDefault();
$('html,body').animate({
scrollTop: $('#' + $(this).attr('href').split("#").slice(-1)[0] ).offset().top - $('header').height()
},700 ,'swing');
});
});
@rohmann
rohmann / mp-promo-tagging.php
Last active December 29, 2015 14:59
When "on sale" is toggled, a "promo" tag will automatically be added/removed from the product. http://git.io/pOvGzg
<?php
function auto_tag_on_sale( $meta_id, $post_id, $meta_key) {
if ('mp_is_sale' != $meta_key){
return;
}
$meta = get_post_custom($post_id);
$on_sale = false;
@rohmann
rohmann / escalate.php
Created October 25, 2013 18:53
Tool to esaclate an admin to super admin in WordPress
<?php
/*
Plugin Name: Escalate to Super Admin
Plugin URI: https://gist.github.com/rohmann/7159907
Description: Tool to convert normal admin to super admin.
Place in mu-plugins folder. Then visit /wp-admin with a normal admin account. Next, go to the network dashboard to test it. Finally, delete this plugin to prevent abuse
Author: Alexander Rohmann
Author URI: https://gist.github.com/rohmann
Version: 1.0
*/
<?php
class View {
public static function __callStatic($name,$parameters) {
try {
//Get template name from method call
$fname = TEMPLATES_DIR . implode('/', explode("_",$name) ).'.php';
@rohmann
rohmann / hide-siteurl-option.php
Created September 7, 2013 22:39
Some CSS to hide the Site URL and Home URL from the Wordpress settings page. http://git.io/fFVxOA
<?php
add_action('admin_head', 'custom_admin_css');
function custom_admin_css() { ?>
<style>
label[for=siteurl], input[name=siteurl], label[for=home], input[name=home], input[name=home] + p.description {
display: none;
}
</style>
<?php
@rohmann
rohmann / wp-dont-add-to-main-blog.php
Created September 2, 2013 02:19
Don't add a user to the primary blog on signup. http://git.io/thkt6g
<?php
add_action('wpmu_activate_blog','remove_user_from_primary_site',999,5);
function remove_user_from_primary_site($blog_id, $user_id, $password, $title, $meta){
remove_user_from_blog($user_id,1);
}
@rohmann
rohmann / remove-blog-option.php
Last active December 21, 2015 16:39
Removes the "Gimme a site / Just a username" option from Wordpress multisite signups. http://git.io/NO6z0A
<?php
function remove_signup_option(){
//Predefine what kind of registration is happening. wp-signup.php won't show the option if one is declared
global $active_signup;
$active_signup='blog';
}
add_action('signup_hidden_fields','remove_signup_option');
@rohmann
rohmann / github_webhook.php
Last active December 21, 2015 15:28
Simple script for use with GitHub web hooks
<?php
//Only allow requests from Github (see: https://gist.github.com/webtekk/6326465)
if (!githubOrigin()) die('Unauthorized');
$data = json_decode($_POST['payload'],true);
//Only continue if this commit is on the master branch
if (!$data['ref'] == 'refs/heads/master') die('Not a master branch commit');