Skip to content

Instantly share code, notes, and snippets.

View sivel's full-sized avatar
😏

Matt Martz sivel

😏
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / guide_rax.rst
Last active December 28, 2015 16:49
Ansible Rackspace Guide
@sivel
sivel / rax.py.diff
Last active January 3, 2016 03:59
My "improvements" on the Ansible rax.py inventory script
@@ -22,9 +22,11 @@
inventory: rax
short_description: Rackspace Public Cloud external inventory script
description:
- - Generates inventory that Ansible can understand by making API request to Rackspace Public Cloud API
+ - Generates inventory that Ansible can understand by making API request to
+ Rackspace Public Cloud API
- |
- When run against a specific host, this script returns the following variables:
+ When run against a specific host, this script returns the following
@sivel
sivel / better-ssh-authorized-keys-management.md
Last active April 8, 2024 07:53
Better SSH Authorized Keys Management

Better SSH Authorized Keys Management

A seemingly common problem that people encounter is how to handle all of your users authorized_keys file.

People struggle over management, ensuring that users only have specific keys in the authorized_keys file or even a method for expiring keys. A centralized key management system could help provide all of this functionality with a little scripting.

One piece of functionality overlooked in OpenSSH is the AuthorizedKeysCommand configuration keyword. This configuration allows you to specify a command that will run during login to retrieve a users public key file from a remote source and perform validation just as if the authorized_keys file was local.

Here is an example directory structure for a set of users with SSH public keys that can be shared out via a web server: