Archive for the ‘Technology’ Category

Marcellus Wallace

Tuesday, December 8th, 2009

NSFW

GeekTool

Saturday, December 5th, 2009

I’ve been playing around with GeekTool for a couple of days and I’ve finally gotten everything I want on my desktop.

Here’s what my desktop looks like at the moment:

My GeekTool Desktop

My GeekTool Desktop

For reference, here’s my list of GeekTool Scripts:

  • Computer Name: hostname -s
  • Login Name: whoami
  • Day: date “+%A”
  • Month: date “+%b”
  • Day (numerical): date “+%e”
  • Time: date +”%I:%M”
  • AM/PM: date +”%p”
  • Mac OS X Version: sw_vers | awk -F’:\t’ ‘{print $2}’ | paste -d ‘ ‘ – - – ;
  • Disk Usage: df -H | grep disk0s2 | awk ‘{print “Disk:”, $3, “/”, $2, “-”, $4, “available”}’
  • Uptime: uptime | awk ‘{print “Up: ” $3 ” days”}’
  • Airport Network Name: airport -I | grep -e “\bSSID:” | awk ‘{print $2}’
  • Airport Channel: airport -I | grep -e “channel:” | awk ‘{print “Channel: ” $2}’
  • Airport Max Rate: airport -I | grep -e “maxRate:” | awk ‘{print “Max Rate: ” $2}’
  • Airport Link Authorisation: airport -I | grep -e “link auth:” | awk ‘{print “Auth: ” $3}’
  • External IP: echo `curl -s http://checkip.dyndns.org/ | sed ’s/[a-zA-Z<>/ :]//g’`
  • Running Processes: ps -c -U pmac -o command,%cpu,%mem -r
  • Airport IP: ipconfig getifaddr en1
  • Calendar: cal
  • Network Location: scselect 2>&1 | grep ‘^ \*’ | sed -e ’s:^[^(]*(\([^)]*\))$:\1:g’

Most of these commands were culled from various websites, while I came up with the rest myself.

“custom_domain is null” error message in Firefox

Thursday, July 9th, 2009

Problem: When opening a “localhost” address using Firefox, a JavaScript error message is displayed with the error message “current_domain is null”.

Description: Using Firefox version 3.0.11. Error message only appears when connecting to a site hosted on the local machine. Disabling all add-ons resolves the problem. Re-enabled add-ons one by one. Re-enabling LongURL Expander causes the problem to re-appear. Error message is known issue with version 2.0.0 of the add-on.

Solution: As per the comments on the the add-on page, edit the longurlmobileexpander.js file to make the requirement for the second part of the domain name optional.

  • On Mac OS X, open home folder and browse to Library/Application Support/Firefox/Profiles/[profile].default/extension/{a7101e54-830c-4d33-a3ed-bedc17ec44da}/content
  • Open longurlmobileexpander.js in TextEdit.
  • Edit line 78 to read:


var current_domain = document.location.href.match(/^https?:\/\/(?:www\.)?([^\.]+(\.[^\/]+)?)/i);

  • Save changes.

Thanks to Mathias Jansen for the solution.

Disabling Ethernet Prevents Mac OS X From Waking

Tuesday, July 7th, 2009

Problem: When MacBook lid is closed, fan continues to spin and MacBook becomes very hot.

Description: When in use the MacBook fan behaves as expected. On closing the lid to put the MacBook sleep, the fan continues to spin and the base of the machine becomes very hot.

Opening the lid displays a black screen. No mouse or login screen displayed. Fan continues to spin at what seems to be maximum RPM. Closing the lid again does not stop the fan from spinning.

Only available option is to hold the power button to shut down the system.

On pressing the power button to restart the system, the MacBook starts, displays grey start up screen for a second or two and then restarts automatically. MacBook then starts normally.

Once the user logins, the system works as normal again. Putting the system to sleep, causes the problem to reoccur.

Solution: The user deactivated the Ethernet interface within System Preferences -> Network. Reactivating the Ethernet interface and restarting the machine resolved the problem.

(Who’d have thought that disabling the Ethernet interface would prevent the system from sleeping? Certainly not me when I decided to do so.)

Image Dump

Friday, June 5th, 2009

For my enjoyment. And maybe yours:

Abstruse Goose: Biologists

Abstruse Goose: Biologists

Atheism Motivational

Atheism Motivational

Troll Slayer

Troll Slayer

Software Engineering Explained

Software Engineering Explained

Breastfeeding

Breastfeeding

Should Apple Ban an iPhone App for this?

Thursday, June 4th, 2009

Via El Reg.

Blogging & Social Media for Business Seminar

Thursday, June 4th, 2009

Absolute Hotel, Limerick. June 13th. 9:30 am.

If you run a business and are interested in creating a proper online presence, then sign up now.

Plugin Review – Add Twitter RSS

Thursday, April 16th, 2009

