Skip to content

Instantly share code, notes, and snippets.

@markjaquith
markjaquith / gist:4500280
Last active April 17, 2024 21:06
Bash command to fix a quirk with Sublime Text 2's "subl" command. Sometimes, when using it, under hard-to-pinpoint circumstances, it will open up Sublime Text 2 completely blank (i.e. the file you asked it to open will not be open). This snippet fixes that by essentially kicking subl under the table to wake it up and then passing on the command …
function subl() {
if [[ ! -p /dev/stdin ]]; then
command subl > /dev/null 2>&1
fi
command subl "$@"
}
@georgestephanis
georgestephanis / command.xml
Created May 30, 2013 23:09
How to upload a file to a WordPress site via the XML-RPC API. Pretty easy, no? The attachment page if you want a html wrapper to present the file can be found at the following URL: http://yoursite.com/?attachment_id=722 (I left the ID the successful response in as an example)
<?xml version='1.0' encoding='utf-8'?>
<methodCall>
<methodName>wp.uploadFile</methodName>
<params>
<param><value><string>1</string></value></param>
<param><value><string>username</string></value></param>
<param><value><string>password</string></value></param>
<param>
<value>
<struct>
@Viper007Bond
Viper007Bond / whatissoslow.php
Last active October 29, 2023 14:23
WordPress: Times how long it takes each filter and action to run and displays results at the end of the page. Quick and dirty.
<?php
/**
* This little class records how long it takes each WordPress action or filter
* to execute which gives a good indicator of what hooks are being slow.
* You can then debug those hooks to see what hooked functions are causing problems.
*
* This class does NOT time the core WordPress code that is being run between hooks.
* You could use similar code to this that doesn't have an end processor to do that.
*
@mdawaffe
mdawaffe / moon.sh
Created December 5, 2013 02:09
Express the Current Approximate Phase of the Moon as an Emoji Character in UTF-8
#!/bin/bash
# Approximates the phase of the moon using a known new-moon time and a fixed lunar phase of 2551443 seconds.
# Outputs the phase as an emoji in UTF-8
CHARS=(
"\xf0\x9f\x8c\x91" # 0 - NEW
"\xf0\x9f\x8c\x91" # 1 - NEW
"\xf0\x9f\x8c\x92" # 2 - WAXING CRESCENT
@mjangda
mjangda / ajaxurl.php
Created August 18, 2011 22:15
Get a domain-mapping safe admin-ajax URL on WordPress.com
<?php
/**
* Generates a domain-mapping safe URL on WordPress.com
* Core's ajaxurl uses admin_url() which returns *.wordpress.com which doesn't work for the front-end on domain-mapped sites.
* This works around that and generates the correct URL based on context.
*/
function my_admin_ajax_url( $path = '' ) {
if ( is_admin() )
$url = admin_url( 'admin-ajax.php' );
else