Skip to content

Instantly share code, notes, and snippets.

View mgirouard's full-sized avatar
🤘

Michael Girouard mgirouard

🤘
View GitHub Profile
<?php
/*
Plugin Name: Show Server Time
Description: Shows the current server time when scheduling posts. This is helpful when there is a time difference between your local computer and the remote server
Version: 0
Author: Michael Girouard
Author URI: http://www.lovemikeg.com/
*/
function curry (method, scope, params) {
scope = scope || window;
params = params || [];
return function () {
return method.apply(scope, params);
};
};
@mgirouard
mgirouard / destroy-sample-data.php
Created October 1, 2010 02:02
A quick hack to destroy all sample data in an OpenCart catalog.
<?php
$options = getopt('p:');
$prefix = empty($options['p'])
? realpath('.')
: realpath($options['p']);
if (empty($prefix)) {
die("Bad prefix. Try again.\n");
}
<?php
class Calendar
{
protected $date;
public $timezone = 'America/New_York';
public $yearFormat = 'Y';
public $monthFormat = 'n';
public $dayFormat = 'd';
@mgirouard
mgirouard / BooksController.php
Created October 15, 2010 16:59
How to save a file using MongoDB's GridFS in Lithium
<?php
namespace app\controllers;
use \app\models\Book;
use \app\models\Job;
use \app\models\File;
class BooksController extends \lithium\action\Controller {
@mgirouard
mgirouard / action.php
Created October 17, 2010 03:51
How to enable 'admin_' prefixed routes in Lithium
<?php
/* ----- snip (omitting everything already in config/bootstrap/action.php) ----- */
/**
* Filter to capture any admin-specific requests
* This simply updates the internal action name for dispatching purposes. In order for this to
* properly work across the board, you'll need to enable a persistent param for `admin` in your
* routes configuration. Something to the effect of the following will do nicely:
*
@mgirouard
mgirouard / mg_username_shortcode.php
Created November 1, 2010 17:03
A quick shortcode to get a user's username injected into the page
add_shortcode('mg_username', 'mg_username_shortcode');
function mg_username_shortcode($args) {
$user = wp_get_current_user();
if ($user && !empty($user->user_login)) {
return $user->user_login;
}
else {
return '';
}
@mgirouard
mgirouard / update-all.sh
Created January 25, 2012 02:28
How to update all Vendor repositories (SVN or Git)
#!/bin/bash
for p in `ls`
do
echo Updating $p
[[ -d $p/.git ]] && cd $p && git pull && cd ..
[[ -d $p/.svn ]] && svn up $p
done
@mgirouard
mgirouard / vendor-repo-index.sh
Created February 1, 2012 05:38
Index all vendor repositories in a directory
#!/bin/bash
function git_uri ()
{
echo $(git remote -v | grep "$1" | grep "fetch" | sed -E -e 's/^[a-z]+| |\(.+\)//g')
}
for VENDOR in `ls`; do
# Skip files
[[ -f $VENDOR ]] && continue
mbp:EC6 m2$ ab -n 100 -c 10 http://www.willistherage.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking www.willistherage.com (be patient).....done
Server Software: Apache/2.2.3
Server Hostname: www.willistherage.com