It’s proving to be a great week for my plugin’s. Following on from WordCast PodCast mentioning WP Frame Breaker, Weblog Tools Collection have just posted a review of another one of my plugins – Add Twitter RSS.

If you use Add Twitter RSS, head on over and let them know what you think.

Add as always, feedback and requests for more options are always welcome.

WordCast Pod Cast

Wednesday, April 15th, 2009

My WP Frame Breaker plugin gets a mention on this weeks WordCast PodCast: WordCast 51: Big-Wheeled Sedan. How cool is that?

You can hear more at about the 49:35 mark.

Thanks to the guys at WordCast PodCast for the mention.

WordPress 2.8 – New Widget API

Tuesday, April 14th, 2009

WordPress 2.8 and the new Widget API

WordPress 2.8 is due sometime this month, and one of the major changes is the new Widget API.

Hand in hand comes the new Widget Panel which uses AJAX to update your sidebars. The latest beta has the new Widget Panel included:

WordPress 2.8 Widget Panel

WordPress 2.8 Widget Panel

Still very much a work in progress, the Panel doesn’t fully work yet and there’s a bit of work to be doen on the presentation side.

Multi Widgets

The biggest change is going to be for plugin writers. The new Widget API is designed to make the process of writing widgets, especially multi widgets easier.

As anyone who has ever written a multi-widget will tell you, the documentation is virtually non-existent and what tutorials are available are cryptic.[1]

The Widget API

As 2.8 will be released in the near future, now is the time to start thinking about updating your widgets to take advantage of the new API. As the Widget API isn’t fully documented yet, I decided to have a look at the source files to see what’s involved in writing a widget using the API.

The relevant files are:

  • /wp-includes/widgets.php
  • /wp-includes/default-widgets

Using the Widget API

The new Widget API provides a WP_Widget class and it’s by extending this class that you create your own widget. Your widget then over-rides 3 three methods within WP_Widget:

  1. widget()
  2. update()
  3. form()

The easiest way to demonstrate this is by creating a basic text widget. So we’ll build a WordPress 2.8 Text Widget.

Building Your Widget

As with the current version of WordPress, your widget needs to contain the some basic information so that WordPress will recognise it as a plugin:


<?php
/*
Plugin Name: New Widget API
Plugin URI: http://www.paulmc.org/whatithink/
Description: Demonstration of the WordPress 2.8 Widget API
Version: 1.0
Author: Paul McCarthy
Author URI: http://www.paulmc.org/whatithink
*/

The first step is to create your widget class by extending WP_Widget:


class WP_My_Widget extends WP_Widget {

Your widget needs a constructor, that is, a function that will be called when the widget is loaded. Your constructor must have the same name as your widget. Within the constructor, specify an array to hold your widget options, control options and call the WP_Widget constructor.


function WP_My_Widget() {

$widget_ops = array ('classname' => 'my_widget', 'description' => __('The description for your Widget') );
$control_ops = array ('width' => '300', 'height' => '400');

$this->WP_Widget('my_widget', __('My Widget'), $widget_ops, $control_ops);

}

Once you’ve created your constructor, it’s time to over-ride the methods needed to make your widget work. The first method to over-ride is widget().

The widget() method is where your widget does it’s work. The widget() method takes two parameters. The first provides you with access to the widget display settings and the second provides access to that particular instance settings.

As this is a simple text widget, we’ll use just two settings – title and text.


function widget($args, $instance) {

extract ($args);

$title = empty($instance['title']) ? __('My Widget Title') : apply_filters('widget_title', $instance['title']);
$text = apply_filters('widget_text', $instant['text']);

echo $before_widget . $before_title . $title . $after_title;
echo $text;
echo $after_widget;
}

The next method that we’ll over-ride is the update() method. This method provides us with the means to update and save our widget settings. It takes two parameters, the first is an array that contains the settings provided by the user via the widget form, and the second is an array containing the old settings for the widget.


function update ($new_instance, $old_instance) {

$instance = $old_instance;

$instance['title'] = strip_tags($new_instance['title']);
$instance['text'] = $new_instance['text'];

return $instance;
}

That’s it. All the method does is store the old settings in an array, update the array with the new settings and then pass the new settings back to the WP_Widget class. The WP_Widget class handles the actual updating and saving.

Our next method to over-ride is form(). This method is used to display the widget control form. It takes one parameter, an array with the current settings.


function form ($instance) {

$instance = wp_parse_args( (array) $instance, array('title' => '', 'text' => ''));

$title = strip_tags($instance['title']);
$text = format_to_edit($instance['text']);

?>

<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" />
</label>
<textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text ?></textarea>
</p>

<?php
}
}

That’s it. A simple text widget written using the WordPress 2.8 Widget API.

If you’d like to review the full code, with comments, then you can download it here:

New Widget API Plugin File

  1. I’ve been looking into transforming one of my widgets into a multi-widget, but given the hassle involved, I’m just going to hold off until 2.8 is released. []