Skip to content

Instantly share code, notes, and snippets.

View sivel's full-sized avatar

sivel / Matt Martz sivel

View GitHub Profile
@sivel
sivel / gfm2html
Created September 14, 2013 15:35
Code to convert github flavored markdown to RST
#!/usr/bin/env python
import requests
import sys
import json
import re
if len(sys.argv) == 2:
markdown_file = sys.argv[1]
@sivel
sivel / sync_container_to_folder.py
Created May 18, 2013 00:08
Sync a remote Rackspace CloadFiles container to a local directory
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2012 Rackspace
# Copyright 2013 Matt Martz
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
@sivel
sivel / ContentMD5-ReqDotMD5.pm
Created February 20, 2012 19:14
nginx Perl Module to Output Content-MD5 HTTP Header
# nginx Embedded Perl module for adding a Content-MD5 HTTP header
#
# This perl module, will output an MD5 of a requested file using the
# Content-MD5 HTTP header, by pulling the hex hash from a file of the
# same name with .md5 appended to the end, if it exists.
#
# Author: Matt Martz <matt@sivel.net>
# Link: https://gist.github.com/1870822#file_content_md5_req_dot_md5.pm
# License: http://www.nginx.org/LICENSE
@sivel
sivel / the-queries.php
Created June 14, 2011 17:14
Output or log queries generated by WordPress
<?php
if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES )
add_action( 'wp_footer', 'the_queries' );
function the_queries() {
global $wpdb;
if ( defined( 'LOGQUERIES' ) && LOGQUERIES ) {
foreach ( $wpdb->queries as $query )
error_log( trim( $query[0] ) . "\n", 3, WP_CONTENT_DIR . '/debug.log' );
} else {
@sivel
sivel / wp-tag-svn-up.sh
Created May 16, 2011 20:03
Automated WordPress upgrades using SVN tags
#!/bin/bash
TAGSURL='http://core.svn.wordpress.org/tags/'
STABLETAG=`curl -s $TAGSURL | awk -F '">' '{print $2}' | awk -F"/<" '{print $1}' | egrep "^[0-9].[0-9]" | sort -n | tail -n 1`
if [ $STABLETAG == '' ]
then
echo "Stable tag not found, exiting..."
exit 1
fi
for ADDON in `ls -1d /home/user/sites/*/`
do
@sivel
sivel / better-cache-bust.php
Created May 13, 2011 20:28
Improve WordPress cache busting to move the version into the URL path, instead of as a query variable
<?php
/*
Plugin Name: Better Cache Bust
Plugin URI: http://sivel.net/
Description: Moves the resource version in the URL path instead of as a query var
Version: 1.0
Author: Matt Martz
Author URI: http://sivel.net/
*/
@sivel
sivel / sivel-cdn.php
Created May 17, 2010 20:29
Simple WordPress plugin for repointing resource URLs to a CDN pull style host
<?php
/*
Plugin Name: Sivel CDN
Plugin URI: http://sivel.net/
Description: Points media urls at a CDN
Version: 1.0
Author: Matt Martz
Author URI: http://sivel.net/
*/
#!/usr/bin/python
import urllib, re, sys
def content_match(url, match, nocase):
uh = urllib.urlopen(url)
if re.search(match, uh.read(), re.I if nocase else 0) and uh.getcode() == 200:
return [True, uh.geturl(), uh.getcode()]
else:
return [False, uh.geturl(), uh.getcode()]
@sivel
sivel / test-head-footer.php
Created April 25, 2010 14:46
WordPress Plugin to test for the existence and functionality of wp_head and wp_footer in the active theme