Skip to content

Instantly share code, notes, and snippets.

@aaronpeterson
aaronpeterson / disable get_adjacent_post
Last active June 12, 2018 19:04
get_adjacent_post buster for a wordpress custom post type.
<php
// in your constructor, etc
add_filter('get_previous_post_where', array($this, 'removePreviousPost'));
// have not tested this one but maybe?
add_filter('get_next_post_where', array($this, 'removePreviousPost'));
// kill with impossible sql
// @see https://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/link-template.php#L1173
public function removePreviousPost($where) {
/**
* This hasn't been unit tested. It also depends on address_component.types[0]
* being the primary type of interest i.e. not something like "political"...
*/
function convertAddressComponents(addrComponents) {
var address = {};
var typeMap = {
street_number: "streetNumber",
// less
.gm-style {
img {
max-width: inherit !important;
}
}
/* css */
.gm-style img {
max-width: inherit !important;
@aaronpeterson
aaronpeterson / gist:6051292
Created July 22, 2013 04:33
An untested example of async.each to decorate a list of users.
// populate users with User.find, etc, then inside that callback:
var results = [];
async.each(users, function(user, cb) {
Foo.find({"user._id":user._id}, function(err, result) {
// note: return isn't returning anything valuable, it's just a shortcut to leave the function to avoid ugly } else {
if (err) return cb(err);
if (result === true) {
// whatever this is...
@aaronpeterson
aaronpeterson / mpnml
Created February 21, 2013 02:46 — forked from holms/mpnml
sudo port -v install mysql5-server
# Don't do any post-install instructions
sudo -u _mysql mysql_install_db5
# if above command produce this error: ERROR: 1004 Can't create file '/var/tmp/#sqle967_1_0.frm' (errno: 9)
# do this:
# sudo chown -R mysql:mysql /opt/local/var/db/mysql5
# sudo chmod u+rwx,go= /opt/local/var/db/mysql5
# sudo /opt/local/lib/mysql5/bin/mysql_install_db --user=mysql
@aaronpeterson
aaronpeterson / Styles.cs
Created September 11, 2012 20:51 — forked from AngryAnt/Styles.cs
Handy utility functions for creating solid colour textures for GUI use.
// Usage:
m_SideBarTexture = CreateTexture (CreateColor ("#30433C"));
// The goodness:
static Color CreateColor (string hexCode, float alpha = 1.0f)
{
if (hexCode.Length == 7 && hexCode[0] == '#')
{
@aaronpeterson
aaronpeterson / gist:1874366
Created February 21, 2012 06:40
Cakephp flatten
<?php
// from my ApiComponent
/**
* Flatten Model find data
*
* Will flatten data from a find or find multi response by moving the specified
* className up to the root of the array. Useful for converting find results to
* REST responses.
*
@aaronpeterson
aaronpeterson / launch.sh
Created December 21, 2011 18:30
Asynchronous CakePHP Shell
#!/bin/bash
DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
RUN_IN_BACKGROUND=0
MAX_FORKS=1
usage() {
cat << EOF
usage: $0 options