@madpilot makes

Web directions update #3: Campaign monitor

I just attended the talk given by Dave Greiner & Ben Richardson who created Campaign Monitor and it was the first talk of today that really hit home. Don’t get me wrong, the other talks have been excellent, but this one, for me anyway was about something that REALLY interested me. That is, creating and marketing a online application that solves a specific problem, all while working somewhere else full time. For those of you plpaying at home, I’m doing exactly that with 88 Miles.

It was very reassuring that these guys went through simple experiences that I have had or am currently having. I’m going to stalk, erm, filnd them after all the talks finish and picks their brains.

I’m currently in John Allsopp’s microformats and mashup talk. It is filling my geek quota quite nicely…

More soon.

Cleaning up this town

Kelly Goto has just finished her talk – very interesting. Maybe not in terms of real concepts, but definately has supplied food for though.

Now listening to Jeremy Keith about AJAX. Been eXcellent so far :)

I’m in the foyer of Web Directions

That’s right kiddies, I have arrived in Sydney and I’m waiting for the first talks to start.

I’ve set up a Flickr feed (You can see the results down the bottom of the sidebar, to your right. Please mind the gap.

I’ve set up Shozu to send any photos I take from my picture phone straight to Flickr in (almost) real time, so enjoy the love. Assuming that I remember to take some photos :)

So watch this space for all the latest news from the coolest web conference this side of Sydney harbour…

Fixing ZeroCfgSvn.exe crashes

I use a Toshiba Satellite M70 which has an Intel ProSet Wireless 2200BG Wireless network card.

I have had a couple of problems with the wireless card though:

  1. When I boot, the wireless connects for about a minute, then the connection drops and it reconnects – this plays havoc on my IM programs not to mention slows my boot time considerably
  2. After I installed VMWare, the Zero Configurations Service kept crashing. This was annoying to say the least.

After a little Googling, it became apparent that the issue is the driver. Easy – go and get the latest driver from Toshiba, right? Wrong – I updated to the lastest version and still no fix.

The solution: Just on to the intel website, select Wireless > Wireless LAN Products menu item on the left and select the wireless card you have.

Download the 123Mb (?!) driver file and install. You will lose your saved Access Point information though.

If you are like me and prefer to have Windows manage you connections, Right-click on the task bar icon and select “Allow Windows to Manage my connections”.

If you are also like me and HATE erronoues taskbar icons, open the Intel Wireless Manager (Start > Programs > Intel PROSet Wireless > Intel PROSet Wireless). Click the Tools > Applications Settings menu and uncheck the “Show application icon in the taskbar” checkbox.

That should do the job quite nicely.

More people to play with

Exciting news just to hand! The perth web industry has been going to through a bit of a shake up of late – perpetual freelancers taking full time jobs (That’s me), stalwalts of the industry going out on there own, mergers and aquisitions.

“Mergers and aquisitions”, you say?

“I’ve heard but nothing!”

Yes, dear reader, this little secret has been very well kept (rare for the industry over here) – two major players in the boutique web arena have joined forces in a super-mega-power play of gigantic small business proportions.

Bam creative (my new place of employ) has recently aquired Cube7 (an old client of mine). Customary website here. This is extremely exciting news as both of these companies are well sort after in the local market.

This event is being simul-blogged by Miles Burke and Simon Wright.

Update: Improved validation in CakePHP for version 1.x

I recently started a new project in CakePHP and thought it time to use version 1. But it seems the way that the validator code works has changed, so here is the updated code:

The following goes in app_model.php

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">{</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">if</span> <span class="br0">(</span>[empty</span>](http://www.php.net/empty)<span class="br0">(</span><span class="re0">$data</span><span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="re0">$data</span> = <span class="re0">$this</span>-><span class="me1">data</span>;
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">if</span> <span class="br0">(</span>!<span class="re0">$this</span>-><span class="me1">beforeValidate</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">return</span> <span class="kw2">false</span>;
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">if</span> <span class="br0">(</span>![isset</span>](http://www.php.net/isset)<span class="br0">(</span><span class="re0">$this</span>-><span class="me1">validate</span><span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">return</span> <span class="kw2">true</span>;
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">if</span> <span class="br0">(</span>![empty</span>](http://www.php.net/empty)<span class="br0">(</span><span class="re0">$data</span><span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="re0">$data</span> = <span class="re0">$data</span>;
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span> <span class="kw1">elseif</span> <span class="br0">(</span>[isset</span>](http://www.php.net/isset)<span class="br0">(</span><span class="re0">$this</span>-><span class="me1">data</span><span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="re0">$data</span> = <span class="re0">$this</span>-><span class="me1">data</span>;
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">if</span> <span class="br0">(</span>[isset</span>](http://www.php.net/isset)<span class="br0">(</span><span class="re0">$data</span><span class="br0">[</span><span class="re0">$this</span>-><span class="me1">name</span><span class="br0">]</span><span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="re0">$data</span> = <span class="re0">$data</span><span class="br0">[</span><span class="re0">$this</span>-><span class="me1">name</span><span class="br0">]</span>;
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="re0">$errors</span> = [array</span>](http://www.php.net/array)<span class="br0">(</span><span class="br0">)</span>;
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">foreach</span><span class="br0">(</span><span class="re0">$this</span>-><span class="me1">validate</span> <span class="kw1">as</span> <span class="re0">$field_name</span> => <span class="re0">$validators</span><span class="br0">)</span> <span class="br0">{</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">foreach</span><span class="br0">(</span><span class="re0">$validators</span> <span class="kw1">as</span> <span class="re0">$validator</span><span class="br0">)</span> <span class="br0">{</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">if</span> <span class="br0">(</span>[preg_match</span>](http://www.php.net/isset)<span class="br0">(</span><span class="re0">$validator</span><span class="br0">[</span><span class="st0">&#8216;expression&#8217;</span><span class="br0">]</span>, <span class="re0">$data</span><span class="br0">[</span><span class="re0">$field_name</span><span class="br0">]</span><span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="re0">$errors</span><span class="br0">[</span><span class="re0">$field_name</span><span class="br0">]</span> = <span class="re0">$validator</span><span class="br0">[</span><span class="st0">&#8216;message&#8217;</span><span class="br0">]</span>;
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="re0">$this</span>-><span class="me1">validationErrors</span> = <span class="re0">$errors</span>;
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">return</span> <span class="re0">$errors</span>;
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
  </div>
</li>

The validation helper method (See my previous post) looks like this:

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="re0">$messages</span> = <span class="st0">&#8220;&#8221;</span>;
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">if</span><span class="br0">(</span>[isset</span>](http://www.php.net/isset)<span class="br0">(</span><span class="re0">$this</span>-><span class="me1">validationErrors</span><span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">foreach</span><span class="br0">(</span><span class="re0">$this</span>-><span class="me1">validationErrors</span> <span class="kw1">as</span> <span class="re0">$tag</span><span class="br0">)</span> <span class="br0">{</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">foreach</span><span class="br0">(</span><span class="re0">$tag</span> <span class="kw1">as</span> <span class="re0">$element</span> => <span class="re0">$message</span><span class="br0">)</span> <span class="br0">{</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="re0">$messages</span> .= [empty</span>](http://www.php.net/sprintf)<span class="br0">(</span><span class="re0">$message</span><span class="br0">)</span> ? <span class="st0">&#8216;Error in field: &#8216;</span> . <span class="re0">$element</span> : <span class="re0">$message</span><span class="br0">)</span>;
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">return</span> <span class="re0">$messages</span>;
  </div>
</li>

<li class="li1">
  <div class="de1">
    <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
  </div>
</li>

How I work

Lifehacker have been running a “How I work series” which has given an interesting look into how their editiors work on a day-to-day basis.

Well time for me to blatently rip off the idea :)

I challenge all of the Westcoastbloggers to answer the same questions on their blogs.

What desktop software do you use every day?

I’m still an Outlook user. Originally I used it because it sync’d with my PocketPC nicely, now it is just because I like it. I occasionally use Thunderbird on Linux.

I will often have a copy of either notepad (Microsoft’s BEST program – ever!) or notepad2 open. Notepad2 supports colour highlighting and UNIX line endings, so fills the gap nicely when notepad won’t cut the mustard. Unfortunately it doesn’t support ruby yet :(

I use Illium’s eWallet for password management. It is almost always open so I don’t have to remember all of my clients passwords. Also sync with my PocketPC so I can access stuff away from my laptop.

The command line utility NCFTP is my trusted FTP client. I started using this on Linux and fell in love with it, so I jumped at the changed to use it when the windows version came out.

If I’m text editing on Linux, I use VIM. There is a Windows version, but notepad is easier.

I use PuTTY to SSH in to the various servers that I work on. Since I work on a development server and I use Subversion for version control, this is a must have.

Although I try to keep this closed whereever possible, I use FeedDemon 2.0 for my RSS feeds.

What web sites do you use every day?

I always have my time tracking system, 88 miles open in a firefox tab

I frequent the port80 forums.

It goes without saying that Google gets fired up many times a day.

What PDA/personal organizer/system do you use to keep organized?

I have a Compaq iPaq, but don’t use it that often anymore. I used to use it mainly for time tracking, but now I use 88 miles. I have a big A4 paper diary in which I write meetings, todo lists and reminders for the next day (I’m more likely to read them in there as it is always right in front of me). If I’m out I will take my PDA because it is a bit smaller than my paper diary. I’m trialling Remember the Milk as a task list manager. Although I still seem more inclinded to write stuff down on paper.

My desktop

88 Miles has a blog

If you are interested in 88 Miles updates, bug fixes and announcements, you can go to blog.88miles.net and get your fix. Please leave a comment – I really appreciate the feedback.

Image verification for comments in WordPress 2.0

I’m sick of blog spam. It is such a pain to have to mark it all as spam (And what exactly does that function do? I’ve seen the same spam come through many times, so it doesn’t seem to learn…)

Anyways, here is my quick and dirty hack to add a image verification box on the comments page (Warning WordPress hack ahead – I’ll bother to learn the plugin system one day…)

This hack requires the following PHP libraries installed on your server: Freetype, GD and mcrypt.

Create a new file in $PATH_TO_YOU_BLOG/wp-image-verify.php

Insert the following code:

<?php
  require( dirname(__FILE__) . /wp-config.php’ );
  $verifier = $_REQUEST[‘verifier’];
  $display_string = decrypt($verifier);
  $image_details = imagettfbbox (10, 0, /usr/share/fonts/TTF/tahoma.ttf’, $display_string);
  $image = imagecreatetruecolor($image_details[4]  $image_details[5], (0  $image_details[5])  (0  $image_details[3]) + 1);
  imageantialias($image, true);
  $background = imagecolorallocate($image, 255, 255, 255);
  imagefill($image, 0, 0, $background);
  imagettftext($image, 10, 0, $image_details[0] + 1, 0  $image_details[5], imagecolorallocate($image, 119, 119, 119), /usr/share/fonts/TTF/tahoma.ttf’, $display_string);
  header(“Content-type: image/png”);
  imagepng($image);
?>

Note – you will probably (ok will) have to change the path of the font as /usr/share/fonts/TTF/tahoma.ttf is a font I copied from my windows directory.

Open $PATH_TO_YOU_BLOG/wp-comments-post.php and add the following lines at around line 25:

$verifier = trim($_POST[‘verifier’]);
$verifier_compare = decrypt($_POST[‘verifier_hash’]);

Open $PATH_TO_YOU_BLOG/includes/comments-functions.php and add the following lines at the top of the file:

// image verifier functions – by Myles Eftos
$key = “afedss”; // Enter a 5 character string
$iv = “sdfesdf”; // Enter a 7 character IV
function random_string($length = 6) {
  $str = ;
  for($i = 0; $i < $length; $i++) {
    $str .= chr(rand(ord(‘A’), ord(‘Z’)));
  }
  return $str;
}

function encrypt($string) {
  global $key;
  global $iv;
  return base64_encode(mcrypt_encrypt(MCRYPT_DES, $key, $string, MCRYPT_MODE_ECB, $iv));
}

function decrypt($string) {
  global $key;
  global $iv;
  return chop(mcrypt_decrypt(MCRYPT_DES, $key, base64_decode($string), MCRYPT_MODE_ECB, $iv));
}

All done :)

Indenting highlighted source code with WordPress 2.0

Ok, after going away and thinking about the problem, I came up with a quick and dirty (But seemingly effective and compliant) way of doing the indenting. It does require a small modification to the GeSHi code. I’m going to use an empty inline tag (ins tag – which stands for insert – how appropriate…)

Open the geshi.php file (See my previous post about code highlighting in WordPress 2.0 if you have no idea what I’m talking about) and find the indent function. Search for all the nbsp elements and replace with:

<ins class="in"></ins>

Now open the insertcode.css file and the style.css (in your theme) and add:

ins.in {
  margin-left: 15px;
}

Voila! indenting. The output looks like this:

<?php
echo "hello" . world();
function world() {
  return "world";
}
?>

A few more notes: html and xml highlighting is pretty well broken unless you add a erroneous space between the angle bracket and the tag (See this example) and don’t try to use special characters. I’m currently tweaking the colour coding classes to make them look nicer too. I’ll post these when they are done.

Previous Next