Skip to content

Instantly share code, notes, and snippets.

View robinnorth's full-sized avatar
:octocat:

Robin North robinnorth

:octocat:
View GitHub Profile
@robinnorth
robinnorth / wordpress_export-post-data.php
Created April 26, 2013 11:44
WordPress: Simple, configurable script to export post data to a CSV file
<?php
/**
* Export WordPress post data to CSV
* Based on <http://stackoverflow.com/a/3474698> and <http://ran.ge/2009/10/27/howto-create-stream-csv-php/>
*/
/**
*********************************************************************
* Configuration
*********************************************************************
@robinnorth
robinnorth / bash_cheat-sheet.sh
Created April 15, 2013 08:25
Bash: Cheat sheet
# chmod all files in directory, including .hidden files
chmod [MODE] .[a-zA-Z0-9_]*
# create gzipped tarball, preserving permissions
tar -c -p -v -z -f /home/example/www.example.com_site-2013-04-15.tar.gz -C /home/example/ .
# Recursively chmod only directories
find . -type d -exec chmod 755 {} \;
# Similarly, recursively set the execute bit on every directory
@robinnorth
robinnorth / wordpress_delete-post-revisions.sql
Created April 15, 2013 08:23
WordPress: Delete post revisions
DELETE a, b, c
FROM wp_posts a
LEFT JOIN wp_term_relationships b
ON a.ID = b.object_id
LEFT JOIN wp_postmeta c
ON a.ID = c.post_id
WHERE a.post_type = 'revision';
@robinnorth
robinnorth / wordpress_prepare-database-for-production.sql
Created April 15, 2013 08:22
WordPress: Prepare database for production environment
# Update options
UPDATE wp_options SET option_value = REPLACE( option_value, 'staging.com', 'production.com' );
# UPDATE wp_options SET option_value = REPLACE( option_value, 'admin@staging.com', 'admin@production.com' );
# Update inline images
UPDATE wp_posts SET post_content = REPLACE( post_content, 'staging.com', 'production.com' );
# Update image attachment GUID
UPDATE wp_posts SET guid = REPLACE( guid, 'staging.com', 'production.com' ) WHERE post_type = 'attachment';
@robinnorth
robinnorth / git_bulk-delete-local-tags.sh
Created April 14, 2013 21:49
Git: Bulk delete local tags
$ git tag | awk '/^(.*\w)$/ {print $1}' | xargs git tag -d
@robinnorth
robinnorth / git_bulk-delete-remote-tags.sh
Last active December 16, 2015 05:28 — forked from technogoat/gist:1528381
Git: Bulk delete remote tags
$ git ls-remote --tags origin | awk '/^(.*)(\s+)(.*[a-z])$/ {print ":" $2}' | xargs git push origin