Skip to content

Instantly share code, notes, and snippets.

View collegeman's full-sized avatar

Aaron Collegeman collegeman

View GitHub Profile
<?php
/**
* Given a URL, normalize that URL.
* @param String URL
* @return String Normalized URL
*/
function normalizeUrl($url)
{
$newUrl = "";
$url = parse_url($url);
@collegeman
collegeman / common-four-letter-words-en.php
Created August 4, 2015 15:35
1000 common four-letter English words as a PHP array
<?php
array(
'abet',
'abut',
'ache',
'alit',
'ante',
'arch',
'aver',
'avow',
@collegeman
collegeman / error_logr.php
Created February 6, 2014 20:48
A better function for dumping something to the log (PHP)
<?php
/**
* Debugging output like a boss: automatically print_r the content of any arguments,
* and print those contents + the stack trace to the error log.
* @param As many params as you want, type is irrelevant
*/
function error_logr(/* whatever you want */) {
$args = func_get_args();
$message = !empty($args[0]) && is_string($args[0]) ? array_shift($args[0]) : null;
$e = new Exception($message);
{
"data": [
{
"id": "10101060157562796",
"from": {
"name": "Aaron Collegeman",
"id": "25515241"
},
"start_time": "2013-04-03T03:39:10+0000",
"end_time": "2013-04-03T03:39:10+0000",
<?php
// don't show Facebook Comments on Pages
add_filter('fbc_disable_on_pages', '__return_true');
@collegeman
collegeman / google-analytics-keywords.js
Created November 1, 2012 14:26
Get a list of individual organic search keywords, sorted by frequency, from the Google Analytics UI
// step 1: Open Google Analytics to Traffic Sources => Sources => Search => Organic
// step 2: Change "Show rows" field to 500
// step 3: Open the JS console, and run the following script
var s = document.createElement('script'); s.src = '//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js'; document.getElementsByTagName('body')[0].appendChild(s);
var text = jQuery('td.sf span').map(function(i, el) { return jQuery(el).text(); });
// step 4: Then run this one:
var words = {};
@collegeman
collegeman / sharepress-mu.php
Created October 6, 2012 15:35
This file allows you to configure SharePress once for an entire WordPress MU installation.
<?php
/**
* Working with WordPress MU or Multi-Network? Configure the settings below,
* and then drop this file into wp-content/mu-plugins. These settings can
* also be configured on a theme-by-theme basis by copying them into each
* theme's functions.php file. Enjoy!
*/
@define('SHAREPRESS_MU_LICENSE_KEY', '');
@define('SHAREPRESS_MU_APP_ID', '');
@collegeman
collegeman / vt_resize.php
Created May 21, 2012 13:29 — forked from coreyweb/vt_resize.php
Resize images dynamically using WordPress' built in image manipulation functions.
<?php
/**
* Resize images dynamically using wp built in functions.
* @author Victor Teixeira http://profiles.wordpress.org/vteixeira/
* @author Aaron Collegeman http://aaroncollegeman.com
* @see http://core.trac.wordpress.org/ticket/15311
*
* php 5.2+
*
* Examples:
@collegeman
collegeman / wp-recent-posts-by-comments.php
Created May 18, 2012 16:14 — forked from coreyweb/gist:2718955
Recent WordPress Posts by Comment Frequency
<?php
/*
@author Corey Brown https://github.com/coreyweb
This code will display the 10 most commented on posts.
Rules:
- published within the last month
- at least one comment made in the last week
#!/usr/bin/env python
#
# webkit2png.py
#
# Creates screenshots of webpages using by QtWebkit.
#
# Copyright (c) 2008 Roland Tapken <roland@dau-sicher.de>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License