Skip to content

Instantly share code, notes, and snippets.

View dessibelle's full-sized avatar
🦊
Yes

Simon Fransson dessibelle

🦊
Yes
View GitHub Profile
@dessibelle
dessibelle / override-wptouch-urls.php
Created November 28, 2011 17:45
PHP: Override WPtouch's content_url function to make use of `content_url` instead of `WP_CONTENT_URL`.
<?php
/*
Plugin Name: Override WPtouch URLs
Plugin URI: http://dessibelle.se
Description: Overrides WPtouch's content_url function to make use of `content_url` instead of `WP_CONTENT_URL`.
Author: Simon Fransson
Version: 1.0
Author URI: http://dessibelle.se/
*/
@dessibelle
dessibelle / memroy-consumtion.php
Created February 25, 2012 11:54
PHP: Print WordPress memory consumption in footer
// Prints WordPress memory consumption in footer. Measured at script start, 'init', 'wp_head' and 'wp_footer'.
$start = memory_get_usage();
add_action('wp_head', create_function('', 'global $header; $header = memory_get_usage();'));
add_action('wp_head', create_function('', 'global $init; $init = memory_get_usage();'));
add_action('wp_footer', create_function('', 'global $start; echo "<pre>Start: " . number_format($start, 0, ".", ",") . " bytes</pre>\n";'));
add_action('wp_footer', create_function('', 'global $init; echo "<pre>Init: " . number_format($init, 0, ".", ",") . " bytes</pre>\n";'));
add_action('wp_footer', create_function('', 'global $header; echo "<pre>Header: " . number_format($header, 0, ".", ",") . " bytes</pre>\n";'));
add_action('wp_footer', create_function('', 'echo "<pre>End: " . number_format(memory_get_usage(), 0, ".", ",") . " bytes</pre>\n";'));
@dessibelle
dessibelle / keychain-dump.txt
Created March 1, 2012 12:55
TextMate search/replace regex for keychain dumps
# Dump keychain using: security dump-keychain /Path/to/keychain.keychain -d > keychain
# Open resulting file in TextMate. The following regex will strip out Name, Account, Protocol, Host and Password and wrap everything else in HTML comments which can be removed using Bundles > HTML > Strip HTML tags from document…
# Search for
(?m:attributes.*?0x00000007 <blob>="([^"]+).*?"?acct"<blob>="([^"]+).*?"ptcl"<uint32>="([^"]+).*?"srvr"<blob>="([^"]+).*?data:\n"([^"]+)".*?class:)
# Replace with
\n\n--><entry>Name: $1\nAccount: $2\nProtocol: $3\nHost: $4\nPassword: $5</entry><!--\n\n
@dessibelle
dessibelle / install-wordpress.sh
Created May 12, 2012 13:24
Shell script: WordPress install script
#!/usr/bin/env bash
# == ABOUT ==
# Gets localized version of WordPress and plugins from svn, sets up wp-config.php
# and creates database, downloads some standard components from github (and local
# git server) and runs theme template setup.
# == INSTALLATION ==
#
# Install script: git clone git://gist.github.com/2666478.git tmp.$$; sudo mv tmp.$$/install-wordpress.sh /usr/bin/; chmod 755 /usr/bin/install-wordpress.sh; rm -rf tmp.$$/;
@dessibelle
dessibelle / html5video.sh
Created June 20, 2012 07:50
Shell script: HTML5 Video Transcoding
#!/usr/bin/env bash
MISSING_DEPENDENCIES=false
command -v HandBrakeCLI >/dev/null 2>&1 || { echo >&2 "I require HandBrakeCLI but it's not installed."; MISSING_DEPENDENCIES=true; }
command -v ffmpeg2theora >/dev/null 2>&1 || { echo >&2 "I require ffmpeg2theora but it's not installed."; MISSING_DEPENDENCIES=true; }
if $MISSING_DEPENDENCIES ; then
echo >&2 ""
echo >&2 "Aborting."
@dessibelle
dessibelle / download-website.sh
Created September 18, 2012 09:26
Shell script: Download website
#!/usr/bin/env bash
if [ $# -gt 0 ] ; then
URL=$1
else
while :
do
read -p "Site: " URL
if [ -n "$URL" ] ; then
@dessibelle
dessibelle / deploy.sh
Created September 18, 2012 15:48
Shell script: Deploy website
#!/usr/bin/env bash
# === Operation plan ===
#
# [ ] Support for different systems, using `find $SITE -name wp-config.php` for WordPress
# [ ] Add/read/set directives for environment DEVELOPMENT / STAGING / PRODUCTION in wp-config.php etc.
# [ ] Different database credentials etc. depending on environment
# [ ] Automatically change environment in wp-config.php etc. when deploying
# [*] Create some kind of .deploy_rc file to hold server settings (host, credentials, remote path etc.)
# and store inside site directory (is that really wise?)
@dessibelle
dessibelle / wordpress-nfd-to-nfc-filename-conversion.sh
Created January 31, 2013 19:39
Two commands needed to perform UTF-8 NFD to NFC decomposition on all files in a directory, and uploading the resulting directory to a webserver. Useful for treating files created on a Linux server (NFC), downloaded to Mac OS X (NFD) and needing to be uploaded back to the original server (NFC). Must, naturally, be run on Linux or at least used on…
#!/usr/bin/env bash
convmv -f utf8 -t utf8 --nfc --replace --nosmart --no-test -r uploads/
rsync -avz -e ssh uploads/ username@host:mysite.com/public_html/wordpress/wp-content/uploads
@dessibelle
dessibelle / gist:6595023
Created September 17, 2013 14:24
Fix for missing activation hook in Taxonomy Order 1.1
--- orig.taxonomy-order.php 2013-09-17 16:18:19.000000000 +0200
+++ taxonomy-order.php 2013-09-17 16:18:50.000000000 +0200
@@ -86,7 +86,7 @@
self::$plugin_url = WP_PLUGIN_URL . '/' . self::$plugin_folder;
self::$plugin_file = self::$plugin_dir . '/taxonomy-order.php';
- register_activation_hook( self::$plugin_file, array( $this, 'activation_hook' ) );
+ // register_activation_hook( self::$plugin_file, array( $this, 'activation_hook' ) );
add_action( 'init', array($this, 'interface_wpdbfix') );
@dessibelle
dessibelle / jetpack-override.css
Created September 18, 2013 10:56
Example WordPress plugin to override CSS
/* CSS overrides goes here */
#some-elem .some-class {
display: none;
}