Author Archive: Jonathan Brinley

Hello, ChromeOS

That would be the Cr-48 ChromeOS laptop that arrived unannounced at my door this week.

Haven’t had much chance to delve into it, yet, but at the moment it’s looking like a good computer for:

  • The kitchen
  • Children
  • Business meetings
  • Casual web browsing
  • General on-the-go connectivity, when a smartphone just isn’t enough (it does SSH and has a full-size keyboard)

More to come…

Understanding Rewrite Tags, or, Custom Permalinks for Custom Post Types in WordPress 3.0+, Part 2

You may recall my ancient post about customizing your custom post type permalinks. When I wrote that, I was still stumbling somewhat blindly through WordPress’s rewrite API. After hacking a little more with it, I think I finally understand what I’m doing enough to write a little more confidently. Continue reading

Solr and JSONP

Need to send an Ajax request to a Solr server that’s on a different domain? You will, of course, need to use JSONP instead of an ordinary JSON request, due to JavaScript’s cross-domain security restrictions. To get a properly padded response from Solr, add the json.wrf parameter to your query string, giving it the name of your callback function. In jQuery:

jQuery.ajax({
  url: mySolrUrl,
  data: myQueryParameters,
  success: mySuccessCallback,
  dataType: 'jsonp',
  jsonp: 'json.wrf'
});

Of course, for this to work the Solr server you’re accessing needs to be publicly accessible, which probably isn’t ideal for security.

Excerpts for WordPress Pages

WordPress lets you create excerpts for Posts, but not for Pages. Generally, that makes good sense. If you need excerpts for pages, though, it’s pretty simple to add.

function my_init() {
  add_post_type_support('page', array('excerpt'));
}
add_action('init', 'my_init');

That’s all there is to it. Works with WordPress 3.0+.

Update 2010-10-01: Hey, look, I made it into a plugin.

Downgrade PHP to 5.2 on Ubuntu 10.04

As of version 6.14, Drupal works with PHP 5.3, but many essential modules still issue warnings (usually due to passing expressions by reference). If your Ubuntu 10.04 (Lucid Lynx) server is running 5.3, this script will automate the downgrade to the latest 5.2 by telling aptitude to use the source lists for Ubuntu 9.10 (Karmic Koala).

Thanks to Nick Veenhof, mrkandy, and their many commenters, from whom this script is derived.

php_installed=`dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
 
# remove all php packge
sudo aptitude purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
 
# use karmic for php pakage
# pin-params:  a (archive), c (components), v (version), o (origin) and l (label).
echo -e "Package: php5\nPin: release a=karmic\nPin-Priority: 991\n"  | sudo tee /etc/apt/preferences.d/php > /dev/null
apt-cache search php5-|grep php5-|awk '{print "Package:", $1,"\nPin: release a=karmic\nPin-Priority: 991\n"}'|sudo tee -a /etc/apt/preferences.d/php > /dev/null
apt-cache search -n libapache2-mod-php5 |awk '{print "Package:", $1,"\nPin: release a=karmic\nPin-Priority: 991\n"}'| sudo tee -a /etc/apt/preferences.d/php > /dev/null
echo -e "Package: php-pear\nPin: release a=karmic\nPin-Priority: 991\n"  | sudo tee -a /etc/apt/preferences.d/php > /dev/null
 
# add karmic to source list
egrep '(main restricted|universe|multiverse)' /etc/apt/sources.list|grep -v "#"| sed s/lucid/karmic/g | sudo tee /etc/apt/sources.list.d/karmic.list > /dev/null
 
# update package database (use apt-get if aptitude crash)
sudo apt-get update
 
# install php
sudo apt-get install $php_installed
 
sudo aptitude hold `dpkg -l | grep php5| awk '{print $2}' |tr "\n" " "`
 
#done

Of course, make sure to restart Apache when you’re finished.