Skip to content

Instantly share code, notes, and snippets.

View rnagle's full-sized avatar

Ryan Nagle rnagle

View GitHub Profile
@rnagle
rnagle / delete_blog_users.sql
Last active August 29, 2015 14:18
Prepare a standalone WP blog for migration to multisite install
-- This SQL file will remove all users for a specific blog from the network tables (`wp_users` and `wp_usermeta`)
-- Set the value of `@newBlogID` to the ID of the blog for which you want to remove all users.
-- Useful for reimporting content and users/rerunning a migration.
@newBlogID = TKTK;
DROP TEMPORARY TABLE IF EXISTS temp_user_ids;
CREATE TEMPORARY TABLE IF NOT EXISTS temp_user_ids SELECT user_id as ID FROM wp_usermeta WHERE meta_key = CONCAT('wp_', @newBlogID, '_capabilities');
DELETE FROM wp_users WHERE ID in (SELECT ID from temp_user_ids);
DELETE FROM wp_usermeta WHERE user_id in (SELECT ID from temp_user_ids);
@rnagle
rnagle / phpmailer_debug_settings.php
Created March 12, 2015 15:16
WordPress: set up phpmailer for debugging
<?php
function phpmailer_debug_settings($phpmailer) {
$phpmailer->isSMTP();
$phpmailer->Host = 'localhost';
$phpmailer->Port = 1025;
}
add_action('phpmailer_init', 'phpmailer_debug_settings');
@rnagle
rnagle / ipinfo
Created August 29, 2014 16:47
A command line interface for the services provided by http://ipinfo.io
#!/bin/bash
function print_help() {
echo "A command line interface for the services provided by http://ipinfo.io
Example usage:
ipinfo [ADDRESS] [ip | hostname | loc | org | city | region | country | phone | geo]
ipinfo 8.8.8.8 geo
{ "ip": "8.8.8.8", "city": null, "region": null, "country": "US", "loc": "38.0000,-97.0000" }
@rnagle
rnagle / dnsmasqutil
Created August 20, 2014 16:04
Utility script for stopping, starting and restarting dnsmasq
#!/bin/bash
#
# Install:
#
# Copy this file to a location included in your PATH.
#
# Usage:
#
# $ dnsmasqutil stop|start|restart
@rnagle
rnagle / APDate.js
Last active August 29, 2015 13:58
AP date formatter
/**
* Author: Ryan Nagle
* https://gist.github.com/rnagle/10181125
*
* APDate takes an object with keys describing a date/time. The method `ap` returns
* a string using AP style for the specified day, month, year.
*
* Usage:
*
* var d = new APDate({ month: 8, day: 8, year: 1989 });
@rnagle
rnagle / omniture.js
Last active June 17, 2023 11:46
omniture.js
// Omniture.js is a clean up of Tribune's boilerplate Omniture
// code with some added convenience methods for setting vars,
// recording page views, etc.
//
// It sets up a singleton `omniture` object to use for all your
// Omniture needs.
//
// Example use:
//
// window.omniture.init('saccountgoeshere', {
@rnagle
rnagle / ChartView.js
Created March 7, 2014 19:17
ChartView.js
/**
* Original author: David Eads (https://github.com/eads)
*
* Wrap D3 charting components in a simple Backbone view interface
*
* Provides a redrawing path, data sync, and fallback for non-d3 browsers.
*
* Views that extend ChartView should implement their own "draw" function and go to work.
*
* var collection = new Backbone.Collection([ ["Maria", 33], ["Heather", 29] ]);
@rnagle
rnagle / ObligationDebtChartView.js
Created March 7, 2014 19:16
ObligationDebtChartView.js
var ObligationDebtChartView = ChartView.extend({
constructor: function(options) {
ChartView.apply(this, arguments);
this.create_tooltip();
this.$chart_container.attr('id', 'debt-chart-container');
return this;
},
draw: function() {
@rnagle
rnagle / gist:3990130
Created October 31, 2012 21:46
Experiment with Casper.js
var clients = Array(10),
url = 'http://localhost:5000/';
var on = function(resource) {
if (resource.url.match('data.json'))
this.echo("[update] Received: " + resource.url, 'INFO');
};
var start = function() {
if (this.resourceExists('data.json')) {
@rnagle
rnagle / gist:3966178
Created October 27, 2012 20:48
S3 Utils
import os
from boto import connect_s3
from boto.exception import S3ResponseError
from boto.s3.key import Key
from config import AWS_SECRET_ACCESS_KEY, AWS_ACCESS_KEY_ID, S3_BUCKET
bucket_name = S3_BUCKET
conn = connect_s3(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)